this.ngOnInit();
}
+ // ... though if includeDescendants is true, shelving
+ // locations at the descendants of the context OU are
+ // also included; this is a special case for the
+ // carousels editor
+ @Input() set includeDescendants(value: boolean) {
+ this._includeDescendants = value;
+ this.ngOnInit();
+ }
+ get includeDescendants(): boolean {
+ return this._includeDescendants;
+ }
+
get contextOrgId(): number {
return this._contextOrgId;
}
// Load locations for multiple context org units.
private _contextOrgIds = [];
+ private _includeDescendants = false;
@Input() set contextOrgIds(value: number[]) {
this._contextOrgIds = value;
}
// Emits an acpl object or null on combobox value change
@Output() valueChange: EventEmitter<IdlObject>;
+ // Emits the combobox entry or null on value change
+ @Output() entryChange: EventEmitter<ComboboxEntry>;
@Input() required: boolean;
private loc: ItemLocationService
) {
this.valueChange = new EventEmitter<IdlObject>();
+ this.entryChange = new EventEmitter<ComboboxEntry>();
}
ngOnInit() {
const id = entry ? entry.id : null;
this.propagateChange(id);
this.valueChange.emit(id ? this.loc.locationCache[id] : null);
+ this.entryChange.emit(entry ? entry : null);
}
writeValue(id: number) {
let orgIds = [];
contextOrgIds.forEach(id => orgIds = orgIds.concat(this.org.ancestors(id, true)));
+ if (this.includeDescendants) {
+ contextOrgIds.forEach(id => orgIds = orgIds.concat(this.org.descendants(id, true)));
+ }
this.filterOrgsApplied = true;
permOrgIds.forEach(orgId => {
if (orgIds.includes(orgId)) {
trimmedOrgIds = trimmedOrgIds.concat(this.org.ancestors(orgId, true));
+ if (this.includeDescendants) {
+ trimmedOrgIds = trimmedOrgIds.concat(this.org.descendants(orgId, true));
+ }
}
});
<div>
<div class="row">
- <eg-combobox [idlBaseQuery]="idlBaseQuery" [idlClass]="idlClass"
- [idlIncludeLibraryInLabel]="linkedLibraryLabel" [asyncSupportsEmptyTermClick]="true"
- (onChange)="valueSelected($event)">
- </eg-combobox>
+ <ng-container *ngIf="idlClass === 'acpl'">
+ <div class="col-6">
+ <eg-item-location-select (entryChange)="valueSelected($event)"
+ [contextOrgId]="acplContextOrgId"
+ [includeDescendants]="acplIncludeDescendants"
+ domId='location-input'>
+ </eg-item-location-select>
+ </div>
+ <div class="col-6">
+ <label for="context_library" class="form-label" i18n>Owned by</label>
+ <eg-org-select
+ domId="context_library"
+ [applyDefault]="true"
+ (onChange)="acplContextOrgId = $event.id()">
+ </eg-org-select>
+ <label class="form-check-label" for="acplIncludeDescendants" i18n>Include descendants?</label>
+ <input type="checkbox"
+ domId="acplIncludeDescendants"
+ id="acplIncludeDescendants"
+ [(ngModel)]="acplIncludeDescendants"
+ class="ml-1">
+ </div>
+ </ng-container>
+ <ng-container *ngIf="idlClass !== 'acpl'">
+ <eg-combobox [idlBaseQuery]="idlBaseQuery" [idlClass]="idlClass"
+ [idlIncludeLibraryInLabel]="linkedLibraryLabel" [asyncSupportsEmptyTermClick]="true"
+ (onChange)="valueSelected($event)">
+ </eg-combobox>
+ </ng-container>
<button class="btn btn-outline-dark" (click)="addSelectedValue()" [disabled]="!this.selected" i18n>Add</button>
</div>
<div class="row" *ngFor="let entry of entrylist">
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',
@Output() onChange: EventEmitter<string>;
+ acplContextOrgId: number;
+ acplIncludeDescendants: boolean;
+
constructor(
private store: StoreService,
private pcrud: PcrudService,
+ private org: OrgService,
) {
this.entrylist = [];
this.onChange = new EventEmitter<string>();
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());
}
import {CourseService} from './share/course.service';
import {FileExportService} from '@eg/share/util/file-export.service';
import {OfflineService} from '@eg/staff/share/offline.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.
EgCommonModule,
CommonWidgetsModule,
GridModule,
- CatalogCommonModule
+ CatalogCommonModule,
+ ItemLocationSelectModule
],
exports: [
EgCommonModule,