id="patron-checkout-barcode" type="text"/>
<input class="btn btn-default" type="submit" value="[% l('Submit') %]"/>
-
- <!-- do we really need a button?
- <span class="input-group-btn">
- <input type="submit" class="btn btn-default" value="[% l('Submit') %]"/>
- </span>
- -->
</div>
</form>
.controller('PatronSearchCtrl',
['$scope','$q','$routeParams','$timeout','$window','$location','egEnv',
'$filter','egIDL','egNet','egAuth','egEvent','egUser',
- 'patronSvc','egGridDataProvider','egPrintStore',
+ 'patronSvc','egGridDataProvider','egPrintStore','egOrg',
function($scope, $q, $routeParams, $timeout, $window, $location, egEnv,
$filter, egIDL, egNet, egAuth, egEvent, egUser,
- patronSvc , egGridDataProvider , egPrintStore) {
+ patronSvc , egGridDataProvider , egPrintStore , egOrg) {
$scope.initTab('search');
$scope.focusMe = true;
fullSearch.count,
fullSearch.sort,
fullSearch.inactive,
- fullSearch.home_ou,
+ fullSearch.home_ou || egOrg.tree().id(),
egUser.defaultFleshFields,
fullSearch.offset
// refresh itself.
$scope.search = function(args) { // args === $scope.searchArgs
if (args && Object.keys(args).length)
- provider.increment();
+ provider.increment(true);
}
// TODO: move this into the (forthcoming) grid row activate action
delete $scope.autoFields;
}
- if (grid.dataProvider) {
-
- // refresh the grid contents each time the data
- // provider's revision changes
- $scope.$watch(
- function() { return grid.dataProvider.revision() },
- function(newVal, oldVal) {
- if (newVal !== oldVal) grid.collect();
- }
- );
-
- } else {
+ if (!grid.dataProvider) {
grid.selfManagedData = true;
grid.dataProvider = egGridFlatDataProvider.instance({
function() { return grid.dataProvider.query() },
function(newVal, oldVal) {
if (newVal !== oldVal)
- grid.collect()
+ grid.dataProvider.load(true);
},
true // object comparison
);
delete $scope.query;
}
+ grid.dataProvider.load = function(reset) {
+ if (reset) grid.offset = 0;
+ grid.collect();
+ }
+
$scope.itemFieldValue = grid.dataProvider.itemFieldValue;
$scope.indexValue = function(item) {
return grid.indexValue(item)
var gridData = this;
gridData.sort = [];
- gridData._revision = 0;
gridData.query = args.query;
gridData.idlClass = args.idlClass;
gridData.columnsProvider = args.columnsProvider;
return {};
}
- gridData.revision = function() {
- return gridData._revision;
- }
-
- // incrementing the revision tells the grid that a data
- // refresh is needed.
- gridData.increment = function() {
- gridData._revision++;
+ // incrementing the provider informs the grid it's time to
+ // redraw itself. If reset is true, it resets the grid paging
+ // to page 0.
+ gridData.increment = function(reset) {
+ gridData.load(reset);
}
// returns a promise whose notify() delivers items
}
service.setItem = function(key, value) {
- return service.setRemoteItem(key, value)['catch'](
+ var str = JSON.stringify(value);
+ return service.setRemoteItem(key, str)['catch'](
function(msg) {
- return service.setLocalItem(msg.key, msg.value);
+ return service.setLocalItem(msg.key, str);
}
);
}
// set the value for a stored or new item
service.setRemoteItem = function(key, value) {
- value = JSON.stringify(value); // all values stored as JSON text
return service.attemptHatchDelivery({
key : key,
value : value,
}
service.setLocalItem = function(key, value) {
- $window.localStorage.setItem(key, JSON.stringify(value));
+ $window.localStorage.setItem(key, value);
}
// appends the value to the existing item stored at key.
}
// assumes the appender and appendee are both strings
+ // TODO: support arrays as well
service.appendLocalItem = function(key, value) {
var item = service.getLocalItem(key);
if (item) {