|
|
@@ -73,8 +73,8 @@ export default {
|
|
73
|
73
|
return this.$route.params.sortBy
|
|
74
|
74
|
},
|
|
75
|
75
|
pType() {
|
|
76
|
|
- if(!typeFromRoute(this.$route)) return
|
|
77
|
|
- return this.sortBy ? `${convertTitleCase(typeFromRoute(this.$route).split('/')[0])}s` : `${convertTitleCase(this.type)}s`
|
|
|
76
|
+ if(!this.type) return
|
|
|
77
|
+ return `${convertTitleCase(this.type)}s`
|
|
78
|
78
|
},
|
|
79
|
79
|
loaded() {
|
|
80
|
80
|
if (!this.pType) return
|
|
|
@@ -86,18 +86,9 @@ export default {
|
|
86
|
86
|
},
|
|
87
|
87
|
},
|
|
88
|
88
|
methods: {
|
|
89
|
|
- _getDispatchParams(perPageOverride) {
|
|
90
|
|
- return {
|
|
91
|
|
- sortType: this.sortBy,
|
|
92
|
|
- params: {
|
|
93
|
|
- limit: perPageOverride ? perPageOverride : this.perPage,
|
|
94
|
|
- page: this.page
|
|
95
|
|
- }
|
|
96
|
|
- }
|
|
97
|
|
- },
|
|
98
|
89
|
clearAllPosts() {
|
|
99
|
90
|
if(!this.type) return console.error(`post type: ${this.type} not found...`)
|
|
100
|
|
- this.$store.commit(`CLEAR_${this.type.toUpperCase()}S`)
|
|
|
91
|
+ this.$store.commit(`CLEAR_${this.pType.toUpperCase()}`)
|
|
101
|
92
|
// this.$store.commit(`${this.type.toUpperCase()}S_LOADED`)
|
|
102
|
93
|
},
|
|
103
|
94
|
async loadMorePosts() {
|
|
|
@@ -117,23 +108,20 @@ export default {
|
|
117
|
108
|
if(!this.type) throw `post type: ${this.type} not found...`
|
|
118
|
109
|
|
|
119
|
110
|
// Set some default dispatch paramters
|
|
120
|
|
- let dispatchAction = `getMore${this.pType}`
|
|
121
|
|
- let params = this._getDispatchParams()
|
|
|
111
|
+ let dispatchAction = 'More'
|
|
|
112
|
+ let params = { limit: this.perPage, page: this.page }
|
|
122
|
113
|
|
|
123
|
114
|
// For episodes, or material sort we grab EVERYTHING
|
|
124
|
115
|
const getAllClause = this.type == 'episode' || this.type == 'artist' && this.sortBy == sortTypes.material
|
|
125
|
116
|
if(getAllClause) {
|
|
126
|
|
- dispatchAction = `getAll${this.pType}`
|
|
127
|
|
- params = this._getDispatchParams(-1)
|
|
128
|
|
-
|
|
129
|
|
- // Clear sortType if this is an episodes list
|
|
130
|
|
- params.sortType = this.type == 'episode' ? null : params.sortType
|
|
|
117
|
+ dispatchAction = 'All'
|
|
|
118
|
+ params.limit = -1
|
|
131
|
119
|
}
|
|
132
|
120
|
|
|
133
|
121
|
let res = []
|
|
134
|
122
|
// We always grab all pages on hero init so no need to do it here
|
|
135
|
123
|
if(this.pType && this.keepFetching && this.type != 'page') {
|
|
136
|
|
- res = await this.$store.dispatch(dispatchAction, params)
|
|
|
124
|
+ res = await this.$store.dispatch(`get${dispatchAction}${this.pType}`, { sortType: this.sortBy, params })
|
|
137
|
125
|
}
|
|
138
|
126
|
|
|
139
|
127
|
// Stop trying to load more posts
|
|
|
@@ -192,9 +180,6 @@ export default {
|
|
192
|
180
|
}
|
|
193
|
181
|
},
|
|
194
|
182
|
clearAndInitPostList(caller) {
|
|
195
|
|
- console.log(`clearAndInitPostList from ${caller}...`)
|
|
196
|
|
- console.log('---')
|
|
197
|
|
-
|
|
198
|
183
|
this.page = 0
|
|
199
|
184
|
this.keepFetching = true
|
|
200
|
185
|
|
|
|
@@ -212,8 +197,8 @@ export default {
|
|
212
|
197
|
// This only fires navigating from
|
|
213
|
198
|
// a list page, to another list page
|
|
214
|
199
|
// and the post type has changed
|
|
215
|
|
- type(newType, oldType) {
|
|
216
|
|
- if(!postTypes.includes(newType)) return console.warn('type not valid...')
|
|
|
200
|
+ type(newType) {
|
|
|
201
|
+ if(!postTypes.includes(newType)) return console.warn('Type not valid...')
|
|
217
|
202
|
|
|
218
|
203
|
// Ignore types with presorts so the sortBy watcher can handle them
|
|
219
|
204
|
const ignore = ['event', 'exhibition', 'artist']
|
|
|
@@ -221,16 +206,10 @@ export default {
|
|
221
|
206
|
|
|
222
|
207
|
this.clearAndInitPostList('type change')
|
|
223
|
208
|
},
|
|
224
|
|
- sortBy(newSort, oldSort) {
|
|
|
209
|
+ sortBy(newSort) {
|
|
225
|
210
|
if(Object.values(sortTypes).includes(newSort)) {
|
|
226
|
211
|
this.clearAndInitPostList('sort change')
|
|
227
|
212
|
}
|
|
228
|
|
- },
|
|
229
|
|
- // Only fire if the sort type has changed
|
|
230
|
|
- // and the post type is the same
|
|
231
|
|
- // and both sorts are valid
|
|
232
|
|
- $route(to, from) {
|
|
233
|
|
- console.log('to :', to)
|
|
234
|
213
|
}
|
|
235
|
214
|
},
|
|
236
|
215
|
mounted() {
|