web staff: grid stuff
authorBill Erickson <berick@esilibrary.com>
Fri, 28 Mar 2014 13:56:59 +0000 (09:56 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 28 Mar 2014 13:56:59 +0000 (09:56 -0400)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/css/style.css.tt2
Open-ILS/src/templates/staff/parts/t_autogrid.tt2
Open-ILS/src/templates/staff/test/t_autogrid.tt2
Open-ILS/src/templates/staff/test/t_autogrid2.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/services/grid.js
Open-ILS/web/js/ui/default/staff/services/list.js
Open-ILS/web/js/ui/default/staff/test/app.js

index 977c15f..8ed9c70 100644 (file)
@@ -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 { 
index 45987c2..29d73b2 100644 (file)
   </div>
 </div>
 
+<!--
+<br/>
+-->
+
 <div ng-show="list.items.length == 0" 
   class="alert alert-info">[% l('No Items To Display') %]</div>
 
         style="flex:{{column.flex}}"
         ng-show="list.displayColumns[column.name]">
       <a href="javascript:;" ng-click="sortOn(column.name)">{{column.label}}</a>
+      <div style="height:100%;color:black">
+        foo
+        
+      </div>
     </div>
   </div>
 
index a164670..dc52faa 100644 (file)
@@ -15,7 +15,7 @@
   <eg-grid-field path="name" flex="5"></eg-grid-field>
   <eg-grid-field path="id"></eg-grid-field>
   <eg-grid-field path="ou_type.depth"></eg-grid-field>
-  <eg-grid-field path="billing_address.street1" flex="3"></eg-grid-field>
+  <eg-grid-field path="billing_address.street1" flex="3" label="[% l('Address') %]"></eg-grid-field>
   <eg-grid-field path="opac_visible"></eg-grid-field>
   <eg-grid-field path="phone"></eg-grid-field>
   <eg-grid-field path="email"></eg-grid-field>
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 (file)
index 0000000..7d53a5d
--- /dev/null
@@ -0,0 +1,8 @@
+
+<eg-grid
+  persist-key="eg.staff.test.grid.auto-fields"
+  idl-class="rmsr"
+  is-scroll="true"
+  sort="testGridSort"
+  query="testGridQuery"
+  auto-fields="true"/>
index 75ca484..5b32df0 100644 (file)
@@ -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();
         }
     };
 })
index f100f6f..d40f1d6 100644 (file)
@@ -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;
index 7e73a45..e715b3b 100644 (file)
@@ -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 = []
 });
 
  
 
+