@davoodmehraban89 / Factor-easy / commits / c61dfe6
Fork 0

سامانه صدور فاکتور و حسابداری

Expose organization switching and access controls after module rail rebuild

davoodmehraban89 committed Sep 30, 2026 at 06:58 UTC c61dfe6a1dae710868ddffc8ec4a9c9d46f96f11
1 file changed +16
js/organization-shell.js new
+16
@@ -0,0 +1,16 @@
1 +/* Slice B organization shell controls loaded after platform-modules. */
2 +(function(){
3 +function canManage(){return !!currentUser&&(currentUser.isOrganizationOwner||(currentUser.modulePermissions||[]).some(p=>Array.isArray(p.capabilities)&&p.capabilities.includes('configure')))}
4 +window.showFinoraOrganizationSwitcher=function(){
5 + const xs=currentUser?.organizations||[];if(xs.length<2)return;
6 + let el=document.getElementById('finora-org-switch-modal');if(!el){el=document.createElement('div');el.id='finora-org-switch-modal';el.className='modal-backdrop';document.body.appendChild(el)}
7 + el.innerHTML='<div class="modal-card" style="max-width:520px"><h3>انتخاب سازمان فعال</h3><p class="af-hint">اطلاعات، لایسنس و دسترسی‌ها بر اساس سازمان انتخاب‌شده بارگذاری می‌شوند.</p>'+finoraOrganizationSwitcherHtml()+'<div style="margin-top:14px"><button class="btn btn-secondary" onclick="document.getElementById(\'finora-org-switch-modal\').classList.remove(\'active\')">بستن</button></div></div>';el.classList.add('active');
8 +};
9 +function ensureOrgShell(){
10 + const rail=document.getElementById('module-rail');if(!rail||!currentUser)return;
11 + if((currentUser.organizations||[]).length>1&&!document.getElementById('finora-org-switch-btn')){const b=document.createElement('button');b.id='finora-org-switch-btn';b.className='module-tab';b.title='تغییر سازمان';b.innerHTML='<span>⇄</span><b>سازمان</b>';b.onclick=showFinoraOrganizationSwitcher;rail.appendChild(b)}
12 + if(canManage()&&!document.getElementById('finora-org-access-btn')){const b=document.createElement('button');b.id='finora-org-access-btn';b.className='module-tab';b.title='سازمان و دسترسی‌ها';b.innerHTML='<span>♙</span><b>دسترسی‌ها</b>';b.onclick=showOrganizationAccessManager;rail.appendChild(b)}
13 +}
14 +const baseEnter=enterApp;enterApp=async function(authUser){const r=await baseEnter(authUser);ensureOrgShell();return r};
15 +const baseRefresh=refreshAllSurfaces;refreshAllSurfaces=function(){const r=baseRefresh();ensureOrgShell();return r};
16 +})();