import { ChangeDetectionStrategy, Component, Injector, ViewChild } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { MatDialogRef } from '@angular/material/dialog';
import { MatSelectionList } from '@angular/material/list';
import { OTableBaseDialogClass } from '../o-table-base-dialog.class';
import { ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatListModule } from '@angular/material/list';
import { MatTooltipModule } from '@angular/material/tooltip';
import { OTranslatePipe } from '../../../../../pipes/o-translate.pipe';
import { OMatErrorDirective } from '../../../../../directives/o-mat-error.directive';
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/checkbox";
import * as i5 from "@angular/material/form-field";
import * as i6 from "@angular/material/icon";
import * as i7 from "@angular/material/input";
import * as i8 from "@angular/material/list";
import * as i9 from "@angular/material/tooltip";
export class OTableStoreConfigurationDialogComponent extends OTableBaseDialogClass {
    constructor(dialogRef, injector) {
        super(injector);
        this.dialogRef = dialogRef;
        this.injector = injector;
        this.properties = [{
                property: 'sort-columns',
                name: 'TABLE.DIALOG.PROPERTIES.SORT',
                info: 'TABLE.DIALOG.PROPERTIES.SORT.INFO'
            }, {
                property: 'oColumns-display',
                name: 'TABLE.DIALOG.PROPERTIES.COLUMNS_DISPLAY',
                info: 'TABLE.DIALOG.PROPERTIES.COLUMNS_DISPLAY.INFO'
            }, {
                property: 'quick-filter',
                name: 'TABLE.DIALOG.PROPERTIES.QUICK_FILTER',
                info: 'TABLE.DIALOG.PROPERTIES.QUICK_FILTER.INFO'
            }, {
                property: 'columns-filter',
                name: 'TABLE.DIALOG.PROPERTIES.COLUMNS_FILTER',
                info: 'TABLE.DIALOG.PROPERTIES.COLUMNS_FILTER.INFO'
            }, {
                property: 'filter-builder',
                name: 'TABLE.DIALOG.PROPERTIES.FILTER_BUILDER',
                info: 'TABLE.DIALOG.PROPERTIES.FILTER_BUILDER.INFO'
            }, {
                property: 'page',
                name: 'TABLE.DIALOG.PROPERTIES.PAGE',
                info: 'TABLE.DIALOG.PROPERTIES.PAGE.INFO'
            }];
        this.formGroup = new FormGroup({
            name: new FormControl('', [
                Validators.required
            ]),
            description: new FormControl('')
        });
        this.setFormControl(this.formGroup.get('name'));
    }
    ngAfterViewInit() {
        this.propertiesList.selectAll();
    }
    areAllSelected() {
        return this.propertiesList && this.propertiesList.options && this.propertiesList.options.length === this.propertiesList.selectedOptions.selected.length;
    }
    onSelectAllChange(event) {
        event.checked ? this.propertiesList.selectAll() : this.propertiesList.deselectAll();
    }
    getConfigurationAttributes() {
        return this.formGroup.value;
    }
    getSelectedTableProperties() {
        const selected = this.propertiesList.selectedOptions.selected;
        return selected.length ? selected.map(item => item.value) : [];
    }
    isIndeterminate() {
        return !this.areAllSelected();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: OTableStoreConfigurationDialogComponent, deps: [{ token: i1.MatDialogRef }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: OTableStoreConfigurationDialogComponent, isStandalone: true, selector: "o-table-store-configuration-dialog", viewQueries: [{ propertyName: "propertiesList", first: true, predicate: ["propertiesList"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<span mat-dialog-title>{{ 'TABLE.BUTTONS.SAVE_CONFIGURATION' | oTranslate }}</span>\n\n<mat-dialog-content>\n  <div mat-subheader>{{ 'TABLE.DIALOG.SAVE_CONFIGURATION' | oTranslate }}</div>\n  <form #form [formGroup]=\"formGroup\" class=\"o-flex-column\">\n    <mat-form-field subscriptSizing=\"dynamic\">\n      <input matInput [matTooltip]=\"tooltipText\" [matTooltipClass]=\"tooltipClass\" placeholder=\"{{ 'TABLE.DIALOG.CONFIGURATION_NAME' | oTranslate }}\"\n        formControlName=\"name\" required />\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\" subscriptSizing=\"dynamic\">\n        <textarea matInput placeholder=\"{{ 'TABLE.DIALOG.CONFIGURATION_DESCRIPTION' | oTranslate }}\" formControlName=\"description\" rows=\"4\"\n        cols=\"50\"></textarea>\n      </mat-form-field>\n      <div class=\"inner-subheader\" mat-subheader>{{ 'TABLE.DIALOG.CONFIGURATION_PROPERTIES' | oTranslate }}</div>\n      <div class=\"o-flex-column\">\n        <mat-checkbox (change)=\"onSelectAllChange($event)\" [checked]=\"areAllSelected()\" [indeterminate]=\"isIndeterminate()\" class=\"select-all-checkbox\">\n          {{ 'SELECT_ALL' | oTranslate }}\n        </mat-checkbox>\n\n        <mat-selection-list #propertiesList class=\"o-table-save-configuration-dialog-list o-scroll\">\n          @for (property of properties; track property) {\n            <mat-list-option checkboxPosition=\"before\" [value]=\"property.property\">\n              <span matListItemTitle class=\"o-flex\">{{ property.name | oTranslate }}</span>\n              @if (property.info) {\n                <mat-icon matListItemIcon matTooltip=\"{{ property.info | oTranslate }}\" class=\"o-tscd-list-tooltip\">info</mat-icon>\n              }\n            </mat-list-option>\n          }\n        </mat-selection-list>\n      </div>\n    </form>\n  </mat-dialog-content>\n\n  <mat-dialog-actions align=\"end\">\n    <button type=\"button\" mat-stroked-button class=\"mat-primary\" [mat-dialog-close]=\"false\" class=\"o-button-default cancel\">\n    {{ 'CANCEL' | oTranslate }}</button>\n    <button type=\"button\" mat-stroked-button class=\"mat-primary\" [mat-dialog-close]=\"true\"\n    [disabled]=\"!formGroup.valid || propertiesList.selectedOptions.selected.length===0\" class=\"o-button-primary\">{{ 'SAVE' | oTranslate }}</button>\n  </mat-dialog-actions>\n", styles: [".o-table-save-configuration-dialog-list{max-height:120px;overflow-y:scroll}.o-table-save-configuration-dialog-list .mat-mdc-list-item .o-tscd-list-tooltip.mat-icon{opacity:.25}\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: MatCheckboxModule }, { kind: "component", type: i4.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { 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: i5.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i5.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i7.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: MatListModule }, { kind: "component", type: i8.MatSelectionList, selector: "mat-selection-list", inputs: ["color", "compareWith", "multiple", "hideSingleSelectionIndicator", "disabled"], outputs: ["selectionChange"], exportAs: ["matSelectionList"] }, { kind: "component", type: i8.MatListOption, selector: "mat-list-option", inputs: ["togglePosition", "checkboxPosition", "color", "value", "selected"], outputs: ["selectedChange"], exportAs: ["matListOption"] }, { kind: "directive", type: i8.MatListItemIcon, selector: "[matListItemIcon]" }, { kind: "directive", type: i8.MatListSubheaderCssMatStyler, selector: "[mat-subheader], [matSubheader]" }, { kind: "directive", type: i8.MatListItemTitle, selector: "[matListItemTitle]" }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i9.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: OTableStoreConfigurationDialogComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [ReactiveFormsModule, MatButtonModule, MatCheckboxModule, MatDialogModule, MatFormFieldModule, MatIconModule, MatInputModule, MatListModule, MatTooltipModule, OTranslatePipe, OMatErrorDirective], selector: 'o-table-store-configuration-dialog', changeDetection: ChangeDetectionStrategy.OnPush, template: "<span mat-dialog-title>{{ 'TABLE.BUTTONS.SAVE_CONFIGURATION' | oTranslate }}</span>\n\n<mat-dialog-content>\n  <div mat-subheader>{{ 'TABLE.DIALOG.SAVE_CONFIGURATION' | oTranslate }}</div>\n  <form #form [formGroup]=\"formGroup\" class=\"o-flex-column\">\n    <mat-form-field subscriptSizing=\"dynamic\">\n      <input matInput [matTooltip]=\"tooltipText\" [matTooltipClass]=\"tooltipClass\" placeholder=\"{{ 'TABLE.DIALOG.CONFIGURATION_NAME' | oTranslate }}\"\n        formControlName=\"name\" required />\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\" subscriptSizing=\"dynamic\">\n        <textarea matInput placeholder=\"{{ 'TABLE.DIALOG.CONFIGURATION_DESCRIPTION' | oTranslate }}\" formControlName=\"description\" rows=\"4\"\n        cols=\"50\"></textarea>\n      </mat-form-field>\n      <div class=\"inner-subheader\" mat-subheader>{{ 'TABLE.DIALOG.CONFIGURATION_PROPERTIES' | oTranslate }}</div>\n      <div class=\"o-flex-column\">\n        <mat-checkbox (change)=\"onSelectAllChange($event)\" [checked]=\"areAllSelected()\" [indeterminate]=\"isIndeterminate()\" class=\"select-all-checkbox\">\n          {{ 'SELECT_ALL' | oTranslate }}\n        </mat-checkbox>\n\n        <mat-selection-list #propertiesList class=\"o-table-save-configuration-dialog-list o-scroll\">\n          @for (property of properties; track property) {\n            <mat-list-option checkboxPosition=\"before\" [value]=\"property.property\">\n              <span matListItemTitle class=\"o-flex\">{{ property.name | oTranslate }}</span>\n              @if (property.info) {\n                <mat-icon matListItemIcon matTooltip=\"{{ property.info | oTranslate }}\" class=\"o-tscd-list-tooltip\">info</mat-icon>\n              }\n            </mat-list-option>\n          }\n        </mat-selection-list>\n      </div>\n    </form>\n  </mat-dialog-content>\n\n  <mat-dialog-actions align=\"end\">\n    <button type=\"button\" mat-stroked-button class=\"mat-primary\" [mat-dialog-close]=\"false\" class=\"o-button-default cancel\">\n    {{ 'CANCEL' | oTranslate }}</button>\n    <button type=\"button\" mat-stroked-button class=\"mat-primary\" [mat-dialog-close]=\"true\"\n    [disabled]=\"!formGroup.valid || propertiesList.selectedOptions.selected.length===0\" class=\"o-button-primary\">{{ 'SAVE' | oTranslate }}</button>\n  </mat-dialog-actions>\n", styles: [".o-table-save-configuration-dialog-list{max-height:120px;overflow-y:scroll}.o-table-save-configuration-dialog-list .mat-mdc-list-item .o-tscd-list-tooltip.mat-icon{opacity:.25}\n"] }]
        }], ctorParameters: () => [{ type: i1.MatDialogRef }, { type: i0.Injector }], propDecorators: { propertiesList: [{
                type: ViewChild,
                args: ['propertiesList']
            }] } });
//# sourceMappingURL=data:application/json;base64, 