import { __decorate } from "tslib";
import { Component, ViewChild, Output, EventEmitter } from '@angular/core';
import { SettingService } from '../../../../services/setting/setting.service';
let GridPopupEditorComponent = class GridPopupEditorComponent {
    constructor(settingService) {
        this.settingService = settingService;
        this.save = new EventEmitter();
        this.columns = [];
    }
    ngOnInit() {
    }
    setGridOption(gridOption) {
        this.gridOption = gridOption;
    }
    open(item) {
        this.item = item;
        this.columns = this.gridOption.columns.filter(column => item.editorHandler[column.field].visible);
    }
    onCancel() {
        this.modal.close();
    }
    onSave() {
        this.modal.close();
        this.save.emit(this.item);
    }
};
GridPopupEditorComponent.ctorParameters = () => [
    { type: SettingService }
];
__decorate([
    ViewChild('modal')
], GridPopupEditorComponent.prototype, "modal", void 0);
__decorate([
    Output()
], GridPopupEditorComponent.prototype, "save", void 0);
GridPopupEditorComponent = __decorate([
    Component({
        selector: 'sd-grid-popup-editor',
        template: "<sd-modal-control title=\"Configuration\" #modal>\r\n  <sd-modal-body *ngIf=\"item && gridOption?.columns\">\r\n    <form #formEditor=\"ngForm\">\r\n      <ng-template ngFor let-column [ngForOf]=\"columns\">\r\n        <div class=\"row\">\r\n          <div class=\"col-md-4\"></div>\r\n          <div class=\"col-md-8\">\r\n            <sd-input-control *ngIf=\"column.type === 'string'\" [(model)]=\"item[column.field]\"></sd-input-control>\r\n            <sd-input-control *ngIf=\"column.type === 'number'\" [(model)]=\"item[column.field]\" type=\"number\">\r\n            </sd-input-control>\r\n            <sd-select-control *ngIf=\"column.type === 'values'\" [(model)]=\"item[column.field]\" [items]=\"column.values\">\r\n            </sd-select-control>\r\n            <sd-switch-control *ngIf=\"column.type === 'boolean'\" [(model)]=\"item[column.field]\">\r\n            </sd-switch-control>\r\n            <sd-radio-control *ngIf=\"column.type === 'radio'\" [(model)]=\"item[column.field]\" [items]=\"column.values\">\r\n            </sd-radio-control>\r\n          </div>\r\n        </div>\r\n      </ng-template>\r\n    </form>\r\n  </sd-modal-body>\r\n  <sd-modal-footer>\r\n    <button type=\"button\" class=\"btn btn-info btn-sm mr-auto\" (click)=\"onCancel()\">\r\n      <i class=\"fa fa-refresh\"></i> {{'Cancel' | sdTranslate }}</button>\r\n    <button type=\"button\" class=\"btn btn-primary btn-sm\" (click)=\"onSave()\">\r\n      <i class=\"fa fa-floppy-o\"></i> {{'Save' | sdTranslate }}</button>\r\n  </sd-modal-footer>\r\n</sd-modal-control>",
        styles: [".btn{color:#fff;background-color:#919191;border-color:#919191;box-shadow:0 2px 2px 0 rgba(153,153,153,.14),0 3px 1px -2px rgba(153,153,153,.2),0 1px 5px 0 rgba(153,153,153,.12)}.btn:active,.btn:hover{box-shadow:0 14px 26px -12px rgba(153,153,153,.14),0 3px 1px -2px rgba(153,153,153,.2),0 1px 5px 0 rgba(153,153,153,.12)}.btn.btn-sm{padding:.2rem .5rem;font-size:11px}.btn.btn-xs{padding:.1rem .3rem;font-size:9px}.btn.btn-round{border-radius:30px}.btn.btn-primary{color:#fff;background-color:#c82c37;border-color:#c82c37;box-shadow:0 2px 2px 0 rgba(156,39,176,.14),0 3px 1px -2px rgba(156,39,176,.2),0 1px 5px 0 rgba(156,39,176,.12)}.btn.btn-primary:active,.btn.btn-primary:hover{box-shadow:0 14px 26px -12px rgba(156,39,176,.42),0 4px 23px 0 rgba(0,0,0,.12),0 8px 10px -5px rgba(156,39,176,.2)}.btn.btn-info{color:#fff;background-color:#00bcd4;border-color:#00bcd4;box-shadow:0 2px 2px 0 rgba(0,188,212,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,188,212,.12)}.btn.btn-info:active,.btn.btn-info:hover{box-shadow:0 14px 26px -12px rgba(0,188,212,.42),0 4px 23px 0 rgba(0,0,0,.12),0 8px 10px -5px rgba(0,188,212,.2)}.btn.btn-success{color:#fff;background-color:#4caf50;border-color:#4caf50;box-shadow:0 2px 2px 0 rgba(76,175,80,.14),0 3px 1px -2px rgba(76,175,80,.2),0 1px 5px 0 rgba(76,175,80,.12)}.btn.btn-success:active,.btn.btn-success:hover{box-shadow:0 14px 26px -12px rgba(76,175,80,.42),0 4px 23px 0 rgba(0,0,0,.12),0 8px 10px -5px rgba(76,175,80,.2)}.btn.btn-warning{color:#fff;background-color:#ff9800;border-color:#ff9800;box-shadow:0 2px 2px 0 rgba(255,152,0,.14),0 3px 1px -2px rgba(255,152,0,.2),0 1px 5px 0 rgba(255,152,0,.12)}.btn.btn-warning:active,.btn.btn-warning:hover{box-shadow:0 14px 26px -12px rgba(255,152,0,.42),0 4px 23px 0 rgba(0,0,0,.12),0 8px 10px -5px rgba(255,152,0,.2)}.btn.btn-danger{color:#fff;background-color:#f44336;border-color:#f44336;box-shadow:0 2px 2px 0 rgba(244,67,54,.14),0 3px 1px -2px rgba(244,67,54,.2),0 1px 5px 0 rgba(244,67,54,.12)}.btn.btn-danger:active,.btn.btn-danger:hover{box-shadow:0 14px 26px -12px rgba(244,67,54,.42),0 4px 23px 0 rgba(0,0,0,.12),0 8px 10px -5px rgba(244,67,54,.2)}", "::-webkit-scrollbar{width:7px;height:7px}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb{background:#888;border-radius:50px}::-webkit-scrollbar-thumb:hover{background:#555}"]
    })
], GridPopupEditorComponent);
export { GridPopupEditorComponent };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZC1wb3B1cC1lZGl0b3IuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vc3VwZXJkZXYtYW5ndWxhci1jb3JlLyIsInNvdXJjZXMiOlsibGliL2NvbnRyb2xzL2dyaWQtY29udHJvbC9jb21wb25lbnRzL2dyaWQtcG9wdXAtZWRpdG9yL2dyaWQtcG9wdXAtZWRpdG9yLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsT0FBTyxFQUFFLFNBQVMsRUFBVSxTQUFTLEVBQUUsTUFBTSxFQUFFLFlBQVksRUFBRSxNQUFNLGVBQWUsQ0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