LP1857910 make field doc grid sortable/pageable
authorJason Etheridge <jason@EquinoxOLI.org>
Wed, 6 Apr 2022 21:04:16 +0000 (17:04 -0400)
committerJane Sandberg <js7389@princeton.edu>
Fri, 20 May 2022 00:16:46 +0000 (18:16 -0600)
Signed-off-by: Jason Etheridge <jason@EquinoxOLI.org>
Signed-off-by: Jane Sandberg <js7389@princeton.edu>
Open-ILS/src/eg2/src/app/staff/admin/local/field-documentation/field-documentation.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/field-documentation/field-documentation.component.ts

index c6ee7bb..25474a7 100644 (file)
@@ -19,7 +19,7 @@
 
 <div class='w-11 mt-3'>
   <eg-grid #fieldDocGrid [dataSource]="gridDataSource"
-    persistKey="admin.config.idl_field_doc" idlClass="fdoc">
+    persistKey="admin.config.idl_field_doc" idlClass="fdoc" [sortable]="true">
     <eg-grid-toolbar-button 
       label="New Field Documentation" i18n-label (onClick)="createNew()">
     </eg-grid-toolbar-button>
index a8ff1ec..664f990 100644 (file)
@@ -114,11 +114,22 @@ export class FieldDocumentationComponent implements OnInit {
     setCurrentFieldDoc() {
         if (this.selectedClass) {
             this.fields = this.selectedClass.fields;
-            this.pcrud.search('fdoc',
-                {fm_class: this.selectedClass.id}
-            ).subscribe(fdocs => {
-                this.gridDataSource.data.push(fdocs);
-            });
+            this.gridDataSource.getRows = (pager: Pager, sort: any[]) => {
+                const orderBy: any = {};
+                if (sort.length) {
+                    // Sort specified from grid
+                    orderBy['fdoc'] = sort[0].name + ' ' + sort[0].dir;
+                }
+
+                const searchOps = {
+                    fm_class: this.selectedClass.id,
+                    offset: pager.offset,
+                    limit: pager.limit,
+                    order_by: orderBy
+                };
+                return this.pcrud.retrieveAll('fdoc', searchOps, {fleshSelectors: true});
+            };
+            this.fieldDocGrid.reload();
         }
     }
 
@@ -180,4 +191,4 @@ export class FieldDocumentationComponent implements OnInit {
             }
         );
     }
-}
\ No newline at end of file
+}