newOwner: EgIdlObject;
newName: String;
+ //initialOrg: EgIdlObject; // XXX testing
+
// Org selector callbacks
shouldDisableOrg = (org: EgIdlObject): boolean => {
// TODO: check register perms too
ngOnInit() {
this.store.getItem('eg.workstation.all')
.then(res => this.workstations = res);
+
+ // this.initialOrg = this.org.root().children()[0];
}
selected(): Workstation {
selected: OrgDisplay;
// Read-only properties optionally provided by the calling component.
- @Input() placeholder: String;
+ @Input() placeholder: string;
@Input() initialOrg: EgIdlObject;
- @Input() stickySetting: String;
- @Input() displayField: String = 'shortname';
+ @Input() stickySetting: string;
+ @Input() displayField: string = 'shortname';
// Call-backs
- // Note onChange could be handled via an EventEmitter, but
+ // Note: onChange could be handled via an EventEmitter, but
// should* functions require real time two-way communication.
@Input() onChange: (org:EgIdlObject) => void;
@Input() shouldDisable: (org:EgIdlObject) => boolean;
) {}
ngOnInit() {
+ if (this.initialOrg) {
+ this.selected = this.formatForDisplay(this.initialOrg);
+ }
+ }
+
+ formatForDisplay(org: EgIdlObject): OrgDisplay {
+ return {
+ id : org.id(),
+ label : PAD_SPACE.repeat(org.ou_type().depth())
+ + org[this.displayField](),
+ disabled : false
+ };
}
orgChanged(selEvent: NgbTypeaheadSelectItemEvent) {
.distinctUntilChanged()
.map(term => {
- // TODO: displayField / shortname
return this.org.list().filter(org => {
// Find orgs matching the search term
- return org.shortname()
+ return org[this.displayField]()
.toLowerCase().indexOf(term.toLowerCase()) > -1
}).filter(org => {
// Exclude hidden orgs
return !this.shouldHide || !this.shouldHide(org)
- }).map(org => {
-
- return {
- id : org.id(),
- label : PAD_SPACE.repeat(org.ou_type().depth()) + org.shortname(),
- disabled : this.shouldDisable && this.shouldDisable(org)
- }
- })
+ }).map(org => { return this.formatForDisplay(org) })
});
}
}