mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-05 05:29:13 +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;
|
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
|
* 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
|
else
|
||||||
@ -724,7 +750,7 @@ class calendar_uilist extends calendar_ui
|
|||||||
{
|
{
|
||||||
$success++;
|
$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.dataStoreUID','calendar::'.$id,$this->to_client($this->bo->read($id,$recur_date)));
|
||||||
Api\Json\Response::get()->call('egw.refresh','','calendar',$id,'edit');
|
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,
|
if ($this->bo->set_status($event,$GLOBALS['egw_info']['user']['account_id'],$new_status,$recur_date,
|
||||||
false,true,$skip_notification))
|
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)));
|
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
|
* @param _senders
|
||||||
*/
|
*/
|
||||||
CalendarApp.prototype.cal_delete = function (_action, _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 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
|
// Loop so we ask if any of the selected entries is part of a series
|
||||||
for (var i = 0; i < _senders.length; i++) {
|
for (var i = 0; i < _senders.length; i++) {
|
||||||
var id = _senders[i].id;
|
var id = _senders[i].id;
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/);
|
matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/);
|
||||||
}
|
}
|
||||||
|
ids.push(id.split("::").pop());
|
||||||
}
|
}
|
||||||
if (matches) {
|
if (matches) {
|
||||||
var popup = jQuery('#calendar-list_delete_popup').get(0);
|
// At least one event is a series, use its data to trigger the prompt
|
||||||
if (typeof popup != 'undefined') {
|
var cal_event_1 = this.egw.dataGetUIDdata(matches[0]);
|
||||||
// nm action - show popup
|
|
||||||
nm_open_popup(_action, _senders);
|
|
||||||
}
|
}
|
||||||
return;
|
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;
|
||||||
}
|
}
|
||||||
nm_action(_action, _senders);
|
}.bind(this));
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Confirmation dialog for moving a series entry
|
* Confirmation dialog for moving a series entry
|
||||||
|
@ -2111,8 +2111,11 @@ class CalendarApp extends EgwApp
|
|||||||
*/
|
*/
|
||||||
cal_delete(_action, _senders)
|
cal_delete(_action, _senders)
|
||||||
{
|
{
|
||||||
var backup = _action.data;
|
let all = _action.parent.data.nextmatch.getSelection().all;
|
||||||
var matches = false;
|
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
|
// Loop so we ask if any of the selected entries is part of a series
|
||||||
for(var i = 0; i < _senders.length; i++)
|
for(var i = 0; i < _senders.length; i++)
|
||||||
@ -2122,19 +2125,31 @@ class CalendarApp extends EgwApp
|
|||||||
{
|
{
|
||||||
matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/);
|
matches = id.match(/^(?:calendar::)?([0-9]+):([0-9]+)$/);
|
||||||
}
|
}
|
||||||
|
ids.push(id.split("::").pop());
|
||||||
}
|
}
|
||||||
if (matches)
|
if (matches)
|
||||||
{
|
{
|
||||||
var popup = jQuery('#calendar-list_delete_popup').get(0);
|
// At least one event is a series, use its data to trigger the prompt
|
||||||
if (typeof popup != 'undefined')
|
let cal_event = this.egw.dataGetUIDdata( matches[0]);
|
||||||
|
}
|
||||||
|
et2_calendar_event.recur_prompt(cal_event.data,function(button_id,event_data) {
|
||||||
|
switch(button_id)
|
||||||
{
|
{
|
||||||
// nm action - show popup
|
case 'single':
|
||||||
nm_open_popup(_action,_senders);
|
case 'exception':
|
||||||
}
|
// Just this one, handle in the normal way but over AJAX
|
||||||
return;
|
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