import { __decorate } from "tslib";
import { Component, ViewChild, Output, EventEmitter } from '@angular/core';
import { SettingService } from '../../../../services/setting/setting.service';
var GridPopupEditorComponent = /** @class */ (function () {
    function GridPopupEditorComponent(settingService) {
        this.settingService = settingService;
        this.save = new EventEmitter();
        this.columns = [];
    }
    GridPopupEditorComponent.prototype.ngOnInit = function () {
    };
    GridPopupEditorComponent.prototype.setGridOption = function (gridOption) {
        this.gridOption = gridOption;
    };
    GridPopupEditorComponent.prototype.open = function (item) {
        this.item = item;
        this.columns = this.gridOption.columns.filter(function (column) { return item.editorHandler[column.field].visible; });
    };
    GridPopupEditorComponent.prototype.onCancel = function () {
        this.modal.close();
    };
    GridPopupEditorComponent.prototype.onSave = function () {
        this.modal.close();
        this.save.emit(this.item);
    };
    GridPopupEditorComponent.ctorParameters = function () { return [
        { 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: ["", "::-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);
    return GridPopupEditorComponent;
}());
export { GridPopupEditorComponent };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ3JpZC1wb3B1cC1lZGl0b3IuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vc3VwZXJkZXYtYW5ndWxhci1jb3JlLyIsInNvdXJjZXMiOlsibGliL2NvbnRyb2xzL2dyaWQtY29udHJvbC9jb21wb25lbnRzL2dyaWQtcG9wdXAtZWRpdG9yL2dyaWQtcG9wdXAtZWRpdG9yLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsT0FBTyxFQUFFLFNBQVMsRUFBVSxTQUFTLEVBQUUsTUFBTSxFQUFFLFlBQVksRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUduRixPQUFPLEVBQUUsY0FBYyxFQUFFLE1BQU0sOENBQThDLENBQUM7QUFTOUU7SUFRRSxrQ0FBb0IsY0FBOEI7UUFBOUIsbUJBQWMsR0FBZCxjQUFjLENBQWdCO1FBTHhDLFNBQUksR0FBRyxJQUFJLFlBQVksRUFBWSxDQ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