feat: add catalog module toggle
- Add catalog module to POS config endpoints, sidebar filter, config UI - Add catalog toggle to Instance Manager tenant modules modal
This commit is contained in:
@@ -322,7 +322,7 @@ def get_tenant_modules(tenant_id):
|
|||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
try:
|
try:
|
||||||
modules = {}
|
modules = {}
|
||||||
for key in ["module_whatsapp", "module_marketplace", "module_meli"]:
|
for key in ["module_whatsapp", "module_marketplace", "module_meli", "module_catalog"]:
|
||||||
cur.execute("SELECT value FROM tenant_config WHERE key = %s", (key,))
|
cur.execute("SELECT value FROM tenant_config WHERE key = %s", (key,))
|
||||||
row = cur.fetchone()
|
row = cur.fetchone()
|
||||||
modules[key.replace("module_", "")] = (row[0] or "").lower() == "true" if row else True
|
modules[key.replace("module_", "")] = (row[0] or "").lower() == "true" if row else True
|
||||||
@@ -346,6 +346,7 @@ def update_tenant_modules(tenant_id, modules):
|
|||||||
"whatsapp": "module_whatsapp",
|
"whatsapp": "module_whatsapp",
|
||||||
"marketplace": "module_marketplace",
|
"marketplace": "module_marketplace",
|
||||||
"meli": "module_meli",
|
"meli": "module_meli",
|
||||||
|
"catalog": "module_catalog",
|
||||||
}
|
}
|
||||||
for field, key in key_map.items():
|
for field, key in key_map.items():
|
||||||
value = "true" if modules.get(field) else "false"
|
value = "true" if modules.get(field) else "false"
|
||||||
|
|||||||
@@ -513,6 +513,7 @@ async function saveModules() {
|
|||||||
whatsapp: document.getElementById("mod-whatsapp").checked,
|
whatsapp: document.getElementById("mod-whatsapp").checked,
|
||||||
marketplace: document.getElementById("mod-marketplace").checked,
|
marketplace: document.getElementById("mod-marketplace").checked,
|
||||||
meli: document.getElementById("mod-meli").checked,
|
meli: document.getElementById("mod-meli").checked,
|
||||||
|
catalog: document.getElementById("mod-catalog").checked,
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await api(`/api/tenants/${currentModulesTenantId}/modules`, {
|
const res = await api(`/api/tenants/${currentModulesTenantId}/modules`, {
|
||||||
|
|||||||
@@ -345,7 +345,7 @@
|
|||||||
<span class="toggle-slider"></span>
|
<span class="toggle-slider"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group" style="display:flex;align-items:center;justify-content:space-between;padding:12px 0;">
|
<div class="form-group" style="display:flex;align-items:center;justify-content:space-between;padding:12px 0;border-bottom:1px solid var(--border);">
|
||||||
<div>
|
<div>
|
||||||
<div style="font-weight:600;color:var(--text);">MercadoLibre</div>
|
<div style="font-weight:600;color:var(--text);">MercadoLibre</div>
|
||||||
<div style="font-size:12px;color:var(--text-muted);">Mostrar menú de MercadoLibre</div>
|
<div style="font-size:12px;color:var(--text-muted);">Mostrar menú de MercadoLibre</div>
|
||||||
@@ -355,6 +355,16 @@
|
|||||||
<span class="toggle-slider"></span>
|
<span class="toggle-slider"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group" style="display:flex;align-items:center;justify-content:space-between;padding:12px 0;">
|
||||||
|
<div>
|
||||||
|
<div style="font-weight:600;color:var(--text);">Catálogo</div>
|
||||||
|
<div style="font-size:12px;color:var(--text-muted);">Mostrar menú de Catálogo de productos</div>
|
||||||
|
</div>
|
||||||
|
<label class="toggle-switch">
|
||||||
|
<input type="checkbox" id="mod-catalog">
|
||||||
|
<span class="toggle-slider"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-secondary" onclick="closeModulesModal()">Cancelar</button>
|
<button class="btn btn-secondary" onclick="closeModulesModal()">Cancelar</button>
|
||||||
|
|||||||
@@ -597,6 +597,7 @@ def get_modules():
|
|||||||
'whatsapp': _bool('module_whatsapp'),
|
'whatsapp': _bool('module_whatsapp'),
|
||||||
'marketplace': _bool('module_marketplace'),
|
'marketplace': _bool('module_marketplace'),
|
||||||
'meli': _bool('module_meli'),
|
'meli': _bool('module_meli'),
|
||||||
|
'catalog': _bool('module_catalog'),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@@ -612,6 +613,7 @@ def update_modules():
|
|||||||
'module_whatsapp': 'true' if data.get('whatsapp') else 'false',
|
'module_whatsapp': 'true' if data.get('whatsapp') else 'false',
|
||||||
'module_marketplace': 'true' if data.get('marketplace') else 'false',
|
'module_marketplace': 'true' if data.get('marketplace') else 'false',
|
||||||
'module_meli': 'true' if data.get('meli') else 'false',
|
'module_meli': 'true' if data.get('meli') else 'false',
|
||||||
|
'module_catalog': 'true' if data.get('catalog') else 'false',
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value in settings.items():
|
for key, value in settings.items():
|
||||||
|
|||||||
@@ -700,9 +700,11 @@ const Config = (() => {
|
|||||||
var cbWa = document.getElementById('cfg-module-whatsapp');
|
var cbWa = document.getElementById('cfg-module-whatsapp');
|
||||||
var cbMp = document.getElementById('cfg-module-marketplace');
|
var cbMp = document.getElementById('cfg-module-marketplace');
|
||||||
var cbMeli = document.getElementById('cfg-module-meli');
|
var cbMeli = document.getElementById('cfg-module-meli');
|
||||||
|
var cbCat = document.getElementById('cfg-module-catalog');
|
||||||
if (cbWa) cbWa.checked = data.whatsapp !== false;
|
if (cbWa) cbWa.checked = data.whatsapp !== false;
|
||||||
if (cbMp) cbMp.checked = data.marketplace !== false;
|
if (cbMp) cbMp.checked = data.marketplace !== false;
|
||||||
if (cbMeli) cbMeli.checked = data.meli !== false;
|
if (cbMeli) cbMeli.checked = data.meli !== false;
|
||||||
|
if (cbCat) cbCat.checked = data.catalog !== false;
|
||||||
localStorage.setItem('pos_modules', JSON.stringify(data));
|
localStorage.setItem('pos_modules', JSON.stringify(data));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Config.loadModules:', e);
|
console.error('Config.loadModules:', e);
|
||||||
@@ -717,6 +719,7 @@ const Config = (() => {
|
|||||||
whatsapp: document.getElementById('cfg-module-whatsapp').checked,
|
whatsapp: document.getElementById('cfg-module-whatsapp').checked,
|
||||||
marketplace: document.getElementById('cfg-module-marketplace').checked,
|
marketplace: document.getElementById('cfg-module-marketplace').checked,
|
||||||
meli: document.getElementById('cfg-module-meli').checked,
|
meli: document.getElementById('cfg-module-meli').checked,
|
||||||
|
catalog: document.getElementById('cfg-module-catalog').checked,
|
||||||
};
|
};
|
||||||
var res = await fetch(API + '/modules', {
|
var res = await fetch(API + '/modules', {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
{ label: _t('nav_main'), items: [
|
{ label: _t('nav_main'), items: [
|
||||||
{ name: _t('dashboard'), href: '/pos/dashboard', icon: '<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/>' },
|
{ name: _t('dashboard'), href: '/pos/dashboard', icon: '<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/>' },
|
||||||
{ name: _t('pos'), href: '/pos/sale', icon: '<rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8M12 17v4"/>' },
|
{ name: _t('pos'), href: '/pos/sale', icon: '<rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8M12 17v4"/>' },
|
||||||
{ name: _t('catalog'), href: '/pos/catalog', icon: '<path d="M4 6h16M4 10h16M4 14h16M4 18h16"/>' },
|
moduleEnabled('catalog') ? { name: _t('catalog'), href: '/pos/catalog', icon: '<path d="M4 6h16M4 10h16M4 14h16M4 18h16"/>' } : null,
|
||||||
{ name: _t('inventory'), href: '/pos/inventory', icon: '<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/>' },
|
{ name: _t('inventory'), href: '/pos/inventory', icon: '<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/><polyline points="3.27 6.96 12 12.01 20.73 6.96"/><line x1="12" y1="22.08" x2="12" y2="12"/>' },
|
||||||
|
|
||||||
]},
|
]},
|
||||||
|
|||||||
@@ -295,6 +295,16 @@
|
|||||||
<span class="toggle__slider"></span>
|
<span class="toggle__slider"></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="toggle-row">
|
||||||
|
<div class="toggle-row__info">
|
||||||
|
<span class="toggle-row__label">Catálogo</span>
|
||||||
|
<span class="toggle-row__desc">Mostrar el menú de Catálogo de productos</span>
|
||||||
|
</div>
|
||||||
|
<label class="toggle">
|
||||||
|
<input type="checkbox" id="cfg-module-catalog" checked />
|
||||||
|
<span class="toggle__slider"></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<div style="margin-top:var(--space-4);text-align:right;">
|
<div style="margin-top:var(--space-4);text-align:right;">
|
||||||
<button class="btn btn--primary" onclick="Config.saveModules()">Guardar módulos</button>
|
<button class="btn btn--primary" onclick="Config.saveModules()">Guardar módulos</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user