|
50 | 50 | <transition-group name="fade_scale_list" tag='tbody'> |
51 | 51 | <a17-bucket-item v-for="(child, index) in bucket.children" :key="`${child.id}_${index}`" :item="child" |
52 | 52 | :restricted="restricted" :draggable="bucket.children.length > 1" |
| 53 | + :sourceLabels="sourceLabels" |
53 | 54 | :singleBucket="singleBucket" :singleSource="singleSource" :bucket="bucket.id" |
54 | 55 | :buckets="buckets" v-on:add-to-bucket="addToBucket" |
55 | 56 | v-on:remove-from-bucket="deleteFromBucket" |
|
120 | 121 | // Optionnal additionnal actions showing up after the Publish button |
121 | 122 | extraActions: { |
122 | 123 | type: Array, |
123 | | - default: function () { return [] } |
| 124 | + default() { return [] } |
124 | 125 | } |
125 | 126 | }, |
126 | 127 | components: { |
|
132 | 133 | 'a17-vselect': VSelect, |
133 | 134 | draggable |
134 | 135 | }, |
135 | | - data: function () { |
| 136 | + data() { |
136 | 137 | return { |
137 | 138 | currentBucketID: '', |
138 | 139 | currentItem: '', |
|
152 | 153 | ...mapGetters([ |
153 | 154 | 'currentSource' |
154 | 155 | ]), |
155 | | - singleBucket: function () { |
| 156 | + sourceLabels() { |
| 157 | + const labels = {}; |
| 158 | + this.dataSources.forEach((source) => { |
| 159 | + labels[source.type] = source.label; |
| 160 | + }) |
| 161 | + return labels; |
| 162 | + }, |
| 163 | + singleBucket() { |
156 | 164 | return this.buckets.length === 1 |
157 | 165 | }, |
158 | | - singleSource: function () { |
| 166 | + singleSource() { |
159 | 167 | return this.dataSources.length === 1 |
160 | 168 | }, |
161 | | - overrideBucketText: function () { |
| 169 | + overrideBucketText() { |
162 | 170 | const bucket = this.buckets.find(b => b.id === this.currentBucketID) |
163 | 171 | let bucketName = '' |
164 | 172 | let bucketSize = '' |
|
170 | 178 | } |
171 | 179 | }, |
172 | 180 | methods: { |
173 | | - addToBucket: function (item, bucket) { |
| 181 | + addToBucket(item, bucket) { |
174 | 182 | const index = this.buckets.findIndex(b => b.id === bucket) |
175 | 183 |
|
176 | 184 | if (!item && index === -1) return |
|
188 | 196 |
|
189 | 197 | if (count > -1 && count < this.buckets[index].max) { |
190 | 198 | // Commit before dispatch to prevent ui visual effect timeout |
191 | | - this.checkRestriced(item) |
| 199 | + this.checkRestricted(item) |
192 | 200 | this.$store.commit(BUCKETS.ADD_TO_BUCKET, data) |
193 | 201 | } else if (this.overridableMax || this.overrideItem) { |
194 | | - this.checkRestriced(item) |
| 202 | + this.checkRestricted(item) |
195 | 203 | this.$store.commit(BUCKETS.ADD_TO_BUCKET, data) |
196 | 204 | this.$store.commit(BUCKETS.DELETE_FROM_BUCKET, { index, itemIndex: 0 }) |
197 | 205 | this.overrideItem = false |
198 | 206 | } else { |
199 | 207 | this.$refs.overrideBucket.open() |
200 | 208 | } |
201 | 209 | }, |
202 | | - deleteFromBucket: function (item, bucket) { |
| 210 | + deleteFromBucket(item, bucket) { |
203 | 211 | const bucketIndex = this.buckets.findIndex(b => b.id === bucket) |
204 | 212 | if (bucketIndex === -1) return |
205 | 213 |
|
206 | | - const itemIndex = this.buckets[bucketIndex].children.findIndex(c => c.id === item.id && c.content_type.value === item.content_type.value) |
| 214 | + const itemIndex = this.buckets[bucketIndex].children.findIndex(c => c.id === item.id && c.type === item.type) |
207 | 215 |
|
208 | 216 | if (itemIndex === -1) return |
209 | 217 |
|
|
213 | 221 | } |
214 | 222 | this.$store.commit(BUCKETS.DELETE_FROM_BUCKET, data) |
215 | 223 | }, |
216 | | - toggleFeaturedInBucket: function (item, bucket) { |
| 224 | + toggleFeaturedInBucket(item, bucket) { |
217 | 225 | const bucketIndex = this.buckets.findIndex(b => b.id === bucket) |
218 | 226 | if (bucketIndex === -1) return |
219 | 227 |
|
220 | | - const itemIndex = this.buckets[bucketIndex].children.findIndex(c => c.id === item.id && c.content_type.value === item.content_type.value) |
| 228 | + const itemIndex = this.buckets[bucketIndex].children.findIndex(c => c.id === item.id && c.type === item.type) |
221 | 229 |
|
222 | 230 | if (itemIndex === -1) return |
223 | 231 |
|
|
228 | 236 |
|
229 | 237 | this.$store.commit(BUCKETS.TOGGLE_FEATURED_IN_BUCKET, data) |
230 | 238 | }, |
231 | | - checkRestriced: function (item) { |
| 239 | + checkRestricted(item) { |
232 | 240 | // Remove item from each bucket if option restricted to one bucket is active |
233 | 241 | if (this.restricted) { |
234 | 242 | this.buckets.forEach((bucket) => { |
235 | 243 | bucket.children.forEach((child) => { |
236 | | - if (child.id === item.id && child.content_type.value === item.content_type.value) { |
| 244 | + if (child.id === item.id && child.type === item.type) { |
237 | 245 | this.deleteFromBucket(item, bucket.id) |
238 | 246 | } |
239 | 247 | }) |
240 | 248 | }) |
241 | 249 | } |
242 | 250 | }, |
243 | | - sortBucket: function (evt, index) { |
| 251 | + sortBucket(evt, index) { |
244 | 252 | const data = { |
245 | 253 | bucketIndex: index, |
246 | 254 | oldIndex: evt.moved.oldIndex, |
247 | 255 | newIndex: evt.moved.newIndex |
248 | 256 | } |
249 | 257 | this.$store.commit(BUCKETS.REORDER_BUCKET_LIST, data) |
250 | 258 | }, |
251 | | - changeDataSource: function (value) { |
| 259 | + changeDataSource(value) { |
252 | 260 | this.$store.commit(BUCKETS.UPDATE_BUCKETS_DATASOURCE, value) |
253 | 261 | this.$store.commit(BUCKETS.UPDATE_BUCKETS_DATA_PAGE, 1) |
254 | 262 | this.$store.dispatch(ACTIONS.GET_BUCKETS) |
255 | 263 | }, |
256 | | - filterBucketsData: function (formData) { |
| 264 | + filterBucketsData(formData) { |
257 | 265 | this.$store.commit(BUCKETS.UPDATE_BUCKETS_DATA_PAGE, 1) |
258 | 266 | this.$store.commit(BUCKETS.UPDATE_BUCKETS_FILTER, formData || { search: '' }) |
259 | 267 | // reload datas |
260 | 268 | this.$store.dispatch(ACTIONS.GET_BUCKETS) |
261 | 269 | }, |
262 | | - updateOffset: function (value) { |
| 270 | + updateOffset(value) { |
263 | 271 | this.$store.commit(BUCKETS.UPDATE_BUCKETS_DATA_PAGE, 1) |
264 | 272 | this.$store.commit(BUCKETS.UPDATE_BUCKETS_DATA_OFFSET, value) |
265 | 273 |
|
266 | 274 | // reload datas |
267 | 275 | this.$store.dispatch(ACTIONS.GET_BUCKETS) |
268 | 276 | }, |
269 | | - updatePage: function (value) { |
| 277 | + updatePage(value) { |
270 | 278 | this.$store.commit(BUCKETS.UPDATE_BUCKETS_DATA_PAGE, value) |
271 | 279 | // reload datas |
272 | 280 | this.$store.dispatch(ACTIONS.GET_BUCKETS) |
273 | 281 | }, |
274 | | - override: function () { |
| 282 | + override() { |
275 | 283 | this.overrideItem = true |
276 | 284 | this.addToBucket(this.currentItem, this.currentBucketID) |
277 | 285 | this.$refs.overrideBucket.close() |
278 | 286 | }, |
279 | | - save: function () { |
| 287 | + save() { |
280 | 288 | this.$store.dispatch(ACTIONS.SAVE_BUCKETS) |
281 | 289 | } |
282 | 290 | } |
|
0 commit comments