LP1889694 catalog record summary condensed WIP
authorBill Erickson <berickxx@gmail.com>
Fri, 31 Jul 2020 17:14:50 +0000 (13:14 -0400)
committerBill Erickson <berickxx@gmail.com>
Fri, 31 Jul 2020 17:14:50 +0000 (13:14 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/catalog/bib-record.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.html
Open-ILS/src/eg2/src/app/staff/catalog/result/results.component.ts
Open-ILS/src/perlmods/lib/OpenILS/Application/Search/Biblio.pm

index 3d93945..7510fe0 100644 (file)
@@ -124,6 +124,7 @@ export class BibRecordService {
             const summary = new BibRecordSummary(metabibSummary.record, orgId);
             summary.net = this.net; // inject
             summary.metabibId = Number(metabibSummary.metabib_id);
+            summary.metabibRecords = metabibSummary.metabib_records;
             summary.display = metabibSummary.display;
             summary.attributes = metabibSummary.attributes;
             summary.holdCount = metabibSummary.hold_count;
index 41804cc..515a376 100644 (file)
       </div>
       <div
         [ngClass]="{'col-lg-10': !searchContext.basket, 'col-lg-12': searchContext.basket}">
-        <div *ngIf="shouldStartRendering()">
-          <div *ngFor="let summary of searchContext.result.records; let idx = index">
-            <div *ngIf="summary">
-              <eg-catalog-result-record [summary]="summary" [index]="idx">
-              </eg-catalog-result-record>
-            </div>
+        <div *ngFor="let summary of searchContext.result.records; let idx = index">
+          <div *ngIf="summary">
+            <eg-catalog-result-record [summary]="summary" [index]="idx">
+            </eg-catalog-result-record>
           </div>
         </div>
       </div>
index 5de5535..edcb381 100644 (file)
@@ -105,28 +105,6 @@ export class ResultsComponent implements OnInit, OnDestroy {
         }
     }
 
-    // Records file into place randomly as the server returns data.
-    // To reduce page display shuffling, avoid showing the list of
-    // records until the first few are ready to render.
-    shouldStartRendering(): boolean {
-        return this.searchHasResults();
-
-        /*
-        if (this.searchHasResults()) {
-            const pageCount = this.searchContext.currentResultIds().length;
-            switch (pageCount) {
-                case 1:
-                    return this.searchContext.result.records[0];
-                default:
-                    return this.searchContext.result.records[0]
-                        && this.searchContext.result.records[1];
-            }
-        }
-
-        return false;
-        */
-    }
-
     searchIsDone(): boolean {
         return this.searchContext.searchState === CatalogSearchState.COMPLETE;
     }
index adbe0e7..b07440e 100644 (file)
@@ -2753,7 +2753,12 @@ __PACKAGE__->register_method(
             {desc => 'Array of Record IDs', type => 'array'}
         ],
         return => { 
-            desc => 'Stream of record summary objects'
+            desc => q/
+                Stream of record summary objects including id, record,
+                hold_count, copy_counts, display (metabib display
+                fields), attributes (metabib record attrs), plus
+                metabib_id and metabib_records for the metabib variant.
+            /
         }
     }
 );
@@ -2817,6 +2822,8 @@ sub catalog_record_summary {
     return undef;
 }
 
+# Start with a bib summary and augment the data with additional
+# metarecord content.
 sub get_one_metarecord_summary {
     my ($e, $rec_id) = @_;
 
@@ -2830,8 +2837,23 @@ sub get_one_metarecord_summary {
     $response->{metabib_id} = $rec_id;
     $response->{metabib_records} = [map {$_->source} @$maps];
 
-    # augment mraf
+    my @other_bibs = map {$_->source} grep {$_->source != $bre_id} @$maps;
 
+    # Augment the record attributes with those of all of the records
+    # linked to this metarecord.
+    if (@other_bibs) {
+        my $attrs = $e->search_metabib_record_attr_flat({id => \@other_bibs});
+
+        my $attributes = $response->{attributes};
+
+        for my $attr (@$attrs) {
+            $attributes->{$attr->attr} = [] unless $attributes->{$attr->attr};
+            push(@{$attributes->{$attr->attr}}, $attr->value) # avoid dupes
+                unless grep {$_ eq $attr->value} @{$attributes->{$attr->attr}};
+        }
+    }
+
+    return $response;
 }
 
 sub get_one_record_summary {
@@ -2844,6 +2866,7 @@ sub get_one_record_summary {
         }
     }]) or return {};
 
+    # Compressed display fields are pachaged as JSON
     my $display = {};
     $display->{$_->name} = OpenSRF::Utils::JSON->JSON2perl($_->value)
         foreach @{$bre->compressed_display_entries};