Ver código fonte

feat: sort by options in the list pages

tags/0.9.0
John Maeda 6 anos atrás
pai
commit
aef239acec
2 arquivos alterados com 17 adições e 6 exclusões
  1. 5
    5
      vue-theme/src/index.js
  2. 12
    1
      vue-theme/src/pages/list.vue

+ 5
- 5
vue-theme/src/index.js Ver arquivo

@@ -18,11 +18,11 @@ const router = new VueRouter({
18 18
         { path: '/episodes', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: false } },
19 19
         { path: '/:type', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true } },
20 20
         // Sorted List Pages 
21
-        { path: '/:type/alphabetized', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true } },
22
-        { path: '/:type/most-recent', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true } },
23
-        { path: '/:type/by-material', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true } },
24
-        { path: '/:type/by-episode', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true } },
25
-        { path: '/:type/by-artist', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true } },
21
+        { path: '/:type/alphabetized', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true, sortBy: 'alphabetized' } },
22
+        { path: '/:type/most-recent', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true, sortBy: 'most-recent' } },
23
+        { path: '/:type/by-material', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true, sortBy: 'by-material' } },
24
+        { path: '/:type/by-episode', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true, sortBy: 'by-episode' } },
25
+        { path: '/:type/by-artist', component: () => import(/* webpackChunkName: "pages-list" */ './pages/list.vue'), props: { sidebar: true, sortBy: 'by-artist' } },
26 26
         // Single Pages
27 27
         { path: '/:type/:slug', component: () => import(/* webpackChunkName: "pages-single" */ './pages/single.vue'), props: { sidebar: true } },
28 28
     ]

+ 12
- 1
vue-theme/src/pages/list.vue Ver arquivo

@@ -3,6 +3,8 @@
3 3
     article.f-grow
4 4
         header.f-row.center
5 5
             h1 {{ type }} list
6
+            span(v-if="sortBy")
7
+                h1  sorted by {{ sortBy.replace('-', ' ') }}
6 8
         section.shadow
7 9
             h4 {{ type }}
8 10
             p {{ Object.values(posts).length }}
@@ -27,6 +29,9 @@ export default {
27 29
     props: {
28 30
         sidebar: {
29 31
             type: Boolean
32
+        },
33
+        sortBy: {
34
+            type: String
30 35
         }
31 36
     },
32 37
     components: {
@@ -56,7 +61,13 @@ export default {
56 61
     },
57 62
     mounted() {
58 63
         let type = this.type.charAt(0).toUpperCase() + this.type.slice(1)
59
-        this.$store.dispatch(`getAll${type}`)
64
+        
65
+        if(this.sortBy) {
66
+            // TODO: Make a sorted call instead
67
+            this.$store.dispatch(`getAll${type}`)
68
+        } else {
69
+            this.$store.dispatch(`getAll${type}`)
70
+        }
60 71
     }
61 72
 }
62 73
 </script>

Carregando…
Cancelar
Salvar