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
This commit is contained in:
Nathan Gray 2015-12-07 18:32:59 +00:00
parent d547416956
commit ecc189fd05
2 changed files with 32 additions and 13 deletions

View File

@ -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,14 +1261,24 @@ app.classes.calendar = AppJS.extend(
*/
cal_open: function(_action, _senders)
{
// Try for easy way - find a widget
if(_senders[0].iface.getWidget)
{
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 matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/);
if (matches)
var data = egw.dataGetUIDdata(id);
if (data && data.data)
{
this.edit_series(matches[1],matches[2]);
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;
@ -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];

View File

@ -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: