From ecc189fd053caec1da623dc9c58a10d6e86f9ce9 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 7 Dec 2015 18:32:59 +0000 Subject: [PATCH] Fix some action issues - Keep event widget ActionObject ID matching event ID - Add ability to pass extra data to default recur_prompt callback - Fix open context menu action did not prompt for series vs exception --- calendar/js/app.js | 25 ++++++++++++++++++------- calendar/js/et2_widget_event.js | 20 ++++++++++++++------ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/calendar/js/app.js b/calendar/js/app.js index 4dce8f3c37..25d83d3b76 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1159,6 +1159,7 @@ app.classes.calendar = AppJS.extend( */ action_open: function(_action, _events) { + debugger; var id = _events[0].id.split('::'); if(_action.data.open) { @@ -1260,15 +1261,25 @@ app.classes.calendar = AppJS.extend( */ cal_open: function(_action, _senders) { - // Check for series - var id = _senders[0].id; - var matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/); - if (matches) + // Try for easy way - find a widget + if(_senders[0].iface.getWidget) { - this.edit_series(matches[1],matches[2]); - return; + var widget = _senders[0].iface.getWidget(); + return widget.recur_prompt(); } + // Nextmatch in list view does not have a widget, but we can pull + // the data by ID + // Check for series + var id = _senders[0].id; + var data = egw.dataGetUIDdata(id); + if (data && data.data) + { + et2_calendar_event.recur_prompt(data.data); + return; + } + var matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/); + // Check for other app integration data sent from server var backup = _action.data; if(_action.parent.data && _action.parent.data.nextmatch) @@ -1529,7 +1540,7 @@ app.classes.calendar = AppJS.extend( { for(var s in _set) { - if (new_state[s] !== _set[s]) + if (new_state[s] !== _set[s] && (typeof new_state[s] == 'string' || typeof new_state[s] !== 'string' && new_state[s]+'' !== _set[s]+'')) { changed.push(s + ': ' + new_state[s] + ' -> ' + _set[s]); new_state[s] = _set[s]; diff --git a/calendar/js/et2_widget_event.js b/calendar/js/et2_widget_event.js index 98dd372aea..cc4a147bc5 100644 --- a/calendar/js/et2_widget_event.js +++ b/calendar/js/et2_widget_event.js @@ -184,7 +184,10 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM], var formatted_start = this._parent.date_helper.getValue(); this.set_id('event_' + event.app_id); - + if(this._actionObject) + { + this._actionObject.id = 'calendar::' + event.app_id; + } // Make sure category stuff is there // Fake it to use the cache / call - if already there, these will return // immediately. @@ -585,10 +588,11 @@ var et2_calendar_event = et2_valueWidget.extend([et2_IDetachedDOM], * Show the recur prompt for this event * * @param {function} callback + * @param {Object} [extra_data] */ - recur_prompt: function(callback) + recur_prompt: function(callback, extra_data) { - et2_calendar_event.recur_prompt(this.options.value,callback); + et2_calendar_event.recur_prompt(this.options.value,callback,extra_data); }, /** @@ -671,16 +675,19 @@ et2_register_widget(et2_calendar_event, ["calendar-event"]); * @param {string|Date} event_data.start - Start date/time for the event * @param {number} event_data.recur_type - Recur type, or 0 for a non-recurring event * @param {Function} [callback] - Callback is called with the button (exception, series, single or cancel) and the event data. + * @param {Object} [extra_data] - Additional data passed to the callback, used as extra parameters for default callback * * @augments {et2_calendar_event} */ -et2_calendar_event.recur_prompt = function(event_data, callback) +et2_calendar_event.recur_prompt = function(event_data, callback, extra_data) { var edit_id = event_data.app_id; var edit_date = event_data.start; var egw = this.egw ? (typeof this.egw == 'function' ? this.egw() : this.egw) : (window.opener || window).egw; var that = this; + var extra_params = extra_data && typeof extra_data == 'object' ? extra_data : {}; + extra_params.date = edit_date; if(typeof callback != 'function') { callback = function(_button_id) @@ -688,11 +695,12 @@ et2_calendar_event.recur_prompt = function(event_data, callback) switch(_button_id) { case 'exception': - egw.open(edit_id, event_data.app||'calendar', 'edit', {date:edit_date,exception: '1'}); + extra_params.exception = '1'; + egw.open(edit_id, event_data.app||'calendar', 'edit', extra_params); break; case 'series': case 'single': - egw.open(edit_id, event_data.app||'calendar', 'edit', {date:edit_date}); + egw.open(edit_id, event_data.app||'calendar', 'edit', extra_params); break; case 'cancel': default: