LP#626157 Ang2 experiments
authorBill Erickson <berickxx@gmail.com>
Fri, 8 Dec 2017 21:24:03 +0000 (16:24 -0500)
committerBill Erickson <berickxx@gmail.com>
Mon, 11 Dec 2017 17:39:51 +0000 (12:39 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/webby-src/src/app/share/catalog/catalog.service.ts
Open-ILS/webby-src/src/app/staff/catalog/catalog.module.ts
Open-ILS/webby-src/src/app/staff/catalog/record/record.component.html
Open-ILS/webby-src/src/app/staff/catalog/record/record.component.ts
Open-ILS/webby-src/src/app/staff/catalog/record/record.service.ts [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/catalog/search-form.component.html
Open-ILS/webby-src/src/app/staff/share/bib-summary.component.css [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/share/bib-summary.component.html [new file with mode: 0644]
Open-ILS/webby-src/src/app/staff/share/bib-summary.component.ts [new file with mode: 0644]

index daf9783..b1311af 100644 (file)
@@ -201,7 +201,7 @@ export class EgCatalogService {
      * Bib record via UNAPI as mods (for now) with holdings summary
      * and record attributes.
      */
-    getBibSummary(bibId: number, orgId: number, depth: number): Promise<any> {
+    getBibSummary(bibId: number, orgId?: number, depth?: number): Promise<any> {
         return new Promise((resolve, reject) => {
             this.unapi.getAsXmlDocument({
                 target: 'bre', 
index 72e4e4f..fb3c559 100644 (file)
@@ -9,6 +9,7 @@ import {EgCatalogComponent} from './catalog.component';
 import {SearchFormComponent} from './search-form.component';
 import {ResultsComponent} from './result/results.component';
 import {RecordComponent} from './record/record.component';
+import {EgBibSummaryComponent} from '../share/bib-summary.component';
 import {ResultPaginationComponent} from './result/pagination.component';
 import {ResultFacetsComponent} from './result/facets.component';
 import {ResultRecordComponent} from './result/record.component';
@@ -20,6 +21,7 @@ import {StaffRecordService} from './record/record.service';
     EgCatalogComponent,
     ResultsComponent,
     RecordComponent,
+    EgBibSummaryComponent,
     SearchFormComponent,
     ResultRecordComponent,
     ResultFacetsComponent,
index 13d805d..0bc3f35 100644 (file)
@@ -1,56 +1,7 @@
 
 <div id="staff-catalog-record-container">
-
-  <!-- TODO MOVE RECORD SUMMARY TO SHARE MODULE -->
-  <style>
-    .eg-bib-record-summary {
-    }
-    .eg-bib-record-summary .card-body {
-      padding: .25rem;
-    }
-    .eg-bib-record-summary .list-group-item {
-      padding: .25rem;
-    }
-  </style>
-  <div class='eg-bib-record-summary card w-100' *ngIf="staffRecord.bibSummary">
-    <div class="card-header font-weight-bold" i18n>
-      Record Summary
-      <!-- TODO expandy at right-->
-    </div>
-    <div class="card-body">
-      <ul class="list-group list-group-flush">
-        <li class="list-group-item">
-          <div class="d-flex">
-            <div class="flex-1 font-weight-bold" i18n>Title</div>
-            <div class="flex-3">{{staffRecord.bibSummary.title}}</div>
-            <div class="flex-1 font-weight-bold pl-1" i18n>Edition</div>
-            <div class="flex-2">{{staffRecord.bibSummary.edition}}</div>
-            <div class="flex-1 font-weight-bold" i18n>TCN</div>
-            <div class="flex-1">{{staffRecord.bibSummary.tcn_value}}</div>
-            <div class="flex-1 font-weight-bold pl-1" i18n>Created By</div>
-            <div class="flex-2" *ngIf="staffRecord.bibSummary.creator.usrname">
-              {{staffRecord.bibSummary.creator.usrname()}}
-            </div>
-          </div>
-        </li>
-        <li class="list-group-item">
-          <div class="d-flex">
-            <div class="flex-1 font-weight-bold" i18n>Author</div>
-            <div class="flex-3">{{staffRecord.bibSummary.author}}</div>
-            <div class="flex-1 font-weight-bold pl-1" i18n>Pubdate</div>
-            <div class="flex-2">{{staffRecord.bibSummary.pubdate}}</div>
-            <div class="flex-1 font-weight-bold" i18n>Database ID</div>
-            <div class="flex-1">{{staffRecord.bibSummary.id}}</div>
-            <div class="flex-1 font-weight-bold pl-1" i18n>Last Edited By</div>
-            <div class="flex-2" *ngIf="staffRecord.bibSummary.editor.usrname">
-              {{staffRecord.bibSummary.editor.usrname()}}
-            </div>
-          </div>
-        </li>
-      </ul>
-    </div>
-  </div>
-
+  <eg-bib-summary [bibSummary]="staffRecord.bibSummary">
+  </eg-bib-summary>
 </div>
 
 
index 21a9a4b..f7f7af8 100644 (file)
@@ -6,6 +6,7 @@ import {CatalogSearchContext, CatalogSearchState}
   from '@eg/share/catalog/search-context';
 import {StaffCatalogService} from '../staff-catalog.service';
 import {StaffRecordService} from './record.service';
+import {EgBibSummaryComponent} from '../../share/bib-summary.component';
 
 @Component({
   selector: 'eg-catalog-record',
@@ -25,8 +26,9 @@ export class RecordComponent implements OnInit {
     ) {}
 
     ngOnInit() { 
+        this.recordId = +this.route.snapshot.paramMap.get('id');
         this.searchContext = this.staffCat.searchContext;
-        this.staffRecord.setRecord(+this.route.snapshot.paramMap.get('id'));
+        this.staffRecord.setRecord(this.recordId);
     }
 }
 
diff --git a/Open-ILS/webby-src/src/app/staff/catalog/record/record.service.ts b/Open-ILS/webby-src/src/app/staff/catalog/record/record.service.ts
new file mode 100644 (file)
index 0000000..224ba06
--- /dev/null
@@ -0,0 +1,54 @@
+import {Injectable} from '@angular/core';
+import {Router, ActivatedRoute} from '@angular/router';
+import {EgOrgService} from '@eg/core/org';
+import {EgCatalogService} from '@eg/share/catalog/catalog.service';
+import {EgCatalogUrlService} from '@eg/share/catalog/catalog-url.service';
+import {CatalogSearchContext} from '@eg/share/catalog/search-context';
+import {StaffCatalogService} from '../staff-catalog.service';
+import {EgPcrudService} from '@eg/core/pcrud';
+
+/**
+ * Shared bits needed by the staff version of the catalog.
+ */
+
+@Injectable()
+export class StaffRecordService {
+
+    recordId: number;
+    bibSummary: any; // TODO: bib summary class
+    searchContext: CatalogSearchContext;
+
+    constructor(
+        private router: Router,
+        private route: ActivatedRoute,
+        private org: EgOrgService,
+        private pcrud: EgPcrudService,
+        private cat: EgCatalogService,
+        private staffCat: StaffCatalogService,
+        private catUrl: EgCatalogUrlService
+    ) { }
+
+    setRecord(id: number): void { 
+        this.recordId = id;
+        this.searchContext = this.staffCat.searchContext;
+
+        this.cat.getBibSummary(
+            this.recordId,
+            this.searchContext.searchOrg.id(), 
+            this.searchContext.searchOrg.ou_type().depth()
+        ).then(summary => { 
+            this.bibSummary = summary;
+            this.pcrud.search('au', {id: [summary.creator, summary.editor]})
+            .subscribe(user => {
+                if (user.id() == summary.creator)
+                    summary.creator = user;
+                if (user.id() == summary.editor)
+                    summary.editor = user;
+            })
+
+            // probably other stuff
+        });
+    }
+}
+
+
index 42c512f..6955f28 100644 (file)
@@ -66,15 +66,18 @@ TODO focus search input
     <div class="col-3">
       <div *ngIf="idx == 0" class="float-right">
         <button class="btn btn-success" type="button"
+          [disabled]="searchIsActive()"
           (click)="searchContext.pager.offset=0;searchByForm()">
           Search
         </button>
         <button class="btn btn-warning" type="button"
+          [disabled]="searchIsActive()"
           (click)="searchContext.reset()">
           Clear Form
         </button>
         <button class="btn btn-outline-secondary" type="button"
           *ngIf="!showAdvanced()"
+          [disabled]="searchIsActive()"
           (click)="showAdvancedSearch=true">
           More Filters
         </button>
@@ -134,13 +137,16 @@ TODO focus search input
         </div>
       </div>
       <div class="flex-2 pl-1">
-        <div *ngIf="searchIsActive()">
-          <div class="progress">
-            <div class="progress-bar progress-bar-striped active w-100"
-              role="progressbar" aria-valuenow="100" 
-              aria-valuemin="0" aria-valuemax="100">
-              <span class="sr-only" i18n>Searching..</span>
-            </div>
+        <!-- alignment -->
+      </div>
+    </div>
+    <div class="col-3">
+      <div *ngIf="searchIsActive()">
+        <div class="progress">
+          <div class="progress-bar progress-bar-striped active w-100"
+            role="progressbar" aria-valuenow="100" 
+            aria-valuemin="0" aria-valuemax="100">
+            <span class="sr-only" i18n>Searching..</span>
           </div>
         </div>
       </div>
diff --git a/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.css b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.css
new file mode 100644 (file)
index 0000000..bec1012
--- /dev/null
@@ -0,0 +1,8 @@
+.eg-bib-summary {
+}
+.eg-bib-summary .card-body {
+  padding: .25rem;
+}
+.eg-bib-summary .list-group-item {
+  padding: .25rem;
+}
diff --git a/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.html b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.html
new file mode 100644 (file)
index 0000000..05737d8
--- /dev/null
@@ -0,0 +1,52 @@
+
+<div class='eg-bib-summary card w-100' *ngIf="summary">
+  <div class="card-header font-weight-bold" i18n>
+    Record Summary
+    <!-- TODO expandy at right-->
+  </div>
+  <div class="card-body">
+    <ul class="list-group list-group-flush">
+      <li class="list-group-item">
+        <div class="d-flex">
+          <div class="flex-1 font-weight-bold" i18n>Title:</div>
+          <div class="flex-3">{{summary.title}}</div>
+          <div class="flex-1 font-weight-bold pl-1" i18n>Edition:</div>
+          <div class="flex-1">{{summary.edition}}</div>
+          <div class="flex-1 font-weight-bold" i18n>TCN:</div>
+          <div class="flex-1">{{summary.tcn_value}}</div>
+          <div class="flex-1 font-weight-bold pl-1" i18n>Created By:</div>
+          <div class="flex-1" *ngIf="summary.creator.usrname">
+            {{summary.creator.usrname()}}
+          </div>
+        </div>
+      </li>
+      <li class="list-group-item">
+        <div class="d-flex">
+          <div class="flex-1 font-weight-bold" i18n>Author:</div>
+          <div class="flex-3">{{summary.author}}</div>
+          <div class="flex-1 font-weight-bold pl-1" i18n>Pubdate:</div>
+          <div class="flex-1">{{summary.pubdate}}</div>
+          <div class="flex-1 font-weight-bold" i18n>Database ID:</div>
+          <div class="flex-1">{{summary.id}}</div>
+          <div class="flex-1 font-weight-bold pl-1" i18n>Last Edited By:</div>
+          <div class="flex-1" *ngIf="summary.editor.usrname">
+            {{summary.editor.usrname()}}
+          </div>
+        </div>
+      </li>
+      <li class="list-group-item">
+        <div class="d-flex">
+          <div class="flex-1 font-weight-bold" i18n>Bib Call #:</div>
+          <div class="flex-3">{{summary.callNumber}}</div>
+          <div class="flex-1 font-weight-bold" i18n>Record Owner:</div>
+          <div class="flex-1">TODO</div>
+          <div class="flex-1 font-weight-bold pl-1" i18n>Created On:</div>
+          <div class="flex-1">{{summary.create_date | date:'shortDate'}}</div>
+          <div class="flex-1 font-weight-bold pl-1" i18n>Last Edited On:</div>
+          <div class="flex-1">{{summary.edit_date | date:'shortDate'}}</div>
+        </div>
+      </li>
+    </ul>
+  </div>
+</div>
+
diff --git a/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.ts b/Open-ILS/webby-src/src/app/staff/share/bib-summary.component.ts
new file mode 100644 (file)
index 0000000..41990af
--- /dev/null
@@ -0,0 +1,70 @@
+import {Component, OnInit, Input} from '@angular/core';
+import {EgNetService} from '@eg/core/net';
+import {EgPcrudService} from '@eg/core/pcrud';
+import {EgCatalogService} from '@eg/share/catalog/catalog.service';
+
+@Component({
+  selector: 'eg-bib-summary',
+  styleUrls: ['bib-summary.component.css'],
+  templateUrl: 'bib-summary.component.html'
+})
+export class EgBibSummaryComponent implements OnInit {
+
+    // If provided, the record will be fetched by the component.
+    @Input() recordId: number;
+
+    // Otherwise, we'll use the provided bib summary object.
+    summary: any;
+    @Input() set bibSummary(s: any) {
+        if (s) {
+            this.summary = s;
+            this.fetchBibCallNumber();
+        }
+    }
+
+    constructor(
+        private cat: EgCatalogService,
+        private net: EgNetService,
+        private pcrud: EgPcrudService
+    ) {}
+
+    ngOnInit() { 
+        if (this.recordId) this.loadSummary();
+    }
+
+    loadSummary(): void {
+        this.cat.getBibSummary(this.recordId).then(summary => { 
+            this.summary = summary;
+            this.fetchBibCallNumber();
+            
+            // Flesh the user data
+            this.pcrud.search('au', {id: [summary.creator, summary.editor]})
+            .subscribe(user => {
+                if (user.id() == summary.creator)
+                    summary.creator = user;
+                if (user.id() == summary.editor)
+                    summary.editor = user;
+            })
+        });
+    }
+
+    fetchBibCallNumber(): void {
+        if (!this.summary || this.summary.callNumber) return;
+
+        // TODO labelClass = cat.default_classification_scheme YAOUS
+        let labelClass = 1;
+
+        this.net.request(
+            'open-ils.cat',
+            'open-ils.cat.biblio.record.marc_cn.retrieve',
+            this.summary.id, labelClass
+        ).subscribe(cnArray => {
+            if (cnArray && cnArray.length > 0) {
+                let key1 = Object.keys(cnArray[0])[0];
+                this.summary.callNumber = cnArray[0][key1];
+            }
+        });
+    }
+}
+
+