LPXXX Catalog title link uses routerLink user/berick/lpxxx-ang-catalog-title-links
authorBill Erickson <berickxx@gmail.com>
Tue, 12 Mar 2019 16:56:47 +0000 (12:56 -0400)
committerBill Erickson <berickxx@gmail.com>
Tue, 12 Mar 2019 16:56:47 +0000 (12:56 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.html
Open-ILS/src/eg2/src/app/staff/catalog/result/record.component.ts

index 90f066b..f97395a 100644 (file)
           <div class="row">
             <div class="col-lg-12 font-weight-bold">
               <!-- nbsp allows the column to take shape when no value exists -->
-              <a href="javascript:void(0)"
-                (click)="navigateToRecord(summary)">
-                {{summary.display.title || '&nbsp;'}}
-              </a>
+              <ng-container *ngIf="hasMrConstituentRecords(summary)">
+                  <a routerLink="/staff/catalog/search"
+                    [queryParams]="appendFromMrParam(summary)">
+                    {{summary.display.title || '&nbsp;'}}
+                  </a>
+              </ng-container>
+              <ng-container *ngIf="!hasMrConstituentRecords(summary)">
+                <a routerLink="/staff/catalog/record/{{summary.id}}"
+                  [queryParams]="currentParams()">
+                  {{summary.display.title || '&nbsp;'}}
+                </a>
+              </ng-container>
             </div>
           </div>
           <div class="row pt-2">
index dd13b9d..cea36a1 100644 (file)
@@ -82,22 +82,27 @@ export class ResultRecordComponent implements OnInit, OnDestroy {
         this.staffCat.search();
     }
 
-    /**
-     * Propagate the search params along when navigating to each record.
-     */
-    navigateToRecord(summary: BibRecordSummary) {
+
+    // Returns the URL parameters for the current page plus the
+    // "fromMetarecord" param used for linking title links to
+    // MR constituent result records list.
+    appendFromMrParam(summary: BibRecordSummary): any {
+        this.searchContext.termSearch.fromMetarecord = summary.metabibId;
         const params = this.catUrl.toUrlParams(this.searchContext);
+        this.searchContext.termSearch.fromMetarecord = null;
+        return params;
+    }
 
-        // Jump to metarecord constituent records page when a
-        // MR has more than 1 constituents.
-        if (summary.metabibId && summary.metabibRecords.length > 1) {
-            this.searchContext.termSearch.fromMetarecord = summary.metabibId;
-            this.staffCat.search();
-            return;
-        }
+    // Returns true if the selected record summary is a metarecord summary
+    // and it links to more than one constituent bib record.
+    hasMrConstituentRecords(summary: BibRecordSummary): boolean {
+        return (
+            summary.metabibId && summary.metabibRecords.length > 1
+        );
+    }
 
-        this.router.navigate(
-            ['/staff/catalog/record/' + summary.id], {queryParams: params});
+    currentParams(): any {
+        return this.catUrl.toUrlParams(this.searchContext);
     }
 
     toggleBasketEntry() {