MODIFICAR PENDIENTES Y COMPLETADOS
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
<div class='tabs'>
|
<div class='tabs'>
|
||||||
<button class='tab active' data-tab='calendario'>Calendario</button>
|
<button class='tab active' data-tab='calendario'>Calendario</button>
|
||||||
<button class='tab' data-tab='pendientes'>Pendientes</button>
|
<button class='tab' data-tab='pendientes'>Pendientes</button>
|
||||||
|
<button class='tab' data-tab='completados'>Completados</button>
|
||||||
</div>
|
</div>
|
||||||
<div id='calendario' class='section active'>
|
<div id='calendario' class='section active'>
|
||||||
<div class='calendar-header'>
|
<div class='calendar-header'>
|
||||||
@@ -45,6 +46,9 @@
|
|||||||
</form>
|
</form>
|
||||||
<div id='listaPendientes' class='lista-pendientes'></div>
|
<div id='listaPendientes' class='lista-pendientes'></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id='completados' class='section'>
|
||||||
|
<div id='listaCompletados' class='lista-pendientes'></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id='modalDia' class='modal glass hidden'>
|
<div id='modalDia' class='modal glass hidden'>
|
||||||
<div class='modal-content'>
|
<div class='modal-content'>
|
||||||
|
|||||||
+135
-13
@@ -9,6 +9,7 @@ async function cargarPendientes() {
|
|||||||
todosPendientes = await res.json();
|
todosPendientes = await res.json();
|
||||||
renderCalendar();
|
renderCalendar();
|
||||||
renderLista();
|
renderLista();
|
||||||
|
renderCompletados();
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatearFecha(fechaStr) {
|
function formatearFecha(fechaStr) {
|
||||||
@@ -68,13 +69,31 @@ function abrirModalDia(fecha, pendientes) {
|
|||||||
document.getElementById('modalTitulo').textContent = 'Pendientes del ' + formatearFecha(fecha);
|
document.getElementById('modalTitulo').textContent = 'Pendientes del ' + formatearFecha(fecha);
|
||||||
const cont = document.getElementById('modalPendientes');
|
const cont = document.getElementById('modalPendientes');
|
||||||
cont.innerHTML = '';
|
cont.innerHTML = '';
|
||||||
|
|
||||||
|
const noCompletados = pendientes.filter(function(p) { return p.estado !== 'completado'; });
|
||||||
|
const completados = pendientes.filter(function(p) { return p.estado === 'completado'; });
|
||||||
|
|
||||||
if (!pendientes.length) {
|
if (!pendientes.length) {
|
||||||
cont.innerHTML = '<p>No hay pendientes para este dia.</p>';
|
cont.innerHTML = '<p>No hay pendientes para este dia.</p>';
|
||||||
} else {
|
} else {
|
||||||
pendientes.forEach(function(p) {
|
if (noCompletados.length) {
|
||||||
const div = crearCardPendiente(p);
|
const tit = document.createElement('div');
|
||||||
cont.appendChild(div);
|
tit.className = 'subsubtitulo';
|
||||||
});
|
tit.textContent = 'Pendientes (' + noCompletados.length + ')';
|
||||||
|
cont.appendChild(tit);
|
||||||
|
noCompletados.forEach(function(p) {
|
||||||
|
cont.appendChild(crearCardPendiente(p));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (completados.length) {
|
||||||
|
const titC = document.createElement('div');
|
||||||
|
titC.className = 'subsubtitulo';
|
||||||
|
titC.textContent = 'Completados (' + completados.length + ')';
|
||||||
|
cont.appendChild(titC);
|
||||||
|
completados.forEach(function(p) {
|
||||||
|
cont.appendChild(crearCardPendiente(p));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
document.getElementById('modalDia').classList.remove('hidden');
|
document.getElementById('modalDia').classList.remove('hidden');
|
||||||
}
|
}
|
||||||
@@ -83,7 +102,9 @@ function crearCardPendiente(p) {
|
|||||||
const vencido = esVencido(p);
|
const vencido = esVencido(p);
|
||||||
const div = document.createElement('div');
|
const div = document.createElement('div');
|
||||||
div.className = 'pendiente-card ' + (vencido ? 'vencido' : p.urgencia);
|
div.className = 'pendiente-card ' + (vencido ? 'vencido' : p.urgencia);
|
||||||
let html = '<div class="pendiente-info">' +
|
|
||||||
|
let html = '<div class="pendiente-header">' +
|
||||||
|
'<div class="pendiente-info">' +
|
||||||
'<div><strong>' + escaparHtml(p.descripcion) + '</strong>';
|
'<div><strong>' + escaparHtml(p.descripcion) + '</strong>';
|
||||||
if (vencido) {
|
if (vencido) {
|
||||||
html += '<span class="badge-vencido">Vencido</span>';
|
html += '<span class="badge-vencido">Vencido</span>';
|
||||||
@@ -91,10 +112,41 @@ function crearCardPendiente(p) {
|
|||||||
html += '</div>' +
|
html += '</div>' +
|
||||||
'<div>' + formatearFecha(p.fecha) + ' - ' + p.estado + ' - Urgencia: ' + p.urgencia + '</div>' +
|
'<div>' + formatearFecha(p.fecha) + ' - ' + p.estado + ' - Urgencia: ' + p.urgencia + '</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="pendiente-actions">' +
|
'<div class="menu-wrapper">' +
|
||||||
|
'<button class="menu-btn" onclick="toggleMenu(' + p.id + ')">\u22EF</button>' +
|
||||||
|
'<div class="menu-dropdown" id="menu-' + p.id + '">' +
|
||||||
'<button onclick="editarPendiente(' + p.id + ')">Editar</button>' +
|
'<button onclick="editarPendiente(' + p.id + ')">Editar</button>' +
|
||||||
'<button onclick="eliminarPendiente(' + p.id + ')">Eliminar</button>' +
|
'<button class="menu-delete" onclick="eliminarPendiente(' + p.id + ')">Eliminar</button>' +
|
||||||
|
'</div>' +
|
||||||
|
'</div>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
|
html += '<div class="acceso-rapido">';
|
||||||
|
|
||||||
|
html += '<div class="acceso-grupo">';
|
||||||
|
html += '<span class="acceso-label">Prioridad:</span>';
|
||||||
|
['alta', 'media', 'baja'].forEach(function(u) {
|
||||||
|
const activo = p.urgencia === u ? ' activo' : '';
|
||||||
|
const etiqueta = u.charAt(0).toUpperCase() + u.slice(1);
|
||||||
|
html += '<button class="quick-btn urgencia-' + u + activo + '" onclick="cambioRapido(' + p.id + ', \'urgencia\', \' + u + '\')">' + etiqueta + '</button>';
|
||||||
|
});
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
html += '<div class="acceso-grupo">';
|
||||||
|
html += '<span class="acceso-label">Estado:</span>';
|
||||||
|
[
|
||||||
|
{ val: 'pendiente', label: 'Pendiente' },
|
||||||
|
{ val: 'en progreso', label: 'En proceso' },
|
||||||
|
{ val: 'completado', label: 'Completado' }
|
||||||
|
].forEach(function(e) {
|
||||||
|
const activo = p.estado === e.val ? ' activo' : '';
|
||||||
|
const cls = e.val.replace(' ', '_');
|
||||||
|
html += '<button class="quick-btn estado-' + cls + activo + '" onclick="cambioRapido(' + p.id + ', \'estado\', \' + e.val + '\')">' + e.label + '</button>';
|
||||||
|
});
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
|
html += '</div>';
|
||||||
|
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
return div;
|
return div;
|
||||||
}
|
}
|
||||||
@@ -105,6 +157,52 @@ function escaparHtml(texto) {
|
|||||||
return div.innerHTML;
|
return div.innerHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let menuAbiertoId = null;
|
||||||
|
|
||||||
|
function toggleMenu(id) {
|
||||||
|
if (menuAbiertoId === id) {
|
||||||
|
const m = document.getElementById('menu-' + menuAbiertoId);
|
||||||
|
if (m) m.classList.remove('show');
|
||||||
|
menuAbiertoId = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (menuAbiertoId !== null) {
|
||||||
|
const prev = document.getElementById('menu-' + menuAbiertoId);
|
||||||
|
if (prev) prev.classList.remove('show');
|
||||||
|
}
|
||||||
|
const menu = document.getElementById('menu-' + id);
|
||||||
|
if (menu) {
|
||||||
|
menu.classList.add('show');
|
||||||
|
menuAbiertoId = id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('click', function(e) {
|
||||||
|
if (menuAbiertoId !== null && !e.target.closest('.menu-wrapper')) {
|
||||||
|
const prev = document.getElementById('menu-' + menuAbiertoId);
|
||||||
|
if (prev) prev.classList.remove('show');
|
||||||
|
menuAbiertoId = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
async function cambioRapido(id, campo, valor) {
|
||||||
|
const p = todosPendientes.find(function(x) { return x.id === id; });
|
||||||
|
if (!p) return;
|
||||||
|
const body = {
|
||||||
|
descripcion: p.descripcion,
|
||||||
|
fecha: p.fecha,
|
||||||
|
estado: p.estado,
|
||||||
|
urgencia: p.urgencia
|
||||||
|
};
|
||||||
|
body[campo] = valor;
|
||||||
|
await fetch(API + '/' + id, {
|
||||||
|
method: 'PUT',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(body)
|
||||||
|
});
|
||||||
|
cargarPendientes();
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('cerrarModal').onclick = function() {
|
document.getElementById('cerrarModal').onclick = function() {
|
||||||
document.getElementById('modalDia').classList.add('hidden');
|
document.getElementById('modalDia').classList.add('hidden');
|
||||||
};
|
};
|
||||||
@@ -159,17 +257,23 @@ function renderLista() {
|
|||||||
const cont = document.getElementById('listaPendientes');
|
const cont = document.getElementById('listaPendientes');
|
||||||
cont.innerHTML = '';
|
cont.innerHTML = '';
|
||||||
|
|
||||||
const vencidos = todosPendientes.filter(function(p) { return esVencido(p); });
|
const noCompletados = todosPendientes.filter(function(p) { return p.estado !== 'completado'; });
|
||||||
const normales = todosPendientes.filter(function(p) { return !esVencido(p); });
|
const vencidos = noCompletados.filter(function(p) { return esVencido(p); });
|
||||||
|
const normales = noCompletados.filter(function(p) { return !esVencido(p); });
|
||||||
|
|
||||||
if (!todosPendientes.length) {
|
if (!noCompletados.length) {
|
||||||
cont.innerHTML = '<p>No hay pendientes aun.</p>';
|
cont.innerHTML = '<p>No hay pendientes.</p>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const titTotal = document.createElement('div');
|
||||||
|
titTotal.className = 'subtitulo';
|
||||||
|
titTotal.textContent = 'Pendientes (' + noCompletados.length + ')';
|
||||||
|
cont.appendChild(titTotal);
|
||||||
|
|
||||||
if (vencidos.length) {
|
if (vencidos.length) {
|
||||||
const titVencidos = document.createElement('div');
|
const titVencidos = document.createElement('div');
|
||||||
titVencidos.className = 'subtitulo';
|
titVencidos.className = 'subsubtitulo';
|
||||||
titVencidos.textContent = 'Vencidos / Prioritarios (' + vencidos.length + ')';
|
titVencidos.textContent = 'Vencidos / Prioritarios (' + vencidos.length + ')';
|
||||||
cont.appendChild(titVencidos);
|
cont.appendChild(titVencidos);
|
||||||
vencidos.forEach(function(p) {
|
vencidos.forEach(function(p) {
|
||||||
@@ -179,7 +283,7 @@ function renderLista() {
|
|||||||
|
|
||||||
if (normales.length) {
|
if (normales.length) {
|
||||||
const titNormales = document.createElement('div');
|
const titNormales = document.createElement('div');
|
||||||
titNormales.className = 'subtitulo';
|
titNormales.className = 'subsubtitulo';
|
||||||
titNormales.textContent = 'Pendientes (' + normales.length + ')';
|
titNormales.textContent = 'Pendientes (' + normales.length + ')';
|
||||||
cont.appendChild(titNormales);
|
cont.appendChild(titNormales);
|
||||||
normales.forEach(function(p) {
|
normales.forEach(function(p) {
|
||||||
@@ -188,6 +292,24 @@ function renderLista() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderCompletados() {
|
||||||
|
const cont = document.getElementById('listaCompletados');
|
||||||
|
if (!cont) return;
|
||||||
|
cont.innerHTML = '';
|
||||||
|
const completados = todosPendientes.filter(function(p) { return p.estado === 'completado'; });
|
||||||
|
if (!completados.length) {
|
||||||
|
cont.innerHTML = '<p>No hay completados aun.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const tit = document.createElement('div');
|
||||||
|
tit.className = 'subtitulo';
|
||||||
|
tit.textContent = 'Completados (' + completados.length + ')';
|
||||||
|
cont.appendChild(tit);
|
||||||
|
completados.forEach(function(p) {
|
||||||
|
cont.appendChild(crearCardPendiente(p));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async function editarPendiente(id) {
|
async function editarPendiente(id) {
|
||||||
const p = todosPendientes.find(function(x) { return x.id === id; });
|
const p = todosPendientes.find(function(x) { return x.id === id; });
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
|
|||||||
+133
-2
@@ -274,6 +274,12 @@ h1 {
|
|||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
border-left: 5px solid;
|
border-left: 5px solid;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pendiente-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
@@ -323,6 +329,130 @@ h1 {
|
|||||||
background: rgba(255,255,255,0.3);
|
background: rgba(255,255,255,0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.menu-wrapper {
|
||||||
|
position: relative;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-btn {
|
||||||
|
background: rgba(255,255,255,0.15);
|
||||||
|
border: none;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: 0.2s;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-btn:hover {
|
||||||
|
background: rgba(255,255,255,0.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-dropdown {
|
||||||
|
display: none;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 38px;
|
||||||
|
background: rgba(30, 40, 60, 0.95);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 6px;
|
||||||
|
box-shadow: 0 8px 24px rgba(0,0,0,0.4);
|
||||||
|
z-index: 50;
|
||||||
|
min-width: 120px;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-dropdown.show {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-dropdown button {
|
||||||
|
padding: 9px 14px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
cursor: pointer;
|
||||||
|
background: rgba(255,255,255,0.1);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
text-align: left;
|
||||||
|
transition: 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-dropdown button:hover {
|
||||||
|
background: rgba(255,255,255,0.25);
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-dropdown .menu-delete:hover {
|
||||||
|
background: rgba(255, 46, 46, 0.6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.acceso-rapido {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
padding-top: 8px;
|
||||||
|
border-top: 1px solid rgba(255,255,255,0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.acceso-grupo {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.acceso-label {
|
||||||
|
font-size: 0.72rem;
|
||||||
|
color: rgba(255,255,255,0.55);
|
||||||
|
margin-right: 4px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-btn {
|
||||||
|
padding: 5px 11px;
|
||||||
|
border: 1px solid rgba(255,255,255,0.2);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: rgba(255,255,255,0.08);
|
||||||
|
color: #fff;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.78rem;
|
||||||
|
transition: 0.2s;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-btn:hover {
|
||||||
|
background: rgba(255,255,255,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-btn.activo {
|
||||||
|
font-weight: 700;
|
||||||
|
border-color: transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.quick-btn.urgencia-alta.activo { background: #ff6b6b; }
|
||||||
|
.quick-btn.urgencia-media.activo { background: #feca57; color: #333; }
|
||||||
|
.quick-btn.urgencia-baja.activo { background: #48dbfb; color: #333; }
|
||||||
|
|
||||||
|
.quick-btn.estado-pendiente.activo { background: #6c757d; }
|
||||||
|
.quick-btn.estado-en_progreso.activo { background: #4dabf7; }
|
||||||
|
.quick-btn.estado-completado.activo { background: #51cf66; }
|
||||||
|
|
||||||
|
.subsubtitulo {
|
||||||
|
margin: 14px 0 8px;
|
||||||
|
font-size: 0.92rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: rgba(255,255,255,0.7);
|
||||||
|
}
|
||||||
|
|
||||||
.modal {
|
.modal {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
@@ -393,8 +523,9 @@ h1 {
|
|||||||
.dot { width: 6px; height: 6px; }
|
.dot { width: 6px; height: 6px; }
|
||||||
.calendar-header h2 { font-size: 1.05rem; }
|
.calendar-header h2 { font-size: 1.05rem; }
|
||||||
.nav-btn { width: 38px; height: 38px; }
|
.nav-btn { width: 38px; height: 38px; }
|
||||||
.pendiente-card { flex-direction: column; }
|
.pendiente-card { gap: 8px; }
|
||||||
.pendiente-actions { width: 100%; justify-content: flex-end; }
|
.acceso-rapido { flex-direction: column; gap: 6px; }
|
||||||
|
.quick-btn { font-size: 0.72rem; padding: 4px 8px; }
|
||||||
.badge-vencido { font-size: 0.65rem; padding: 2px 6px; }
|
.badge-vencido { font-size: 0.65rem; padding: 2px 6px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user