diff --git a/calendar/inc/class.calendar_uilist.inc.php b/calendar/inc/class.calendar_uilist.inc.php index ed3531eb58..dec2fd0e5f 100644 --- a/calendar/inc/class.calendar_uilist.inc.php +++ b/calendar/inc/class.calendar_uilist.inc.php @@ -557,6 +557,32 @@ class calendar_uilist extends calendar_ui return $this->bo->total; } + /** + * Apply an action to multiple events, but called via AJAX instead of submit + * + * @param string $action + * @param string[] $selected + * @param bool $all_selected All events are selected, not just what's in $selected + * @param bool $skip_notification + */ + public function ajax_action($action, $selected, $all_selected, $skip_notification = false) + { + $success = 0; + $failed = 0; + $action_msg = ''; + $session_name = 'calendar_list'; + + if($this->action($action, $selected, $all_selected, $success, $failed, $action_msg, $session_name, $msg, $skip_notification)) + { + $msg = lang('%1 event(s) %2',$success,$action_msg); + } + elseif(is_null($msg)) + { + $msg .= lang('%1 event(s) %2, %3 failed because of insufficient rights !!!',$success,$action_msg,$failed); + } + Api\Json\Response::get()->message($msg); + } + /** * apply an action to multiple events * @@ -699,9 +725,9 @@ class calendar_uilist extends calendar_ui } } - if(Api\Json\Response::isJSONResponse()) + if(Api\Json\Request::isJSONRequest()) { - Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'delete'); + Api\Json\Response::get()->call('egw.refresh','','calendar',$recur_date ? "$id:$recur_date" : $id,'delete'); } } else @@ -724,7 +750,7 @@ class calendar_uilist extends calendar_ui { $success++; - if(Api\Json\Response::isJSONResponse()) + if(Api\Json\Response::isJSONRequest()) { Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date))); Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit'); @@ -748,7 +774,7 @@ class calendar_uilist extends calendar_ui if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date, false,true,$skip_notification)) { - if(Api\Json\Response::isJSONResponse()) + if(Api\Json\Response::isJSONRequest()) { Api\Json\Response::get()->call('egw.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date))); } diff --git a/calendar/js/app.js b/calendar/js/app.js index 3623a76488..c66515eb4b 100644 --- a/calendar/js/app.js +++ b/calendar/js/app.js @@ -1891,24 +1891,39 @@ var CalendarApp = /** @class */ (function (_super) { * @param _senders */ CalendarApp.prototype.cal_delete = function (_action, _senders) { - var backup = _action.data; + var all = _action.parent.data.nextmatch.getSelection().all; + var no_notifications = _action.parent.getActionById("no_notifications").checked; var matches = false; + var ids = []; + var cal_event = this.egw.dataGetUIDdata(_senders[0].id); // Loop so we ask if any of the selected entries is part of a series for (var i = 0; i < _senders.length; i++) { var id = _senders[i].id; if (!matches) { matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/); } + ids.push(id.split("::").pop()); } if (matches) { - var popup = jQuery('#calendar-list_delete_popup').get(0); - if (typeof popup != 'undefined') { - // nm action - show popup - nm_open_popup(_action, _senders); - } - return; + // At least one event is a series, use its data to trigger the prompt + var cal_event_1 = this.egw.dataGetUIDdata(matches[0]); } - nm_action(_action, _senders); + et2_widget_event_1.et2_calendar_event.recur_prompt(cal_event.data, function (button_id, event_data) { + switch (button_id) { + case 'single': + case 'exception': + // Just this one, handle in the normal way but over AJAX + egw.json("calendar.calendar_uilist.ajax_action", [_action.id, ids, all, no_notifications]).sendRequest(true); + break; + case 'series': + // No recurrences, handle in the normal way but over AJAX + egw.json("calendar.calendar_uilist.ajax_action", ["delete_series", ids, all, no_notifications]).sendRequest(true); + break; + case 'cancel': + default: + break; + } + }.bind(this)); }; /** * Confirmation dialog for moving a series entry diff --git a/calendar/js/app.ts b/calendar/js/app.ts index 638a9e6b64..f1905919c3 100644 --- a/calendar/js/app.ts +++ b/calendar/js/app.ts @@ -2111,8 +2111,11 @@ class CalendarApp extends EgwApp */ cal_delete(_action, _senders) { - var backup = _action.data; - var matches = false; + let all = _action.parent.data.nextmatch.getSelection().all; + let no_notifications = _action.parent.getActionById("no_notifications").checked; + let matches = false; + let ids = []; + let cal_event = this.egw.dataGetUIDdata(_senders[0].id); // Loop so we ask if any of the selected entries is part of a series for(var i = 0; i < _senders.length; i++) @@ -2122,19 +2125,31 @@ class CalendarApp extends EgwApp { matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/); } + ids.push(id.split("::").pop()); } if (matches) { - var popup = jQuery('#calendar-list_delete_popup').get(0); - if (typeof popup != 'undefined') - { - // nm action - show popup - nm_open_popup(_action,_senders); - } - return; + // At least one event is a series, use its data to trigger the prompt + let cal_event = this.egw.dataGetUIDdata( matches[0]); } + et2_calendar_event.recur_prompt(cal_event.data,function(button_id,event_data) { + switch(button_id) + { + case 'single': + case 'exception': + // Just this one, handle in the normal way but over AJAX + egw.json("calendar.calendar_uilist.ajax_action",[_action.id, ids, all, no_notifications]).sendRequest(true); + break; + case 'series': + // No recurrences, handle in the normal way but over AJAX + egw.json("calendar.calendar_uilist.ajax_action",["delete_series", ids, all, no_notifications]).sendRequest(true); + break; + case 'cancel': + default: + break; + } + }.bind(this) ); - nm_action(_action, _senders); } /**