From 66201201509a49b589dff674532a0a7234df7acd Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 29 Mar 2022 15:11:55 -0400 Subject: [PATCH] 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 --- .../org-unit-settings.component.ts | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) 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]) { -- 2.11.0