From 39bac20cb3869c787e49c6c472d3018a09efdf57 Mon Sep 17 00:00:00 2001 From: Kyle Huckins Date: Tue, 24 Jan 2017 15:41:45 -0800 Subject: [PATCH] LP#1528924 Item Status List Columns Add several new columns to Item Status List. Refactor of ItemSvc to properly grab circ-related information. Signed-off-by: Kyle Huckins Changes to be committed: modified: Open-ILS/src/templates/staff/cat/item/t_list.tt2 modified: Open-ILS/web/js/ui/default/staff/cat/item/app.js Signed-off-by: Kyle Huckins Signed-off-by: Mike Rylander --- .../src/templates/staff/cat/item/t_list.tt2 | 86 +++++++++- .../web/js/ui/default/staff/cat/item/app.js | 156 ++++++++++++++---- 2 files changed, 202 insertions(+), 40 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 index 9755360308..ca2cf5d6ca 100644 --- a/Open-ILS/src/templates/staff/cat/item/t_list.tt2 +++ b/Open-ILS/src/templates/staff/cat/item/t_list.tt2 @@ -58,16 +58,94 @@ - - - - + + + + + {{item['_circ']['due_date'] | date:'MM/dd/yy HH:mm a'}} + + + {{item['call_number.record.simple_record.title']}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Open-ILS/web/js/ui/default/staff/cat/item/app.js b/Open-ILS/web/js/ui/default/staff/cat/item/app.js index 5f0ecb04fd..dba013ca79 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/item/app.js +++ b/Open-ILS/web/js/ui/default/staff/cat/item/app.js @@ -59,8 +59,9 @@ function(egCore) { service.flesh = { flesh : 3, flesh_fields : { - acp : ['call_number','location','status','location','floating','circ_modifier','age_protect'], - acn : ['record','prefix','suffix'], + acp : ['call_number','location','status','location','floating','circ_modifier', + 'age_protect','circ_lib'], + acn : ['record','prefix','suffix','label_class'], bre : ['simple_record','creator','editor'] }, select : { @@ -70,51 +71,134 @@ function(egCore) { } } - // resolved with the last received copy - service.fetch = function(barcode, id, noListDupes) { - var promise; + service.circFlesh = { + flesh : 2, + flesh_fields : { + circ : [ + 'usr', + 'workstation', + 'checkin_workstation', + 'checkin_lib', + 'duration_rule', + 'max_fine_rule', + 'recurring_fine_rule' + ], + au : ['card'] + }, + order_by : {circ : 'xact_start desc'}, + limit : 1 + } + + //Retrieve separate copy, combcirc, and accs information + service.getCopy = function(barcode, id) { + if (barcode) return egCore.pcrud.search( + 'acp', {barcode : barcode, deleted : 'f'}, + service.flesh).then(function(copy) {return copy}); + + return egCore.pcrud.retrieve( 'acp', id, service.flesh) + .then(function(copy) {return copy}); + } + service.getCirc = function(id) { + return egCore.pcrud.search('combcirc', { target_copy : id }, + service.circFlesh).then(function(circ) {return circ}); + } + service.getSummary = function(id) { + return circ_summary = egCore.net.request( + 'open-ils.circ', + 'open-ils.circ.renewal_chain.retrieve_by_circ.summary', + egCore.auth.token(), id).then( + function(circ_summary) {return circ_summary}); + } + + //Combine copy, circ, and accs information + service.retrieveCopyData = function(barcode, id) { + var copyData = {}; - if (barcode) { - promise = egCore.pcrud.search('acp', - {barcode : barcode, deleted : 'f'}, service.flesh); - } else { - promise = egCore.pcrud.retrieve('acp', id, service.flesh); + var fetchCopy = function(barcode, id) { + return service.getCopy(barcode, id) + .then(function(copy) { + copyData.copy = copy; + return copyData; + }); + } + var fetchCirc = function(copy) { + return service.getCirc(copy.id()) + .then(function(circ) { + copyData.circ = circ; + return copyData; + }); } + var fetchSummary = function(circ) { + return service.getSummary(circ.id()) + .then(function(summary) { + copyData.circ_summary = summary; + return copyData; + }); + } + return fetchCopy(barcode, id).then(function(res) { + return fetchCirc(copyData.copy).then(function(res) { + if (copyData.circ) { + return fetchSummary(copyData.circ).then(function() { + return copyData; + }); + } else { + return copyData; + } + }); + }); - var lastRes; - return promise.then( - function() {return lastRes}, - null, // error + } - // notify reads the stream of copies, one at a time. - function(copy) { + // resolved with the last received copy + service.fetch = function(barcode, id, noListDupes) { + var copy; + var circ; + var circ_summary; + var lastRes = {}; + + return service.retrieveCopyData(barcode, id) + .then(function(copyData) { + //Make sure we're getting a completed copyData - no plain acp or circ objects + if (copyData.circ) { + // flesh circ_lib locally + copyData.circ.circ_lib(egCore.org.get(copyData.circ.circ_lib())); + copyData.circ.checkin_workstation( + egCore.org.get(copyData.circ.checkin_workstation())); + } + var flatCopy; - var flatCopy; + if (noListDupes) { + // use the existing copy if possible + flatCopy = service.copies.filter( + function(c) {return c.id == copyData.copy.id()})[0]; + } - egCore.pcrud.search('aihu', - {item : copy.id()}, {}, {idlist : true, atomic : true}) - .then(function(uses) { - copy._inHouseUseCount = uses.length; - }); + if (!flatCopy) { + flatCopy = egCore.idl.toHash(copyData.copy, true); - if (noListDupes) { - // use the existing copy if possible - flatCopy = service.copies.filter( - function(c) {return c.id == copy.id()})[0]; + if (copyData.circ) { + flatCopy._circ = egCore.idl.toHash(copyData.circ, true); + flatCopy._circ_summary = egCore.idl.toHash(copyData.circ_summary, true); } + flatCopy.index = service.index++; + service.copies.unshift(flatCopy); + } - if (!flatCopy) { - flatCopy = egCore.idl.toHash(copy, true); - flatCopy.index = service.index++; - service.copies.unshift(flatCopy); - } + //Get in-house use count + egCore.pcrud.search('aihu', + {item : flatCopy.id}, {}, {idlist : true, atomic : true}) + .then(function(uses) { + flatCopy._inHouseUseCount = uses.length; + copyData.copy._inHouseUseCount = uses.length; + }); - return lastRes = { - copy : copy, - index : flatCopy.index - } + return lastRes = { + copy : copyData.copy, + index : flatCopy.index } - ); + }); + + } return service; -- 2.43.2