import { Component, Input } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@c8y/ngx-components";
import * as i3 from "@c8y/ngx-components/icon-selector";
export class ApplicationPropertiesFormComponent {
    constructor(formBuilder) {
        this.formBuilder = formBuilder;
        this.disabled = false;
        this.initForm();
    }
    ngOnChanges(changes) {
        if (changes.application &&
            changes.application.currentValue !== changes.application.previousValue) {
            this.setForm(this.application);
        }
        if (changes.disabled && changes.disabled.currentValue !== changes.disabled.previousValue) {
            changes.disabled.currentValue ? this.formGroup.disable() : this.formGroup.enable();
        }
    }
    initForm() {
        this.formGroup = this.formBuilder.group({
            name: [Validators.required, Validators.maxLength(120)],
            key: [Validators.required, Validators.maxLength(120)],
            contextPath: [Validators.required, Validators.maxLength(120)],
            icon: [undefined, [Validators.minLength(1)]]
        });
    }
    setForm(applicationConfig) {
        this.formGroup.patchValue({ ...applicationConfig });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: ApplicationPropertiesFormComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.9", type: ApplicationPropertiesFormComponent, selector: "c8y-application-properties-form", inputs: { application: "application", disabled: "disabled" }, usesOnChanges: true, ngImport: i0, template: "<form\n  class=\"c8y-wizard-form text-left\"\n  name=\"appDeployForm\"\n  (ngSubmit)=\"(formGroup.valid)\"\n  [formGroup]=\"formGroup\"\n  novalidate\n>\n  <c8y-form-group>\n    <label\n      for=\"name\"\n      translate\n    >\n      Name\n    </label>\n    <input\n      class=\"form-control\"\n      placeholder=\"{{ 'e.g. My application' | translate }}\"\n      name=\"name\"\n      type=\"text\"\n      required\n      formControlName=\"name\"\n    />\n  </c8y-form-group>\n  <c8y-form-group>\n    <label\n      for=\"key\"\n      translate\n    >\n      Application key\n    </label>\n    <input\n      class=\"form-control\"\n      placeholder=\"{{ 'e.g. my-application-key' | translate }}\"\n      name=\"key\"\n      type=\"text\"\n      required\n      formControlName=\"key\"\n    />\n  </c8y-form-group>\n  <c8y-form-group>\n    <label\n      for=\"contextPath\"\n      translate\n    >\n      Path\n    </label>\n    <div class=\"input-group\">\n      <span class=\"input-group-addon\">/apps/</span>\n      <input\n        class=\"form-control\"\n        placeholder=\"{{ 'e.g. my-application' | translate }}\"\n        name=\"contextPath\"\n        type=\"text\"\n        required\n        formControlName=\"contextPath\"\n      />\n    </div>\n  </c8y-form-group>\n  <c8y-form-group>\n    <label>{{ 'Select icon' | translate }}</label>\n    <c8y-icon-selector-wrapper\n      name=\"icon\"\n      formControlName=\"icon\"\n    ></c8y-icon-selector-wrapper>\n  </c8y-form-group>\n</form>\n", dependencies: [{ kind: "directive", type: i2.C8yTranslateDirective, selector: "[translate],[ngx-translate]" }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "component", type: i2.FormGroupComponent, selector: "c8y-form-group", inputs: ["hasError", "hasWarning", "hasSuccess", "novalidation", "status"] }, { kind: "directive", type: i2.RequiredInputPlaceholderDirective, selector: "input[required], input[formControlName]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: i3.IconSelectorWrapperComponent, selector: "c8y-icon-selector-wrapper", inputs: ["canRemoveIcon", "selectedIcon", "iconSize"], outputs: ["onSelect"] }, { kind: "pipe", type: i2.C8yTranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.9", ngImport: i0, type: ApplicationPropertiesFormComponent, decorators: [{
            type: Component,
            args: [{ selector: 'c8y-application-properties-form', template: "<form\n  class=\"c8y-wizard-form text-left\"\n  name=\"appDeployForm\"\n  (ngSubmit)=\"(formGroup.valid)\"\n  [formGroup]=\"formGroup\"\n  novalidate\n>\n  <c8y-form-group>\n    <label\n      for=\"name\"\n      translate\n    >\n      Name\n    </label>\n    <input\n      class=\"form-control\"\n      placeholder=\"{{ 'e.g. My application' | translate }}\"\n      name=\"name\"\n      type=\"text\"\n      required\n      formControlName=\"name\"\n    />\n  </c8y-form-group>\n  <c8y-form-group>\n    <label\n      for=\"key\"\n      translate\n    >\n      Application key\n    </label>\n    <input\n      class=\"form-control\"\n      placeholder=\"{{ 'e.g. my-application-key' | translate }}\"\n      name=\"key\"\n      type=\"text\"\n      required\n      formControlName=\"key\"\n    />\n  </c8y-form-group>\n  <c8y-form-group>\n    <label\n      for=\"contextPath\"\n      translate\n    >\n      Path\n    </label>\n    <div class=\"input-group\">\n      <span class=\"input-group-addon\">/apps/</span>\n      <input\n        class=\"form-control\"\n        placeholder=\"{{ 'e.g. my-application' | translate }}\"\n        name=\"contextPath\"\n        type=\"text\"\n        required\n        formControlName=\"contextPath\"\n      />\n    </div>\n  </c8y-form-group>\n  <c8y-form-group>\n    <label>{{ 'Select icon' | translate }}</label>\n    <c8y-icon-selector-wrapper\n      name=\"icon\"\n      formControlName=\"icon\"\n    ></c8y-icon-selector-wrapper>\n  </c8y-form-group>\n</form>\n" }]
        }], ctorParameters: () => [{ type: i1.FormBuilder }], propDecorators: { application: [{
                type: Input
            }], disabled: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 