import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormBuilder, FormControl, Validators } from '@angular/forms';
import { PortalMessageService } from '@onecx/angular-integration-interface';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@onecx/angular-integration-interface";
import * as i3 from "primeng/api";
import * as i4 from "primeng/button";
import * as i5 from "primeng/dialog";
import * as i6 from "primeng/inputtext";
export class HelpItemEditorComponent {
    constructor(fb, portalMessageService) {
        this.fb = fb;
        this.portalMessageService = portalMessageService;
        this.displayDialog = true;
        this.displayDialogChange = new EventEmitter();
        this.saveHelpItem = new EventEmitter();
        this.formGroup = this.fb.group({
            appId: new FormControl({ value: null, disabled: true }, [Validators.required]),
            helpItemId: new FormControl({ value: null, disabled: true }, [Validators.required]),
            resourceUrl: new FormControl(null, Validators.required),
        });
    }
    ngOnChanges(changes) {
        if (changes['helpItem'] && this.helpItem) {
            this.formGroup.patchValue({ ...this.helpItem });
        }
    }
    save() {
        if (this.formGroup.valid && this.helpItem) {
            this.helpItem.resourceUrl = this.formGroup.value['resourceUrl'];
            this.saveHelpItem.emit(this.helpItem);
        }
        else {
            this.portalMessageService.error({
                summaryKey: 'OCX_HELP_ITEM_EDITOR.SAVE_ERROR',
            });
        }
    }
    close() {
        this.displayDialogChange.emit(false);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: HelpItemEditorComponent, deps: [{ token: i1.FormBuilder }, { token: i2.PortalMessageService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: HelpItemEditorComponent, selector: "ocx-help-item-editor", inputs: { displayDialog: "displayDialog", helpItem: "helpItem" }, outputs: { displayDialogChange: "displayDialogChange", saveHelpItem: "saveHelpItem" }, usesOnChanges: true, ngImport: i0, template: "<p-dialog\n  header=\"Edit help item for this page\"\n  [contentStyle]=\"{ overflow: 'visible' }\"\n  [style]=\"{ width: '400px', 'max-height': '300px' }\"\n  [(visible)]=\"displayDialog\"\n  (onHide)=\"close()\"\n>\n  <form [formGroup]=\"formGroup\" class=\"p-grid p-fluid help-editor-form\">\n    <div class=\"p-col-12\">\n      <span class=\"p-float-label\">\n        <input id=\"helpItemId\" type=\"text\" pInputText name=\"helpItemId\" formControlName=\"helpItemId\" />\n        <label for=\"helpItemId\">Help Item Id</label>\n      </span>\n    </div>\n    <div class=\"p-col-12\">\n      <span class=\"p-float-label\">\n        <input id=\"appId\" type=\"text\" pInputText name=\"appId\" formControlName=\"appId\" />\n        <label for=\"appId\">Application Id</label>\n      </span>\n    </div>\n    <div class=\"p-col-12\">\n      <span class=\"p-float-label\">\n        <input id=\"resourceUrl\" type=\"text\" pInputText name=\"resourceUrl\" formControlName=\"resourceUrl\" />\n        <label for=\"resourceUrl\">Url</label>\n      </span>\n    </div>\n  </form>\n  <ng-template pTemplate=\"footer\">\n    <button pButton class=\"primary\" value=\"Save\" label=\"Save\" icon=\"pi pi-check\" (click)=\"save()\"></button>\n    <button\n      pButton\n      icon=\"pi pi-times\"\n      class=\"flat\"\n      value=\"Cancel\"\n      label=\"Cancel\"\n      (click)=\"displayDialog = false\"\n    ></button\n  ></ng-template>\n</p-dialog>\n", styles: [".help-editor-form{margin:5px}.help-editor-form div{margin:10px}\n"], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.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: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i3.PrimeTemplate, selector: "[pTemplate]", inputs: ["type", "pTemplate"] }, { kind: "directive", type: i4.ButtonDirective, selector: "[pButton]", inputs: ["iconPos", "loadingIcon", "label", "icon", "loading", "severity", "raised", "rounded", "text", "outlined", "size", "plain"] }, { kind: "component", type: i5.Dialog, selector: "p-dialog", inputs: ["header", "draggable", "resizable", "positionLeft", "positionTop", "contentStyle", "contentStyleClass", "modal", "closeOnEscape", "dismissableMask", "rtl", "closable", "responsive", "appendTo", "breakpoints", "styleClass", "maskStyleClass", "maskStyle", "showHeader", "breakpoint", "blockScroll", "autoZIndex", "baseZIndex", "minX", "minY", "focusOnShow", "maximizable", "keepInViewport", "focusTrap", "transitionOptions", "closeIcon", "closeAriaLabel", "closeTabindex", "minimizeIcon", "maximizeIcon", "visible", "style", "position"], outputs: ["onShow", "onHide", "visibleChange", "onResizeInit", "onResizeEnd", "onDragEnd", "onMaximize"] }, { kind: "directive", type: i6.InputText, selector: "[pInputText]", inputs: ["variant"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: HelpItemEditorComponent, decorators: [{
            type: Component,
            args: [{ selector: 'ocx-help-item-editor', template: "<p-dialog\n  header=\"Edit help item for this page\"\n  [contentStyle]=\"{ overflow: 'visible' }\"\n  [style]=\"{ width: '400px', 'max-height': '300px' }\"\n  [(visible)]=\"displayDialog\"\n  (onHide)=\"close()\"\n>\n  <form [formGroup]=\"formGroup\" class=\"p-grid p-fluid help-editor-form\">\n    <div class=\"p-col-12\">\n      <span class=\"p-float-label\">\n        <input id=\"helpItemId\" type=\"text\" pInputText name=\"helpItemId\" formControlName=\"helpItemId\" />\n        <label for=\"helpItemId\">Help Item Id</label>\n      </span>\n    </div>\n    <div class=\"p-col-12\">\n      <span class=\"p-float-label\">\n        <input id=\"appId\" type=\"text\" pInputText name=\"appId\" formControlName=\"appId\" />\n        <label for=\"appId\">Application Id</label>\n      </span>\n    </div>\n    <div class=\"p-col-12\">\n      <span class=\"p-float-label\">\n        <input id=\"resourceUrl\" type=\"text\" pInputText name=\"resourceUrl\" formControlName=\"resourceUrl\" />\n        <label for=\"resourceUrl\">Url</label>\n      </span>\n    </div>\n  </form>\n  <ng-template pTemplate=\"footer\">\n    <button pButton class=\"primary\" value=\"Save\" label=\"Save\" icon=\"pi pi-check\" (click)=\"save()\"></button>\n    <button\n      pButton\n      icon=\"pi pi-times\"\n      class=\"flat\"\n      value=\"Cancel\"\n      label=\"Cancel\"\n      (click)=\"displayDialog = false\"\n    ></button\n  ></ng-template>\n</p-dialog>\n", styles: [".help-editor-form{margin:5px}.help-editor-form div{margin:10px}\n"] }]
        }], ctorParameters: () => [{ type: i1.FormBuilder }, { type: i2.PortalMessageService }], propDecorators: { displayDialog: [{
                type: Input
            }], displayDialogChange: [{
                type: Output
            }], helpItem: [{
                type: Input
            }], saveHelpItem: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 