diff --git a/src/components/Inicio/curso.vue b/src/components/Inicio/curso.vue
index c8c79df..5fb60b1 100644
--- a/src/components/Inicio/curso.vue
+++ b/src/components/Inicio/curso.vue
@@ -1,12 +1,12 @@
div.info_curso
h4.titulo_curso(@mouseenter="resaltarTodasCeldas" @mouseleave="quitarResaltadoCeldas"
- title="Agregar curso a mi horario."
+ :title="cursoAgregado? 'Remover de mi horario': 'Agregar curso a mi horario'"
@click.stop="agregarCursoAMiHorario"
)
input.marcador_curso(type="checkbox" v-model="cursoAgregado")
span.ancho {{ curso.abreviado }} >
- | {{ curso.nombre }}
+ | {{ curso.nombre }} {{ nombreCurso }}
table.datos
tr
bloque(v-for="(grupos, profesor) in teoria"
@@ -49,8 +49,6 @@
export default
name: "curso"
components: { bloque }
- data: ->
- cursoAgregado: no
props:
curso:
type: Object
@@ -62,6 +60,7 @@
type: String
required: true
computed:
+ esMiHorario: -> @nombreAño is "Mi horario"
teoria: ->
vm = this
profesores = {}
@@ -89,25 +88,38 @@
break
estaVacio
+ nombreAñoMin: ->
+ nombreAño = @nombreAño
+ nombreAño.substring 0, nombreAño.indexOf " "
+ idCurso: ->
+ if @nombreAñoMin is "Mi"
+ @nombreCurso
+ else
+ "_" + @nombreAñoMin + @curso.abreviado
+ cursoAgregado: ->
+ cursosUsuario = @$store.state.horarioUsuario
+
+ for idCurso, _ of cursosUsuario
+ if idCurso is @idCurso then return true
+
+ false
methods:
agregarCursoAMiHorario: ->
if @cursoAgregado
- @cursoAgregado = false
- @$store.commit "removerCursoMiHorario", @nombreCurso
+ @$store.commit "removerCursoMiHorario", @idCurso
else
- @cursoAgregado = true
+ idCurso = @idCurso
nombre = @nombreCurso
datos = @curso
- @$store.commit "agregarCursoAMiHorario", { nombre, datos }
+ @$store.commit "agregarCursoAMiHorario", { nombre: idCurso, datos: datos }
obtenerClase: (grupo, esLab) ->
obtenerClaseGrupoCurso @nombreAño, @curso.abreviado, grupo, esLab
procesarTeoria: () ->
- nombreAño = @nombreAño
cursoAbreviado = @curso.abreviado
curso = @curso
- nombreStore = "_" + (nombreAño.substring 0, nombreAño.indexOf " ")
+ nombreStore = "_" + @nombreAñoMin
for nombreGrupo, { Horas } of curso.Teoria
for horaId in Horas
@@ -123,6 +135,25 @@
@$store.commit "agregarACelda", {idCelda, datos}
+ desprocesarTeoria: () ->
+ cursoAbreviado = @curso.abreviado
+ curso = @curso
+ nombreStore = "_" + @nombreAñoMin
+
+ for nombreGrupo, { Horas } of curso.Teoria
+ for horaId in Horas
+ datos = { cursoAbreviado, nombreGrupo, esLab: no }
+ idCelda = nombreStore + horaId
+
+ @$store.commit "quitarDeCelda", idCelda
+
+ for nombreGrupo, { Horas } of curso.Laboratorio
+ for horaId in Horas
+ datos = { cursoAbreviado, nombreGrupo, esLab: yes }
+ idCelda = nombreStore + horaId
+
+ @$store.commit "quitarDeCelda", idCelda
+
resaltarTodasCeldas: () ->
resaltarCurso @nombreAño, @curso.abreviado
@@ -132,6 +163,9 @@
mounted: ->
@procesarTeoria()
+ beforeDestroy: ->
+ @desprocesarTeoria()
+
#
diff --git a/src/components/Inicio/curso/bloque.vue b/src/components/Inicio/curso/bloque.vue
index fa9302a..a121248 100644
--- a/src/components/Inicio/curso/bloque.vue
+++ b/src/components/Inicio/curso/bloque.vue
@@ -9,7 +9,7 @@
@mouseleave="quitarResaltadoGrupo(grupo)"
@click="toggleActivo(grupo)"
)
- | L{{ grupo }}
+ | {{ esLab? 'T': 'G' }}{{ grupo }}
//
diff --git a/src/store/index.js b/src/store/index.js
index 95e8f86..522c585 100644
--- a/src/store/index.js
+++ b/src/store/index.js
@@ -15,8 +15,9 @@ export default new Vuex.Store({
agregarACelda(state, {idCelda, datos}) {
state.celdas[idCelda].push(datos);
},
- quitarDeCelda(state) {
-
+ quitarDeCelda(state, idCelda) {
+ const ref = state.celdas[idCelda];
+ while (ref.length > 0) ref.pop()
},
agregarCursoAMiHorario(state, {nombre, datos} ) {
if (!state.horarioUsuario[nombre]) {
diff --git a/src/views/Inicio.vue b/src/views/Inicio.vue
index 87788ab..02e9f36 100644
--- a/src/views/Inicio.vue
+++ b/src/views/Inicio.vue
@@ -1,7 +1,7 @@
div.home
h2.titulo {{ datos.titulo }}
- p Puedes agregar cursos de diferentes años al horario.
+ p Puedes agregar cursos de diferentes años a tu horario.
anio(:año="horarioUsuario" nombreAño="Mi horario")
anio(v-for="(año, i) in datos.años" :key="i"
:año="año" :nombreAño="i"