LPXXX Item Status Angular WIP
authorBill Erickson <berickxx@gmail.com>
Mon, 21 Jun 2021 21:51:10 +0000 (17:51 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 29 Jun 2021 20:31:33 +0000 (16:31 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/cat/item/status.component.html
Open-ILS/src/eg2/src/app/staff/cat/item/status.component.ts
Open-ILS/src/eg2/src/app/staff/cat/item/summary.component.ts
Open-ILS/src/eg2/src/app/staff/share/circ/circ.service.ts

index b44b315..d383d5a 100644 (file)
@@ -3,7 +3,6 @@
 
 <eg-barcode-select #barcodeSelect></eg-barcode-select>
 <eg-circ-components></eg-circ-components>
-<eg-copy-alerts-dialog #copyAlertsDialog></eg-copy-alerts-dialog>
 <eg-bucket-dialog #bucketDialog></eg-bucket-dialog>
 
 <div class="row">
index 65b8a64..7764ba1 100644 (file)
@@ -109,7 +109,7 @@ export class ItemStatusComponent implements OnInit, AfterViewInit {
             } else {
                 this.itemBarcode = null;
 
-                if (this.tab == 'list') {
+                if (this.tab === 'list') {
                     this.selectInput();
                     return this.getItemById(res.id);
                 } else {
@@ -133,18 +133,18 @@ export class ItemStatusComponent implements OnInit, AfterViewInit {
             flesh : 4,
             flesh_fields : {
                 acp : [
-                    'call_number','location','status','floating','circ_modifier',
-                    'age_protect','circ_lib','copy_alerts', 'creator',
+                    'call_number', 'location', 'status', 'floating', 'circ_modifier',
+                    'age_protect', 'circ_lib', 'copy_alerts', 'creator',
                     'editor', 'circ_as_type', 'latest_inventory', 'floating'
                 ],
-                acn : ['record','prefix','suffix','label_class', 'owning_lib'],
-                bre : ['simple_record','creator','editor'],
+                acn : ['record', 'prefix', 'suffix', 'label_class', 'owning_lib'],
+                bre : ['simple_record', 'creator', 'editor'],
                 alci : ['inventory_workstation']
             },
             select : {
                 // avoid fleshing MARC on the bre
                 // note: don't add simple_record.. not sure why
-                bre : ['id','tcn_value','creator','editor', 'create_date', 'edit_date'],
+                bre : ['id', 'tcn_value', 'creator', 'editor', 'create_date', 'edit_date'],
             }
         };
 
index 41cc81c..721c803 100644 (file)
@@ -59,7 +59,7 @@ export class ItemSummaryComponent implements OnInit {
     loadCircInfo(): Promise<any> {
 
         const copyOrg =
-            this.item.call_number().id() == -1 ?
+            this.item.call_number().id() === -1 ?
             this.item.circ_lib().id() :
             this.item.call_number().owning_lib().id();
 
@@ -69,52 +69,32 @@ export class ItemSummaryComponent implements OnInit {
                 return this.org.settings('circ.item_checkout_history.max')
                 .then(sets => {
                     this.maxHistoryCount = sets['circ.item_checkout_history.max'] || 4;
-                })
+                });
             }
         })
-        .then(_ => {
-
-            return this.pcrud.search('aacs',
-                {target_copy : this.item.id()},
-                {   flesh: 2,
-                    flesh_fields: {
-                        aacs: [
-                            'usr',
-                            'workstation',
-                            'checkin_workstation',
-                            'duration_rule',
-                            'max_fine_rule',
-                            'recurring_fine_rule'
-                        ],
-                        au: ['card']
-                    },
-                    order_by: {aacs: 'xact_start desc'},
-                    limit:  1
-                }
-
-            ).toPromise();
-        })
+
+        .then(_ => this.circs.getLatestCirc(this.item.id()))
 
         .then(circ => {
             this.circ = circ;
 
-            if (!circ) return Promise.resolve();
+            if (!circ) { return Promise.resolve(); }
 
             return this.circs.getCircChain(this.circ.id())
             .then(summary => {
-                this.circSummary = summary
+                this.circSummary = summary;
 
                 if (this.maxHistoryCount <= 1) { return; }
 
                 return this.circs.getPrevCircChain(this.circ.id())
-                .then(summary => {
-                    if (!summary) { return; }
+                .then(prevSummary => {
+                    if (!prevSummary) { return; }
 
-                    this.prevCircSummary = summary.summary;
+                    this.prevCircSummary = prevSummary.summary;
 
-                    if (summary.usr) { // aged circs have no 'usr'.
+                    if (prevSummary.usr) { // aged circs have no 'usr'.
 
-                        return this.pcrud.retrieve('au', summary.usr,
+                        return this.pcrud.retrieve('au', prevSummary.usr,
                             {flesh : 1, flesh_fields : {au : ['card']}})
                         .toPromise().then(user => this.prevCircUser = user);
                     }
index 882a808..ee56fed 100644 (file)
@@ -4,7 +4,7 @@ import {map, concatMap, mergeMap} from 'rxjs/operators';
 import {IdlObject} from '@eg/core/idl.service';
 import {NetService} from '@eg/core/net.service';
 import {OrgService} from '@eg/core/org.service';
-import {PcrudService} from '@eg/core/pcrud.service';
+import {PcrudService, PcrudQueryOps} from '@eg/core/pcrud.service';
 import {EventService, EgEvent} from '@eg/core/event.service';
 import {AuthService} from '@eg/core/auth.service';
 import {BibRecordService, BibRecordSummary} from '@eg/share/catalog/bib-record.service';
@@ -1246,5 +1246,30 @@ export class CircService {
 
         ).toPromise();
     }
+
+    getLatestCirc(copyId: number, ops?: PcrudQueryOps): Promise<IdlObject> {
+
+        if (!ops) {
+            ops = {
+                flesh: 2,
+                flesh_fields: {
+                    aacs: [
+                        'usr',
+                        'workstation',
+                        'checkin_workstation',
+                        'duration_rule',
+                        'max_fine_rule',
+                        'recurring_fine_rule'
+                    ],
+                    au: ['card']
+                }
+            };
+        }
+
+        ops.order_by = {aacs: 'xact_start desc'};
+        ops.limit = 1;
+
+        return this.pcrud.search('aacs', {target_copy : copyId}, ops).toPromise();
+    }
 }