import { ChangeDetectionStrategy, Component, Inject, Injector } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { MatTooltipModule } from '@angular/material/tooltip';
import { OMatErrorDirective } from '../../../../directives/o-mat-error.directive';
import { OTranslatePipe } from '../../../../pipes/o-translate.pipe';
import { OTableBaseDialogClass } from '../../../../components/table/extensions/dialog/o-table-base-dialog.class';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/dialog";
import * as i2 from "@angular/forms";
import * as i3 from "@angular/material/button";
import * as i4 from "@angular/material/form-field";
import * as i5 from "@angular/material/input";
import * as i6 from "@angular/material/tooltip";
export class OStoreFilterDialogComponent extends OTableBaseDialogClass {
    constructor(dialogRef, injector, data) {
        super(injector);
        this.dialogRef = dialogRef;
        this.injector = injector;
        this.filterNames = [];
        this.formGroup = new FormGroup({
            name: new FormControl('', [
                Validators.required,
                this.filterNameValidator.bind(this)
            ]),
            description: new FormControl('')
        });
        this.setFormControl(this.formGroup.get('name'));
        this.loadFilterNames(data);
    }
    loadFilterNames(filterNames) {
        this.filterNames = filterNames;
    }
    getFilterAttributes() {
        return this.formGroup.value;
    }
    filterNameValidator(control) {
        const ctrlValue = control.value;
        if (this.filterNames.indexOf(ctrlValue) !== -1) {
            return { filterNameAlreadyExists: true };
        }
        return {};
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OStoreFilterDialogComponent, deps: [{ token: i1.MatDialogRef }, { token: i0.Injector }, { token: MAT_DIALOG_DATA }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: OStoreFilterDialogComponent, isStandalone: true, selector: "o-store-filter-dialog", usesInheritance: true, ngImport: i0, template: "<span mat-dialog-title>{{ 'TABLE.BUTTONS.SAVE_FILTER' | oTranslate }}</span>\n\n<mat-dialog-content>\n  <div mat-subheader>{{ 'TABLE.DIALOG.SAVE_FILTER' | oTranslate }}</div>\n  <form #form [formGroup]=\"formGroup\" class=\"o-flex-column\">\n    <mat-form-field>\n      <input matInput [matTooltip]=\"tooltipText\" [matTooltipClass]=\"tooltipClass\" placeholder=\"{{ 'TABLE.DIALOG.FILTER_NAME' | oTranslate }}\"\n        formControlName=\"name\" required>\n      <mat-error *oMatError=\"hasError(formGroup.controls['name'], 'filterNameAlreadyExists')\">\n        {{ 'TABLE.DIALOG.FILTER_NAME_ALREADY_EXISTS' | oTranslate }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError(formGroup.controls['name'], 'required')\">\n        {{ 'FORM_VALIDATION.REQUIRED' | oTranslate }}\n      </mat-error>\n    </mat-form-field>\n    <mat-form-field class=\"example-full-width\">\n      <textarea matInput placeholder=\"{{ 'TABLE.DIALOG.FILTER_DESCRIPTION' | oTranslate }}\" formControlName=\"description\" rows=\"4\"\n        cols=\"50\"></textarea>\n    </mat-form-field>\n  </form>\n</mat-dialog-content>\n\n<mat-dialog-actions align=\"end\">\n  <button type=\"button\" mat-stroked-button [mat-dialog-close]=\"false\" class=\"o-button-default cancel\">{{ 'CANCEL' | oTranslate }}</button>\n  <button type=\"button\" mat-stroked-button [mat-dialog-close]=\"true\" [disabled]=\"!formGroup.valid\" class=\"o-button-primary\">\n    {{'SAVE' | oTranslate }}\n  </button>\n</mat-dialog-actions>\n", dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.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: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i3.MatButton, selector: "    button[mat-button], button[mat-raised-button], button[mat-flat-button],    button[mat-stroked-button]  ", exportAs: ["matButton"] }, { kind: "ngmodule", type: MatDialogModule }, { kind: "directive", type: i1.MatDialogClose, selector: "[mat-dialog-close], [matDialogClose]", inputs: ["aria-label", "type", "mat-dialog-close", "matDialogClose"], exportAs: ["matDialogClose"] }, { kind: "directive", type: i1.MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: i1.MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "directive", type: i1.MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "component", type: i4.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i4.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i5.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl],      input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i6.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "pipe", type: OTranslatePipe, name: "oTranslate" }, { kind: "directive", type: OMatErrorDirective, selector: "[oMatError]", inputs: ["oMatError"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OStoreFilterDialogComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [ReactiveFormsModule, MatButtonModule, MatDialogModule, MatFormFieldModule, MatInputModule, MatTooltipModule, OTranslatePipe, OMatErrorDirective], selector: 'o-store-filter-dialog', changeDetection: ChangeDetectionStrategy.OnPush, template: "<span mat-dialog-title>{{ 'TABLE.BUTTONS.SAVE_FILTER' | oTranslate }}</span>\n\n<mat-dialog-content>\n  <div mat-subheader>{{ 'TABLE.DIALOG.SAVE_FILTER' | oTranslate }}</div>\n  <form #form [formGroup]=\"formGroup\" class=\"o-flex-column\">\n    <mat-form-field>\n      <input matInput [matTooltip]=\"tooltipText\" [matTooltipClass]=\"tooltipClass\" placeholder=\"{{ 'TABLE.DIALOG.FILTER_NAME' | oTranslate }}\"\n        formControlName=\"name\" required>\n      <mat-error *oMatError=\"hasError(formGroup.controls['name'], 'filterNameAlreadyExists')\">\n        {{ 'TABLE.DIALOG.FILTER_NAME_ALREADY_EXISTS' | oTranslate }}\n      </mat-error>\n      <mat-error *oMatError=\"hasError(formGroup.controls['name'], 'required')\">\n        {{ 'FORM_VALIDATION.REQUIRED' | oTranslate }}\n      </mat-error>\n    </mat-form-field>\n    <mat-form-field class=\"example-full-width\">\n      <textarea matInput placeholder=\"{{ 'TABLE.DIALOG.FILTER_DESCRIPTION' | oTranslate }}\" formControlName=\"description\" rows=\"4\"\n        cols=\"50\"></textarea>\n    </mat-form-field>\n  </form>\n</mat-dialog-content>\n\n<mat-dialog-actions align=\"end\">\n  <button type=\"button\" mat-stroked-button [mat-dialog-close]=\"false\" class=\"o-button-default cancel\">{{ 'CANCEL' | oTranslate }}</button>\n  <button type=\"button\" mat-stroked-button [mat-dialog-close]=\"true\" [disabled]=\"!formGroup.valid\" class=\"o-button-primary\">\n    {{'SAVE' | oTranslate }}\n  </button>\n</mat-dialog-actions>\n" }]
        }], ctorParameters: () => [{ type: i1.MatDialogRef }, { type: i0.Injector }, { type: Array, decorators: [{
                    type: Inject,
                    args: [MAT_DIALOG_DATA]
                }] }] });
//# sourceMappingURL=data:application/json;base64, 