Calendar: Disable convert actions if they don't support integrated app

This commit is contained in:
nathangray 2021-02-23 11:39:36 -07:00
parent aed4b78dda
commit 60a486298c
3 changed files with 48 additions and 0 deletions

View File

@ -1017,6 +1017,9 @@ class calendar_uilist extends calendar_ui
'allowOnMultiple' => false,
'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=calendar&action_id=$id',
'popup' => Link::get_registry('infolog', 'add_popup'),
// Limit infolog convert to only the apps that support it (some entries may be other apps via integration)
'enabled' => 'javaScript:app.calendar.action_convert_enabled_check',
'convert_apps' => Api\Hooks::implemented('infolog_set')
);
}
if($GLOBALS['egw_info']['user']['apps']['mail'])
@ -1063,6 +1066,9 @@ class calendar_uilist extends calendar_ui
'onExecute' => 'javaScript:app.calendar.action_open',
'open' => '{"app": "timesheet", "type": "add", "extra": "link_app[]=$app&link_id[]=$app_id"}',
'popup' => Link::get_registry('timesheet', 'add_popup'),
// Limit timesheet convert to only the apps that support it (some entries may be other apps via integration)
'enabled' => 'javaScript:app.calendar.action_convert_enabled_check',
'convert_apps' => Api\Hooks::implemented('timesheet_set')
);
$actions['timesheet-add'] = array( // automatic add for multiple events
'icon' => 'timesheet/navbar',

View File

@ -1667,6 +1667,25 @@ var CalendarApp = /** @class */ (function (_super) {
this.egw.open_link(url, _action.data.target, _action.data.popup);
}
};
/**
* Check to see if we know how to convert this entry to the given app
*
* The current entry may not be an actual calendar event, it may be some other app
* that is participating via integration hook. This is determined by checking the
* hooks defined for <appname>_set, indicating that the app knows how to provide
* information for that application
*
* @param {egwAction} _action
* @param {egwActionObject[]} _events
*/
CalendarApp.prototype.action_convert_enabled_check = function (_action, _events) {
var supported_apps = _action.data.convert_apps || [];
var entry = egw.dataGetUIDdata(_events[0].id);
if (supported_apps && entry && entry.data) {
return supported_apps.length > 0 && supported_apps.indexOf(entry.data.app) >= 0;
}
return true;
};
/**
* Context menu action (on a single event) in non-listview to generate ical
*

View File

@ -1816,6 +1816,29 @@ class CalendarApp extends EgwApp
}
}
/**
* Check to see if we know how to convert this entry to the given app
*
* The current entry may not be an actual calendar event, it may be some other app
* that is participating via integration hook. This is determined by checking the
* hooks defined for <appname>_set, indicating that the app knows how to provide
* information for that application
*
* @param {egwAction} _action
* @param {egwActionObject[]} _events
*/
action_convert_enabled_check(_action, _events) : boolean
{
let supported_apps = _action.data.convert_apps || [];
let entry = egw.dataGetUIDdata(_events[0].id);
if(supported_apps && entry && entry.data)
{
return supported_apps.length > 0 && supported_apps.indexOf(entry.data.app) >= 0;
}
return true;
}
/**
* Context menu action (on a single event) in non-listview to generate ical
*