})
export class IntervalInputComponent implements ControlValueAccessor, OnInit {
+ @Input() initialValue: string;
+ @Output() onChange = new EventEmitter<string>();
+
period: string;
unit = 'days';
propagateTouch = () => {};
ngOnInit() {
+ if (this.initialValue) {
+ this.writeValue(this.initialValue);
+ }
}
changeListener(): void {
this.propagateChange(this.period + ' ' + this.unit);
+ this.onChange.emit(this.period + ' ' + this.unit);
}
writeValue(value: string) {
/**
- * <eg-multi-select idlClass="acpl" linkedLibraryLabel="owning_lib">
+ * <eg-multi-select idlClass="acpl" linkedLibraryLabel="owning_lib" idlKey="id">
* </eg-multi-select>
*/
import {Component, OnInit, Input, Output, ViewChild, EventEmitter, ElementRef} from '@angular/core';
entrylist: ComboboxEntry[];
@Input() idlClass: string;
+ @Input() idlBaseQuery: any = null;
+ @Input() idlKey: string;
@Input() linkedLibraryLabel: string;
@Input() startValue: string;
}
ngOnInit() {
+ if (!this.idlKey) {
+ this.idlKey = 'id';
+ }
+
if (this.startValue && this.startValue !== '{}') {
let valstr = this.startValue;
valstr = valstr.replace(/^{/, '');
valstr = valstr.replace(/}$/, '');
const ids = valstr.split(',');
+ const searchHash = {};
+ searchHash[this.idlKey] = ids;
const extra_args = {};
if (this.linkedLibraryLabel) {
const flesh_fields: Object = {};
flesh_fields[this.idlClass] = [ this.linkedLibraryLabel ];
extra_args['flesh'] = 1;
extra_args['flesh_fields'] = flesh_fields;
- this.pcrud.search(this.idlClass, { 'id' : ids }, extra_args).pipe(map(data => {
+ this.pcrud.search(this.idlClass, searchHash, extra_args).pipe(map(data => {
this.entrylist.push({
'id' : data.id(),
'label' : data.name() + ' (' + data[this.linkedLibraryLabel]().shortname() + ')'
});
})).toPromise();
} else {
- this.pcrud.search(this.idlClass, { 'id' : ids }, extra_args).pipe(map(data => {
+ this.pcrud.search(this.idlClass, searchHash, extra_args).pipe(map(data => {
this.entrylist.push({ 'id' : data.id(), 'label' : data.name() });
})).toPromise();
}
@Input() domId: string;
+ @Output() onChange = new EventEmitter<any>();
+
@ViewChildren(OrgSelectComponent) orgSelects: QueryList<OrgSelectComponent>;
// this is the most up-to-date value used for ngModel and reactive form
this.emitArray = () => {
// Prepare and emit an array containing the primary org id and
- // optionally ancestor and descendant org units.
+ // optionally ancestor and descendant org units, and flags that select those.
this.options.orgIds = [this.options.primaryOrgId];
+ this.options.includeAncestors = this.includeAncestors.value;
+ this.options.includeDescendants = this.includeDescendants.value;
if (this.includeAncestors.value) {
this.options.orgIds = this.org.ancestors(this.options.primaryOrgId, true);
this.options.orgIds = Object.keys(hash).map(id => Number(id));
this.propagateChange(this.options);
+ this.onChange.emit(this.options);
};
}