import{j as w}from"./chunk-JBNKEIUX.js";import"./chunk-5SW267PH.js";import"./chunk-PU7DBJLZ.js";import"./chunk-3DDBG3AR.js";import"./chunk-5MLUVH77.js";import"./chunk-SMMBZMNL.js";import"./chunk-S5GA3KRV.js";import"./chunk-EFONMPAR.js";import"./chunk-YQXLYYOT.js";import"./chunk-6RITFGP2.js";import"./chunk-HGXDKXJP.js";import"./chunk-WQUXAKOL.js";import"./chunk-LYNKRDJC.js";import"./chunk-SKY4LXUD.js";import"./chunk-BZT47AWD.js";import"./chunk-5WQBRAHK.js";import"./chunk-4FTRQKHH.js";import"./chunk-TTWRMELT.js";import"./chunk-EMJ4QQUL.js";import"./chunk-QPCAJSKO.js";import"./chunk-QV67LFVX.js";import"./chunk-4O3FVBGX.js";import{b}from"./chunk-TGWIHQDX.js";import{d as i}from"./chunk-Q5KZV54I.js";import{a as S}from"./chunk-YHVRQUSB.js";import"./chunk-3Z7PXZF3.js";import{a as F}from"./chunk-43BLBOSI.js";import"./chunk-IWSLIKCG.js";import"./chunk-2DXJE6G7.js";import"./chunk-7RP244JU.js";import"./chunk-LHGSJXTX.js";import"./chunk-ZKNPBXGB.js";import{b as g}from"./chunk-S3ADKFO2.js";import{E as v}from"./chunk-I5MYHHJE.js";import{Fb as r,Ib as h,S as p,Wa as u,Xc as y,f as m,gb as a,lb as f}from"./chunk-CKLXM6EG.js";import{a as d,b as c}from"./chunk-TSRGIXR5.js";var T=class l{constructor(o,e,t,n,s){this.apiService=o;this.route=e;this.translate=t;this.cdr=n;this.toast=s}title;urlApi;translationPrefix="customFields";fullWidthFields=["select","input","date","table","radio","textarea","multi-select"];values;categories;isEdit=!1;isShowMode=!1;fields;destroy$=new m;titleOfButton;ngOnInit(){this.route.paramMap.subscribe(o=>{let e=o.get("id");this.isShowMode=this.route.snapshot.routeConfig?.path?.includes("show")??!1,e?(this.getDetails(e),this.isShowMode?(this.title="show-custom-field",this.urlApi=`procurement/custom-field/show/${e}`):(this.isEdit=!0,this.titleOfButton="edit",this.title="edit-custom-field",this.urlApi=`procurement/custom-field/update/${e}`)):(this.isEdit=!1,this.titleOfButton="add",this.title="add-custom-field",this.urlApi="procurement/custom-field/store")}),this.fields=[{type:"input",title:"name_ar",inputType:"text",class:"col-6",controlName:"name_ar",validators:[i.required],readOnly:this.isShowMode},{type:"input",title:"name_en",inputType:"text",class:"col-6",controlName:"name_en",validators:[i.required],readOnly:this.isShowMode},{type:"select",title:"relatedCategory",options:[],optionsUrl:"procurement/public/category/show-categories",class:"col-6",controlName:"category_id",nestedName:"category",validators:[i.required],readOnly:this.isShowMode},{type:"select",title:"customFieldtype",controlName:"type",class:"col-6",options:[{name:"Text",id:"Text"},{name:"Checkbox",id:"Checkbox"},{name:"Date",id:"Date"},{name:"Number",id:"Number"},{name:"Toggle",id:"Toggle"}],validators:[i.required],readOnly:this.isShowMode},{type:"radio",title:"active",controlName:"visible",class:"col-6",options:[{name:this.translate.instant("yes"),id:1},{name:this.translate.instant("no"),id:0}],validators:[i.required],readOnly:this.isShowMode,RadioDefaultValue:1},{type:"radio",title:"required",controlName:"required",class:"col-6",options:[{name:this.translate.instant("true"),id:1},{name:this.translate.instant("false"),id:0}],validators:[i.required],readOnly:this.isShowMode},{type:"input",title:"value",inputType:"text",class:"col-6",controlName:"value",readOnly:this.isShowMode}]}getDetails(o){this.apiService.Get(`procurement/custom-field/show/${o}`).pipe(p(this.destroy$)).subscribe({next:e=>{this.values=c(d({},e.data),{category_id:e.data.category_id});let t=this.fields?.find(s=>s.controlName==="type"),n=this.fields.find(s=>s.controlName==="category_id");n.options=[{id:e.data.category.id,name:e.data.category.name}],this.isShowMode&&(t.options=[{id:e.data.type,name:e.data.type}]),this.cdr.detectChanges()},error:e=>{console.error(e)}})}static \u0275fac=function(e){return new(e||l)(a(S),a(v),a(g),a(y),a(b))};static \u0275cmp=f({type:l,selectors:[["app-custom-field-actions"]],decls:2,vars:10,consts:[[3,"title","Translationprefix","showTitle","showBreadcrumb"],["routeAfterSuccess","/settings/custom-fields","titleOfButton2","cancel",3,"fields","url","formValues","fullWidthFields","readOnly","titleOfButton"]],template:function(e,t){e&1&&h(0,"app-page-title",0)(1,"app-main-form",1),e&2&&(r("title",t.title)("Translationprefix",t.translationPrefix)("showTitle",!0)("showBreadcrumb",!0),u(),r("fields",t.fields)("url",t.urlApi)("formValues",t.values)("fullWidthFields",t.fullWidthFields)("readOnly",t.isShowMode)("titleOfButton",t.titleOfButton))},dependencies:[F,w],styles:["[_nghost-%COMP%]     .p-multiselect{border-radius:8px!important;background:#e8e8e8b3!important;display:flex;padding:24px!important;border:none!important}"]})};export{T as CustomFieldActions};
