mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
Implement client side delete confirmation
This commit is contained in:
parent
fe086b752b
commit
03cd666e8b
@ -494,17 +494,19 @@ class infolog_ui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($values) && isset($values['nm']['rows']['document'])) // handle insert in default document button like an action
|
// Handle legacy buttons like actions
|
||||||
|
if(is_array($values))
|
||||||
{
|
{
|
||||||
list($id) = @each($values['nm']['rows']['document']);
|
foreach(array('document', 'view', 'delete') as $button)
|
||||||
$values['nm']['action'] = 'document';
|
{
|
||||||
$values['nm']['selected'] = array($id);
|
if(isset($values['nm']['rows'][$button]))
|
||||||
}
|
{
|
||||||
elseif (is_array($values) && isset($values['nm']['rows']['view'])) // Handle view parent / sub buttons like an action
|
list($id) = @each($values['nm']['rows'][$button]);
|
||||||
{
|
$values['nm']['action'] = $button;
|
||||||
list($id) = @each($values['nm']['rows']['view']);
|
$values['nm']['selected'] = array($id);
|
||||||
$values['nm']['action'] = 'view';
|
break; // Only one can come per submit
|
||||||
$values['nm']['selected'] = array($id);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (is_array($values) && !empty($values['nm']['action']))
|
if (is_array($values) && !empty($values['nm']['action']))
|
||||||
{
|
{
|
||||||
@ -608,22 +610,6 @@ class infolog_ui
|
|||||||
// todo: move this to actions(), interactive delete only if subs
|
// todo: move this to actions(), interactive delete only if subs
|
||||||
switch($do)
|
switch($do)
|
||||||
{
|
{
|
||||||
case 'delete':
|
|
||||||
if (!($values['msg'] = $this->delete($do_id,$called_as,$called_as ? '' : 'index'))) return;
|
|
||||||
// did we deleted the entries, whos subentries we are showing?
|
|
||||||
if ($action == 'sp' && $action_id == $do_id)
|
|
||||||
{
|
|
||||||
// redirect to our referer or reset the subentry view
|
|
||||||
if (!$called_as && $own_referer)
|
|
||||||
{
|
|
||||||
$this->tmpl->location($own_referer); // eg. redirect back to calendar
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unset($action_id); unset($action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'close':
|
case 'close':
|
||||||
$closesingle=true;
|
$closesingle=true;
|
||||||
case 'close_all':
|
case 'close_all':
|
||||||
@ -950,6 +936,7 @@ class infolog_ui
|
|||||||
'confirm_multiple' => 'Are you sure you want to delete these entries ?',
|
'confirm_multiple' => 'Are you sure you want to delete these entries ?',
|
||||||
'group' => ++$group,
|
'group' => ++$group,
|
||||||
'disableClass' => 'rowNoDelete',
|
'disableClass' => 'rowNoDelete',
|
||||||
|
'onExecute' => 'javaScript:confirm_delete',
|
||||||
);
|
);
|
||||||
|
|
||||||
//echo "<p>".__METHOD__."($do_email, $tid_filter, $org_view)</p>\n"; _debug_array($actions);
|
//echo "<p>".__METHOD__."($do_email, $tid_filter, $org_view)</p>\n"; _debug_array($actions);
|
||||||
@ -1073,9 +1060,9 @@ class infolog_ui
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
$action_msg = lang('deleted');
|
$action_msg = $settings == 'sub' ? lang(' (and children) deleted') : lang('deleted');
|
||||||
$result = $this->delete($id, '', 'multi-action', $skip_notifications);
|
//$result = $this->bo->delete($id, $settings=='sub', false, $skip_notifications);
|
||||||
if($result != '')
|
if($result == true)
|
||||||
{
|
{
|
||||||
$success++;
|
$success++;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ function submit_popup(button)
|
|||||||
{
|
{
|
||||||
button.form.submit_button.value = button.name; // set name of button (sub-action)
|
button.form.submit_button.value = button.name; // set name of button (sub-action)
|
||||||
|
|
||||||
// call regular nm_action to transmitt action and senders correct
|
// call regular nm_action to transmit action and senders correct
|
||||||
nm_action(infolog_popup_action, infolog_popup_senders);
|
nm_action(infolog_popup_action, infolog_popup_senders);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,4 +50,29 @@ function hide_popup(element, div_id)
|
|||||||
if(popup) {
|
if(popup) {
|
||||||
popup.style.display = 'none';
|
popup.style.display = 'none';
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Confirm delete
|
||||||
|
* If entry has children, asks if you want to delete children too
|
||||||
|
*
|
||||||
|
* @param _action
|
||||||
|
* @param _senders
|
||||||
|
*/
|
||||||
|
function confirm_delete(_action, _senders)
|
||||||
|
{
|
||||||
|
var child_button = document.getElementById('exec[delete_sub]');
|
||||||
|
var d_prompt = document.getElementById('delete_prompt');
|
||||||
|
if(d_prompt.previousSibling) $(d_prompt.previousSibling).remove();
|
||||||
|
var children = false;
|
||||||
|
if(child_button) {
|
||||||
|
for(var i = 0; i < _senders.length; i++) {
|
||||||
|
children = children || $(_senders[i].iface.node).hasClass('rowHasSubs');
|
||||||
|
}
|
||||||
|
child_button.style.display = children ? 'block' : 'none';
|
||||||
|
|
||||||
|
$(d_prompt).text(_senders.length > 1 ? _action.data.confirm_multiple : _action.data.confirm);
|
||||||
|
}
|
||||||
|
open_popup(_action, _senders);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user