Bläddra i källkod

:poop: found this uncommited code

tags/0.9.0
j 5 år sedan
förälder
incheckning
fc0311ec32

+ 20
- 4
vue-theme/src/components/gallery.vue Visa fil

1
 <template lang="pug">
1
 <template lang="pug">
2
 .gallery.active.f-col.center
2
 .gallery.active.f-col.center
3
     button(@click="hideGallery").hide hide
3
     button(@click="hideGallery").hide hide
4
-    p {{ imageIds }}
5
-    p image: {{ imageIds[selected] }}
4
+    
5
+    .wrap(v-if="allMediaLoaded")
6
+        p image: {{ imageIds[activeImageIndex] }}
7
+        p {{ imageIds }}
8
+        p {{ allMedia }}
9
+    .loading(v-else)
10
+        p loading...
11
+
6
     ul
12
     ul
7
         li(v-for="(image, i) of images" :class="{ active: i === selected }")
13
         li(v-for="(image, i) of images" :class="{ active: i === selected }")
8
             .image-wrapper.f-col.center
14
             .image-wrapper.f-col.center
14
 </template>
20
 </template>
15
 
21
 
16
 <script>
22
 <script>
23
+import { mapGetters } from 'vuex'
24
+
17
 export default {
25
 export default {
18
     props: {
26
     props: {
19
         imageIds: { type: Array, required: true },
27
         imageIds: { type: Array, required: true },
25
             selected: -1
33
             selected: -1
26
         }
34
         }
27
     },
35
     },
36
+    computed: {
37
+        ...mapGetters({
38
+            allMedia: 'allMedia',
39
+            allMediaLoaded: 'allMediaLoaded',
40
+        })
41
+    },
28
     methods: {
42
     methods: {
29
         prev() {
43
         prev() {
30
             this.selected > 0 ? this.selected-- : this.selected = this.imageIds.length - 1
44
             this.selected > 0 ? this.selected-- : this.selected = this.imageIds.length - 1
54
             this.selected = newVal
68
             this.selected = newVal
55
         }
69
         }
56
     },
70
     },
57
-    mounted() {
71
+    async mounted() {
58
         // Set the first selection
72
         // Set the first selection
59
         this.selected = this.activeImageIndex
73
         this.selected = this.activeImageIndex
60
-
74
+        this.$store.dispatch(`getMediaById`, this.imageIds)
61
         window.addEventListener('keydown', this.interpretKeypress)
75
         window.addEventListener('keydown', this.interpretKeypress)
62
     },
76
     },
63
     unmounted() {
77
     unmounted() {
68
 
82
 
69
 <style lang="postcss">
83
 <style lang="postcss">
70
 .gallery
84
 .gallery
85
+    .wrap
86
+        width: 60vw
71
     &.active
87
     &.active
72
         position: fixed
88
         position: fixed
73
         top: 0
89
         top: 0

+ 6
- 6
vue-theme/src/pages/single.vue Visa fil

28
                     //- Just a regular block
28
                     //- Just a regular block
29
                     .block(v-else v-html="block")
29
                     .block(v-else v-html="block")
30
 
30
 
31
-    //- sidebar(v-if="sidebar" :type="`${type}`")
32
-    //-     .shadow
33
-    //-         h1.t-up single slot
34
-    //-         div
35
-    //-             p body whatever
31
+    sidebar(v-if="sidebar" :type="`${type}`")
32
+        .shadow
33
+            h1.t-up single slot
34
+            div
35
+                p body whatever
36
 </template>
36
 </template>
37
 
37
 
38
 <script>
38
 <script>
96
         },
96
         },
97
         checkAndSetHero(posts) {
97
         checkAndSetHero(posts) {
98
             const post = posts[this.$route.params.slug]
98
             const post = posts[this.$route.params.slug]
99
-            if(!post || ! post.hero) return
99
+            if(!post || !post.hero) return
100
 
100
 
101
             const json = JSON.parse(post.hero)
101
             const json = JSON.parse(post.hero)
102
             this.$store.commit('SET_HERO', json)
102
             this.$store.commit('SET_HERO', json)

+ 8
- 5
vue-theme/src/store/modules/media.js Visa fil

6
 }
6
 }
7
 
7
 
8
 const getters = {
8
 const getters = {
9
-    allArtists: state => state.all,
10
-    allArtistsLoaded: state => state.loaded,
9
+    allMedia: state => state.all,
10
+    allMediaLoaded: state => state.loaded,
11
 }
11
 }
12
 
12
 
13
 const actions = {
13
 const actions = {
14
-    getMediaById({ commit }, ids) {
14
+    async getMediaById({ commit }, ids) {
15
         commit('CLEAR_MEDIA')
15
         commit('CLEAR_MEDIA')
16
         commit('MEDIA_LOADED', false)
16
         commit('MEDIA_LOADED', false)
17
-        ids.forEach(id => {
18
-            api.getSingleMedia(id, media => {
17
+        
18
+        const p = ids.map(async id => {
19
+            return await api.getSingleMedia(id, media => {
19
                 commit('STORE_FETCHED_MEDIA', { media })
20
                 commit('STORE_FETCHED_MEDIA', { media })
20
             })
21
             })
21
         })
22
         })
23
+        console.log(p)
24
+        await Promise.all(p)
22
         commit('MEDIA_LOADED', true) 
25
         commit('MEDIA_LOADED', true) 
23
     }
26
     }
24
 }
27
 }

+ 1
- 1
vue-theme/src/utils/api.js Visa fil

20
             }).catch(e => { cb(e) })
20
             }).catch(e => { cb(e) })
21
         }
21
         }
22
     },
22
     },
23
-    getSingleMedia(id) {
23
+    getSingleMedia(id, cb) {
24
         axios.get(SETTINGS.API_MEDIA_PATH + `${id}`).then(response => {
24
         axios.get(SETTINGS.API_MEDIA_PATH + `${id}`).then(response => {
25
             cb(response.data)
25
             cb(response.data)
26
         }).catch(e => { cb(e) })
26
         }).catch(e => { cb(e) })

Laddar…
Avbryt
Spara