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