import{j as y}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 as v}from"./chunk-TGWIHQDX.js";import{d as a}from"./chunk-Q5KZV54I.js";import{a as h}from"./chunk-YHVRQUSB.js";import"./chunk-3Z7PXZF3.js";import{a as S}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 f}from"./chunk-S3ADKFO2.js";import{E as u}from"./chunk-I5MYHHJE.js";import{Fb as s,Ib as c,S as l,Wa as d,Xc as m,f as n,gb as r,lb as p}from"./chunk-CKLXM6EG.js";import"./chunk-TSRGIXR5.js";var g=class o{constructor(i,e,t,w,O){this.apiService=i;this.route=e;this.translate=t;this.cdr=w;this.toast=O}title;urlApi;translationPrefix="departments";fullWidthFields=["select","input","date","table","radio","textarea"];values;isEdit=!1;isShowMode=!1;fields;destroy$=new n;titleOfButton;ngOnInit(){this.route.paramMap.subscribe(i=>{let e=i.get("id");this.isShowMode=this.route.snapshot.routeConfig?.path?.includes("show")??!1,e?(this.getDetails(e),this.isShowMode?(this.title="show-department",this.urlApi=`procurement/departments/show/${e}`):(this.isEdit=!0,this.titleOfButton="edit",this.title="edit-department",this.urlApi=`procurement/departments/update/${e}`)):(this.isEdit=!1,this.titleOfButton="add",this.title="add-department",this.urlApi="procurement/departments/add")}),this.fields=[{type:"input",title:"name_ar",inputType:"text",class:"col-6",controlName:"name_ar",validators:[a.required,a.maxLength(50)],readOnly:this.isShowMode},{type:"input",title:"name_en",inputType:"text",class:"col-6",controlName:"name_en",validators:[a.required,a.maxLength(50)],readOnly:this.isShowMode},{type:"textarea",title:"description_ar",inputType:"text",class:"col-6",controlName:"description_ar",readOnly:this.isShowMode},{type:"textarea",title:"description_en",inputType:"text",class:"col-6",controlName:"description_en",readOnly:this.isShowMode},{type:"radio",title:"active",controlName:"status",class:"col-12",options:[{name:this.translate.instant("yes"),id:1},{name:this.translate.instant("no"),id:0}],validators:[a.required],readOnly:this.isShowMode,RadioDefaultValue:1}]}getDetails(i){this.apiService.Get(`procurement/departments/show/${i}`).pipe(l(this.destroy$)).subscribe({next:e=>{this.values=e.data,this.isShowMode&&this.fields.push({type:"input",title:"created_at",class:"col-6",controlName:"created_at",readOnly:!0,value:this.values.created_at},{type:"input",title:"updated_at",class:"col-6",controlName:"updated_at",readOnly:!0,value:this.values.updated_at})},error:e=>{console.error(e)}})}static \u0275fac=function(e){return new(e||o)(r(h),r(u),r(f),r(m),r(v))};static \u0275cmp=p({type:o,selectors:[["app-department-actions"]],decls:2,vars:10,consts:[[3,"title","Translationprefix","showTitle","showBreadcrumb"],["routeAfterSuccess","/settings/departments","titleOfButton2","cancel",3,"fields","url","formValues","fullWidthFields","readOnly","titleOfButton"]],template:function(e,t){e&1&&c(0,"app-page-title",0)(1,"app-main-form",1),e&2&&(s("title",t.title)("Translationprefix",t.translationPrefix)("showTitle",!0)("showBreadcrumb",!0),d(),s("fields",t.fields)("url",t.urlApi)("formValues",t.values)("fullWidthFields",t.fullWidthFields)("readOnly",t.isShowMode)("titleOfButton",t.titleOfButton))},dependencies:[S,y],encapsulation:2})};export{g as DepartmentActions};
