}
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.
</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>
// 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;
};
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);
}