/**
* Data shared across FF controllers.
+ * TODO: this call all live in FFMainCtrl
*/
.factory('ffService',
['$rootScope', 'egOrg', 'egAuth',
egStartup.go().then(function() {
// after startup, we want to fetch the perm orgs for our
// logged in user. From there, we can drive the org selector
- // TODO: we need an FF-specific perm, since login perms are
- // all or none.
- egUser.hasPermAt('STAFF_LOGIN')
+ egUser.hasPermAt('FULFILLMENT_ADMIN')
.then(function(orgList) {
- console.log('setting login list at ' +
- orgList.map(function(org) { return org.shortname() }));
ffService.orgList(orgList);
$scope.ffService = ffService;
});
};
}
);
+
+ // data collection and pagination
+
+ // collector function collects the list of items
+ // and calls itemList.addItem for each one.
+ $scope.setCollector = function(colFn) {
+ $scope.collector = colFn;
+ }
+
+ $scope.firstPage = function() {
+ $scope.itemList.offset = 0;
+ $scope.collector();
+ };
+
+ $scope.nextPage = function() {
+ $scope.itemList.offset += $scope.itemList.limit;
+ $scope.collector();
+ };
+
+ $scope.prevPage = function() {
+ $scope.itemList.offset -= $scope.itemList.limit;
+ $scope.collector();
+ };
+
}])
.controller('TransitsCtrl',
['$scope', '$q', 'egPCRUD', 'ffService',
function ($scope, $q, egPCRUD, ffService) {
- $scope.drawTable = function() {
+ $scope.setCollector(function() {
var deferred = $q.defer();
$scope.itemList.items = [];
{ limit : $scope.itemList.limit,
offset : $scope.itemList.offset,
flesh : 1,
- flesh_fields : {atc : ['target_copy']}
+ flesh_fields : {atc : ['target_copy']},
+ order_by : {'atc' : 'source_send_time, id'}
}, {atomic : true}
).then(function(transits) {
angular.forEach(transits, function(transit) {
{barcode : transit.target_copy().barcode()});
});
});
- };
+ });
- // outbound tab defaults to lender view
- return $scope.drawTable($scope.tab_outbound == true);
+ return $scope.collector();
}])
.controller('CircCtrl',
['$scope', '$q', 'egPCRUD', 'ffService',
function ($scope, $q, egPCRUD, ffService) {
- $scope.drawTable = function() {
+ $scope.setCollector(function() {
var deferred = $q.defer();
$scope.itemList.items = [];
{ limit : $scope.itemList.limit,
offset : $scope.itemList.offset,
flesh : 1,
- flesh_fields : {circ : ['target_copy']}
+ flesh_fields : {circ : ['target_copy']},
+ order_by : {'circ' : 'xact_start, id'}
}, {atomic : true}
).then(function(circs) {
angular.forEach(circs, function(circ) {
{barcode : circ.target_copy().barcode()});
});
});
- };
+ });
// outbound tab defaults to lender view
- return $scope.drawTable();
+ return $scope.collector();
}])
headers: {'Content-Type': 'multipart/form-data'}
})
.success(function(data, status, headers, config) {
- console.log("upload finished");
$scope.in_flight = false;
$scope.uploadComplete = true;
deferred.resolve(data);
})
.error(function(data, status, headers, config){
- console.warn("upload failed");
+ console.warn("upload failed: " + status);
$scope.in_flight = false;
$scope.uploadFailed = true;
deferred.reject(status);