From fb668ab8144c5560f1940f61d173155968a78444 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 13 Mar 2014 10:07:12 -0400 Subject: [PATCH] web staff: autogrid experiments Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/parts/t_autogrid.tt2 | 57 ++++++++++++++++++---- Open-ILS/src/templates/staff/t_base.tt2 | 5 +- Open-ILS/src/templates/staff/test/t_autogrid.tt2 | 16 +++++- .../web/js/ui/default/staff/services/autogrid.js | 40 +++++++++++---- 4 files changed, 96 insertions(+), 22 deletions(-) diff --git a/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 b/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 index 8a781b3ab5..981723de13 100644 --- a/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/parts/t_autogrid.tt2 @@ -6,10 +6,15 @@ .eg-grid-header-row { font-weight: bold; } .eg-grid div.row {border-bottom: 2px solid #ddd} .eg-grid-content-row:nth-child(even) {background-color: rgb(248, 248, 248);} - .col-md-1 { overflow: hidden } + .eg-grid-content-column { overflow: hidden }
+ + +
+ +
@@ -17,23 +22,57 @@
- -
+ +
-
- {{column.label}} +
+
+ +
+
#
+
+
+
+ +
+ +
+
+
+ +
+
{{$index + 1}}
+
+
+
+
+
+ {{dataList.fieldValue(item, column.name) | egGridvalueFilter:column}} +
+
+
+
+ +
diff --git a/Open-ILS/src/templates/staff/t_base.tt2 b/Open-ILS/src/templates/staff/t_base.tt2 index 6009417ae2..67ff9b78b3 100644 --- a/Open-ILS/src/templates/staff/t_base.tt2 +++ b/Open-ILS/src/templates/staff/t_base.tt2 @@ -8,7 +8,10 @@ - + + diff --git a/Open-ILS/src/templates/staff/test/t_autogrid.tt2 b/Open-ILS/src/templates/staff/test/t_autogrid.tt2 index 946e2bb0e0..7355272003 100644 --- a/Open-ILS/src/templates/staff/test/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/test/t_autogrid.tt2 @@ -11,11 +11,22 @@ - - + + + + + + + + + + + + diff --git a/Open-ILS/web/js/ui/default/staff/services/autogrid.js b/Open-ILS/web/js/ui/default/staff/services/autogrid.js index 4632c4ed6d..54a69b80f0 100644 --- a/Open-ILS/web/js/ui/default/staff/services/autogrid.js +++ b/Open-ILS/web/js/ui/default/staff/services/autogrid.js @@ -41,7 +41,8 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod']) // if we stick w/ Bootstrap grids for display, we're // limited to 12 visible columns at a time. - this.maxFieldCount = 12; + //this.maxFieldCount = 12; + this.maxFieldCount = 11; $scope.dataList = egList.create(); @@ -63,12 +64,20 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod']) * an IDL field via compileAutoFields. */ this.addColumn = function(fieldSpec) { + + /* + if (Object.keys($scope.dataList.displayColumns).length + >= self.maxFieldCount) { + fieldSpec.display = false; + } + */ + var field = { name : fieldSpec.name, label : fieldSpec.label, path : fieldSpec.path, datatype : fieldSpec.datatype, - display : (fieldSpec.display === false) ? false : true + display : (fieldSpec.display !== false) }; if (!field.path) field.path = field.name; field = self.absorbField(field); @@ -101,14 +110,6 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod']) } } } - - // once we exceeed the number of display fields, - // the others are added as hidden fields, accessible - // via the column picker. - if ($scope.dataList.allColumns.length >= self.maxFieldCount) { - console.log('setting to false ' + field.name); - field.display = false; - } self.addColumn(field); } ); @@ -193,6 +194,24 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod']) return new_field; } + // EXPERIMENT + this.applyColumnLayout = function() { + var cols = $scope.dataList.allColumns; + var overflow = 2 * (cols.length - this.maxFieldCount); + var groupedColumns = []; + + current_bunch = []; + angular.forEach(cols, function(col, idx) { + current_bunch.push(col); + if (idx < overflow - 1 || current_bunch.length > 1) { + groupedColumns.push(current_bunch); + current_bunch = []; + } + }); + + $scope.dataList.groupedColumns = groupedColumns; + } + /** * For stock grids, makes a flattened_search call to retrieve * the requested values. @@ -200,6 +219,7 @@ angular.module('egGridMod', ['egCoreMod', 'egListMod', 'egUiMod']) */ $scope.fetchData = function() { $scope.dataList.resetPageData(); + self.applyColumnLayout(); if (self.dataFetcher) return self.dataFetcher(); -- 2.11.0