From: Galen Charlton Date: Fri, 2 Jun 2017 22:06:09 +0000 (-0400) Subject: webstaff: improve editing issuances X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=71adf9a706e4416f4508d6256db4efde1155d670;p=working%2FEvergreen.git webstaff: improve editing issuances Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js b/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js index d7fc34f32b..329c7e1dc8 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js +++ b/Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js @@ -99,12 +99,12 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , orderByF 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(); @@ -112,7 +112,7 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , orderByF 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', diff --git a/Open-ILS/web/js/ui/default/staff/serials/services/core.js b/Open-ILS/web/js/ui/default/staff/serials/services/core.js index 1d13fa852c..ec109397da 100644 --- a/Open-ILS/web/js/ui/default/staff/serials/services/core.js +++ b/Open-ILS/web/js/ui/default/staff/serials/services/core.js @@ -298,6 +298,7 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm 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; @@ -332,6 +333,14 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm } 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()); @@ -378,11 +387,15 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm }; 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]/)) {