From 8fe0efccbae8b73eb63727c17afb01373c77efe6 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 24 Mar 2014 10:53:42 -0400 Subject: [PATCH] web staff autogrid; sorting Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/parts/t_autogrid.tt2 | 113 ++++++++++++--------- Open-ILS/src/templates/staff/test/t_autogrid.tt2 | 4 +- .../web/js/ui/default/staff/services/autogrid.js | 70 ++++++------- Open-ILS/web/js/ui/default/staff/test/app.js | 20 +++- 4 files changed, 120 insertions(+), 87 deletions(-) diff --git a/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 b/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 index 9379c4b944..4091ab4d3a 100644 --- a/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 @@ -1,126 +1,147 @@
- + +
-
+
-
- [% INCLUDE 'staff/parts/column_picker.tt2' listname='dataList' %] +
+ [% INCLUDE 'staff/parts/column_picker.tt2' listname='list' %]
+ +
[% l('#') %]
- +
+ ng-show="list.displayColumns[column.name]"> {{column.label}}
-
+ + +
-
[% l('Wider') %]
-
- [% l('Narrower') %]
-
- [% l('Sort') %]
+
[% l('Wider') %]
+
[% l('Narrower') %]
+
[% l('Sort') %]
-
+ ng-show="list.displayColumns[column.name]"> +
-
+
-
+
+ +
- {{$index + 1 + dataList.pageOffset}} + {{$index + 1 + list.pageOffset}}
+ ng-model="list.selected[list.indexValue(item)]"/>
- {{dataList.fieldValue(item, column.name) | egGridvalueFilter:column}} + ng-show="list.displayColumns[column.name]"> + {{list.fieldValue(item, column.name) | egGridvalueFilter:column}}
diff --git a/Open-ILS/src/templates/staff/test/t_autogrid.tt2 b/Open-ILS/src/templates/staff/test/t_autogrid.tt2 index d4102ecd7c..1a8aa84675 100644 --- a/Open-ILS/src/templates/staff/test/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/test/t_autogrid.tt2 @@ -4,8 +4,10 @@ idl-class="aou" sort="testGridSort" query="testGridQuery" + persist-key="eg.staff.test.grid.explicit-fields" id-field="id"> @@ -30,7 +32,7 @@

AutoGrid w/ Auto Fields

= self.maxFieldCount) { - fieldSpec.display = false; - } - var field = { name : fieldSpec.name, label : fieldSpec.label, @@ -127,7 +125,7 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' }; if (!field.path) field.path = field.name; field = self.absorbField(field); - $scope.dataList.addColumn(field); + $scope.list.addColumn(field); field.flexWidth = 2; // TODO: } @@ -137,7 +135,7 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' * from the "selector" field as well. */ this.compileAutoFields = function() { - if ($scope.dataList.allColumns.length) return; + if ($scope.list.allColumns.length) return; $scope.idField = $scope.idField || egIDL.classes[$scope.idlClass].pkey; @@ -250,10 +248,12 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' * For non-stock grids, calls the external data fetcher */ $scope.fetchData = function() { - $scope.dataList.resetPageData(); - if (self.dataFetcher) - return self.dataFetcher(); + // when a list is provided, data management is + // handled externally. + if ($scope.egList) return; + + $scope.list.resetPageData(); if (!$scope.query) { console.error("egGrid requires a query"); @@ -268,11 +268,11 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' if ($scope.autoFields) self.compileAutoFields(); - $scope.dataList.indexField = $scope.idField; + $scope.list.indexField = $scope.idField; var queryFields = {} - angular.forEach($scope.dataList.allColumns, function(field) { - if ($scope.dataList.displayColumns[field.name]) + angular.forEach($scope.list.allColumns, function(field) { + if ($scope.list.displayColumns[field.name]) queryFields[field.name] = field.path || field.name; }); @@ -286,22 +286,22 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod', 'ui.bootstrap' offset : self.offset } ).then(null, null, function(item) { - $scope.dataList.items.push(item); + $scope.list.items.push(item); }); } $scope.handleRowClick = function($event, item) { - var index = $scope.dataList.indexValue(item); + var index = $scope.list.indexValue(item); if ($event.ctrlKey || $event.metaKey /* mac command */) { - $scope.dataList.toggleOneSelection(index); + $scope.list.toggleOneSelection(index); } else { - $scope.dataList.selectOne(index); + $scope.list.selectOne(index); } } $scope.itemIsSelected = function(item) { - return $scope.dataList.selected[ - $scope.dataList.indexValue(item) + return $scope.list.selected[ + $scope.list.indexValue(item) ]; } } 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 b9917c8060..7e73a4518c 100644 --- a/Open-ILS/web/js/ui/default/staff/test/app.js +++ b/Open-ILS/web/js/ui/default/staff/test/app.js @@ -19,15 +19,25 @@ angular.module('egTestApp', ['ngRoute', 'ui.bootstrap', function($scope, $rootScope, $timeout) { }]) -.controller('TestGridCtrl', - ['$scope', -function($scope) { +.controller('TestGridCtrl', function($scope, $timeout, egList) { var self = this; - console.log('TestGridCtrl'); + $scope.testGridQuery = {id : {'<>' : null}}; $scope.testGridSort = ['depth', 'parent_ou_id', 'name'] -}]); + $scope.testEgList = egList.create(); + $timeout(function() { + $scope.testEgList.items.push({ + name : 'foo', + id : '1' + }) + $scope.testEgList.items.push({ + name : 'bar', + id : '2' + }) + + }); +}); -- 2.11.0