}
$scope.add_issuances = function () {
- var lastItem = egSerialsCoreSvc.itemList[egSerialsCoreSvc.itemList.length - 1];
-
- if (lastItem) lastItem = egCore.idl.fromHash('siss', lastItem.issuance);
-
- return egSerialsCoreSvc.new_holding_code({
- title : egCore.strings.SERIALS_ISSUANCE_PREDICT,
- request_count : true,
- prev_iss : lastItem
- }).then(function(hc) {
-
- var base_iss;
- if (!lastItem) {
- base_iss = new egCore.idl.siss();
- base_iss.creator( egCore.auth.user().id() );
- base_iss.editor( egCore.auth.user().id() );
- base_iss.date_published( hc.date.toISOString() );
- base_iss.subscription( $scope.ssubId );
- base_iss.caption_and_pattern( hc.scap );
- base_iss.holding_code( JSON.stringify(hc.holding_code) );
- base_iss.holding_type( hc.type );
- }
-
- // if we're predicting without a preexisting holding, reduce the count
- if (!lastItem) hc.count--;
-
- return egCore.net.request(
- 'open-ils.serial',
- 'open-ils.serial.make_predictions',
- egCore.auth.token(),
- { ssub_id : $scope.ssubId,
- include_base_issuance : lastItem ? 0 : 1,
- num_to_predict : hc.count,
- base_issuance : base_iss || lastItem
- }
- ).then(
- function(resp) {
- var evt = egCore.evt.parse(resp);
- if (evt) {
- ngToast.danger(egCore.strings.SERIALS_ISSUANCE_FAIL_SAVE);
- } else {
- ngToast.success(egCore.strings.SERIALS_ISSUANCE_SUCCESS_SAVE);
- return reload($scope.ssubId,_paging_filter);
- }
- },
- function(resp) {
- ngToast.danger(egCore.strings.SERIALS_ISSUANCE_FAIL_SAVE);
- }
- );
+ egSerialsCoreSvc.add_issuances($scope.ssubId).then(function() {
+ return reload($scope.ssubId,_paging_filter);
});
}
return deferred.resolve();
}
+ service.add_issuances = function (mySsubId) {
+ var lastItem = service.itemList[service.itemList.length - 1];
+
+ if (lastItem) lastItem = egCore.idl.fromHash('siss', lastItem.issuance);
+
+ return service.new_holding_code({
+ title : egCore.strings.SERIALS_ISSUANCE_PREDICT,
+ request_count : true,
+ prev_iss : lastItem
+ }).then(function(hc) {
+
+ var base_iss;
+ if (!lastItem) {
+ base_iss = new egCore.idl.siss();
+ base_iss.creator( egCore.auth.user().id() );
+ base_iss.editor( egCore.auth.user().id() );
+ base_iss.date_published( hc.date.toISOString() );
+ base_iss.subscription( mySsubId );
+ base_iss.caption_and_pattern( hc.scap );
+ base_iss.holding_code( JSON.stringify(hc.holding_code) );
+ base_iss.holding_type( hc.type );
+ }
+
+ // if we're predicting without a preexisting holding, reduce the count
+ if (!lastItem) hc.count--;
+
+ return egCore.net.request(
+ 'open-ils.serial',
+ 'open-ils.serial.make_predictions',
+ egCore.auth.token(),
+ { ssub_id : mySsubId,
+ include_base_issuance : lastItem ? 0 : 1,
+ num_to_predict : hc.count,
+ base_issuance : base_iss || lastItem
+ }
+ ).then(
+ function(resp) {
+ var evt = egCore.evt.parse(resp);
+ if (evt) {
+ ngToast.danger(egCore.strings.SERIALS_ISSUANCE_FAIL_SAVE);
+ } else {
+ ngToast.success(egCore.strings.SERIALS_ISSUANCE_SUCCESS_SAVE);
+ }
+ },
+ function(resp) {
+ ngToast.danger(egCore.strings.SERIALS_ISSUANCE_FAIL_SAVE);
+ }
+ );
+ });
+ }
+
return service;
}]);