mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
Calendar: Handle deleting without reload
This commit is contained in:
parent
1cbbfbd9a5
commit
42492d8ea5
@ -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)));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user