type : item.issuance.type ? item.issuance.type : 'basic',
can_change_adhoc : true
}).then(function(result) {
- if (result.adhoc) {
+ if (!result.adhoc) {
item.issuance.holding_code = JSON.stringify(result.holding_code);
item.issuance.holding_type = result.type;
} else {
item.issuance.label = result.label;
- item.issuance.holding_type = null;
+ item.issuance.holding_type = result.type;
}
item.issuance.date_published = result.date.toISOString();
item.issuance.edit_date = 'now';
var iss = egCore.idl.fromHash('siss',item.issuance);
- if (iss.holding_type()) { // not an ad hoc issuance, get predicted label
+ if (!result.adhoc) { // not an ad hoc issuance, get predicted label
return egCore.net.request(
'open-ils.serial',
'open-ils.serial.make_prediction_values',
var curr_iss = args.curr_iss;
var adhoc = false;
var link = '1.1';
+ var current_values = {};
var sub = service.get_ssub(service.subId);
if (!sub) return args;
}
if (!curr_iss.holding_code()) {
adhoc = true;
+ } else {
+ var tmp = JSON.parse(curr_iss.holding_code());
+ for (var i = 2; i < tmp.length; i += 2) {
+ // we're intentionally being a bit sloppy here, as
+ // the only subfields we are about in this context
+ // are the ones that are not repeatable
+ current_values[tmp[i]] = tmp[i + 1];
+ }
}
date = new Date(curr_iss.date_published());
};
var chron_part = val.replace(/[)(]+/g,'');
- try {
- pat_part.value = service.get_chron_part[chron_part](date);
- } catch (e) {
- // not a chron part
- pat_part.value = '';
+ if (sf in current_values) {
+ pat_part.value = current_values[sf];
+ } else {
+ try {
+ pat_part.value = service.get_chron_part[chron_part](date);
+ } catch (e) {
+ // not a chron part
+ pat_part.value = '';
+ }
}
if (sf.match(/[a-f]/)) {