mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 17:18:54 +01:00
Addressbook: Delete contacts over AJAX to avoid refresh
This commit is contained in:
parent
ba7cbc5d5a
commit
86bd6b719a
@ -804,6 +804,7 @@ class addressbook_ui extends addressbook_bo
|
|||||||
'confirm_multiple' => 'Delete these entries',
|
'confirm_multiple' => 'Delete these entries',
|
||||||
'group' => $group,
|
'group' => $group,
|
||||||
'disableClass' => 'rowNoDelete',
|
'disableClass' => 'rowNoDelete',
|
||||||
|
'onExecute' => 'javaScript:app.addressbook.action',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($this->grants[0] & Acl::DELETE)
|
if ($this->grants[0] & Acl::DELETE)
|
||||||
@ -1131,6 +1132,32 @@ class addressbook_ui extends addressbook_bo
|
|||||||
Api\Cache::setSession('addressbook', 'advanced_search', false);
|
Api\Cache::setSession('addressbook', 'advanced_search', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply an action to multiple events, but called via AJAX instead of submit
|
||||||
|
*
|
||||||
|
* @param string $action
|
||||||
|
* @param string[] $selected
|
||||||
|
* @param bool $all_selected All entries 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 = 'index';
|
||||||
|
|
||||||
|
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 contacts
|
* apply an action to multiple contacts
|
||||||
*
|
*
|
||||||
|
@ -372,6 +372,28 @@ var AddressbookApp = /** @class */ (function (_super) {
|
|||||||
}
|
}
|
||||||
nm_action(_action, _senders);
|
nm_action(_action, _senders);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* Actions via ajax
|
||||||
|
*
|
||||||
|
* @param {egwAction} _action
|
||||||
|
* @param {egwActionObject[]} _selected
|
||||||
|
*/
|
||||||
|
AddressbookApp.prototype.action = function (_action, _selected) {
|
||||||
|
var _a, _b;
|
||||||
|
var all = (_a = _action.parent.data.nextmatch) === null || _a === void 0 ? void 0 : _a.getSelection().all;
|
||||||
|
var no_notifications = ((_b = _action.parent.getActionById("no_notifications")) === null || _b === void 0 ? void 0 : _b.checked) || false;
|
||||||
|
var ids = [];
|
||||||
|
// Loop so we get just the app's ID
|
||||||
|
for (var i = 0; i < _selected.length; i++) {
|
||||||
|
var id = _selected[i].id;
|
||||||
|
ids.push(id.split("::").pop());
|
||||||
|
}
|
||||||
|
switch (_action.id) {
|
||||||
|
case 'delete':
|
||||||
|
egw.json("addressbook.addressbook_ui.ajax_action", [_action.id, ids, all, no_notifications]).sendRequest(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* [More...] in phones clicked: copy allways shown phone numbers to phone popup
|
* [More...] in phones clicked: copy allways shown phone numbers to phone popup
|
||||||
*
|
*
|
||||||
|
@ -442,6 +442,31 @@ class AddressbookApp extends EgwApp
|
|||||||
nm_action(_action, _senders);
|
nm_action(_action, _senders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Actions via ajax
|
||||||
|
*
|
||||||
|
* @param {egwAction} _action
|
||||||
|
* @param {egwActionObject[]} _selected
|
||||||
|
*/
|
||||||
|
action(_action : egwAction, _selected : egwActionObject[])
|
||||||
|
{
|
||||||
|
let all = _action.parent.data.nextmatch?.getSelection().all;
|
||||||
|
let no_notifications = _action.parent.getActionById("no_notifications")?.checked || false;
|
||||||
|
let ids = [];
|
||||||
|
// Loop so we get just the app's ID
|
||||||
|
for(var i = 0; i < _selected.length; i++)
|
||||||
|
{
|
||||||
|
var id = _selected[i].id;
|
||||||
|
ids.push(id.split("::").pop());
|
||||||
|
}
|
||||||
|
switch(_action.id)
|
||||||
|
{
|
||||||
|
case 'delete':
|
||||||
|
egw.json("addressbook.addressbook_ui.ajax_action",[_action.id, ids, all, no_notifications]).sendRequest(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [More...] in phones clicked: copy allways shown phone numbers to phone popup
|
* [More...] in phones clicked: copy allways shown phone numbers to phone popup
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user