2024-02-01 14:41:05 +01:00
|
|
|
|
import { Component, Input, OnInit } from '@angular/core';
|
|
|
|
|
import { UntypedFormArray, UntypedFormGroup } from '@angular/forms';
|
|
|
|
|
import { DescriptionTemplateExternalSelectSourceEditorModel } from '../../../description-template-editor.model';
|
|
|
|
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
|
|
|
|
import { DescriptionTemplateExternalSelectHttpMethodType } from '@app/core/common/enum/description-template-external-select-http-method-type';
|
|
|
|
|
import { DescriptionTemplateExternalSelectAuthType } from '@app/core/common/enum/description-template-external-select-auth-type';
|
2024-02-05 16:59:11 +01:00
|
|
|
|
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
2024-02-01 14:41:05 +01:00
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-description-template-editor-external-select-field-component',
|
|
|
|
|
styleUrls: ['./description-template-editor-external-select-field.component.scss'],
|
|
|
|
|
templateUrl: './description-template-editor-external-select-field.component.html'
|
|
|
|
|
})
|
|
|
|
|
export class DescriptionTemplateEditorExternalSelectFieldComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
@Input() form: UntypedFormGroup;
|
2024-02-05 16:59:11 +01:00
|
|
|
|
@Input() validationErrorModel: ValidationErrorModel;
|
|
|
|
|
@Input() rootPath: string;
|
|
|
|
|
|
2024-02-01 14:41:05 +01:00
|
|
|
|
methodTypeValues = this.enumUtils.getEnumValues<DescriptionTemplateExternalSelectHttpMethodType>(DescriptionTemplateExternalSelectHttpMethodType);
|
|
|
|
|
authTypeValues = this.enumUtils.getEnumValues<DescriptionTemplateExternalSelectAuthType>(DescriptionTemplateExternalSelectAuthType);
|
|
|
|
|
|
|
|
|
|
constructor (
|
|
|
|
|
public enumUtils: EnumUtils
|
|
|
|
|
) {}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
addSource() {
|
2024-02-05 16:59:11 +01:00
|
|
|
|
const externalDataset = new DescriptionTemplateExternalSelectSourceEditorModel(this.validationErrorModel);
|
|
|
|
|
const externalSelectArray = this.form.get('data').get('sources') as UntypedFormArray;
|
|
|
|
|
externalSelectArray.push(externalDataset.buildForm({rootPath: this.rootPath + 'data.sources[' + externalSelectArray.length + '].'}));
|
2024-02-01 14:41:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
removeSource(index: number) {
|
|
|
|
|
(<UntypedFormArray>this.form.get('data').get('sources')).removeAt(index);
|
|
|
|
|
}
|
|
|
|
|
}
|