From 5444c52a6b7ffe9e5772a68e16bd6ca64332a4cf Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 28 Mar 2014 09:56:59 -0400 Subject: [PATCH] web staff: grid stuff Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/css/style.css.tt2 | 3 ++ Open-ILS/src/templates/staff/parts/t_autogrid.tt2 | 8 +++++ Open-ILS/src/templates/staff/test/t_autogrid.tt2 | 2 +- Open-ILS/src/templates/staff/test/t_autogrid2.tt2 | 8 +++++ Open-ILS/web/js/ui/default/staff/services/grid.js | 43 +++++++++++++---------- Open-ILS/web/js/ui/default/staff/services/list.js | 15 ++++---- Open-ILS/web/js/ui/default/staff/test/app.js | 15 ++++++++ 7 files changed, 68 insertions(+), 26 deletions(-) create mode 100644 Open-ILS/src/templates/staff/test/t_autogrid2.tt2 diff --git a/Open-ILS/src/templates/staff/css/style.css.tt2 b/Open-ILS/src/templates/staff/css/style.css.tt2 index 977c15ff5b..8ed9c7005c 100644 --- a/Open-ILS/src/templates/staff/css/style.css.tt2 +++ b/Open-ILS/src/templates/staff/css/style.css.tt2 @@ -109,6 +109,9 @@ table.list tr.selected td { .eg-grid-action-row { border: none; justify-content:flex-end; /* i.e. float right */ + + /* margin should not have to be this large; something's up */ + margin-bottom: 15px; } .eg-grid-header-row { diff --git a/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 b/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 index 45987c2ccb..29d73b2798 100644 --- a/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 @@ -38,6 +38,10 @@ + +
[% l('No Items To Display') %]
@@ -60,6 +64,10 @@ style="flex:{{column.flex}}" ng-show="list.displayColumns[column.name]"> {{column.label}} +
+ foo + +
diff --git a/Open-ILS/src/templates/staff/test/t_autogrid.tt2 b/Open-ILS/src/templates/staff/test/t_autogrid.tt2 index a1646700f1..dc52faa121 100644 --- a/Open-ILS/src/templates/staff/test/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/test/t_autogrid.tt2 @@ -15,7 +15,7 @@ - + diff --git a/Open-ILS/src/templates/staff/test/t_autogrid2.tt2 b/Open-ILS/src/templates/staff/test/t_autogrid2.tt2 new file mode 100644 index 0000000000..7d53a5d000 --- /dev/null +++ b/Open-ILS/src/templates/staff/test/t_autogrid2.tt2 @@ -0,0 +1,8 @@ + + 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 75ca484c30..5b32df01ce 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -54,11 +54,28 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' function($scope, $timeout, $modal, egIDL, egAuth, egNet, egList) { var self = this; - // TODO: dynamic - this.limit = 20; - this.ofset = 0; + // setup function, called at the end of the controller + this.init = function() { + self.limit = 25; + self.ofset = 0; - $scope.list = $scope.egList || egList.create(); + if (!$scope.query) { + console.error("egGrid requires a query"); + return; + } + + if (!$scope.idlClass) { + console.error("egGrid requires an idlClass"); + return; + } + + $scope.list = $scope.egList || egList.create(); + + if ($scope.autoFields) + self.compileAutoFields(); + + $scope.list.indexField = $scope.idField; + } // column-header click quick sort $scope.sortOn = function(col_name) { @@ -273,20 +290,6 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' $scope.list.resetPageData(); - if (!$scope.query) { - console.error("egGrid requires a query"); - return; - } - - if (!$scope.idlClass) { - console.error("egGrid requires an idlClass"); - return; - } - - if ($scope.autoFields) - self.compileAutoFields(); - - $scope.list.indexField = $scope.idField; var queryFields = {} angular.forEach($scope.list.allColumns, function(field) { @@ -335,6 +338,8 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' // update to new last-selected self.lastSelectedRowIndex = index; + // select each row between the last selected and + // currently selected items while (true) { startPos += ascending ? 1 : -1; var curItem = $scope.list.items[startPos]; @@ -355,6 +360,8 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' $scope.list.indexValue(item) ]; } + + this.init(); } }; }) diff --git a/Open-ILS/web/js/ui/default/staff/services/list.js b/Open-ILS/web/js/ui/default/staff/services/list.js index f100f6f740..d40f1d60c0 100644 --- a/Open-ILS/web/js/ui/default/staff/services/list.js +++ b/Open-ILS/web/js/ui/default/staff/services/list.js @@ -51,14 +51,15 @@ angular.module('egListMod', ['egCoreMod']) this.selected = {}; this.indexValue = function(item) { - if (!item) return null; - // assumes non-object's are bare indexes - if (typeof item != 'object') return item; - if (this.indexFieldAsFunction) { - return item[this.indexField](); - } else { - return item[this.indexField]; + if (angular.isObject(item)) { + if (item !== null) { + if (this.indexFieldAsFunction) + return item[this.indexField](); + return item[this.indexField]; + } } + // passed a non-object; assume it's an index + return item; } // returns true if item1 appears in the list before item2; diff --git a/Open-ILS/web/js/ui/default/staff/test/app.js b/Open-ILS/web/js/ui/default/staff/test/app.js index 7e73a4518c..e715b3b1ae 100644 --- a/Open-ILS/web/js/ui/default/staff/test/app.js +++ b/Open-ILS/web/js/ui/default/staff/test/app.js @@ -12,6 +12,13 @@ angular.module('egTestApp', ['ngRoute', 'ui.bootstrap', resolve : resolver }); + $routeProvider.when('/test/autogrid2', { + templateUrl: './test/t_autogrid2', + controller: 'TestGridCtrl2', + resolve : resolver + }); + + //$routeProvider.otherwise({redirectTo : '/circ/patron/search'}); }) @@ -37,7 +44,15 @@ angular.module('egTestApp', ['ngRoute', 'ui.bootstrap', }) }); +}) + +.controller('TestGridCtrl2', function($scope, $timeout, egList) { + var self = this; + console.log('TestGridCtrl2'); + $scope.testGridQuery = {id : {'<>' : null}}; + $scope.testGridSort = [] }); + -- 2.11.0