LP1879335 Tweak bib-list sorting continued
authorBill Erickson <berickxx@gmail.com>
Thu, 10 Sep 2020 15:04:15 +0000 (11:04 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 11 Sep 2020 13:58:55 +0000 (09:58 -0400)
Teach the bib-list component to honor the sort specification when
fetching its records.  In cases where IDs are sorted externally (via
bibIdSource), this ensures the records retrieved from those IDs are
also similarly sorted.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/share/bib-list/bib-list.component.ts

index 5cacc8e..49fe1d8 100644 (file)
@@ -69,12 +69,20 @@ export class BibListComponent implements OnInit {
             return empty();
         }
 
+        // ID is the currently only supported sort column.  If other
+        // columns are added, callers providing a bibIdSource will need
+        // to implement the new columns as well.
+        const orderBy = {rmsr: 'id'};
+        if (sort.length && sort[0].name === 'id') {
+            orderBy.rmsr = orderBy.rmsr + ' ' + sort[0].dir;
+        }
+
         return from(promise).pipe(switchMap(bibIds => {
 
             if (bibIds.length === 0) { return empty(); }
 
             return this.pcrud.search('rmsr', {id: bibIds}, {
-                order_by: {rmsr: 'id'},
+                order_by: orderBy,
                 flesh: 2,
                 flesh_fields: {
                     rmsr: ['biblio_record'],