LP#1730752 Grid colum 'sort visible to top' option
authorBill Erickson <berickxx@gmail.com>
Thu, 9 Nov 2017 16:21:40 +0000 (11:21 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 9 Feb 2018 16:55:44 +0000 (11:55 -0500)
Adds a new button to the grid configuration dialog to sort visible
columns to the top of the dialog (i.e. the left of the grid).

Fix issue where last modified column remained styled after the dialog
closes.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/share/t_grid_columns.tt2
Open-ILS/web/js/ui/default/staff/services/grid.js

index 4393446..5b1cf6a 100644 (file)
       <div class="col-md-1" ng-if="!disableMultiSort">
         [% l('Sort Priority') %]
       </div>
+      <div class="col-md-3">
+        <button class="btn btn-default" ng-click="elevateVisible()">
+          [% l('Sort Visible Columns To Top') %]
+        </button>
+      </div>
     </div>
     <div class="row" ng-repeat="col in columns" 
       ng-class="{visible : col.visible}">
index e85171d..3f7a9df 100644 (file)
@@ -1087,10 +1087,29 @@ angular.module('egGridMod',
                             $dialogScope.modifyColumnPos = $scope.modifyColumnPos;
                             $dialogScope.disableMultiSort = $scope.disableMultiSort;
                             $dialogScope.columns = $scope.columns;
+
+                            // Push visible columns to the top of the list
+                            $dialogScope.elevateVisible = function() {
+                                var new_cols = [];
+                                angular.forEach($dialogScope.columns, function(col) {
+                                    if (col.visible) new_cols.push(col);
+                                });
+                                angular.forEach($dialogScope.columns, function(col) {
+                                    if (!col.visible) new_cols.push(col);
+                                });
+
+                                // Update all references to the list of columns
+                                $dialogScope.columns = 
+                                    $scope.columns = 
+                                    grid.columnsProvider.columns = 
+                                    new_cols;
+                            }
+
                             $dialogScope.toggle = function(col) {
                                 col.visible = !Boolean(col.visible);
                             }
                             $dialogScope.ok = $dialogScope.cancel = function() {
+                                delete $scope.lastModColumn;
                                 $uibModalInstance.close()
                             }
                         }