mirror of
https://github.com/cheveguerra/Colaborando.git
synced 2026-08-19 00:46:37 +00:00
- Se implemento la habilidad de ordenar los siguientes 5 proyectos en el tablero
This commit is contained in:
@@ -1980,18 +1980,7 @@ $('#accionHabilidadEspecial').click(function () {
|
||||
guardaSesion()
|
||||
}
|
||||
} else if (accionQuincenal === 'Ordenar los próximos 5 proyectos') {
|
||||
// Actualizamos lastUsed
|
||||
setArrayValue(elArreglo, 'accionEspecialLastUsed', quincenaActual)
|
||||
|
||||
// Aquí el código de Investigación y Desarrollo: "Ordenar los próximos 5 proyectos"
|
||||
window.alert(
|
||||
'¡Acción especial activada (Investigación y Desarrollo)!'
|
||||
)
|
||||
|
||||
// Se guarda el avance
|
||||
if (typeof guardaSesion === 'function') {
|
||||
guardaSesion()
|
||||
}
|
||||
abrirDialogoOrdenarProyectos(elArreglo, quincenaActual);
|
||||
} else if (accionQuincenal === 'Omitir un mantenimiento') {
|
||||
// Actualizamos lastUsed
|
||||
setArrayValue(elArreglo, 'accionEspecialLastUsed', quincenaActual)
|
||||
@@ -3706,4 +3695,83 @@ window.confirm = function (message, callback, customWidth) {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function abrirDialogoOrdenarProyectos(elArreglo, quincenaActual) {
|
||||
let proyectosAOrdenar = siguientesProyectos.slice(0, 5);
|
||||
let proyectosRestantes = siguientesProyectos.slice(5);
|
||||
|
||||
let container = $('<div></div>');
|
||||
container.append('<p style="margin-bottom: 15px; font-size: 14px;">Arrastra los proyectos para ordenar la prioridad en la que aparecerán:</p>');
|
||||
|
||||
let list = $('<ul id="sortable-proyectos" style="list-style-type: none; padding: 0; margin: 0;"></ul>');
|
||||
proyectosAOrdenar.forEach((p, idx) => {
|
||||
let item = $(`
|
||||
<li class="ui-state-default" data-id="${p.id}" style="margin: 8px 0; padding: 10px; border: 2px solid gray; border-radius: 4px; background-color: #f9f9f9; cursor: grab; display: flex; justify-content: space-between; align-items: center; font-size: 14px;">
|
||||
<span style="font-weight: bold;">${idx + 1}. ${p.nombreProyecto}</span>
|
||||
<span style="font-size: 11px; background-color: #eee; padding: 2px 6px; border-radius: 3px; color: #555;">${p.departamento}</span>
|
||||
</li>
|
||||
`);
|
||||
list.append(item);
|
||||
});
|
||||
container.append(list);
|
||||
|
||||
container.dialog({
|
||||
modal: true,
|
||||
title: 'Ordenar Próximos 5 Proyectos',
|
||||
width: 500,
|
||||
open: function() {
|
||||
list.sortable({
|
||||
placeholder: "ui-state-highlight",
|
||||
forcePlaceholderSize: true,
|
||||
update: function(event, ui) {
|
||||
list.find('li').each(function(index) {
|
||||
let nombre = $(this).find('span').first().text();
|
||||
nombre = nombre.replace(/^\d+\.\s*/, '');
|
||||
$(this).find('span').first().text((index + 1) + '. ' + nombre);
|
||||
});
|
||||
}
|
||||
});
|
||||
list.disableSelection();
|
||||
$('<style id="sortable-style">.ui-state-highlight { height: 40px; background-color: #ffffcc; border: 2px dashed #999; margin: 8px 0; border-radius: 4px; }</style>').appendTo('head');
|
||||
},
|
||||
close: function() {
|
||||
$('#sortable-style').remove();
|
||||
$(this).dialog('destroy').remove();
|
||||
},
|
||||
buttons: {
|
||||
"Guardar Orden": function() {
|
||||
let nuevoOrdenIds = [];
|
||||
list.find('li').each(function() {
|
||||
nuevoOrdenIds.push(parseInt($(this).data('id')));
|
||||
});
|
||||
|
||||
let nuevosSiguientes = [];
|
||||
nuevoOrdenIds.forEach(id => {
|
||||
let proj = proyectos.find(p => p.id === id);
|
||||
if (proj) nuevosSiguientes.push(proj);
|
||||
});
|
||||
|
||||
nuevosSiguientes = nuevosSiguientes.concat(proyectosRestantes);
|
||||
siguientesProyectos = nuevosSiguientes;
|
||||
|
||||
proyectos.forEach(p => {
|
||||
if (p.estatus === 'En siguientes') p.estatus = 'Pendiente';
|
||||
});
|
||||
siguientesProyectos.forEach(p => {
|
||||
let proj = proyectos.find(pr => pr.id === p.id);
|
||||
if (proj) proj.estatus = 'En siguientes';
|
||||
});
|
||||
|
||||
setArrayValue(elArreglo, 'accionEspecialLastUsed', quincenaActual);
|
||||
var audio = new Audio('./Microwave_bell.wav');
|
||||
audio.play();
|
||||
window.alert('¡Orden de proyectos actualizado con éxito!');
|
||||
|
||||
if (typeof guardaSesion === 'function') guardaSesion();
|
||||
$(this).dialog('close');
|
||||
},
|
||||
"Cancelar": function() { $(this).dialog('close'); }
|
||||
}
|
||||
});
|
||||
}
|
||||
// </script>
|
||||
|
||||
Reference in New Issue
Block a user