title : egCore.strings.SERIALS_EDIT_SISS_HC,
curr_iss : egCore.idl.fromHash('siss',item.issuance),
label : item.issuance.label,
- type : item.issuance.type ? item.issuance.type : 'basic'
+ type : item.issuance.type ? item.issuance.type : 'basic',
+ can_change_adhoc : true
}).then(function(result) {
if (result.adhoc) {
item.issuance.holding_code = JSON.stringify(result.holding_code);
$scope.following_issuance = function (items) {
return egSerialsCoreSvc.new_holding_code({
title : egCore.strings.SERIALS_ISSUANCE_ADD,
- prev_iss : egCore.idl.fromHash('siss',items[0].issuance)
+ prev_iss : egCore.idl.fromHash('siss',items[0].issuance),
+ can_change_adhoc : true
}).then(function(hc) {
if (hc.adhoc) {
var new_iss = new egCore.idl.siss();
});
}
+ $scope.add_special_issuance = function() {
+ return egSerialsCoreSvc.new_holding_code({
+ title : egCore.strings.SERIALS_ISSUANCE_ADD,
+ can_change_adhoc : false,
+ adhoc : true
+ }).then(function(hc) {
+ // perforce add hoc
+ var new_iss = new egCore.idl.siss();
+ new_iss.creator( egCore.auth.user().id() );
+ new_iss.editor( egCore.auth.user().id() );
+ new_iss.date_published( hc.date.toISOString() );
+ new_iss.subscription( $scope.ssubId );
+ new_iss.label( hc.label );
+ new_iss.holding_type( hc.type );
+
+ return egCore.pcrud.create(new_iss).then(function(issuance) {
+ var new_items = [];
+ var sub = egSerialsCoreSvc.get_ssub($scope.ssubId);
+ angular.forEach(sub.distributions(), function(dist) {
+ angular.forEach(dist.streams(), function(stream) {
+ var new_item = new egCore.idl.sitem();
+ new_item.creator( egCore.auth.user().id() );
+ new_item.editor( egCore.auth.user().id() );
+ new_item.issuance( issuance.id() );
+ new_item.stream( stream.id() );
+ new_item.date_expected( hc.date.toISOString() ); // XXX do we have interval math?
+ new_items.push(new_item);
+ });
+ });
+ var promises = [];
+ angular.forEach(new_items, function(item) {
+ promises.push(egCore.pcrud.create(item));
+ });
+
+ $q.all(promises).then(function() {
+ ngToast.success(egCore.strings.SERIALS_ISSUANCE_SUCCESS_SAVE);
+ return reload($scope.ssubId,_paging_filter);
+ },function (error) {
+ ngToast.danger(egCore.strings.SERIALS_ISSUANCE_FAIL_SAVE);
+ });
+ });
+ });
+ }
+
$scope.do_print_routing_lists = false;
egCore.hatch.getItem('eg.serials.items.do_print_routing_lists').then(function(val) {
$scope.do_print_routing_lists = val;
$scope.type = options.type || 'basic';
$scope.args = { adhoc : false };
if (options.adhoc) $scope.args.adhoc = true;
+ $scope.can_change_adhoc = options.can_change_adhoc;
function refresh (n,o) {
if (n && o && n !== o) {
prev_iss : options.prev_iss,
curr_iss : options.curr_iss,
});
+ if (!options.can_change_adhoc && options.adhoc) $scope.args.adhoc = true;
if ($scope.args.type && $scope.type != $scope.args.type)
$scope.type = $scope.args.type;
return service.new_holding_code({
title : egCore.strings.SERIALS_ISSUANCE_PREDICT,
request_count : true,
- prev_iss : lastItem
+ prev_iss : lastItem,
+ allow_adhoc : false
}).then(function(hc) {
var base_iss;