From: Galen Charlton Date: Fri, 9 Sep 2022 16:55:22 +0000 (-0400) Subject: LP#1863387: multi-select now allows filtering shelving locations by owner X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fgmcharlt%2Flp1863387_tune_location_multi_select;p=working%2FEvergreen.git LP#1863387: multi-select now allows filtering shelving locations by owner The Angular multi-select component now has a special case for shelving locations: when the IDL class of "acpl" is selected, rather than just displaying a combobox, the item-location-select component followed by an org selector is displayed. The org select defaults to workstation OU and is used to restrict the list of shelving locations displayed in the shelving location combobox. The effect of this is to allow large consortial to more efficiently select the shelving locations to be used by a carousel. To test ------- [1] Apply the patch. [2] Create or edit carousel definitions. Verify that the widget for the carousel's shelving locations now displays both a combobox for the location selector as well as one for the location owning library. Further verify that when the OU selector for the owning library is changed, that the list of available shelving locations reflects the locations available at the ancestors and descendants of the filter OU. Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts b/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts index 82490a249f..f20a2689ef 100644 --- a/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/item-location-select/item-location-select.component.ts @@ -61,6 +61,8 @@ export class ItemLocationSelectComponent // Emits an acpl object or null on combobox value change @Output() valueChange: EventEmitter; + // Emits the combobox entry or null on value change + @Output() entryChange: EventEmitter; @Input() required: boolean; @@ -85,6 +87,7 @@ export class ItemLocationSelectComponent private pcrud: PcrudService ) { this.valueChange = new EventEmitter(); + this.entryChange = new EventEmitter(); } ngOnInit() { @@ -155,6 +158,7 @@ export class ItemLocationSelectComponent const id = entry ? entry.id : null; this.propagateChange(id); this.valueChange.emit(id ? this.cache[id] : null); + this.entryChange.emit(entry ? entry : null); } writeValue(id: number) { @@ -179,7 +183,7 @@ export class ItemLocationSelectComponent setFilterOrgs(): Promise { let contextOrgIds: number[] = []; - if (this.contextOrgIds) { + if (this.contextOrgIds.length) { contextOrgIds = this.contextOrgIds; } else { contextOrgIds = [this.contextOrgId || this.auth.user().ws_ou()]; diff --git a/Open-ILS/src/eg2/src/app/share/multi-select/multi-select.component.html b/Open-ILS/src/eg2/src/app/share/multi-select/multi-select.component.html index 1926abf220..8a774550a9 100644 --- a/Open-ILS/src/eg2/src/app/share/multi-select/multi-select.component.html +++ b/Open-ILS/src/eg2/src/app/share/multi-select/multi-select.component.html @@ -1,9 +1,22 @@
- - + + + + Owned by + + + + + + +
diff --git a/Open-ILS/src/eg2/src/app/share/multi-select/multi-select.component.ts b/Open-ILS/src/eg2/src/app/share/multi-select/multi-select.component.ts index 3496f5551c..9d7f8e210c 100644 --- a/Open-ILS/src/eg2/src/app/share/multi-select/multi-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/multi-select/multi-select.component.ts @@ -7,7 +7,9 @@ import {map} from 'rxjs/operators'; import {Observable, of, Subject} from 'rxjs'; import {StoreService} from '@eg/core/store.service'; import {PcrudService} from '@eg/core/pcrud.service'; +import {OrgService} from '@eg/core/org.service'; import {ComboboxComponent, ComboboxEntry} from '@eg/share/combobox/combobox.component'; +import {ItemLocationSelectComponent} from '@eg/share/item-location-select/item-location-select.component'; @Component({ selector: 'eg-multi-select', @@ -30,9 +32,12 @@ export class MultiSelectComponent implements OnInit { @Output() onChange: EventEmitter; + acplContextOrgId: number; + constructor( private store: StoreService, private pcrud: PcrudService, + private org: OrgService, ) { this.entrylist = []; this.onChange = new EventEmitter(); @@ -45,7 +50,22 @@ export class MultiSelectComponent implements OnInit { this.selected = null; } } + + getOrgShortname(ou: any) { + if (typeof ou === 'object') { + return ou.shortname(); + } else { + return this.org.get(ou).shortname(); + } + } + addSelectedValue() { + // special case to format the label + if (this.idlClass === 'acpl' && this.selected.userdata) { + this.selected.label = + this.selected.userdata.name() + ' (' + + this.getOrgShortname(this.selected.userdata.owning_lib()) + ')'; + } this.entrylist.push(this.selected); this.onChange.emit(this.compileCurrentValue()); } diff --git a/Open-ILS/src/eg2/src/app/staff/common.module.ts b/Open-ILS/src/eg2/src/app/staff/common.module.ts index 280f92a5b7..ef64b860b4 100644 --- a/Open-ILS/src/eg2/src/app/staff/common.module.ts +++ b/Open-ILS/src/eg2/src/app/staff/common.module.ts @@ -21,6 +21,7 @@ import {PatronBarcodeValidatorDirective} from '@eg/share/validators/patron_barco import {BroadcastService} from '@eg/share/util/broadcast.service'; import {CourseService} from './share/course.service'; import {FileExportService} from '@eg/share/util/file-export.service'; +import {ItemLocationSelectModule} from '@eg/share/item-location-select/item-location-select.module'; /** * Imports the EG common modules and adds modules common to all staff UI's. @@ -46,7 +47,8 @@ import {FileExportService} from '@eg/share/util/file-export.service'; EgCommonModule, CommonWidgetsModule, GridModule, - CatalogCommonModule + CatalogCommonModule, + ItemLocationSelectModule ], exports: [ EgCommonModule,