Procházet zdrojové kódy

:recycle: forcing sort on exhibition and event routes | tweaking list loading order

tags/0.9.0
J před 4 roky
rodič
revize
5a801bd7b4
2 změnil soubory, kde provedl 19 přidání a 17 odebrání
  1. 5
    13
      vue-theme/src/pages/list.vue
  2. 14
    4
      vue-theme/src/router/routes.js

+ 5
- 13
vue-theme/src/pages/list.vue Zobrazit soubor

53
             return typeFromRoute(this.$route)
53
             return typeFromRoute(this.$route)
54
         },
54
         },
55
         pType() {
55
         pType() {
56
+            if(!this.type) return
56
             console.log(this.type, `${convertTitleCase(this.type)}s`)
57
             console.log(this.type, `${convertTitleCase(this.type)}s`)
57
             return this.sortBy ? `${convertTitleCase(this.type.split('/')[0])}s` : `${convertTitleCase(this.type)}s`
58
             return this.sortBy ? `${convertTitleCase(this.type.split('/')[0])}s` : `${convertTitleCase(this.type)}s`
58
         },
59
         },
105
             this.$store.commit('SET_HERO', { url: null, heroType: null })
106
             this.$store.commit('SET_HERO', { url: null, heroType: null })
106
         },
107
         },
107
         async checkAndSetHero(type) {
108
         async checkAndSetHero(type) {
109
+            this.clearHero()
110
+
108
             if (!this['allPagesLoaded']) {
111
             if (!this['allPagesLoaded']) {
109
                 await this.$store.dispatch('getAllPages', { sortType: null, params: null })
112
                 await this.$store.dispatch('getAllPages', { sortType: null, params: null })
110
             }
113
             }
117
                 page => page.slug == type + 's',
120
                 page => page.slug == type + 's',
118
             )[0]
121
             )[0]
119
 
122
 
120
-            // Clear the hero and bail
121
-            if(!page) return this.clearHero()
122
-
123
             let json = { url: page.featured, heroType:'image' }
123
             let json = { url: page.featured, heroType:'image' }
124
             if (
124
             if (
125
                 page.hero &&
125
                 page.hero &&
135
             json.text = page && page.excerpt ? page.excerpt : page.title
135
             json.text = page && page.excerpt ? page.excerpt : page.title
136
             this.$store.commit('SET_HERO', json)
136
             this.$store.commit('SET_HERO', json)
137
         },
137
         },
138
-        scrollTo(hashtag) {
139
-            setTimeout(() => {
140
-                location.href = hashtag
141
-            }, TIMEOUT)
142
-        },
143
         setIntersectionLoader() {
138
         setIntersectionLoader() {
144
             console.warn('setting up intersection handler for:', this.type)
139
             console.warn('setting up intersection handler for:', this.type)
145
             window.removeEventListener("load", e => {}, false)
140
             window.removeEventListener("load", e => {}, false)
165
             console.log('?:', path.pop())
160
             console.log('?:', path.pop())
166
 
161
 
167
             // Always reset the page count
162
             // Always reset the page count
168
-            this.setIntersectionLoader()
169
             this.page = 1
163
             this.page = 1
170
             
164
             
171
-            this.clearHero()
172
             this.checkAndSetHero(this.type)
165
             this.checkAndSetHero(this.type)
173
             
166
             
174
             // TODO: Track last loaded page per post type
167
             // TODO: Track last loaded page per post type
175
             // Less http calls
168
             // Less http calls
176
             this.getPosts(true)
169
             this.getPosts(true)
170
+
171
+            this.setIntersectionLoader()
177
         },
172
         },
178
     },
173
     },
179
     mounted() {
174
     mounted() {
180
-        if (this.$route.hash) {
181
-            setTimeout(() => this.scrollTo(this.$route.hash), TIMEOUT)
182
-        }
183
         this.setIntersectionLoader()
175
         this.setIntersectionLoader()
184
     },
176
     },
185
     created() {
177
     created() {

+ 14
- 4
vue-theme/src/router/routes.js Zobrazit soubor

29
         component: listPage,
29
         component: listPage,
30
         props: { sidebar: true, grid: true, sortBy: `${sortTypes.material}` },
30
         props: { sidebar: true, grid: true, sortBy: `${sortTypes.material}` },
31
     },
31
     },
32
+    {
33
+        path: `/event`,
34
+        component: listPage,
35
+        props: { sidebar: true, sortBy: `${sortTypes.currentAndUpcoming}` },
36
+    },
37
+    {
38
+        path: `/exhibition`,
39
+        component: listPage,
40
+        props: { sidebar: true, sortBy: `${sortTypes.currentAndUpcoming}` },
41
+    },
32
     {
42
     {
33
         path: `/:type/${sortTypes.past}`,
43
         path: `/:type/${sortTypes.past}`,
34
         component: listPage,
44
         component: listPage,
60
         props: { sidebar: true, sortBy: `${sortTypes.material}` },
70
         props: { sidebar: true, sortBy: `${sortTypes.material}` },
61
     },
71
     },
62
     {
72
     {
63
-        path: '/:type/by-episode',
73
+        path: `/:type/${sortTypes.episode}`,
64
         component: listPage,
74
         component: listPage,
65
-        props: { sidebar: true, sortBy: 'by-episode' },
75
+        props: { sidebar: true, sortBy: `${sortTypes.episode}` },
66
     },
76
     },
67
     {
77
     {
68
-        path: '/:type/by-artist',
78
+        path: `/:type/${sortTypes.artist}`,
69
         component: listPage,
79
         component: listPage,
70
-        props: { sidebar: true, sortBy: 'by-artist' },
80
+        props: { sidebar: true, sortBy: `${sortTypes.artist}` },
71
     },
81
     },
72
     {
82
     {
73
         path: '/:type',
83
         path: '/:type',

Načítá se…
Zrušit
Uložit