|
|
@@ -16,7 +16,7 @@
|
|
16
|
16
|
card(:content="post" :type="type" :wide="type == 'exhibition' && i > 1 || type == 'event' && i > 1 ")
|
|
17
|
17
|
|
|
18
|
18
|
footer
|
|
19
|
|
- button(@click="loadMore") load more {{ type }}s...
|
|
|
19
|
+ button(@click="loadMorePosts") load more {{ type }}s...
|
|
20
|
20
|
p {{ `${type} count: ${Object.values(posts).length}` }}
|
|
21
|
21
|
p {{ `show sidebar: ${sidebar}` }}
|
|
22
|
22
|
|
|
|
@@ -57,6 +57,10 @@ export default {
|
|
57
|
57
|
let type = convertTitleCase(this.type) + 's'
|
|
58
|
58
|
return this.sortBy ? `getAll${type.split('/')[0]}` : `getAll${type}`
|
|
59
|
59
|
},
|
|
|
60
|
+ getMoreName() {
|
|
|
61
|
+ let type = convertTitleCase(this.type) + 's'
|
|
|
62
|
+ return this.sortBy ? `getMore${type.split('/')[0]}` : `getMore${type}`
|
|
|
63
|
+ },
|
|
60
|
64
|
loaded() {
|
|
61
|
65
|
let type = convertTitleCase(this.type) + 's'
|
|
62
|
66
|
if (!type) return
|
|
|
@@ -69,11 +73,11 @@ export default {
|
|
69
|
73
|
},
|
|
70
|
74
|
},
|
|
71
|
75
|
methods: {
|
|
72
|
|
- loadMore() {
|
|
|
76
|
+ loadMorePosts() {
|
|
73
|
77
|
this.page++
|
|
74
|
|
- this.getPosts()
|
|
|
78
|
+ this.getPosts(false)
|
|
75
|
79
|
},
|
|
76
|
|
- getPosts(offset) {
|
|
|
80
|
+ getPosts(clear) {
|
|
77
|
81
|
// Limit
|
|
78
|
82
|
let params = {
|
|
79
|
83
|
limit: this.perPage,
|
|
|
@@ -94,8 +98,11 @@ export default {
|
|
94
|
98
|
// }
|
|
95
|
99
|
|
|
96
|
100
|
// Don't dispatch if there's no type
|
|
97
|
|
- if (this.type && this.dispatchName) {
|
|
98
|
|
- this.$store.dispatch(this.dispatchName, { sortType: sort, params })
|
|
|
101
|
+ if (this.type && this.dispatchName && clear) {
|
|
|
102
|
+ this.$store.dispatch(
|
|
|
103
|
+ this.dispatchName,
|
|
|
104
|
+ { sortType: sort, params }
|
|
|
105
|
+ )
|
|
99
|
106
|
|
|
100
|
107
|
if (this.type == 'event') {
|
|
101
|
108
|
this.$store.dispatch(
|
|
|
@@ -115,6 +122,12 @@ export default {
|
|
115
|
122
|
}
|
|
116
|
123
|
)
|
|
117
|
124
|
}
|
|
|
125
|
+ // Add to existing
|
|
|
126
|
+ } else if (!clear) {
|
|
|
127
|
+ this.$store.dispatch(
|
|
|
128
|
+ this.getMoreName,
|
|
|
129
|
+ { sortType: sort, params }
|
|
|
130
|
+ )
|
|
118
|
131
|
}
|
|
119
|
132
|
},
|
|
120
|
133
|
async checkAndSetHero(type) {
|
|
|
@@ -173,7 +186,7 @@ export default {
|
|
173
|
186
|
sort = null
|
|
174
|
187
|
}
|
|
175
|
188
|
|
|
176
|
|
- if (!this[`all${type}Loaded`] || sort) this.getPosts()
|
|
|
189
|
+ if (!this[`all${type}Loaded`] || sort) this.getPosts(true)
|
|
177
|
190
|
},
|
|
178
|
191
|
},
|
|
179
|
192
|
mounted() {
|
|
|
@@ -187,7 +200,7 @@ export default {
|
|
187
|
200
|
|
|
188
|
201
|
// We also need to check if only ONE has been loaded because
|
|
189
|
202
|
// coming from the homepage there will only be 1 item
|
|
190
|
|
- if (!this[`all${type}Loaded`] || this[`all${type}`].length < 2) this.getPosts()
|
|
|
203
|
+ if (!this[`all${type}Loaded`] || this[`all${type}`].length < 2) this.getPosts(true)
|
|
191
|
204
|
},
|
|
192
|
205
|
}
|
|
193
|
206
|
</script>
|