[Cosmo-dev] Fwd: [commits-cosmo] (mde) [4909] Item selection
in the calendar canvas is now persisted correctly
Matthew Eernisse
mde at osafoundation.org
Fri Jun 29 19:20:24 PDT 2007
Bobby,
The problem with that is that in the context in which that variable is
used, "item" refers to either a CalItem or ListItem -- it's very
relevant in the context of the code that that object passed in as a
param is a Note, which is used as the .data property of either type of
"item."
I think that you're right, at some point we may want to examine whether
it's right to be passing these CalItem/ListItems around, when we're
mostly interested in the attached stamped Note, but at this point, in
those areas of the UI code, "item" refers to one of those top-level
Items used in both views.
Feel free to change it back if it really bothers you, but particulary in
the list/cal canvas saveSuccess functions, it would be more confusing
with the old name (which is what prodded me to make the change).
Thanks.
Matthew
Bobby Rullo wrote:
> Can we change this back to newItem? "newItemNote" is unnecessarily unwieldy.
>
> Begin forwarded message:
>
>> *From: *svncheckin at osafoundation.org <mailto:svncheckin at osafoundation.org>
>> *Date: *June 29, 2007 2:57:23 PM PDT
>> *To: *commits-cosmo at osafoundation.org
>> <mailto:commits-cosmo at osafoundation.org>
>> *Subject: **[commits-cosmo] (mde) [4909] Item selection in the
>> calendar canvas is now persisted correctly*
>> *List-Id: *OSAF Cosmo Checkins <commits-cosmo.osafoundation.org>
>>
>> Revision
>> 4909 <http://cvs.osafoundation.org/viewcvs.cgi?rev=4909&view=rev>
>> Author
>> mde
>> Date
>> 2007-06-29 14:57:23 -0700 (Fri, 29 Jun 2007)
>>
>>
>> Log Message
>>
>> Item selection in the calendar canvas is now persisted correctly
>> after the various types of edits to recurring items.
>>
>>
>> Modified Paths
>>
>> * cosmo/trunk/cosmo/src/main/webapp/js/cosmo/service/transport/Rest.js
>> <#cosmotrunkcosmosrcmainwebappjscosmoservicetransportRestjs>
>> * cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/minical.js
>> <#cosmotrunkcosmosrcmainwebappjscosmouiminicaljs>
>> * cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/navbar.js
>> <#cosmotrunkcosmosrcmainwebappjscosmouinavbarjs>
>> * cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/cal/canvas.js
>> <#cosmotrunkcosmosrcmainwebappjscosmoviewcalcanvasjs>
>> * cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/common.js
>> <#cosmotrunkcosmosrcmainwebappjscosmoviewcommonjs>
>> * cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/list/canvas.js
>> <#cosmotrunkcosmosrcmainwebappjscosmoviewlistcanvasjs>
>> * cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/service.js
>> <#cosmotrunkcosmosrcmainwebappjscosmoviewservicejs>
>>
>>
>> Diff
>>
>>
>> Modified:
>> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/service/transport/Rest.js
>> (4908 => 4909)
>>
>> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/service/transport/Rest.js 2007-06-29 21:42:35 UTC (rev 4908)
>> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/service/transport/Rest.js 2007-06-29 21:57:23 UTC (rev 4909)
>> @@ -69,9 +69,9 @@
>> request.headers["Cache-Control"] = "no-cache";
>> request.headers["Pragma"] = "no-cache";
>> // Fight the dark powers of IE's evil caching mechanism
>> - if (dojo.render.html.ie) {
>> + //if (dojo.render.html.ie) {
>> request.preventCache = request.preventCache || true;
>> - }
>> + //}
>> if (request.method){
>> if (!this.methodIsSupported[request.method.toLowerCase()]){
>> request.headers['X-Http-Method-Override'] = request.method;
>>
>>
>> Modified:
>> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/minical.js (4908
>> => 4909)
>>
>> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/minical.js 2007-06-29 21:42:35 UTC (rev 4908)
>> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/minical.js 2007-06-29 21:57:23 UTC (rev 4909)
>> @@ -37,6 +37,8 @@
>> dojo.require("cosmo.util.validate");
>> dojo.require("cosmo.app.pim");
>> dojo.require("cosmo.datetime");
>> +dojo.require("cosmo.datetime.Date");
>> +dojo.require("cosmo.datetime.util");
>> dojo.require("cosmo.service.exception");
>>
>> cosmo.ui.minical.MiniCal = function (p) {
>>
>>
>> Modified:
>> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/navbar.js (4908
>> => 4909)
>>
>> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/navbar.js 2007-06-29 21:42:35 UTC (rev 4908)
>> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/ui/navbar.js 2007-06-29 21:57:23 UTC (rev 4909)
>> @@ -22,6 +22,7 @@
>> dojo.require("cosmo.util.i18n");
>> dojo.require("cosmo.util.hash");
>> dojo.require("cosmo.util.html");
>> +dojo.require("cosmo.datetime.util");
>> dojo.require("cosmo.convenience");
>> dojo.require("cosmo.ui.ContentBox");
>> dojo.require("cosmo.ui.button");
>> @@ -201,8 +202,15 @@
>> d.appendChild(t);
>> };
>> this._showMonthHeader = function () {
>> - var vS = cosmo.view.cal.viewStart;
>> - var vE = cosmo.view.cal.viewEnd;
>> + if (!cosmo.view.cal.viewStart || !cosmo.view.cal.viewEnd) {
>> + var defaultDate = cosmo.app.pim.currDate;
>> + var vS = cosmo.datetime.util.getWeekStart(defaultDate);
>> + var vE = cosmo.datetime.util.getWeekEnd(defaultDate);
>> + }
>> + else {
>> + var vS = cosmo.view.cal.viewStart;
>> + var vE = cosmo.view.cal.viewEnd;
>> + }
>> var mS = vS.getMonth();
>> var mE = vE.getMonth();
>> var headerDiv = this.monthHeader;
>>
>>
>> Modified:
>> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/cal/canvas.js
>> (4908 => 4909)
>>
>> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/cal/canvas.js 2007-06-29 21:42:35 UTC (rev 4908)
>> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/cal/canvas.js 2007-06-29 21:57:23 UTC (rev 4909)
>> @@ -63,7 +63,7 @@
>> this.view = cosmo.view.cal;
>> // UIDs for selected events keyed by the uid of
>> // the currently displayed collection
>> - this.selectedEventIdRegistry = {};
>> + this.selectedItemIdRegistry = {};
>> // Available lozenge colors
>> this.colors = {};
>> // The scrolling div for timed events
>> @@ -645,20 +645,27 @@
>> /**
>> * Set the passed calendar event as the selected one on
>> * canvas
>> - * @param ev CalItem object, the event to select
>> + * @param p CalItem object or CalItem id string, the event to select
>> */
>> - function setSelectedCalItem(ev) {
>> - if (!ev) {
>> - throw('No CalItem passed to setSelectedCalItem.');
>> + function setSelectedCalItem(/* Can be CalItem object or String id */ p) {
>> + if (!p) {
>> + throw('No CalItem or CalItem id passed to setSelectedCalItem.');
>> }
>> // Deselect previously selected event if any
>> var sel = self.getSelectedItem();
>> if (sel) {
>> sel.lozenge.setDeselected();
>> }
>> - self.setSelectedItem(ev);
>> + // Pass the item or id, set as the selected item
>> + // for the current collection
>> + self.setSelectedItem(p);
>> +
>> + // Grab the selected item -- have to do this lookup
>> + // because the passed-in param might be an id string
>> + var sel = self.getSelectedItem();
>> +
>> // Show the associated lozenge as selected
>> - ev.lozenge.setSelected();
>> + sel.lozenge.setSelected();
>> };
>> /**
>> * Removes an event lozenge from the canvas -- called in three cases:
>> @@ -828,7 +835,7 @@
>> dojo.debug("saveSuccess saveType: " + saveType);
>> var delta = cmd.delta;
>> var deferred = null;
>> - var newItem = cmd.newItem;
>> + var newItemNote = cmd.newItemNote; // stamped Note
>>
>> //if the event is recurring and all future or all events are changed, we need to
>> //re expand the event
>> @@ -837,7 +844,7 @@
>> //first remove the event and recurrences from the registry.
>> var idsToRemove = [data.getUid()];
>> if (saveType == recurOpts.ALL_FUTURE_EVENTS){
>> - idsToRemove.push(newItem.getUid());
>> + idsToRemove.push(newItemNote.getUid());
>> }
>> var newRegistry = self.view.filterOutRecurrenceGroup(
>> cosmo.view.cal.itemRegistry.clone(), idsToRemove);
>> @@ -847,7 +854,7 @@
>> var deferredArray = [cosmo.app.pim.serv.expandRecurringItem(data.getMaster(),
>> cosmo.view.cal.viewStart,cosmo.view.cal.viewEnd)];
>> if (saveType == recurOpts.ALL_FUTURE_EVENTS){
>> - deferredArray.push(cosmo.app.pim.serv.expandRecurringItem(newItem,
>> + deferredArray.push(cosmo.app.pim.serv.expandRecurringItem(newItemNote,
>> cosmo.view.cal.viewStart,cosmo.view.cal.viewEnd));
>> }
>> deferred = new dojo.DeferredList(deferredArray);
>> @@ -870,8 +877,8 @@
>> }
>> deferred.addCallback(addExpandedOccurrences);
>>
>> - }
>> - // Non-recurring / "only this item'
>> + }
>> + // Non-recurring / "only this item'
>> else {
>> // Saved event is still in view
>> var inRange = !item.isOutOfViewRange();
>> @@ -888,17 +895,41 @@
>> dojo.debug("updateEventsCallback")
>> // Don't re-render when requests are still processing
>> if (!cosmo.view.service.processingQueue.length) {
>> - if (false /*&& cmd.qualifier.newEvent ||
>> - (cmd.qualifier.onCanvas && opts.saveType != 'instanceOnlyThisEvent')*/) {
>> - var sel = cosmo.view.cal.lastSent;
>> - sel.lozenge.setInputDisabled(false);
>> - dojo.event.topic.publish('/calEvent', { 'action': 'setSelected',
>> - 'data': sel });
>> + updateEventsDisplay();
>> +
>> + // Anything except editing an existing event requires
>> + // adding the selection to an item in the itemRegistry
>> + if (saveType) {
>> + var sel = null;
>> + switch (saveType) {
>> + case 'new':
>> + sel = item;
>> + sel.lozenge.setInputDisabled(false);
>> + break;
>> + case recurOpts.ALL_EVENTS:
>> + case recurOpts.ONLY_THIS_EVENT:
>> + sel = item.data.getItemUid();
>> + break;
>> + case recurOpts.ALL_FUTURE_EVENTS:
>> + sel = newItemNote.getNoteOccurrence(
>> + newItemNote.getEventStamp().getStartDate()).getItemUid();
>> + break;
>> + break;
>> + default:
>> + throw('Undefined saveType of "' + saveType +
>> + '" in command object passed to saveSuccess');
>> + break;
>> +
>> + }
>> + setSelectedCalItem(sel);
>> + sel = self.getSelectedItem();
>> + dojo.event.topic.publish('/calEvent', { action: 'setSelected',
>> + data: sel });
>> }
>> - updateEventsDisplay();
>> - } else {
>> - dojo.debug("how many left in queue: " +cosmo.view.service.processingQueue.length);
>> }
>> + else {
>> + dojo.debug("how many left in queue: " + cosmo.view.service.processingQueue.length);
>> + }
>> }
>>
>> if (deferred){
>>
>>
>> Modified:
>> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/common.js
>> (4908 => 4909)
>>
>> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/common.js 2007-06-29 21:42:35 UTC (rev 4908)
>> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/common.js 2007-06-29 21:57:23 UTC (rev 4909)
>> @@ -87,23 +87,24 @@
>> cosmo.view.canvasBase = new function () {
>> this.getSelectedItem = function () {
>> var key = cosmo.app.pim.currentCollection.getUid();
>> - var id = this.selectedEventIdRegistry[key];
>> + var id = this.selectedItemIdRegistry[key];
>> var reg = this.view.itemRegistry;
>> return reg ? reg.getItem(id) : null;
>> };
>> - this.setSelectedItem = function (ev) {
>> + this.setSelectedItem = function (p) {
>> var key = cosmo.app.pim.currentCollection.getUid();
>> - this.selectedEventIdRegistry[key] = ev.id;
>> + var id = typeof p == 'string' ? p : p.id
>> + this.selectedItemIdRegistry[key] = id;
>> return true;
>> };
>> this.clearSelectedItem = function (ev) {
>> var key = cosmo.app.pim.currentCollection.getUid();
>> - this.selectedEventIdRegistry[key] = '';
>> + this.selectedItemIdRegistry[key] = '';
>> return true;
>> };
>> this.getSelectedItemId = function () {
>> var key = cosmo.app.pim.currentCollection.getUid();
>> - var id = this.selectedEventIdRegistry[key];
>> + var id = this.selectedItemIdRegistry[key];
>> return id;
>> }
>> };
>>
>>
>> Modified:
>> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/list/canvas.js
>> (4908 => 4909)
>>
>> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/list/canvas.js 2007-06-29 21:42:35 UTC (rev 4908)
>> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/list/canvas.js 2007-06-29 21:57:23 UTC (rev 4909)
>> @@ -40,7 +40,7 @@
>> //this.currSelectedId = '';
>> // UIDs for selected events keyed by the uid of
>> // the currently displayed collection
>> - this.selectedEventIdRegistry = {};
>> + this.selectedItemIdRegistry = {};
>> //this.currSelectedItem = null;
>> this.currSortCol = 'Triage';
>> this.currSortDir = 'Desc';
>>
>>
>> Modified:
>> cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/service.js
>> (4908 => 4909)
>>
>> --- cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/service.js 2007-06-29 21:42:35 UTC (rev 4908)
>> +++ cosmo/trunk/cosmo/src/main/webapp/js/cosmo/view/service.js 2007-06-29 21:57:23 UTC (rev 4909)
>> @@ -165,13 +165,13 @@
>> // Break the previous recurrence and start a new one
>> case opts.ALL_FUTURE_EVENTS:
>> dojo.debug("ALL_FUTURE");
>> - var newItem = delta.applyToOccurrenceAndFuture();
>> + var newItemNote = delta.applyToOccurrenceAndFuture();
>> f = function () {
>> doSaveItem(item,
>> {
>> 'saveType': opts.ALL_FUTURE_EVENTS,
>> 'delta': delta,
>> - 'newItem': newItem
>> + 'newItemNote': newItemNote
>> });
>> };
>> break;
>> @@ -233,7 +233,7 @@
>> var isNew = opts['new'] || false;
>> var note = item.data;
>> var delta = opts.delta;
>> - var newItem = opts.newItem;
>> + var newItemNote = opts.newItemNote;
>> dojo.debug("Do save: savetype: " + opts.saveType)
>> dojo.debug("Do save: iznew: " + isNew)
>>
>> @@ -248,17 +248,17 @@
>> break;
>> case OPTIONS.ALL_FUTURE_EVENTS:
>> dojo.debug("about to save note in ALL FUTURE EVENTS")
>> - var newItemDeferred = cosmo.app.pim.serv.
>> - createItem(newItem, cosmo.app.pim.currentCollection);
>> - var requestId = newItemDeferred.id;
>> + var newItemNoteDeferred = cosmo.app.pim.serv.
>> + createItem(newItemNote, cosmo.app.pim.currentCollection);
>> + var requestId = newItemNoteDeferred.id;
>> self.processingQueue.push(requestId);
>>
>> - newItemDeferred.addCallback(function(){
>> - dojo.debug("in newItemDeferred call back")
>> - if (newItemDeferred.results[1] != null){
>> + newItemNoteDeferred.addCallback(function(){
>> + dojo.debug("in newItemNoteDeferred call back")
>> + if (newItemNoteDeferred.results[1] != null){
>> //if there was an error, pass it to handleSaveItem, with the original
>> //item
>> - handleSaveItem(item, newItemDeferred.results[1], requestId,opts.saveType, delta);
>> + handleSaveItem(item, newItemNoteDeferred.results[1], requestId,opts.saveType, delta);
>> }
>> else {
>> //get rid of the id from the processing queue
>> @@ -273,7 +273,7 @@
>> originalDeferred.id,
>> opts.saveType,
>> delta,
>> - newItem);
>> + newItemNote);
>> });
>> self.processingQueue.push(originalDeferred.id);
>> self.lastSent = item;
>> @@ -336,14 +336,14 @@
>> * @param item A ListItem/CalItem object, the original item clicked on,
>> * or created by double-clicking on the cal canvas.
>> * FIXME: Comments below are hopelessly out of date
>> - * @param newItemId String, the id for the item returned when creating a
>> + * @param newItemNoteId String, the id for the item returned when creating a
>> * new item
>> * @param err A JS object, the error returned from the server when
>> * a save operation fails.
>> * @param reqId Number, the id of the async request.
>> * @param optsParam A JS Object, options for the save operation.
>> */
>> - function handleSaveItem(item, err, reqId, saveType, delta, newItem) {
>> + function handleSaveItem(item, err, reqId, saveType, delta, newItemNote) {
>> dojo.debug("handleSaveItem");
>> var OPTIONS = self.recurringEventOptions;
>> var errMsg = '';
>> @@ -376,11 +376,11 @@
>> self.processingQueue.shift();
>> // Broadcast message for success/failure
>> dojo.event.topic.publish('/calEvent', {
>> - 'action': act,
>> - 'data': item,
>> - 'saveType': saveType,
>> - 'delta':delta,
>> - 'newItem':newItem
>> + action: act,
>> + data: item,
>> + saveType: saveType,
>> + delta: delta,
>> + newItemNote: newItemNote
>> });
>> }
>>
>>
>> _______________________________________________
>> Commits-Cosmo mailing list
>> Commits-Cosmo at osafoundation.org <mailto:Commits-Cosmo at osafoundation.org>
>> http://lists.osafoundation.org/cgi-bin/mailman/listinfo/commits-cosmo
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> cosmo-dev mailing list
> cosmo-dev at lists.osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/cosmo-dev
More information about the cosmo-dev
mailing list