<eg-grid-field label="[% l('Call Number') %]" path="call_number.label" visible></eg-grid-field>
<eg-grid-field label="[% l('Location') %]" path="location.name" visible></eg-grid-field>
- <!-- linkpath value must be a quoted string to avoid compile-time
- interpolation, hence the "'s -->
<eg-grid-field label="[% l('Title') %]"
- path="call_number.record.simple_record.title" visible
- linkpath=""[% ctx.base_path %]/opac/record/{{item['call_number.record.id']}}"">
+ path="call_number.record.simple_record.title" visible>
+ <a href="[% ctx.base_path %]/opac/record/{{item['call_number.record.id']}}">
+ {{item['call_number.record.simple_record.title']}}
+ </a>
</eg-grid-field>
</eg-grid>
items-provider="gridDataProvider"
persist-key="circ.patron.items_out">
<eg-grid-field label="[% l('Circ ID') %]" path='id' visible></eg-grid-field>
- <eg-grid-field label="[% l('Barcode') %]" path='target_copy.barcode'
- visible linkpath="'./cat/item/{{item.target_copy().id()}}'">
+ <eg-grid-field label="[% l('Barcode') %]" path='target_copy.barcode' visible>
+ <a href="./cat/item/{{item.target_copy().id()}}" target="_self">
+ {{item.target_copy().barcode()}}
+ </a>
</eg-grid-field>
<eg-grid-field label="[% l('Due Date') %]" path='due_date' visible></eg-grid-field>
<eg-grid-field label="[% l('Checkout / Renewal Library') %]" path='circ_lib.shortname' visible></eg-grid-field>
<eg-grid-field label="[% l('Renewals Remaining') %]" path='renewal_remaining' visible></eg-grid-field>
<eg-grid-field label="[% l('Fines Stopped') %]" path='stop_fines' visible></eg-grid-field>
- <eg-grid-field label="[% l('Title') %]"
- path='target_copy.call_number.record.simple_record.title' visible
- linkpath="'[% ctx.base_path %]/opac/record/{{item.target_copy().call_number().record().id()}}'">
+ <eg-grid-field label="[% l('Title') %]" name="title" visible>
+ <a href="[% ctx.base_path %]/opac/record/{{item.target_copy().call_number().record().id()}}">
+ {{item.target_copy().call_number().record().simple_record().title()}}
+ </a>
</eg-grid-field>
</eg-grid>
ng-repeat="col in columns"
style="flex:{{col.flex}}"
ng-show="col.visible">
-
- <!-- TODO: add support for configurable intra-app routing via
- linkpath. i.e. don't always assume target=_self -->
- <a ng-if="col.linkpath" target="_self"
- ng-href="{{generateLinkPath(col, item)}}">
- {{itemFieldValue(item, col)}}
- </a>
- <span ng-if="!col.linkpath">
+
+ <!-- if the cell comes with its own template,
+ translate that content into HTML and insert it here -->
+ <span ng-if="col.template"
+ ng-bind-html="translateCellTemplate(col, item)">
+ </span>
+
+ <!-- otherwise, simply display the item value, which may
+ pass through datatype-specific filtering. -->
+ <span ng-if="!col.template">
{{itemFieldValue(item, col)}}
</span>
</div>
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;
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
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) {
scope[field] = true;
}
);
+ scope.template = element.html();
egGridCtrl.columnsProvider.add(scope);
scope.$destroy();
}
sort : Number(colSpec.sort) || 0,
required : colSpec.required,
linkpath : colSpec.linkpath,
+ template : colSpec.template,
visible : colSpec.visible,
hidden : colSpec.hidden,
datatype : colSpec.datatype,