LP#1528924 Item Status List Columns
authorKyle Huckins <khuckins@catalystdevworks.com>
Tue, 24 Jan 2017 23:41:45 +0000 (15:41 -0800)
committerMike Rylander <mrylander@gmail.com>
Mon, 17 Apr 2017 19:11:41 +0000 (15:11 -0400)
Add several new columns to Item Status List.

Refactor of ItemSvc to properly grab circ-related information.

Signed-off-by: Kyle Huckins <khuckins@catalystdevworks.com>
 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 <khuckins@catalystdevworks.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/templates/staff/cat/item/t_list.tt2
Open-ILS/web/js/ui/default/staff/cat/item/app.js

index 9755360..ca2cf5d 100644 (file)
   <eg-grid-action handler="transferItems" group="[% l('Transfer') %]"
     label="[% l('Items to Previously Marked Volume') %]"></eg-grid-action>
 
-  <eg-grid-field label="[% l('Barcode') %]"     path='barcode' visible></eg-grid-field>
-  <eg-grid-field label="[% l('Call Number') %]" path="call_number.label" visible></eg-grid-field>
-  <eg-grid-field label="[% l('Location') %]"    path="location.name" visible></eg-grid-field>
-
+  <eg-grid-field label="[% l('Alert Message') %]"  path='alert_message' visible></eg-grid-field>
+  <eg-grid-field label="[% l('Barcode') %]"        path='barcode' visible></eg-grid-field>
+  <eg-grid-field label="[% l('Call Number') %]"    path="call_number.label" visible></eg-grid-field>
+  <eg-grid-field label="[% l('Due Date') %]"       path="_circ.due_date" visible>
+    {{item['_circ']['due_date'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Location') %]"       path="location.name" visible></eg-grid-field>
+  <eg-grid-field label="[% l('Status') %]"         path="status.name" visible></eg-grid-field>
   <eg-grid-field label="[% l('Title') %]"       
     path="call_number.record.simple_record.title" visible>
     <a target="_blank" href="[% ctx.base_path %]/staff/cat/catalog/record/{{item['call_number.record.id']}}">
       {{item['call_number.record.simple_record.title']}} <span ng-show="item['call_number.record.id']" class="glyphicon glyphicon-new-window"/>
     </a>
   </eg-grid-field>
+
+
+  <eg-grid-field label="[% l('Acquisition Cost') %]"     path="cost" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Age-Based Hold Protection') %]"  path="age_protect" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Author') %]"               path="call_number.record.simple_record.author"  hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Checkin Date') %]"         path="_circ_summary.last_checkin_time" hidden>
+    {{item['_circ_summary']['last_checkin_time'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Checkin Scan Date') %]"    path="_circ_summary.last_checkin_scan_time" hidden>
+    {{item['_circ_summary.last_checkin_scan_time'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Checkin Workstation') %]"  path="_circ_summary.last_checkin_workstation" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Checkout Date') %]"  path="_circ_summary.start_time" hidden>
+    {{item['_circ_summary']['start_time'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Checkout Workstation') %]"  path="_circ_summary.checkout_workstation" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Checkout/Renewal Library') %]"  path="_circ.circ_lib.name" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Circulation ID') %]"        path="_circ.id" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Circ or Renewal Workstation') %]"  path="_circ.workstation.name" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Classification') %]"        path="call_number.label_class.name" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('CN Prefix') %]"             path="call_number.prefix.label" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('CN Suffix') %]"             path="call_number.suffix.label" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Circulate as Type') %]"     path="circ_as_type" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Circulate?') %]"            path="circulate" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Circulation Library') %]"   path="_circ_lib.name" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Circulation Modifier') %]"  path="circ_modifier" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Copy ID') %]"               path="id" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Copy Number') %]"           path="copy_number" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Created By') %]"            path="creator" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Date Created') %]"          path="create_date" hidden>
+    {{item['create_date'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Date Last Edited') %]"      path="edit_date" hidden>
+    {{item['edit_date'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Date Record Created') %]"   path="call_number.record.create_date" hidden>
+    {{item['call_number.record.create_date'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Date Record Last Edited') %]"    path="call_number.record.edit_date" hidden>
+    {{item['call_number.record.create_date'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Deleted?') %]"              path="deleted" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Document ID') %]"           path="call_number.record.id" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Edited By') %]"             path="editor" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Fine Level') %]"            path="fine_level" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Fines Stopped') %]"         path="_circ_summary.last_stop_fines" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Fines Stopped Time') %]"    path="_circ_summary.last_stop_fines_time" hidden>
+    {{item['_circ_summary']['last_stop_fines_time'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('Floating?') %]"             path="floating" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Holdable?') %]"             path="holdable" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Holds Count') %]"           path="holds_count" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('In-House Uses') %]"         path="_inHouseUseCount" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('ISBN') %]"                  path="call_number.record.simple_record.isbn" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Loan Duration') %]"         path="loan.duration" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('OPAC Visible?') %]"         path="opac_visible" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Owned By') %]"              path="call_number.record.owner" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Owning Library') %]"        path="call_number.owning_lib" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Parts') %]"                 path="parts" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Price') %]"                 path="price" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Publication Date') %]"      path="call_number.record.simple_record.pubdate" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Publisher') %]"             path="call_number.record.simple_record.publisher" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Quality') %]"               path="call_number.record.simple_record.quality" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Reference?') %]"            path="ref" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Remaining Renewals') %]"    path="_circ.renewals_remaining" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Status Changed Time') %]"   path="status_changed_time" hidden>
+    {{item['status_changed_time'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+  <eg-grid-field label="[% l('TCN') %]"                   path="call_number.record.tcn_value" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('TCN Source') %]"            path="call_number.record.tcn_source" hidden></eg-grid-field>
+  <eg-grid-field label="[% l('Transaction Complete') %]"  path="_circ.xact_finish" hidden>
+    {{item['_circ']['xact_finish'] | date:'MM/dd/yy HH:mm a'}}
+  </eg-grid-field>
+</eg-grid>
 </eg-grid>
 
 <div class="flex-row pad-vert">
index 5f0ecb0..dba013c 100644 (file)
@@ -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;