import { Component, Input, Output, EventEmitter } from '@angular/core';
import { DefaultCreateSaveCancel } from '../../../lib/create-save-cancel-default';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "../../../../icon/icon.component";
import * as i4 from "../../../../button/button.directive";
import * as i5 from "../../../../popover/popover.component";
import * as i6 from "@ngx-translate/core";
export class THeadCreateCancelComponent extends DefaultCreateSaveCancel {
    constructor() {
        super();
        this.create = new EventEmitter();
    }
    ngOnChanges() {
        // ===========================================
        // Call DefaultCreateSaveCancel "ngOnChanges()" life cycle hook.
        // ===========================================
        super.ngOnChanges();
        this.createButtonContent = this.grid.getSetting('add.createButtonContent');
        this.cancelButtonContent = this.grid.getSetting('add.cancelButtonContent');
    }
    onCancel(evt) {
        evt.preventDefault();
        this.grid.createFormShown = false;
        this.cancelCreate.emit();
    }
}
THeadCreateCancelComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: THeadCreateCancelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
THeadCreateCancelComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: THeadCreateCancelComponent, selector: "ng2-st-actions", inputs: { grid: "grid", cancelCreate: "cancelCreate" }, outputs: { create: "create" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
        <div class="form-creator-submit" [formGroup]="editingFormGroup">
            <button type="submit"
                class="slds-m-right--x-small uno-smart-table-action uno-smart-table-action-add-create text-uppercase"
                unoButton
                unoType="green"
                unoSize="x-small"
                (click)="$event.preventDefault(); create.emit($event)"
                [disabled]="!editingFormGroup.valid"
                [title]="createButtonContent | translate"

                uno-popover-trigger
                [unoPopover]="formErrorsTemplate"
                [unoPopoverOpen]="openValidatorPopover"

                unoPopoverPlacement="leftBottom"
                unoPopoverNubbin="right-top"
                unoPopoverSize="small"
                unoPopoverTooltip="true"
                [unoPopoverTheme]="grid.getSetting('popoverTheme') || 'info'">
                    {{ createButtonContent | translate }}
            </button>

            <uno-icon
                icon="close"
                size="xx-small"
                class="uno-smart-table-action uno-smart-table-action-add-cancel"
                [title]="cancelButtonContent | translate"
                (click)="onCancel($event)">
            </uno-icon>
        </div>

        <!-- The "editingFormGroup" ALL Controller's Input Validator errors: -->
        <ng-template #formErrorsTemplate>
            <div class="form-errors-content-container">
                <!--Following errors where found on editing:-->
                <div *ngFor="let cell of grid.dataSet.columns" class="slds-m-top--x-small">
                    <div *ngIf="editingFormGroup.get(cell.id)?.errors">
                        <b style="color:red;">{{ cell.id }}</b> is invalid!
                        <div *ngFor="let errors of errorsData">
                            <div *ngIf="errors.input === cell.id">
                                <div *ngFor="let strError of errors.translated">
                                    {{ strError }}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ng-template>
    `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "component", type: i3.IconComponent, selector: "uno-icon", inputs: ["svgType", "icon", "withOpacity", "color", "size", "customColor"] }, { kind: "directive", type: i4.ButtonDirective, selector: "[unoButton]", inputs: ["unoType", "unoSize"] }, { kind: "directive", type: i5.PopoverTriggerDirective, selector: "[uno-popover-trigger]", inputs: ["unoPopover", "unoPopoverHeader", "unoPopoverFooter", "unoPopoverTemplate", "unoPopoverTemplateData", "hasEdit", "hasDelete", "infoTitle", "infoCreatedBy", "infoModifiedBy", "infoDate", "unoPopoverPlacement", "unoPopoverTheme", "unoPopoverNubbin", "unoPopoverSize", "unoPopoverTooltip", "unoPopoverDelay", "unoPopoverInteractive", "unoPopoverOpen"], outputs: ["unoPopoverToggled", "unoPopoverTemplateEvent"], exportAs: ["unoPopoverTrigger"] }, { kind: "pipe", type: i6.TranslatePipe, name: "translate" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: THeadCreateCancelComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'ng2-st-actions',
                    template: `
        <div class="form-creator-submit" [formGroup]="editingFormGroup">
            <button type="submit"
                class="slds-m-right--x-small uno-smart-table-action uno-smart-table-action-add-create text-uppercase"
                unoButton
                unoType="green"
                unoSize="x-small"
                (click)="$event.preventDefault(); create.emit($event)"
                [disabled]="!editingFormGroup.valid"
                [title]="createButtonContent | translate"

                uno-popover-trigger
                [unoPopover]="formErrorsTemplate"
                [unoPopoverOpen]="openValidatorPopover"

                unoPopoverPlacement="leftBottom"
                unoPopoverNubbin="right-top"
                unoPopoverSize="small"
                unoPopoverTooltip="true"
                [unoPopoverTheme]="grid.getSetting('popoverTheme') || 'info'">
                    {{ createButtonContent | translate }}
            </button>

            <uno-icon
                icon="close"
                size="xx-small"
                class="uno-smart-table-action uno-smart-table-action-add-cancel"
                [title]="cancelButtonContent | translate"
                (click)="onCancel($event)">
            </uno-icon>
        </div>

        <!-- The "editingFormGroup" ALL Controller's Input Validator errors: -->
        <ng-template #formErrorsTemplate>
            <div class="form-errors-content-container">
                <!--Following errors where found on editing:-->
                <div *ngFor="let cell of grid.dataSet.columns" class="slds-m-top--x-small">
                    <div *ngIf="editingFormGroup.get(cell.id)?.errors">
                        <b style="color:red;">{{ cell.id }}</b> is invalid!
                        <div *ngFor="let errors of errorsData">
                            <div *ngIf="errors.input === cell.id">
                                <div *ngFor="let strError of errors.translated">
                                    {{ strError }}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </ng-template>
    `
                }]
        }], ctorParameters: function () { return []; }, propDecorators: { grid: [{
                type: Input
            }], cancelCreate: [{
                type: Input
            }], create: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 