mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-10-06 10:02:21 +02:00
- Automatically add 'Select All' action with Ctrl+A shortcut after first action group
- Implement Select All into selection controller so it works even if all rows aren't loaded
This commit is contained in:
parent
2f0f2ae303
commit
7c7d6391ab
@ -621,12 +621,34 @@ class etemplate_widget_nextmatch extends etemplate_widget
|
|||||||
//echo "actions="; _debug_array($actions);
|
//echo "actions="; _debug_array($actions);
|
||||||
$egw_actions = array();
|
$egw_actions = array();
|
||||||
$n = 1;
|
$n = 1;
|
||||||
|
$group = false;
|
||||||
|
|
||||||
foreach((array)$actions as $id => $action)
|
foreach((array)$actions as $id => $action)
|
||||||
{
|
{
|
||||||
// in case it's only selectbox id => label pairs
|
// in case it's only selectbox id => label pairs
|
||||||
if (!is_array($action)) $action = array('caption' => $action);
|
if (!is_array($action)) $action = array('caption' => $action);
|
||||||
if ($default_attrs) $action += $default_attrs;
|
if ($default_attrs) $action += $default_attrs;
|
||||||
|
|
||||||
|
// Add 'Select All' after first group
|
||||||
|
if ($first_level && $group !== false && $action['group'] != $group && !$egw_actions[$prefix.'select_all'])
|
||||||
|
{
|
||||||
|
|
||||||
|
$egw_actions[$prefix.'select_all'] = array(
|
||||||
|
'caption' => 'Select all',
|
||||||
|
//'checkbox' => true,
|
||||||
|
'hint' => 'Select all entries',
|
||||||
|
'enabled' => true,
|
||||||
|
'shortcut' => array(
|
||||||
|
'keyCode' => 65, // A
|
||||||
|
'ctrl' => true,
|
||||||
|
'caption' => 'Ctrl+A'
|
||||||
|
),
|
||||||
|
'group' => $action['group'],
|
||||||
|
);
|
||||||
|
$action_links[] = $prefix.'select_all';
|
||||||
|
}
|
||||||
|
$group = $action['group'];
|
||||||
|
|
||||||
if (!$first_level && $n == $max_length && count($actions) > $max_length)
|
if (!$first_level && $n == $max_length && count($actions) > $max_length)
|
||||||
{
|
{
|
||||||
$id = 'more_'.count($actions); // we need a new unique id
|
$id = 'more_'.count($actions); // we need a new unique id
|
||||||
@ -680,7 +702,7 @@ class etemplate_widget_nextmatch extends etemplate_widget
|
|||||||
}
|
}
|
||||||
|
|
||||||
$egw_actions[$prefix.$id] = $action;
|
$egw_actions[$prefix.$id] = $action;
|
||||||
|
|
||||||
if (!$first_level && $n++ == $max_length) break;
|
if (!$first_level && $n++ == $max_length) break;
|
||||||
}
|
}
|
||||||
//echo "egw_actions="; _debug_array($egw_actions);
|
//echo "egw_actions="; _debug_array($egw_actions);
|
||||||
|
@ -62,6 +62,7 @@ var et2_dataview_selectionManager = Class.extend(
|
|||||||
this._registeredRows = {};
|
this._registeredRows = {};
|
||||||
this._focusedEntry = null;
|
this._focusedEntry = null;
|
||||||
this._invertSelection = false;
|
this._invertSelection = false;
|
||||||
|
this._selectAll = false;
|
||||||
this._inUpdate = false;
|
this._inUpdate = false;
|
||||||
this._total = 0;
|
this._total = 0;
|
||||||
this._children = [];
|
this._children = [];
|
||||||
@ -160,6 +161,8 @@ var et2_dataview_selectionManager = Class.extend(
|
|||||||
|
|
||||||
resetSelection: function () {
|
resetSelection: function () {
|
||||||
this._invertSelection = false;
|
this._invertSelection = false;
|
||||||
|
this._selectAll = false;
|
||||||
|
this._actionObjectManager.setAllSelected(false);
|
||||||
|
|
||||||
for (var key in this._registeredRows)
|
for (var key in this._registeredRows)
|
||||||
{
|
{
|
||||||
@ -168,6 +171,7 @@ var et2_dataview_selectionManager = Class.extend(
|
|||||||
},
|
},
|
||||||
|
|
||||||
setSelected: function (_uid, _selected) {
|
setSelected: function (_uid, _selected) {
|
||||||
|
this._selectAll = false;
|
||||||
var entry = this._getRegisteredRowsEntry(_uid);
|
var entry = this._getRegisteredRowsEntry(_uid);
|
||||||
this._updateEntryState(entry,
|
this._updateEntryState(entry,
|
||||||
egwSetBit(entry.state, EGW_AO_STATE_SELECTED, _selected));
|
egwSetBit(entry.state, EGW_AO_STATE_SELECTED, _selected));
|
||||||
@ -196,9 +200,11 @@ var et2_dataview_selectionManager = Class.extend(
|
|||||||
// Reset the selection
|
// Reset the selection
|
||||||
this.resetSelection();
|
this.resetSelection();
|
||||||
|
|
||||||
// Set the "invert selection" flag
|
this._selectAll = true;
|
||||||
this._invertSelection = true;
|
|
||||||
|
// Tell action manager to do all
|
||||||
|
this._actionObjectManager.setAllSelected(true);
|
||||||
|
|
||||||
// Update the selection
|
// Update the selection
|
||||||
for (var key in this._registeredRows)
|
for (var key in this._registeredRows)
|
||||||
{
|
{
|
||||||
@ -225,11 +231,10 @@ var et2_dataview_selectionManager = Class.extend(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return an array containing those ids
|
// Return an array containing those ids
|
||||||
// RB: we are currently NOT using "inverted" (selectAll is not bound/called),
|
// RB: we are currently NOT using "inverted"
|
||||||
// but an all attribute comming from objectManager, if Ctrl-A was pressed and nothing deselected later
|
|
||||||
return {
|
return {
|
||||||
//"inverted": this._invertSelection,
|
//"inverted": this._invertSelection,
|
||||||
"all": this._actionObjectManager.getAllSelected(),
|
"all": this._selectAll,
|
||||||
"ids": ids
|
"ids": ids
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -363,8 +368,11 @@ var et2_dataview_selectionManager = Class.extend(
|
|||||||
|
|
||||||
_updateEntryState: function (_entry, _state) {
|
_updateEntryState: function (_entry, _state) {
|
||||||
|
|
||||||
|
if (this._selectAll)
|
||||||
if (this._invertSelection)
|
{
|
||||||
|
_state |= EGW_AO_STATE_SELECTED;
|
||||||
|
}
|
||||||
|
else if (this._invertSelection)
|
||||||
{
|
{
|
||||||
_state ^= EGW_AO_STATE_SELECTED;
|
_state ^= EGW_AO_STATE_SELECTED;
|
||||||
}
|
}
|
||||||
|
@ -2435,7 +2435,7 @@ var et2_nextmatch_entryheader = et2_link_entry.extend(et2_INextmatchHeader,
|
|||||||
} else {
|
} else {
|
||||||
delete (this.nextmatch.activeFilters["col_filter"][this.id]);
|
delete (this.nextmatch.activeFilters["col_filter"][this.id]);
|
||||||
}
|
}
|
||||||
this.nextmatch.applyFilters();
|
this.nextmatch.applyFilters.call(this.nextmatch);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,6 +151,15 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(et2_IDataProvider,
|
|||||||
// Call the nm_action function with the ids
|
// Call the nm_action function with the ids
|
||||||
nm_action(_action, _senders, _target, ids);
|
nm_action(_action, _senders, _target, ids);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set the 'Select All' handler
|
||||||
|
var select_all = this._actionManager.getActionById('select_all');
|
||||||
|
if(select_all)
|
||||||
|
{
|
||||||
|
select_all.set_onExecute(jQuery.proxy(function(action, selected) {
|
||||||
|
this._selectionMgr.selectAll();
|
||||||
|
}, this));
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the object manager
|
// Initialize the object manager
|
||||||
var gom = egw_getObjectManager(this.egw.appName);
|
var gom = egw_getObjectManager(this.egw.appName);
|
||||||
|
Loading…
Reference in New Issue
Block a user