From: Mike Rylander Date: Tue, 29 Mar 2022 19:11:55 +0000 (-0400) Subject: LP#1839341: Really stop duplicates, and provide an initial sort order X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d17f9e3a8a839f96736a02a3f07972f00f25f5dd;p=evergreen%2Fpines.git LP#1839341: Really stop duplicates, and provide an initial sort order Duplicates snuck back in due to something firing the getRows function multiple times, concurrently. We avoid this problem by returning an empty observable if we're already mid-fetch. This commit also sorts the settings by group and label at load time. Finally, we bring back the "change not visible" warning when editing for a location other than the context org as a toast. Signed-off-by: Mike Rylander Signed-off-by: Terran McCanna Signed-off-by: Jane Sandberg --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/org-unit-settings/org-unit-settings.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/org-unit-settings/org-unit-settings.component.ts index 842fb85d48..50a9d98549 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/org-unit-settings/org-unit-settings.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/org-unit-settings/org-unit-settings.component.ts @@ -1,5 +1,5 @@ import {Component, OnInit, Input, ViewChild} from '@angular/core'; -import {Observable, Observer} from 'rxjs'; +import {EMPTY, Observable, Observer} from 'rxjs'; import {Pager} from '@eg/share/util/pager'; import {IdlObject, IdlService} from '@eg/core/idl.service'; import {OrgService} from '@eg/core/org.service'; @@ -44,6 +44,7 @@ export class OrgUnitSettingsComponent implements OnInit { contextOrg: IdlObject; initDone = false; + midFetch = false; gridDataSource: GridDataSource; gridTemplateContext: any; prevFilter: string; @@ -96,6 +97,8 @@ export class OrgUnitSettingsComponent implements OnInit { } fetchSettingTypes(pager: Pager): Observable { + if (this.midFetch) { return EMPTY; } + this.midFetch = true; return new Observable(observer => { this.pcrud.retrieveAll('coust', {flesh: 3, flesh_fields: { 'coust': ['grp', 'view_perm'] @@ -109,6 +112,7 @@ export class OrgUnitSettingsComponent implements OnInit { ok => { this.flattenSettings(observer); this.filterCoust(); + this.midFetch = false; } ); } @@ -224,7 +228,28 @@ export class OrgUnitSettingsComponent implements OnInit { } flattenSettings(observer: Observer) { - this.gridDataSource.data = this.settingTypeArr; + let sorted = this.settingTypeArr.sort((a,b) => { + if (a.grp && b.grp) { + if (a.grp.toLowerCase() < b.grp.toLowerCase()) { + return -1; + } else if (a.grp.toLowerCase() > b.grp.toLowerCase()) { + return 1; + } + } else if (a.grp) { + return -1; + } else if (b.grp) { + return 1; + } + + if (a.label.toLowerCase() < b.label.toLowerCase()) { + return -1; + } else if (a.label.toLowerCase() > b.label.toLowerCase()) { + return 1; + } + + return 0; + }); + this.gridDataSource.data = sorted observer.complete(); } @@ -246,6 +271,9 @@ export class OrgUnitSettingsComponent implements OnInit { ).toPromise().then(res => { if (!noToast) { this.toast.success(entry.label + ' Updated.'); + if (obj.context.id() !== this.contextOrg.id()) { + this.toast.warning('The setting you edited is not the currently chosen org unit, therefore the changes you made are not visible.'); + } } if (!obj.setting[entry.name]) {