Files
nademitex_admin/dist/assets/ActiveSwitchCell-DJZQHZ-8.js
T
mohmdsdgandCopilot 981f4fdaf9 build: refresh admin production assets
Publish the verified admin build output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-24 20:16:16 +03:30

1 line
1.9 KiB
JavaScript

import{O as e,Z as t,at as n,g as r,l as i}from"./_plugin-vue_export-helper-OaxA6A2f.js";import{L as a,z as o}from"./index-CXa4EMLW.js";import{t as s}from"./BaseSwitch-TV5Yvtf7.js";function c(e=480){return new Promise(t=>{window.setTimeout(t,e)})}function l(e){let n=t(null),r=t(null),i=o();async function a(t,a){if(n.value)return a;let o=!a;if(!o&&e.confirmOff&&!await e.confirmOff())return a;n.value=t,r.value=null;let s=a;try{return await e.onPersist(o),i.success(e.successMessage?.(o)??(o?`وضعیت فعال شد.`:`وضعیت غیرفعال شد.`)),o}catch{return r.value=t,i.error(e.errorMessage??`به‌روزرسانی وضعیت انجام نشد.`),s}finally{n.value=null}}function s(e){return n.value===e}function c(e){return r.value===e}return{toggle:a,isLoading:s,hasError:c}}var u=r({__name:`ActiveSwitchCell`,props:{id:{},modelValue:{type:Boolean},entityName:{},entityType:{},persist:{type:Function}},emits:[`update:modelValue`],setup(t,{emit:r}){let o=t,u=r,{toggle:d,isLoading:f,hasError:p}=l({onPersist:async e=>{o.persist?await o.persist(o.id,e):await c()},successMessage:e=>e?`${o.entityType??`مورد`} «${o.entityName}» فعال شد.`:`${o.entityType??`مورد`} «${o.entityName}» غیرفعال شد.`});async function m(e){if(e===o.modelValue)return;let t=o.entityType??`مورد`;if(!await a({title:e?`فعال‌سازی ${t}`:`غیرفعال‌سازی ${t}`,message:e?`آیا از فعال کردن «${o.entityName}» مطمئن هستید؟`:`آیا از غیرفعال کردن «${o.entityName}» مطمئن هستید؟`,tone:e?`primary`:`danger`,confirmLabel:e?`فعال کردن`:`غیرفعال کردن`,cancelLabel:`انصراف`}))return;let n=await d(o.id,o.modelValue);u(`update:modelValue`,n)}return(r,a)=>(e(),i(s,{"model-value":t.modelValue,loading:n(f)(t.id),error:n(p)(t.id),"onUpdate:modelValue":m},null,8,[`model-value`,`loading`,`error`]))}});export{u as t};