Przeglądaj źródła

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

tags/0.9.0
J 6 lat temu
rodzic
commit
49cbe7936a

+ 2
- 0
vue-theme/src/components/navigation/navigation.vue Wyświetl plik

11
             a(href="/") home
11
             a(href="/") home
12
         li
12
         li
13
             a(href="/artists") artists
13
             a(href="/artists") artists
14
+        li
15
+            a(href="/episodes") episodes
14
         li
16
         li
15
             a(href="/lazy") lazy
17
             a(href="/lazy") lazy
16
 </template>
18
 </template>

+ 6
- 18
vue-theme/src/pages/list.vue Wyświetl plik

1
-// Artists/Exhibitions/Events/search-results
2
-// Optional sidebar
3
 <template lang="pug">
1
 <template lang="pug">
4
 .page--list.f-row.between
2
 .page--list.f-row.between
5
     article.f-grow
3
     article.f-grow
36
             allEpisodesLoaded: 'allEpisodesLoaded',
34
             allEpisodesLoaded: 'allEpisodesLoaded',
37
         }),
35
         }),
38
         posts() {
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
     data() {
42
     data() {
53
         }
46
         }
54
     },
47
     },
55
     mounted() {
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
 </script>
54
 </script>

Ładowanie…
Anuluj
Zapisz