import { Component, ChangeDetectorRef } from '@angular/core';
import { ControlContainer, NgForm } from '@angular/forms';
import { FVAbstractControl } from '../../../shared/abstract-control.component';
import { ProcessService } from '../../../../services/process.service';
/**
 * @Author [GrigoreMe](https://github.com/grigoreme)
 */
export class FVControlsListFieldComponent extends FVAbstractControl {
    constructor(ref, process) {
        super(process);
        this.ref = ref;
        this.options = [];
    }
    ngAfterViewInit() {
        super.AfterViewInit();
        this.fetchOptions();
    }
    /**
     * Downloads list-field options.
     */
    fetchOptions() {
        const componentConfig = this.task.componentConfig;
        const getControlsOptions = (referenceName) => {
            const ref = this.controlRef(referenceName);
            return ref && ref.options;
        };
        const refName = this.control.referenceName;
        this.options = (this.task && componentConfig)
            && (this.control.options || getControlsOptions(refName) || [])
            || [];
        this.ref.detectChanges();
    }
}
FVControlsListFieldComponent.decorators = [
    { type: Component, args: [{
                selector: 'fv-controls-list-field',
                template: "<div *ngIf=\"control\" class=\"controlBox\" [attr.id]=\"'control-' + control.referenceName\">\n  <i *ngIf=\"buttonsDebug\" (click)=\"debugStatus =! debugStatus\" class=\"fa fa-stethoscope\"></i>\n  <ng-container *ngIf=\"!hideLabel\">\n    <span class=\"controlName\" [attr.id]=\"'label-' + control.referenceName\">{{ control?.label | ltranslate }}</span>\n    <span *ngIf=\"control?.isRequired\" class=\"required\">*</span>\n    <i *ngIf=\"tooltip\" class=\"fa fa-question-circle\" [tooltip]=\"tooltip | ltranslate\" container=\"body\" placement=\"top\"></i>\n  </ng-container>\n  <div *ngIf=\"debugStatus\" [innerText]=\"toString()\"></div>\n  <div class=\"select-container\">\n    <select *ngIf = \"!control?.isMultiple\"\n      [attr.id]=\"'select-' + control.referenceName\"\n      [disabled]=\"disabled || isReadOnly\"\n      [name]=\"control?.key\"\n      [attr.aria-label]=\"control.controlName | ltranslate\"\n      [required]=\"control?.isRequired ? true : null\"\n      ngModel\n      class=\"form-control custom-control\"\n      type=\"text\">\n      <option\n        *ngFor=\"let option of options\"\n        [innerText]=\"option.label | ltranslate\"\n        [value]=\"option.value\"\n      ></option>\n    </select>\n    <!-- Current version of angular trows exception \"no value accessor\" for select with multiple attribute -->\n    <select *ngIf = \"control?.isMultiple\"\n      [attr.id]=\"'select-' + control.referenceName\"\n      [attr.multiple]=\"true\"\n      [disabled]=\"disabled || isReadOnly\"\n      [name]=\"control?.key\"\n      [attr.aria-label]=\"control.controlName || '' | ltranslate\"\n      [required]=\"control?.isRequired ? true : null\"\n      ngModel\n      class=\"form-control custom-control\"\n      type=\"text\">\n      <option\n        *ngFor=\"let option of options\"\n        [innerText]=\"option.label | ltranslate\"\n        [value]=\"option.value\"\n      ></option>\n    </select>\n  </div>\n  <fv-controls-validator *ngIf=\"group?.controls[control.key]\" [FVFormControl]=\"group?.controls[control.key]\" [group]=\"group\"\n    [control]=\"control\" [task]=\"task\" [tabIndex]=\"tabIndex\"></fv-controls-validator>\n</div>",
                viewProviders: [{ provide: ControlContainer, useExisting: NgForm }],
                styles: [".col{display:inline-flex;flex-basis:0;flex-grow:1;max-width:100%;min-width:50%}.col fv-form-tab{display:block;padding:0 5px;width:100%}.col fv-form-tab .controls-row{margin:0;padding:0;width:100%}.col fv-form-tab div{max-width:100%}.columns-0,.columns-1{max-width:100%;min-width:100%;width:100%}.columns-2{max-width:50%;min-width:50%;width:50%}.columns-3{max-width:33.33%;min-width:33.33%;width:33.33%}.columns-4{max-width:25%;min-width:25%;width:25%}.controlBox .input-group{display:inline-flex;margin-top:5px;width:100%}.controlBox>.input-group>button:not(.input-group-addon),.controlBox>.input-group>input,.controlBox>.input-group>select{height:40px!important;padding:10px;width:100%}.controlBox .input-group button.input-group-addon{height:40px;position:relative;width:35px}.controlBox .input-group span.controlName{color:red}.controlBox .input-group button.input-group-addon i{bottom:0;left:0;position:absolute;right:0;top:10px}.has-text-centered,.table,.table thead th{text-align:center}.gridForm{margin:0 0 10px;padding:0;width:100%}.gridForm .input-group>.form-control{border-radius:unset;margin-right:10px;max-width:50%;min-height:45px;min-width:80px}.gridForm .input-group>.addon{background:none;border:none;color:#36c}.grid-table tbody>tr>td{vertical-align:middle}span.required{color:red}form:not(.ng-untouched) .ng-invalid{border:1px solid red}form:not(.ng-untouched) .ng-invalid.input-group-addon{border-left:none!important}span.error-block{color:red}@media screen and (max-width:426px){.columns-2,.columns-3,.columns-4{max-width:100%;min-width:100%;width:100%}}.tree:last-of-type(.accordion){margin:0}select:disabled{background:#eee}navigator-bot,navigator-top{display:flex}fv-menu-folder:last-of-type>accordion:last-of-type{margin:0;padding:0}.button-group>button:not(:last-child):not(:first-child){margin-left:0!important;margin-right:0!important;padding-left:0!important;padding-right:0!important}.fv_container,.fv_container>*,navigator-after,navigator-before{all:inherit!important;padding:0!important}.lookup-form .gridInputs{width:100%}.lookup-form .gridInputs select{width:40%}.lookup-form .gridInputs input{width:60%}.lookup-form .gridInputs,.lookup-form .gridInputs input,.lookup-form .gridInputs select{max-width:100%}.noMarginY{margin-bottom:0!important;margin-top:0!important}.placeholder,ng-select input:-moz-placeholder,ng-select input:-ms-input-placeholder,ng-select input:-webkit-input-placeholder,ng-select input:placeholder{color:#a9a9a9}select-dropdown>div{position:relative!important;top:0!important}select-dropdown div.options{text-align:left}bs-datepicker-navigation-view{display:block;text-align:center;width:100%}.bs-datepicker-head .previous{float:left}.bs-datepicker-head .next{float:right}textarea{min-height:45px;min-width:100%}.modal-dialog>.modal-content{max-height:100vh}.modal-content>.modal-body{max-height:85vh;overflow-y:auto;padding-bottom:0}.modal-content fv-navigator.nav-bottom{background-color:hsla(0,0%,99.2%,.62);border-bottom-left-radius:10px;border-bottom-right-radius:10px;bottom:0;display:block;height:50px;left:0;margin:0 2px;padding:0 3rem;position:-webkit-sticky;position:sticky;right:0;z-index:999}.modal-content fv-navigator .docked-buttons{width:auto}.modal-content fv-navigator .btn-col:not(.bottom){max-width:unset;padding:6px!important}.modal-dialog .modal-header .pull-right span{font-size:inherit!important}.basic-commands button{margin-right:5px;text-transform:capitalize}"]
            },] }
];
FVControlsListFieldComponent.ctorParameters =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