Limpiar codigo

master
Fernando 2021-08-18 17:09:02 -05:00
parent 07668ed201
commit fe98b12130
3 changed files with 210 additions and 216 deletions

View File

@ -34,6 +34,13 @@ const e = StyleSheet.create({
}, },
}) })
const claseCursoNoAgregado = css(
e.contenedorCurso,
estilosGlobales.contenedor,
)
const claseCursoOculto = css(e.cursoOculto)
interface Props { interface Props {
version: number, version: number,
dataAnio: Cursos, dataAnio: Cursos,
@ -101,27 +108,13 @@ const agruparProfesores = (
return profesores return profesores
} }
export function CursosElem(props: Props) { function CursoE(
const anio = () => props.anioActual().substring(0, props.anioActual().indexOf(" ")) indiceCurso: string,
datosCurso: Curso,
const claseCursoNoAgregado = css( anio: () => string,
e.contenedorCurso, claseCursoAgregado: string,
estilosGlobales.contenedor, props: Props
) ) {
const claseCursoAgregado = css(
e.contenedorCurso,
estilosGlobales.contenedor,
!props.esCursoMiHorario && estilosGlobales.contenedorCursorActivo,
)
const claseCursoOculto = css(e.cursoOculto)
return (
<>
<For each={Object.entries(props.dataAnio)}>
{([indiceCurso, datosCurso]) => {
const idCurso = `${props.version}_${anio()}_${datosCurso.abreviado}` const idCurso = `${props.version}_${anio()}_${datosCurso.abreviado}`
const cursoAgregadoMemo = createMemo( const cursoAgregadoMemo = createMemo(
@ -156,6 +149,26 @@ export function CursosElem(props: Props) {
props.setCursosUsuarios, props.setCursosUsuarios,
)) ))
const IndicadorGrupos = (profesor: string, grupos: [string, () => void][], esLab: boolean) => (
<td style={{"padding-bottom": "0.5rem", "padding-right": "0.75rem"}}>
<span>
{profesor}&nbsp;
</span>
<For each={grupos}>
{([x, fnOnClick]) => (
<IndicadorGrupo
nombre={x}
esLab={esLab}
idParcial={idCurso}
tablaObserver={props.tablaObserver}
onClick={fnOnClick}
/>
)
}
</For>
</td>
)
return ( return (
<div className={claseMemo()}> <div className={claseMemo()}>
<button <button
@ -169,48 +182,12 @@ export function CursosElem(props: Props) {
<tbody> <tbody>
<tr> <tr>
<For each={Object.entries(profesoresTeoria())}> <For each={Object.entries(profesoresTeoria())}>
{([profesor, grupos]) => ( {([profesor, grupos]) => IndicadorGrupos(profesor, grupos, false)}
<td style={{"padding-bottom": "0.5rem", "padding-right": "0.75rem"}}>
<span>
{profesor}&nbsp;
</span>
<For each={grupos}>
{([x, fnOnClick]) => (
<IndicadorGrupo
nombre={x}
esLab={false}
idParcial={idCurso}
tablaObserver={props.tablaObserver}
onClick={fnOnClick}
/>
)
}
</For>
</td>
)}
</For> </For>
</tr> </tr>
<tr> <tr>
<For each={Object.entries(profesoresLab())}> <For each={Object.entries(profesoresLab())}>
{([profesor, grupos]) => ( {([profesor, grupos]) => IndicadorGrupos(profesor, grupos, true)}
<td style={{"padding-bottom": "0.5rem", "padding-right": "0.75rem"}}>
<span>
{profesor}&nbsp;
</span>
<For each={grupos}>
{([x, fnOnClick]) => (
<IndicadorGrupo
nombre={x}
esLab
idParcial={idCurso}
tablaObserver={props.tablaObserver}
onClick={fnOnClick}
/>
)
}
</For>
</td>
)}
</For> </For>
</tr> </tr>
</tbody> </tbody>
@ -223,7 +200,21 @@ export function CursosElem(props: Props) {
</button> </button>
</div> </div>
) )
}} }
export function CursosElem(props: Props) {
const anio = () => props.anioActual().substring(0, props.anioActual().indexOf(" "))
const claseCursoAgregado = css(
e.contenedorCurso,
estilosGlobales.contenedor,
!props.esCursoMiHorario && estilosGlobales.contenedorCursorActivo,
)
return (
<>
<For each={Object.entries(props.dataAnio)}>
{([indiceCurso, datosCurso]) => CursoE(indiceCurso, datosCurso, anio, claseCursoAgregado, props)}
</For> </For>
</> </>
) )

View File

@ -72,6 +72,14 @@ const clasesColores = {
Viernes: css(eColores.viernes), Viernes: css(eColores.viernes),
} }
interface DatosProps {
id: string,
txt: string,
esLab: boolean,
datosGrupo: DatosGrupo,
fnSeleccionar: () => void
}
interface Props { interface Props {
/** /**
* Informacion de los cursos a renderizar en la celda * Informacion de los cursos a renderizar en la celda
@ -82,13 +90,7 @@ interface Props {
* *
* esLab - Boolean que indica si el grupo es de laboratorio * esLab - Boolean que indica si el grupo es de laboratorio
*/ */
datos: { datos: DatosProps[],
id: string,
txt: string,
esLab: boolean,
datosGrupo: DatosGrupo,
fnSeleccionar: () => void
}[],
fnResaltarFila: () => void, fnResaltarFila: () => void,
fnDesresaltarFila: () => void, fnDesresaltarFila: () => void,
dia: Dia, dia: Dia,
@ -97,13 +99,7 @@ interface Props {
const claseSeldaSeleccionada = css(e.celdaSeleccionado) const claseSeldaSeleccionada = css(e.celdaSeleccionado)
export function CeldaFila(props: Props) { function RenderFila(datos: DatosProps, props: Props) {
const datos = props.datos
return (
<div className={css(e.celdaComun, estilosGlobales.inlineBlock)}>
<For each={datos}>
{(datos) => {
const id = datos.id const id = datos.id
const txt = datos.txt const txt = datos.txt
const esLab = datos.esLab const esLab = datos.esLab
@ -199,7 +195,15 @@ export function CeldaFila(props: Props) {
{txt} {txt}
</button> </button>
) )
}} }
export function CeldaFila(props: Props) {
const datos = props.datos
return (
<div className={css(e.celdaComun, estilosGlobales.inlineBlock)}>
<For each={datos}>
{(datos) => RenderFila(datos, props)}
</For> </For>
</div> </div>
) )

View File

@ -132,7 +132,6 @@ export function FilaTabla(props: Props) {
</div> </div>
<For each={dias}> <For each={dias}>
{(dia) => { {(dia) => {
console.log("Renderizar dias")
const diaStr = dia.substring(0, 2) const diaStr = dia.substring(0, 2)
const horaStr = hora.substring(0, 5) const horaStr = hora.substring(0, 5)