Etemplate - add ability to toggle row selection with spacebar

This commit is contained in:
nathangray 2019-05-14 10:22:13 -06:00
parent 310182cc85
commit 07773ded32
2 changed files with 41 additions and 4 deletions

View File

@ -1604,11 +1604,11 @@ egwActionObject.prototype.handleKeyPress = function(_keyCode, _shift, _ctrl, _al
if (selObj != null) if (selObj != null)
{ {
if (!_shift) if (!_shift && !(this.parent && this.parent.data && this.parent.data.keyboard_select))
{ {
this.setAllSelected(false); this.setAllSelected(false);
} }
else else if (!(this.parent && this.parent.data && this.parent.data.keyboard_select))
{ {
var objs = focused.traversePath(selObj); var objs = focused.traversePath(selObj);
for (var i = 0; i < objs.length; i++) for (var i = 0; i < objs.length; i++)
@ -1617,7 +1617,10 @@ egwActionObject.prototype.handleKeyPress = function(_keyCode, _shift, _ctrl, _al
} }
} }
selObj.setSelected(true); if(!(this.parent.data && this.parent.data.keyboard_select))
{
selObj.setSelected(true);
}
selObj.setFocused(true); selObj.setFocused(true);
// Tell the aoi of the object to make it visible // Tell the aoi of the object to make it visible
@ -1630,6 +1633,29 @@ egwActionObject.prototype.handleKeyPress = function(_keyCode, _shift, _ctrl, _al
break; break;
// Space bar toggles selected for current row
case EGW_KEY_SPACE:
if (this.children.length <= 0)
{
break;
}
// Mark that we're selecting by keyboard, or arrows will reset selection
if(!this.parent.data)
{
this.parent.data = {};
}
this.parent.data.keyboard_select = true;
// Get the focused object
var focused = this.getFocusedObject();
focused.setSelected(!focused.getSelected());
// Tell the aoi of the object to make it visible
focused.makeVisible();
return true;
break;
// Handle CTRL-A to select all elements in the current container // Handle CTRL-A to select all elements in the current container
case EGW_KEY_A: case EGW_KEY_A:
if (_ctrl && !_shift && !_alt) if (_ctrl && !_shift && !_alt)
@ -1797,6 +1823,10 @@ egwActionObject.prototype.setAllSelected = function(_selected, _informParent)
{ {
this.parent.updateSelectedChildren(this, _selected); this.parent.updateSelectedChildren(this, _selected);
} }
if(this.parent.data && this.parent.data.keyboard_select)
{
this.parent.data.keyboard_select = false;
}
} }
// Update the children if the should be selected or if they should be // Update the children if the should be selected or if they should be

View File

@ -1646,6 +1646,8 @@ div.message.floating {
/* background-color: silver;*/ /* background-color: silver;*/
} }
/* Allow space for category color indicators, preserving column calculations */ /* Allow space for category color indicators, preserving column calculations */
.et2_nextmatch .egwGridView_outer thead tr > th:first-child { .et2_nextmatch .egwGridView_outer thead tr > th:first-child {
border-left: 6px solid transparent; border-left: 6px solid transparent;
@ -1901,7 +1903,12 @@ ul[id$='favorites_popup_state'] span.filter_value {
margin-right: -11px; margin-right: -11px;
} }
/* End of hierarchy */ /* End of hierarchy */
.et2_nextmatch .egwGridView_grid tr.focused {
background: rgba(153, 204, 255, 0.4);
}
.et2_nextmatch .egwGridView_grid tr.focused.selected {
background: rgba(153, 204, 255, 0.7);
}
/* Nextmatch tiled view */ /* Nextmatch tiled view */
.et2_nextmatch .egwGridView_grid tr.tile { .et2_nextmatch .egwGridView_grid tr.tile {
display: inline-block; display: inline-block;