From 0e70e8487b188007d4dcdaa719d4e0a5b207404b Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 17 Jul 2015 19:22:36 +0000 Subject: [PATCH] webstaff: teach egGrid how to disable multiselect For grids where it makes sense to allow only one row to be selected at a time, egGrid now supports a "-multiselect" feature that: * disables generation of the checkbox column * disables control-/shift/command-click to multiselect Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- Open-ILS/src/templates/staff/share/t_autogrid.tt2 | 4 ++-- Open-ILS/web/js/ui/default/staff/services/grid.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 index 3d021a2b24..53265c6ff1 100644 --- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 @@ -202,7 +202,7 @@
[% l('#') %]
-
+
{{$index + offset() + 1}}
-
+
diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index e2c1c52553..ce0542f9a7 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -34,6 +34,9 @@ angular.module('egGridMod', // -display : columns are hidden by default // -sort : columns are unsortable by default // -multisort : sort priorities config disabled by default + // -multiselect : only one row at a time can be selected; + // choosing this also disables the checkbox + // column features : '@', // optional primary grid label @@ -143,6 +146,7 @@ angular.module('egGridMod', defaultToNoSort : (features.indexOf('-sort') > -1), defaultToNoMultiSort : (features.indexOf('-multisort') > -1) }); + $scope.canMultiSelect = (features.indexOf('-multiselect') == -1); $scope.handleAutoFields = function() { if ($scope.autoFields) { @@ -666,6 +670,12 @@ angular.module('egGridMod', var origSelected = Object.keys($scope.selected); + if (!$scope.canMultiSelect) { + grid.selectOneItem(index); + grid.lastSelectedItemIndex = index; + return; + } + if ($event.ctrlKey || $event.metaKey /* mac command */) { // control-click if (grid.toggleSelectOneItem(index)) -- 2.11.0