ligbox-ops-platform/projects/ops-desk/assets/modules.js
Ligbox Spec Hub 821675ab4a Reorganize monorepo into projects/wizard, ops-desk, finance
Specs stay at repo root (cross-VM). Move deploy and code into logical
projects with README per domain, updated manifest.yaml, and symlinks at
legacy paths for VM122 backward compatibility.
2026-06-19 18:55:03 +00:00

37 lines
1,014 B
JavaScript

/** Registry de módulos Desk — Spec 015 */
const DeskModules = {
list: [],
loaded: false,
async load() {
const data = await api('/v1/modules');
this.list = data.modules || [];
this.loaded = true;
return this.list;
},
isEnabled(moduleId) {
const mod = this.list.find((m) => m.id === moduleId);
if (!mod) return true;
if (typeof mod.enabled_for_role === 'boolean') return mod.enabled_for_role;
return !!mod.enabled;
},
isViewEnabled(view) {
const btn = document.querySelector(`.nav button[data-view="${view}"]`);
if (!btn || btn.hasAttribute('hidden')) return false;
const modId = btn.dataset.module;
if (!modId) return true;
return this.isEnabled(modId);
},
applyVisibility() {
document.querySelectorAll('[data-module]').forEach((el) => {
const modId = el.dataset.module;
if (this.isEnabled(modId)) el.removeAttribute('hidden');
else el.setAttribute('hidden', '');
});
},
};
window.DeskModules = DeskModules;