LP#1626157 admin ui org selector descendants/ancestors
authorBill Erickson <berickxx@gmail.com>
Thu, 31 May 2018 20:29:33 +0000 (16:29 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 31 May 2018 20:29:33 +0000 (16:29 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid.ts
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.html
Open-ILS/src/eg2/src/app/staff/share/admin-page/admin-page.component.ts

index e6a2def..805c5db 100644 (file)
@@ -316,9 +316,14 @@ export class EgGridContext {
 
     }
     reload() {
-        this.pager.reset();
-        this.dataSource.reset();
-        this.dataSource.requestPage(this.pager);
+        // Give the UI time to settle before reloading grid data.
+        // This can help when data retrieval depends on a value
+        // getting modified by an angular digest cycle.
+        setTimeout(() => {
+            this.pager.reset();
+            this.dataSource.reset();
+            this.dataSource.requestPage(this.pager);
+        });
     }
 
     // Subscribe or unsubscribe to page-change events from the pager.
index be72a23..1480593 100644 (file)
     </div>
     <div class="pl-2">
       <div class="form-check">
-        <input type="checkbox" class="form-check-input" id="includeDescendants">
-        <label class="form-check-label" for="includeDescendants" i18n>Include Descendants?</label>
+        <input type="checkbox" (click)="grid.reload()" [(ngModel)]="includeOrgAncestors"
+          class="form-check-input" id="include-ancestors">
+        <label class="form-check-label" for="include-ancestors" i18n>+ Ancestors</label>
       </div>
-    </div>
-    <div class="pl-2">
       <div class="form-check">
-        <input type="checkbox" class="form-check-input" id="includeAncestors">
-        <label class="form-check-label" for="includeAncestors" i18n>Include Ancestors?</label>
+        <input type="checkbox" (click)="grid.reload()" [(ngModel)]="includeOrgDescendants" 
+          class="form-check-input" id="include-descendants">
+        <label class="form-check-label" for="include-descendants" i18n>+ Descendants</label>
       </div>
     </div>
   </div>
index 48b938f..a9b4fcc 100644 (file)
@@ -44,6 +44,13 @@ export class EgAdminPageComponent implements OnInit {
     // Disable the auto-matic org unit field filter
     @Input() disableOrgFilter: boolean;
 
+    // Include objects linking to org units which are ancestors
+    // of the selected org unit.
+    @Input() includeOrgAncestors: boolean;
+
+    // Ditto includeOrgAncestors, but descendants.
+    @Input() includeOrgDescendants: boolean;
+
     @ViewChild('grid') grid: EgGridComponent;
     @ViewChild('editDialog') editDialog: FmRecordEditorComponent;
     @ViewChild('successString') successString: EgStringComponent;
@@ -165,10 +172,23 @@ export class EgAdminPageComponent implements OnInit {
             };
 
             if (this.contextOrg) {
-                // TODO: does the org path need to be configurable?
+                // Filter rows by those linking to the context org and
+                // optionally ancestor and descendant org units.
+
+                let orgs = [this.contextOrg.id()];
+
+                if (this.includeOrgAncestors) {
+                    orgs = this.org.ancestors(this.contextOrg, true);
+                }
+
+                if (this.includeOrgDescendants) {
+                    // can result in duplicate workstation org IDs... meh
+                    orgs = orgs.concat(
+                        this.org.descendants(this.contextOrg, true));
+                }
+
                 const search = {};
-                search[this.orgField] =
-                    this.org.fullPath(this.contextOrg, true);
+                search[this.orgField] = orgs;
                 return this.pcrud.search(this.idlClass, search, searchOps);
             }