import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Validators } from '@angular/forms';
import { TaskAssignmentType } from '../../../models/TaskAssignmentType';
import { Status } from '../../../models/status';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "verben-ng-ui";
import * as i3 from "@angular/router";
export class WorkflowFormComponent {
    fb;
    operations = [];
    get currentData() {
        return this._currentData;
    }
    set currentData(value) {
        this._currentData = value;
        console.log(value?.data);
        if (value?.data) {
            this.form.patchValue({
                Name: value.data.Name || '',
                Description: value.data.Description || '',
                AssignmentType: value.data.AssignmentType || '',
                Service: value.data.Service || '',
                Operation: value.data.Operation || '',
                Status: value.data.Status || '',
            });
        }
        else {
            this.form.reset();
        }
    }
    _currentData = null;
    switchView = new EventEmitter();
    onSave = new EventEmitter();
    form;
    assignmentTypes = Object.values(TaskAssignmentType);
    statuses = Object.values(Status);
    // roles: WritableSignal<Role[]> = signal([]);
    constructor(fb) {
        this.fb = fb;
        this.form = this.fb.group({
            Name: ['', { validators: [Validators.required] }],
            Description: ['', { validators: [Validators.required] }],
            AssignmentType: ['', { validators: [Validators.required] }],
            Service: [''],
            Operation: [''],
            Status: ['', { validators: [Validators.required] }],
        });
    }
    ngOnInit() {
        // this.userAccessRequestFacade.getRoles$().subscribe((data) => {
        //   this.roles.set(data);
        // });
        // try {
        //   this.userAccessRequestFacade.loadRoles();
        // } catch (error) {
        //   // Handle error
        // }
        console.log(this.currentData?.data);
    }
    handleSubmit() {
        if (this.form.valid) {
            // Emit save event with form value
            console.log('Form saved:', this.form.value);
            this.onSave.emit(this.form.value);
        }
    }
    onDelete() {
        // Emit delete event
        console.log('Delete requested');
    }
    disableProcessing() {
        return !this.form.valid;
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WorkflowFormComponent, deps: [{ token: i1.FormBuilder }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: WorkflowFormComponent, selector: "lib-workflow-form", inputs: { operations: "operations", currentData: "currentData" }, outputs: { switchView: "switchView", onSave: "onSave" }, ngImport: i0, template: "<form\n  [formGroup]=\"form\"\n  class=\"flex flex-col px-3 pb-3 rounded-xl h-full w-full relative space-y-4\"\n  (ngSubmit)=\"handleSubmit()\"\n>\n  <verbena-input\n    name=\"Name\"\n    label=\"Name\"\n    formControlName=\"Name\"\n    placeHolder=\"Enter Name\"\n  />\n  <verbena-input\n    name=\"Description\"\n    label=\"Description\"\n    formControlName=\"Description\"\n    placeHolder=\"Enter Description\"\n  />\n\n  <div class=\"space-y-1\">\n    <label for=\"assignment\">Assignment</label>\n\n    <verben-drop-down\n      label=\"Assignment\"\n      styleClass=\"w-full\"\n      width=\"100%\"\n      [multiselect]=\"false\"\n      placeholder=\"Select\"\n      [options]=\"assignmentTypes\"\n      id=\"assignment\"\n      formControlName=\"AssignmentType\"\n      class=\"form-control\"\n    >\n    </verben-drop-down>\n  </div>\n\n  <div class=\"space-y-1\">\n    <label for=\"operation\">Operation</label>\n\n    <verben-drop-down\n      label=\"Operation\"\n      styleClass=\"w-full\"\n      width=\"100%\"\n      [multiselect]=\"false\"\n      placeholder=\"Select\"\n      [options]=\"operations\"\n      optionLabel=\"Description\"\n      optionValue=\"Description\"\n      id=\"operation\"\n      formControlName=\"Operation\"\n      class=\"form-control\"\n    >\n    </verben-drop-down>\n  </div>\n\n  <!-- <div class=\"space-y-1\">\n    <label for=\"object\">Object</label>\n\n    <verbena-input\n      id=\"object\"\n      formControlName=\"Operation\"\n      placeHolder=\"Enter Object\"\n    />\n  </div> -->\n\n  <div class=\"space-y-1\">\n    <label for=\"status\">Status</label>\n\n    <verben-drop-down\n      label=\"Status\"\n      styleClass=\"w-full\"\n      width=\"100%\"\n      [multiselect]=\"false\"\n      [showClear]=\"true\"\n      placeholder=\"Null\"\n      [(options)]=\"statuses\"\n      id=\"status\"\n      formControlName=\"Status\"\n      class=\"form-control\"\n    >\n    </verben-drop-down>\n  </div>\n\n  <!-- buttons -->\n  <div class=\"flex justify-between gap-4 my-2\">\n    <verbena-button\n      width=\"114px\"\n      height=\"39px\"\n      text=\"Delete\"\n      bgColor=\"#999999\"\n      textColor=\"#404040\"\n      borderRadius=\"10px\"\n      [disable]=\"disableProcessing()\"\n    ></verbena-button>\n    <a [routerLink]=\"['/designer', currentData?.data.Code]\" class=\"ml-auto\">\n      <verbena-button\n        (click)=\"switchView.emit()\"\n        text=\"Designer\"\n        styleType=\"ylw-outline\"\n      ></verbena-button>\n    </a>\n    <verbena-button\n      (click)=\"switchView.emit()\"\n      text=\"Switch To Table\"\n      styleType=\"ylw-outline\"\n      class=\"ml-auto\"\n    ></verbena-button>\n    <verbena-button\n      type=\"submit\"\n      text=\"Save\"\n      bgColor=\"#FFE681\"\n      textColor=\"#404040\"\n      borderRadius=\"10px\"\n      pd=\"10px 20px\"\n      width=\"114px\"\n      height=\"39px\"\n      [disable]=\"disableProcessing()\"\n    ></verbena-button>\n  </div>\n</form>\n", styles: [""], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { 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: "component", type: i2.VerbenaInputComponent, selector: "verbena-input", inputs: ["label", "placeHolder", "required", "svgPosition", "minLength", "maxLength", "type", "bgColor", "border", "borderRadius", "textColor", "value", "labelPosition", "labelColor", "disable", "readOnly", "min", "max", "showBorder", "showErrorMessage", "errorMessageColor", "errorBorderColor", "errorPosition", "svg", "fontSize", "svgWidth", "svgHeight", "svgColor", "capitalization", "inputContainerClass", "inputFieldClass", "passLength", "inputWrapperClass", "passwordToggle", "customErrorMessages", "icon", "textPass"], outputs: ["valueChange"] }, { kind: "component", type: i2.VerbenaButtonComponent, selector: "verbena-button", inputs: ["text", "icon", "useIcon", "svgPosition", "iconPosition", "bgColor", "textColor", "border", "borderRadius", "pd", "width", "height", "fontSize", "fontWeight", "disable", "svgSize", "weight", "variant", "styleType", "svg", "svgWidth", "svgHeight", "iconColor", "svgColor", "buttonClass", "buttonTextClass", "isLoading", "spinnerSize", "spinnerColor"] }, { kind: "component", type: i2.DropDownComponent, selector: "verben-drop-down", inputs: ["options", "width", "showHorizontalLine", "horizontalLineColor", "optionLabel", "optionSubLabel", "optionValue", "placeholder", "invalidMessage", "errorPosition", "loadMoreCaption", "display", "showClear", "lazyLoad", "selectKey", "styleClass", "group", "multiselect", "filter", "avoidDuplication", "filterBy", "debounceTime", "minChar", "disabled", "required", "load", "asyncLabel", "search"], outputs: ["optionsChange", "onChange", "onClick", "onClear"] }, { kind: "directive", type: i3.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: WorkflowFormComponent, decorators: [{
            type: Component,
            args: [{ selector: 'lib-workflow-form', template: "<form\n  [formGroup]=\"form\"\n  class=\"flex flex-col px-3 pb-3 rounded-xl h-full w-full relative space-y-4\"\n  (ngSubmit)=\"handleSubmit()\"\n>\n  <verbena-input\n    name=\"Name\"\n    label=\"Name\"\n    formControlName=\"Name\"\n    placeHolder=\"Enter Name\"\n  />\n  <verbena-input\n    name=\"Description\"\n    label=\"Description\"\n    formControlName=\"Description\"\n    placeHolder=\"Enter Description\"\n  />\n\n  <div class=\"space-y-1\">\n    <label for=\"assignment\">Assignment</label>\n\n    <verben-drop-down\n      label=\"Assignment\"\n      styleClass=\"w-full\"\n      width=\"100%\"\n      [multiselect]=\"false\"\n      placeholder=\"Select\"\n      [options]=\"assignmentTypes\"\n      id=\"assignment\"\n      formControlName=\"AssignmentType\"\n      class=\"form-control\"\n    >\n    </verben-drop-down>\n  </div>\n\n  <div class=\"space-y-1\">\n    <label for=\"operation\">Operation</label>\n\n    <verben-drop-down\n      label=\"Operation\"\n      styleClass=\"w-full\"\n      width=\"100%\"\n      [multiselect]=\"false\"\n      placeholder=\"Select\"\n      [options]=\"operations\"\n      optionLabel=\"Description\"\n      optionValue=\"Description\"\n      id=\"operation\"\n      formControlName=\"Operation\"\n      class=\"form-control\"\n    >\n    </verben-drop-down>\n  </div>\n\n  <!-- <div class=\"space-y-1\">\n    <label for=\"object\">Object</label>\n\n    <verbena-input\n      id=\"object\"\n      formControlName=\"Operation\"\n      placeHolder=\"Enter Object\"\n    />\n  </div> -->\n\n  <div class=\"space-y-1\">\n    <label for=\"status\">Status</label>\n\n    <verben-drop-down\n      label=\"Status\"\n      styleClass=\"w-full\"\n      width=\"100%\"\n      [multiselect]=\"false\"\n      [showClear]=\"true\"\n      placeholder=\"Null\"\n      [(options)]=\"statuses\"\n      id=\"status\"\n      formControlName=\"Status\"\n      class=\"form-control\"\n    >\n    </verben-drop-down>\n  </div>\n\n  <!-- buttons -->\n  <div class=\"flex justify-between gap-4 my-2\">\n    <verbena-button\n      width=\"114px\"\n      height=\"39px\"\n      text=\"Delete\"\n      bgColor=\"#999999\"\n      textColor=\"#404040\"\n      borderRadius=\"10px\"\n      [disable]=\"disableProcessing()\"\n    ></verbena-button>\n    <a [routerLink]=\"['/designer', currentData?.data.Code]\" class=\"ml-auto\">\n      <verbena-button\n        (click)=\"switchView.emit()\"\n        text=\"Designer\"\n        styleType=\"ylw-outline\"\n      ></verbena-button>\n    </a>\n    <verbena-button\n      (click)=\"switchView.emit()\"\n      text=\"Switch To Table\"\n      styleType=\"ylw-outline\"\n      class=\"ml-auto\"\n    ></verbena-button>\n    <verbena-button\n      type=\"submit\"\n      text=\"Save\"\n      bgColor=\"#FFE681\"\n      textColor=\"#404040\"\n      borderRadius=\"10px\"\n      pd=\"10px 20px\"\n      width=\"114px\"\n      height=\"39px\"\n      [disable]=\"disableProcessing()\"\n    ></verbena-button>\n  </div>\n</form>\n" }]
        }], ctorParameters: () => [{ type: i1.FormBuilder }], propDecorators: { operations: [{
                type: Input
            }], currentData: [{
                type: Input
            }], switchView: [{
                type: Output
            }], onSave: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 