|
|
@@ -1,5 +1,5 @@
|
|
1
|
1
|
<template lang="pug">
|
|
2
|
|
-.page--single.f-row.between(v-if="allPostsLoaded && allPagesLoaded && allArtistsLoaded && allEpisodesLoaded")
|
|
|
2
|
+.page--single.f-row.between
|
|
3
|
3
|
gallery(:fullscreengallery="fullscreengallery" v-on:close="fullscreengallery = -1" :images="images")
|
|
4
|
4
|
article.f-grow.shadow
|
|
5
|
5
|
header
|
|
|
@@ -49,6 +49,14 @@ export default {
|
|
49
|
49
|
allEpisodes: 'allEpisodes',
|
|
50
|
50
|
allEpisodesLoaded: 'allEpisodesLoaded',
|
|
51
|
51
|
}),
|
|
|
52
|
+ allLoaded() {
|
|
|
53
|
+ const flags = []
|
|
|
54
|
+ flags.push(this.allPagesLoaded)
|
|
|
55
|
+ flags.push(this.allPostsLoaded)
|
|
|
56
|
+ flags.push(this.allArtistsLoaded)
|
|
|
57
|
+ flags.push(this.allEpisodesLoaded)
|
|
|
58
|
+ return flags.every(Boolean)
|
|
|
59
|
+ },
|
|
52
|
60
|
type() { // Checks for type and fixes Episodes route edge case
|
|
53
|
61
|
return this.$route.params.type ? this.$route.params.type : this.$route.fullPath.slice(1)
|
|
54
|
62
|
},
|
|
|
@@ -64,15 +72,14 @@ export default {
|
|
64
|
72
|
},
|
|
65
|
73
|
methods: {
|
|
66
|
74
|
pageBlocks(posts) {
|
|
67
|
|
- console.log('block for: ', this.posts)
|
|
68
|
|
- console.log(this.$route.params.slug)
|
|
|
75
|
+ if(this.images.length < 1) return []
|
|
69
|
76
|
return posts[this.$route.params.slug].blocks.map(block => {
|
|
70
|
77
|
if(block) return block
|
|
71
|
78
|
})
|
|
72
|
79
|
},
|
|
73
|
80
|
checkForImages(posts) {
|
|
74
|
|
- if(Object.keys(posts).length === 0) return
|
|
75
|
|
- console.log(posts)
|
|
|
81
|
+ if(Object.keys(posts).length == 0) return
|
|
|
82
|
+
|
|
76
|
83
|
this.pageBlocks(posts).forEach(block => {
|
|
77
|
84
|
if(!block) return
|
|
78
|
85
|
|
|
|
@@ -96,7 +103,7 @@ export default {
|
|
96
|
103
|
}
|
|
97
|
104
|
},
|
|
98
|
105
|
watch: {
|
|
99
|
|
- posts(newVal, oldVal) {
|
|
|
106
|
+ posts(newVal, oldVal) {
|
|
100
|
107
|
// Loads images from the DOM
|
|
101
|
108
|
this.checkForImages(newVal)
|
|
102
|
109
|
|
|
|
@@ -104,13 +111,13 @@ export default {
|
|
104
|
111
|
|
|
105
|
112
|
// Gottas be on the next render tick
|
|
106
|
113
|
this.$nextTick(() => {
|
|
|
114
|
+ const blocks = this.pageBlocks(newVal)
|
|
107
|
115
|
let gallery
|
|
108
|
|
- this.pageBlocks(newVal).forEach(block => {
|
|
109
|
|
- if(!block) return
|
|
|
116
|
+ blocks.forEach(block => {
|
|
110
|
117
|
gallery = document.querySelectorAll('.blocks-gallery-item figure')
|
|
111
|
118
|
})
|
|
112
|
119
|
|
|
113
|
|
- if(gallery.length < 1) return
|
|
|
120
|
+ if(!gallery || gallery.length < 1) return
|
|
114
|
121
|
|
|
115
|
122
|
gallery.forEach((item, i) => {
|
|
116
|
123
|
item.addEventListener('mouseup', event => { this.fullscreengallery = i })
|
|
|
@@ -120,10 +127,12 @@ export default {
|
|
120
|
127
|
}
|
|
121
|
128
|
},
|
|
122
|
129
|
created() {
|
|
123
|
|
- // TODO: Only makes req if this hasn't been loaded yet
|
|
124
|
|
- let type = this.$route.params.type
|
|
125
|
|
- type = type.charAt(0).toUpperCase() + type.slice(1)
|
|
126
|
|
- this.$store.dispatch(`getAll${type}`)
|
|
|
130
|
+ if(!this.allLoaded) {
|
|
|
131
|
+ let type = this.$route.params.type
|
|
|
132
|
+ type = type.charAt(0).toUpperCase() + type.slice(1)
|
|
|
133
|
+ console.log('retrieving...', type)
|
|
|
134
|
+ this.$store.dispatch(`getAll${type}`)
|
|
|
135
|
+ }
|
|
127
|
136
|
}
|
|
128
|
137
|
}
|
|
129
|
138
|
</script>
|