Explorar el Código

refac: dispatch based on route string | feat: added episodes to the nav

tags/0.9.0
J hace 6 años
padre
commit
49cbe7936a

+ 2
- 0
vue-theme/src/components/navigation/navigation.vue Ver fichero

@@ -11,6 +11,8 @@ nav.main
11 11
             a(href="/") home
12 12
         li
13 13
             a(href="/artists") artists
14
+        li
15
+            a(href="/episodes") episodes
14 16
         li
15 17
             a(href="/lazy") lazy
16 18
 </template>

+ 6
- 18
vue-theme/src/pages/list.vue Ver fichero

@@ -1,5 +1,3 @@
1
-// Artists/Exhibitions/Events/search-results
2
-// Optional sidebar
3 1
 <template lang="pug">
4 2
 .page--list.f-row.between
5 3
     article.f-grow
@@ -36,14 +34,9 @@ export default {
36 34
             allEpisodesLoaded: 'allEpisodesLoaded',
37 35
         }),
38 36
         posts() {
39
-            switch (this.$route.params.type) {
40
-                case 'artists':
41
-                    return this.allArtists
42
-                    break
43
-                case 'episodes':
44
-                    return this.allEpisodes
45
-                    break
46
-            }
37
+            let type = this.$route.params.type
38
+            type = type.charAt(0).toUpperCase() + type.slice(1)
39
+            return this[`all${type}`]
47 40
         },
48 41
     },
49 42
     data() {
@@ -53,14 +46,9 @@ export default {
53 46
         }
54 47
     },
55 48
     mounted() {
56
-        switch (this.$route.params.type) {
57
-            case 'artists':
58
-                this.$store.dispatch('getAllArtists')
59
-                break
60
-            case 'episodes':
61
-                this.$store.dispatch('getAllEpisodes')
62
-                break
63
-        }
49
+        let type = this.$route.params.type
50
+        type = type.charAt(0).toUpperCase() + type.slice(1)
51
+        this.$store.dispatch(`getAll${type}`)
64 52
     }
65 53
 }
66 54
 </script>

Loading…
Cancelar
Guardar