mirror of
https://github.com/cheveguerra/Colaborando.git
synced 2026-08-19 00:46:37 +00:00
refactor(js,ui): depurar funciones huerfanas en jsCode y optimizar tarjetas en colaborando3
Depuracion de codigo muerto en jsCode.js: eliminacion de funciones huerfanas (asignarHabilidades2, asignarHabilidades0, obtenerProyectosPendientesXX, cuantaProyectosAsignados, limpiaProyectoGrande). Consistencia en renderizacion de habilidades acreditadas. Optimizacion de tarjetas de departamento en colaborando3.php ocultando renglones vacios (.dept-hab-item:empty). Actualizacion de CONTEXT.md.
This commit is contained in:
@@ -158,7 +158,7 @@ function llenaDepartamentoGde(depto) {
|
||||
if ($('#habilidadesAcreditadasGde1').text() == '') {
|
||||
$('#habilidadesAcreditadasGde1').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -167,7 +167,7 @@ function llenaDepartamentoGde(depto) {
|
||||
} else if ($('#habilidadesAcreditadasGde2').text() == '') {
|
||||
$('#habilidadesAcreditadasGde2').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -176,7 +176,7 @@ function llenaDepartamentoGde(depto) {
|
||||
} else if ($('#habilidadesAcreditadasGde3').text() == '') {
|
||||
$('#habilidadesAcreditadasGde3').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -208,7 +208,7 @@ function llenaDepartamentoGde(depto) {
|
||||
if ($('#habilidadesAcreditadasGde1').text() == '') {
|
||||
$('#habilidadesAcreditadasGde1').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -217,7 +217,7 @@ function llenaDepartamentoGde(depto) {
|
||||
} else if ($('#habilidadesAcreditadasGde2').text() == '') {
|
||||
$('#habilidadesAcreditadasGde2').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -226,7 +226,7 @@ function llenaDepartamentoGde(depto) {
|
||||
} else if ($('#habilidadesAcreditadasGde3').text() == '') {
|
||||
$('#habilidadesAcreditadasGde3').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -258,7 +258,7 @@ function llenaDepartamentoGde(depto) {
|
||||
if ($('#habilidadesAcreditadasGde1').text() == '') {
|
||||
$('#habilidadesAcreditadasGde1').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -267,7 +267,7 @@ function llenaDepartamentoGde(depto) {
|
||||
} else if ($('#habilidadesAcreditadasGde2').text() == '') {
|
||||
$('#habilidadesAcreditadasGde2').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -276,7 +276,7 @@ function llenaDepartamentoGde(depto) {
|
||||
} else if ($('#habilidadesAcreditadasGde3').text() == '') {
|
||||
$('#habilidadesAcreditadasGde3').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(arreglosCapacitaciones[laHabilidad], 'nombre') +
|
||||
' ' +
|
||||
beneficio +
|
||||
@@ -510,15 +510,6 @@ function llenaDepartamentoChico(depto) {
|
||||
console.log(`[llenaDepartamentoChico] <- FIN para depto: '${depto}'`)
|
||||
}
|
||||
|
||||
function cuantaProyectosAsignados() {
|
||||
let contador = 0
|
||||
for (let i = 0; i < proyectos.length; i++) {
|
||||
if (proyectos[i].estatus == 'En proceso') {
|
||||
contador++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function limpiaProyectoChico(elProyecto) {
|
||||
console.log('Limpia proyecto chico', elProyecto)
|
||||
// console.log($("#" + proyectoActual + " #activoReqProyectoNom1").text())
|
||||
@@ -545,27 +536,6 @@ function limpiaProyectoChico(elProyecto) {
|
||||
}
|
||||
}
|
||||
|
||||
function limpiaProyectoGrande() {
|
||||
console.log('Limpia proyecto grande')
|
||||
$('#TablaProyectoGde').removeAttr('num')
|
||||
$('#TablaProyectoGde').removeAttr('estatus')
|
||||
$('#TablaProyectoGde').css('background-color', '')
|
||||
$('#nombreProyectoGde').text('')
|
||||
$('#descripcionProyectoGde').text('')
|
||||
$('#TablaProyectoGde #puntosGanados').text('')
|
||||
$('#puntosPerdidos').text('')
|
||||
$('#activoReqProyectoNom1').attr('class', '').text('')
|
||||
$('#activoReqProyectoNom2').attr('class', '').text('')
|
||||
$('#activoReqProyectoNom3').attr('class', '').text('')
|
||||
$('#activoReqProyectoCantX1').text('0')
|
||||
$('#activoReqProyectoCantX2').text('0')
|
||||
$('#activoReqProyectoCantX3').text('0')
|
||||
$('#activoReqProyectoCant1').attr('class', '').text('')
|
||||
$('#activoReqProyectoCant2').attr('class', '').text('')
|
||||
$('#activoReqProyectoCant3').attr('class', '').text('')
|
||||
$('#mantoGde').text('MANTENIMIENTO')
|
||||
}
|
||||
|
||||
function llenaProyectoChico(proyectoNum) {
|
||||
console.log('Llenando proyectos! ', proyectoNum)
|
||||
const colores = [
|
||||
@@ -1603,7 +1573,7 @@ $('#accionComprarCapacitacion').click(function () {
|
||||
if ($('#habilidadesAcreditadasGde1').text() == '') {
|
||||
$('#habilidadesAcreditadasGde1').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(
|
||||
arreglosCapacitaciones[habilidadAcreditadaEnEspera],
|
||||
'nombre'
|
||||
@@ -1614,7 +1584,7 @@ $('#accionComprarCapacitacion').click(function () {
|
||||
)
|
||||
$('#' + deptoActual + ' #habilidadesAcreditadasCh1').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(
|
||||
arreglosCapacitaciones[habilidadAcreditadaEnEspera],
|
||||
'nombre'
|
||||
@@ -1622,12 +1592,12 @@ $('#accionComprarCapacitacion').click(function () {
|
||||
', ' +
|
||||
beneficio +
|
||||
tipoRecurso.charAt(0).toUpperCase() +
|
||||
'<br><br>'
|
||||
'<br>'
|
||||
)
|
||||
} else if ($('#habilidadesAcreditadasGde2').text() == '') {
|
||||
$('#habilidadesAcreditadasGde2').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(
|
||||
arreglosCapacitaciones[habilidadAcreditadaEnEspera],
|
||||
'nombre'
|
||||
@@ -1638,7 +1608,7 @@ $('#accionComprarCapacitacion').click(function () {
|
||||
)
|
||||
$('#' + deptoActual + ' #habilidadesAcreditadasCh2').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(
|
||||
arreglosCapacitaciones[habilidadAcreditadaEnEspera],
|
||||
'nombre'
|
||||
@@ -1646,12 +1616,12 @@ $('#accionComprarCapacitacion').click(function () {
|
||||
', ' +
|
||||
beneficio +
|
||||
tipoRecurso.charAt(0).toUpperCase() +
|
||||
'<br><br>'
|
||||
'<br>'
|
||||
)
|
||||
} else if ($('#habilidadesAcreditadasGde3').text() == '') {
|
||||
$('#habilidadesAcreditadasGde3').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(
|
||||
arreglosCapacitaciones[habilidadAcreditadaEnEspera],
|
||||
'nombre'
|
||||
@@ -1662,7 +1632,7 @@ $('#accionComprarCapacitacion').click(function () {
|
||||
)
|
||||
$('#' + deptoActual + ' #habilidadesAcreditadasCh3').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
': ' +
|
||||
findArrayValue(
|
||||
arreglosCapacitaciones[habilidadAcreditadaEnEspera],
|
||||
'nombre'
|
||||
@@ -2754,28 +2724,7 @@ $('.droppableActivos').droppable({
|
||||
},
|
||||
})
|
||||
|
||||
function obtenerProyectosPendientesXX(cuantos) {
|
||||
// Filtrar proyectos pendientes
|
||||
const proyectosPendientes = proyectos.filter(
|
||||
(proyecto) => proyecto.estatus === 'Pendiente'
|
||||
)
|
||||
// const proyectosPendientes = proyectos.filter(proyecto =>
|
||||
// proyecto.estatus === "Pendiente" && proyecto.dificultad !== "Incidencia"
|
||||
// );
|
||||
// Si hay menos de 10 proyectos pendientes, retornar todos los disponibles
|
||||
if (proyectosPendientes.length <= cuantos) {
|
||||
return proyectosPendientes
|
||||
}
|
||||
// Seleccionar 10 proyectos aleatorios
|
||||
const resultado = []
|
||||
const proyectosDisponibles = [...proyectosPendientes]
|
||||
for (let i = 0; i < cuantos && proyectosDisponibles.length > 0; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * proyectosDisponibles.length)
|
||||
resultado.push(proyectosDisponibles[randomIndex])
|
||||
proyectosDisponibles.splice(randomIndex, 1)
|
||||
}
|
||||
return resultado
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pone en el arreglo proyectosPendientes, 7 proyectos al azar de los que están pendientes en el arreglo general.
|
||||
@@ -3012,66 +2961,7 @@ function guardarNuevoTexto(nuevoTexto, deptoOriginal) {
|
||||
console.log('ARREGLO:', arreglosDeptos['arr' + deptoOriginal])
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna las habilidades acreditadas al departamento especificado.
|
||||
*/
|
||||
function asignarHabilidades2(depto) {
|
||||
console.log('>>>>>> Asignando habilidades al departamento:', depto)
|
||||
|
||||
// Obtiene el arreglo del departamento especificado
|
||||
const elArregloDepto = arreglosDeptos['arr' + depto]
|
||||
|
||||
// Lista de habilidades a asignar en orden de prioridad
|
||||
const habilidades = [
|
||||
'habilidadTiempo',
|
||||
'habilidadPersonal',
|
||||
'habilidadCapital',
|
||||
]
|
||||
|
||||
// Arreglo para almacenar las habilidades asignadas
|
||||
const habilidadesAsignadas = [0, 0, 0]
|
||||
|
||||
// Asigna las habilidades en orden de prioridad
|
||||
habilidades.forEach((habilidad, index) => {
|
||||
// Encuentra el valor de la habilidad en el arreglo del departamento
|
||||
const value = elArregloDepto.find((item) => item.name === habilidad).value
|
||||
// Si el valor no es cero y no está ya asignado, se asigna a habilidadesAsignadas
|
||||
if (value !== 0 && !habilidadesAsignadas.includes(value)) {
|
||||
habilidadesAsignadas[index] = value
|
||||
}
|
||||
})
|
||||
|
||||
// Actualiza el DOM con las habilidades asignadas
|
||||
habilidadesAsignadas.forEach((habilidad, index) => {
|
||||
if (habilidad !== 0) {
|
||||
// Obtiene la capacitación correspondiente a la habilidad
|
||||
const capacitacion = arreglosCapacitaciones[habilidad]
|
||||
|
||||
// Obtiene y mapea el tipo de habilidad a un nombre más descriptivo
|
||||
const tipo = mapTipo(obtenerValorCapacitacion(capacitacion, 'tipo'))
|
||||
|
||||
// Obtiene el nombre, beneficio y tipo de recurso de la capacitación
|
||||
const nombre = obtenerValorCapacitacion(capacitacion, 'nombre')
|
||||
const beneficio = obtenerValorCapacitacion(capacitacion, 'beneficio')
|
||||
const tipoRecurso = obtenerValorCapacitacion(capacitacion, 'tipoRecurso')
|
||||
.charAt(0)
|
||||
.toUpperCase()
|
||||
|
||||
// Construye el contenido HTML a insertar
|
||||
const contenido = `${tipo}<br>${nombre}, ${beneficio} ${tipoRecurso}<br><br>`
|
||||
|
||||
// Actualiza el contenido HTML del elemento correspondiente en el DOM
|
||||
$(`#${depto} #habilidadesAcreditadasCh${index + 1}`).html(contenido)
|
||||
}
|
||||
})
|
||||
tieneTresHabilidades(depto)
|
||||
// Asegura que la vista grande se actualice con la acción especial si es el depto actual
|
||||
if (depto === deptoActual) {
|
||||
const elArreglo = arreglosDeptos['arr' + depto]
|
||||
const accion = findArrayValue(elArreglo, 'accionEspecialQuincenal')
|
||||
$('#' + depto + ' #accionEspecialGde').text(accion)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna las habilidades acreditadas al departamento especificado.
|
||||
@@ -3121,9 +3011,9 @@ function asignarHabilidades(depto) {
|
||||
console.log('Capacitación:', capacitacion)
|
||||
console.log('Tipo:', tipo)
|
||||
|
||||
const contenido = `${tipo}<br>${nombre}, ${beneficio} ${tipoRecurso
|
||||
const contenido = `${tipo}: ${nombre}, ${beneficio} ${tipoRecurso
|
||||
.charAt(0)
|
||||
.toUpperCase()}<br><br>`
|
||||
.toUpperCase()}<br>`
|
||||
$(`#${depto} #habilidadesAcreditadasCh${index + 1}`).html(contenido)
|
||||
}
|
||||
})
|
||||
@@ -3198,136 +3088,7 @@ function tieneTresHabilidades(depto) {
|
||||
return completo
|
||||
}
|
||||
|
||||
/**
|
||||
* Asigna las habilidades acreditadas al departamento especificado.
|
||||
**/
|
||||
function asignarHabilidades0(depto) {
|
||||
console.log('>>>>>> Asignando habilidades al departamento:', depto)
|
||||
let habilidad1 = 0
|
||||
let habilidad2 = 0
|
||||
let habilidad3 = 0
|
||||
const elArregloDepto = arreglosDeptos['arr' + depto]
|
||||
// console.log(elArregloDepto)
|
||||
|
||||
const habilidadTiempo = elArregloDepto.find(
|
||||
(item) => item.name === 'habilidadTiempo'
|
||||
).value
|
||||
const habilidadPersonal = elArregloDepto.find(
|
||||
(item) => item.name === 'habilidadPersonal'
|
||||
).value
|
||||
const habilidadCapital = elArregloDepto.find(
|
||||
(item) => item.name === 'habilidadCapital'
|
||||
).value
|
||||
// console.log('habilidadTiempo:', habilidadTiempo)
|
||||
// console.log('habilidadPersonal:', habilidadPersonal)
|
||||
// console.log('habilidadCapital:', habilidadCapital)
|
||||
|
||||
if (habilidadTiempo != 0) {
|
||||
habilidad1 = habilidadTiempo
|
||||
} else if (habilidadPersonal != 0) {
|
||||
habilidad1 = habilidadPersonal
|
||||
} else if (habilidadCapital != 0) {
|
||||
habilidad1 = habilidadCapital
|
||||
}
|
||||
|
||||
if (habilidadTiempo != 0 && habilidadTiempo != habilidad1) {
|
||||
habilidad2 = habilidadTiempo
|
||||
} else if (habilidadPersonal != 0 && habilidadPersonal != habilidad1) {
|
||||
habilidad2 = habilidadPersonal
|
||||
} else if (habilidadCapital != 0 && habilidadCapital != habilidad1) {
|
||||
habilidad2 = habilidadCapital
|
||||
}
|
||||
if (
|
||||
habilidadTiempo != 0 &&
|
||||
habilidadTiempo != habilidad1 &&
|
||||
habilidadTiempo != habilidad2
|
||||
) {
|
||||
habilidad3 = habilidadTiempo
|
||||
} else if (
|
||||
habilidadPersonal != 0 &&
|
||||
habilidadPersonal != habilidad1 &&
|
||||
habilidadPersonal != habilidad2
|
||||
) {
|
||||
habilidad3 = habilidadPersonal
|
||||
} else if (
|
||||
habilidadCapital != 0 &&
|
||||
habilidadCapital != habilidad1 &&
|
||||
habilidadCapital != habilidad2
|
||||
) {
|
||||
habilidad3 = habilidadCapital
|
||||
}
|
||||
|
||||
console.log('laHabilidad1: ', habilidad1)
|
||||
console.log('laHabilidad2: ', habilidad2)
|
||||
console.log('laHabilidad3: ', habilidad3)
|
||||
|
||||
if (habilidad1 != 0) {
|
||||
console.log('laCapacitacion:', arreglosCapacitaciones[habilidad1])
|
||||
let tipo = findArrayValue(arreglosCapacitaciones[habilidad1], 'tipo')
|
||||
if (tipo == 'HC') {
|
||||
tipo = 'Habilidad Conceptual'
|
||||
} else if (tipo == 'HT') {
|
||||
tipo = 'Habilidad Técnica'
|
||||
} else if (tipo == 'HH') {
|
||||
tipo = 'Habilidad Humana'
|
||||
}
|
||||
$('#' + depto + ' #habilidadesAcreditadasCh1').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad1], 'nombre') +
|
||||
', ' +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad1], 'beneficio') +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad1], 'tipoRecurso')
|
||||
.charAt(0)
|
||||
.toUpperCase() +
|
||||
'<br><br>'
|
||||
)
|
||||
}
|
||||
if (habilidad2 != 0) {
|
||||
console.log('laCapacitacion:', arreglosCapacitaciones[habilidad2])
|
||||
let tipo = findArrayValue(arreglosCapacitaciones[habilidad2], 'tipo')
|
||||
if (tipo == 'HC') {
|
||||
tipo = 'Habilidad Conceptual'
|
||||
} else if (tipo == 'HT') {
|
||||
tipo = 'Habilidad Técnica'
|
||||
} else if (tipo == 'HH') {
|
||||
tipo = 'Habilidad Humana'
|
||||
}
|
||||
$('#' + depto + ' #habilidadesAcreditadasCh2').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad2], 'nombre') +
|
||||
', ' +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad2], 'beneficio') +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad2], 'tipoRecurso')
|
||||
.charAt(0)
|
||||
.toUpperCase() +
|
||||
'<br><br>'
|
||||
)
|
||||
}
|
||||
if (habilidad3 != 0) {
|
||||
console.log('laCapacitacion:', arreglosCapacitaciones[habilidad3])
|
||||
let tipo = findArrayValue(arreglosCapacitaciones[habilidad3], 'tipo')
|
||||
if (tipo == 'HC') {
|
||||
tipo = 'Habilidad Conceptual'
|
||||
} else if (tipo == 'HT') {
|
||||
tipo = 'Habilidad Técnica'
|
||||
} else if (tipo == 'HH') {
|
||||
tipo = 'Habilidad Humana'
|
||||
}
|
||||
$('#' + depto + ' #habilidadesAcreditadasCh3').html(
|
||||
tipo +
|
||||
'<br>' +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad3], 'nombre') +
|
||||
', ' +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad3], 'beneficio') +
|
||||
findArrayValue(arreglosCapacitaciones[habilidad3], 'tipoRecurso')
|
||||
.charAt(0)
|
||||
.toUpperCase() +
|
||||
'<br><br>'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Función que se ejecuta al iniciar el juego, DESPUES de cargar los arreglos de activos y departamentos.
|
||||
|
||||
Reference in New Issue
Block a user