argos/dmp-frontend/src/app/shared/components/external-items/external-item-listing/external-item-listing.compo...

67 lines
1.6 KiB
TypeScript
Raw Normal View History

2018-05-28 11:50:42 +02:00
import { Component, OnInit, Input, ContentChild, TemplateRef, ViewChild, Output, EventEmitter } from "@angular/core";
2018-06-05 10:18:01 +02:00
import { FormGroup, FormControl, FormArray, AbstractControl } from "@angular/forms";
2018-05-28 11:50:42 +02:00
import { ExternalSourcesUrlModel } from "../../../../models/external-sources/ExternalSourcesUrlModel";
2018-07-24 13:19:52 +02:00
import { AutoCompleteConfiguration } from "../../auto-complete/AutoCompleteConfiguration";
2018-05-28 11:50:42 +02:00
@Component({
selector: 'app-external-item-listing',
templateUrl: './external-item-listing.component.html',
styleUrls: ['./external-item-listing.component.scss']
})
export class ExternalItemListingComponent implements OnInit {
@Input()
public placeholder: string;
@Input()
2018-06-05 10:18:01 +02:00
public formGroup: AbstractControl;
2018-05-28 11:50:42 +02:00
@Input()
public autoCompleteConfiguration: AutoCompleteConfiguration;
@Input()
public displayFunction: Function;
2018-07-11 15:47:36 +02:00
@Input()
public subtitleFunction: Function;
2018-05-28 11:50:42 +02:00
@Input()
public disabled = true;
2018-08-31 10:14:56 +02:00
@Input()
public viewOnly = false;
2018-05-28 11:50:42 +02:00
@Input()
public titleKey: string;
@Input()
parentTemplate;
@Input()
public options: Array<ExternalSourcesUrlModel>
@Output()
public onItemChange = new EventEmitter<any>();
public choice: string;
public formControl = new FormControl();
2018-06-05 10:18:01 +02:00
2018-05-28 11:50:42 +02:00
ngOnInit() {
if (this.disabled) this.formControl.disable();
}
onItemChangeFunc(event) {
if (event) this.onItemChange.emit(event);
}
selectionChange(event) {
if (this.formControl.disabled) this.formControl.enable();
this.autoCompleteConfiguration.requestItem.criteria["type"] = event.value;
}
2018-06-05 10:18:01 +02:00
deleteItem(name: number) {
(<FormArray>this.formGroup).removeAt(name)
}
2018-05-28 11:50:42 +02:00
}