From: Bill Erickson Date: Mon, 19 May 2014 18:26:52 +0000 (-0400) Subject: replace grid linkpath w/ support for inline, ad-hoc cell templates X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=bb0229e569b65052b60d6456e9abc5357032a77f;p=working%2FEvergreen.git replace grid linkpath w/ support for inline, ad-hoc cell templates Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 index 220a85343e..e4721077ca 100644 --- a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 @@ -11,11 +11,11 @@ - + path="call_number.record.simple_record.title" visible> + + {{item['call_number.record.simple_record.title']}} + diff --git a/Open-ILS/src/templates/staff/circ/patron/t_items_out.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_items_out.tt2 index d381e326d1..9fbd09b752 100644 --- a/Open-ILS/src/templates/staff/circ/patron/t_items_out.tt2 +++ b/Open-ILS/src/templates/staff/circ/patron/t_items_out.tt2 @@ -8,16 +8,19 @@ items-provider="gridDataProvider" persist-key="circ.patron.items_out"> - + + + {{item.target_copy().barcode()}} + - + + + {{item.target_copy().call_number().record().simple_record().title()}} + diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 index 06e8546284..b48d61dcf1 100644 --- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 @@ -261,14 +261,16 @@ ng-repeat="col in columns" style="flex:{{col.flex}}" ng-show="col.visible"> - - - - {{itemFieldValue(item, col)}} - - + + + + + + + {{itemFieldValue(item, col)}} 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 5051681e6c..0ca633be80 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -85,9 +85,9 @@ angular.module('egGridMod', controller : [ '$scope','$q','egCore','egGridFlatDataProvider', - 'egGridColumnsProvider','$filter','$window', + 'egGridColumnsProvider','$filter','$window','$sce', function($scope, $q , egCore, egGridFlatDataProvider, - egGridColumnsProvider , $filter , $window) { + egGridColumnsProvider , $filter , $window , $sce) { var grid = this; @@ -668,6 +668,16 @@ angular.module('egGridMod', return egCore.strings.$replace(col.linkpath, {item : item}); } + // If a column provides its own HTML template, translate it, + // using the current item for the template scope. + // note: $sce is required to avoid security restrictions and + // is OK here, since the template comes directly from a + // local HTML template (not user input). + $scope.translateCellTemplate = function(col, item) { + var html = egCore.strings.$replace(col.template, {item : item}); + return $sce.trustAsHtml(html); + } + $scope.collect = function() { grid.collect() } // asks the dataProvider for a page of data @@ -705,13 +715,6 @@ angular.module('egGridMod', path : '@', // optional; flesh path label : '@', // optional; display label flex : '@', // optional; default flex width - - // optional: url path string for generating links from grid cells. - // The path must be a quoted string and may include interpolation - // expressions. e.g. - // linkpath="'./cat/item/{{item.id()}}'" - linkpath : '=', - }, link : function(scope, element, attrs, egGridCtrl) { @@ -731,6 +734,7 @@ angular.module('egGridMod', scope[field] = true; } ); + scope.template = element.html(); egGridCtrl.columnsProvider.add(scope); scope.$destroy(); } @@ -843,6 +847,7 @@ angular.module('egGridMod', sort : Number(colSpec.sort) || 0, required : colSpec.required, linkpath : colSpec.linkpath, + template : colSpec.template, visible : colSpec.visible, hidden : colSpec.hidden, datatype : colSpec.datatype,