fix(workshop): show autorizada for workshop/mechanic and hide delivery statuses
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

This commit is contained in:
2026-07-02 14:45:25 +00:00
parent c226b1cf77
commit 670db75fcd
2 changed files with 37 additions and 25 deletions

View File

@@ -196,13 +196,16 @@ var Workshop = (function() {
document.querySelectorAll('.restricted-hide').forEach(function(el) { el.style.display = 'none'; });
var searchInput = document.getElementById('filterSearch');
if (searchInput) searchInput.placeholder = 'Buscar orden';
// Limit status filter to the only status taller accounts can see.
// Remove statuses that workshop/mechanic cannot see from the status filter.
var statusSel = document.getElementById('filterStatus');
if (statusSel) {
var hiddenStatuses = isMechanic
? ['cotizada','por_autorizar','autorizacion_parcial','por_facturar','facturada','por_entregar','entregado','por_enviar','enviado','por_recolectar']
: ['por_entregar','entregado','por_enviar','enviado','por_recolectar'];
Array.from(statusSel.options).forEach(function(opt) {
if (opt.value && opt.value !== 'autorizada') opt.remove();
if (opt.value && hiddenStatuses.indexOf(opt.value) !== -1) opt.remove();
});
statusSel.value = 'autorizada';
statusSel.value = '';
}
}
if (hidePrices) {
@@ -261,17 +264,18 @@ var Workshop = (function() {
.then(function(d) {
var cards = document.querySelectorAll('#statsRow .summary-card');
if (isRestricted) {
// Taller accounts only see authorized orders.
// Taller accounts: hide delivery/logistics card; show work-in-progress summary.
cards.forEach(function(card, idx) {
if (idx === 0) {
card.style.display = '';
var label = card.querySelector('.summary-card__label');
if (label) label.textContent = 'Autorizadas';
} else {
card.style.display = 'none';
}
card.style.display = (idx === 2) ? 'none' : ''; // hide "Por entregar"
});
document.getElementById('statReceived').textContent = fmt(d.autorizada || 0);
document.getElementById('statReceived').textContent = fmt(d.por_revisar || 0);
document.getElementById('statRepair').textContent = fmt(
(d.en_reparacion || 0) + (d.en_revision || 0) + (d.revisada || 0) +
(d.cotizada || 0) + (d.por_autorizar || 0) +
(d.autorizada || 0) + (d.autorizacion_parcial || 0)
);
document.getElementById('statReady').textContent = '0';
document.getElementById('statOverdue').textContent = fmt(d.overdue || 0);
return;
}
cards.forEach(function(card) { card.style.display = ''; });
@@ -404,11 +408,12 @@ var Workshop = (function() {
var board = document.getElementById('kanbanBoard');
board.innerHTML = '';
var hiddenCols = [];
if (isRestricted) {
// Taller accounts only see the "autorizada" column.
hiddenCols = COLUMNS.filter(function(c) { return c.key !== 'autorizada'; }).map(function(c) { return c.key; });
} else if (isMechanic) {
hiddenCols = ['cotizada','por_autorizar','autorizada','autorizacion_parcial','por_facturar','facturada'];
if (isMechanic) {
// Mechanic sees everything except commercial and delivery/logistics statuses.
hiddenCols = ['cotizada','por_autorizar','autorizacion_parcial','por_facturar','facturada','por_entregar','entregado','por_enviar','enviado','por_recolectar'];
} else if (role === 'workshop') {
// Workshop sees everything except delivery/logistics statuses.
hiddenCols = ['por_entregar','entregado','por_enviar','enviado','por_recolectar'];
}
COLUMNS.filter(function(col) { return hiddenCols.indexOf(col.key) === -1; }).forEach(function(col) {
var colOrders = orders.filter(function(o) { return o.status === col.key; });