moved all confirmation to api egw_actions and changed select_all to depend on all visible rows selected (Ctrl-A)

This commit is contained in:
Ralf Becker 2013-10-03 15:30:27 +00:00
parent d7f37f5c2d
commit dad39e1d8a
4 changed files with 18 additions and 32 deletions

View File

@ -225,8 +225,11 @@ var et2_dataview_selectionManager = Class.extend(
}
// Return an array containing those ids
// RB: we are currently NOT using "inverted" (selectAll is not bound/called),
// but an all attribute comming from objectManager, if Ctrl-A was pressed and nothing deselected later
return {
"inverted": this._invertSelection,
//"inverted": this._invertSelection,
"all": this._actionObjectManager.getAllSelected(),
"ids": ids
};
},

View File

@ -468,7 +468,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput],
{
return selected;
}
return {ids:[],inverted:false};
return {ids:[],all:false};
},
/**

View File

@ -46,10 +46,6 @@ function nm_action(_action, _senders, _target, _ids)
}
}
// ----------------------
// TODO: Parse the _ids.inverted flag!
// ----------------------
// Translate the internal uids back to server uids
var idsArr = _ids.ids;
for (var i = 0; i < idsArr.length; i++)
@ -69,23 +65,6 @@ function nm_action(_action, _senders, _target, _ids)
var mgr = _action.getManager();
var select_all = mgr.getActionById("select_all");
var confirm_msg = (idsArr.length > 1 || select_all && select_all.checked) &&
typeof _action.data.confirm_multiple != 'undefined' ?
_action.data.confirm_multiple : _action.data.confirm;
// let user confirm the action first (if not select_all set and nm_action == 'submit' --> confirmed later)
if (!(select_all && select_all.checked && _action.data.nm_action == 'submit') &&
typeof _action.data.confirm != 'undefined')
{
if (!confirm(confirm_msg)) return;
}
// in case we only need to confirm multiple selected (only _action.data.confirm_multiple)
else if (typeof _action.data.confirm_multiple != 'undefined' && (idsArr.length > 1 || select_all && select_all.checked))
{
if (!confirm(_action.data.confirm_multiple)) return;
}
var url = '#';
if (typeof _action.data.url != 'undefined')
{
@ -140,11 +119,6 @@ function nm_action(_action, _senders, _target, _ids)
}
// fall through, if popup is open --> submit form
case 'submit':
// let user confirm select-all
if (select_all && select_all.checked)
{
if (!confirm((confirm_msg ? confirm_msg : _action.caption.replace(/^(&nbsp;| | )+/,''))+"\n\n"+select_all.hint)) return;
}
var checkboxes = mgr.getActionsByAttr("checkbox", true);
var checkboxes_elem = document.getElementById(mgr.etemplate_var_prefix+'[nm][checkboxes]');
if (checkboxes && checkboxes_elem)
@ -164,6 +138,7 @@ function nm_action(_action, _senders, _target, _ids)
var value = nextmatch.getValue();
jQuery.extend(value, this.activeFilters, {
"selected": idsArr,
"select_all": _ids.all,
"checkboxes": checkboxes_elem ? checkboxes_elem.value : null
});
value[nextmatch.options.settings.action_var]= _action.id;

View File

@ -367,9 +367,6 @@ egwAction.prototype.updateActions = function(_actions, _app)
}
}
if (typeof elem.confirm != "undefined") elem.confirm = egw.lang(elem.confirm);
if (typeof elem.confirm_multiple != "undefined") elem.confirm_multiple = egw.lang(elem.confirm_multiple);
// set certain enabled functions (if enabled is on it's default of true)
if (elem.enabled === true)
{
@ -512,6 +509,17 @@ egwAction.prototype.execute = function(_senders, _target)
if (this.data && this.data.confirm && this.onExecute.fcnt != window.nm_action &&
typeof et2_dialog != 'undefined') // let old eTemplate run it's own confirmation from nextmatch_action.js
{
var msg = this.data.confirm;
if (_senders.length > 1)
{
if (this.data.confirm_multiple) msg = this.data.confirm_multiple;
// check if we have all rows selected
var obj_manager = egw_getObjectManager(this.getManager().parent.id, false);
if (obj_manager && obj_manager.getAllSelected())
{
msg += "\n\n"+egw().lang('Attention: action will be applied to all rows, not only visible ones!');
}
}
var self = this;
et2_dialog.show_dialog(function(_button)
{
@ -519,7 +527,7 @@ egwAction.prototype.execute = function(_senders, _target)
{
return self.onExecute.exec(self, _senders, _target);
}
}, self.data.confirm, self.data.hint, {}, et2_dialog.BUTTONS_YES_NO, et2_dialog.QUESTION_MESSAGE);
}, msg, self.data.hint, {}, et2_dialog.BUTTONS_YES_NO, et2_dialog.QUESTION_MESSAGE);
return;
}
return this.onExecute.exec(this, _senders, _target);