Quellcode durchsuchen

:recycle: consolidating some module code

tags/0.9.0
J vor 4 Jahren
Ursprung
Commit
fc51bcf09a

+ 8
- 0
vue-theme/src/store/modules/arrangements.js Datei anzeigen

82
     return repacked
82
     return repacked
83
 }
83
 }
84
 
84
 
85
+const allBySlug = state => {
86
+    return Object.values(state.all).reduce((bySlug, post) => {
87
+        bySlug[post.slug] = post
88
+        return bySlug
89
+    }, {})
90
+}
91
+
85
 export {
92
 export {
93
+    allBySlug,
86
     repackBySort,
94
     repackBySort,
87
     _arrangeByMaterial,
95
     _arrangeByMaterial,
88
     _arrangeByType,
96
     _arrangeByType,

+ 2
- 6
vue-theme/src/store/modules/artist.js Datei anzeigen

1
 import api from '../../utils/api'
1
 import api from '../../utils/api'
2
 import { sortTypes } from '../../utils/helpers'
2
 import { sortTypes } from '../../utils/helpers'
3
-import { repackBySort } from './arrangements'
3
+import { allBySlug, repackBySort } from './arrangements'
4
 
4
 
5
 const state = {
5
 const state = {
6
     all: [],
6
     all: [],
11
 
11
 
12
 const getters = {
12
 const getters = {
13
     allArtists: state => state.all,
13
     allArtists: state => state.all,
14
-    allArtistsBySlug: state =>
15
-        Object.values(state.all).reduce((bySlug, artist) => {
16
-            bySlug[artist.slug] = artist
17
-            return bySlug
18
-        }, {}),
14
+    allArtistsBySlug: state => allBySlug(state),
19
     allArtistsLoaded: state => state.loaded,
15
     allArtistsLoaded: state => state.loaded,
20
 }
16
 }
21
 
17
 

+ 2
- 5
vue-theme/src/store/modules/episode.js Datei anzeigen

1
 import api from '../../utils/api'
1
 import api from '../../utils/api'
2
+import { allBySlug } from './arrangements'
2
 
3
 
3
 const state = {
4
 const state = {
4
     all: [],
5
     all: [],
8
 
9
 
9
 const getters = {
10
 const getters = {
10
     allEpisodes: state => state.all,
11
     allEpisodes: state => state.all,
11
-    allEpisodesBySlug: state =>
12
-        Object.values(state.all).reduce((bySlug, episode) => {
13
-            bySlug[episode.slug] = episode
14
-            return bySlug
15
-        }, {}),
12
+    allEpisodesBySlug: state => allBySlug(state),
16
     allEpisodesLoaded: state => state.loaded,
13
     allEpisodesLoaded: state => state.loaded,
17
 }
14
 }
18
 
15
 

+ 2
- 7
vue-theme/src/store/modules/guide.js Datei anzeigen

1
 import api from '../../utils/api'
1
 import api from '../../utils/api'
2
-import { sortTypes } from '../../utils/helpers'
3
-import { repackBySort } from './arrangements'
2
+import { allBySlug, repackBySort } from './arrangements'
4
 
3
 
5
 const state = {
4
 const state = {
6
     all: [],
5
     all: [],
10
 
9
 
11
 const getters = {
10
 const getters = {
12
     allGuides: state => state.all,
11
     allGuides: state => state.all,
13
-    allGuidesBySlug: state =>
14
-        Object.values(state.all).reduce((bySlug, guide) => {
15
-            bySlug[guide.slug] = guide
16
-            return bySlug
17
-        }, {}),
12
+    allGuidesBySlug: state => allBySlug(state),
18
     allGuidesLoaded: state => state.loaded,
13
     allGuidesLoaded: state => state.loaded,
19
 }
14
 }
20
 
15
 

+ 3
- 6
vue-theme/src/store/modules/object.js Datei anzeigen

1
 import api from '../../utils/api'
1
 import api from '../../utils/api'
2
+import { allBySlug, repackBySort } from './arrangements'
2
 
3
 
3
 const state = {
4
 const state = {
4
     all: [],
5
     all: [],
8
 
9
 
9
 const getters = {
10
 const getters = {
10
     allObjects: state => state.all,
11
     allObjects: state => state.all,
11
-    allObjectsBySlug: state =>
12
-        Object.values(state.all).reduce((bySlug, object) => {
13
-            bySlug[object.slug] = object
14
-            return bySlug
15
-        }, {}),
12
+    allObjectsBySlug: state => allBySlug(state),
16
     allObjectsLoaded: state => state.loaded,
13
     allObjectsLoaded: state => state.loaded,
17
 }
14
 }
18
 
15
 
21
         commit('CLEAR_OBJECTS')
18
         commit('CLEAR_OBJECTS')
22
         commit('OBJECTS_LOADED', false)
19
         commit('OBJECTS_LOADED', false)
23
         const storeFetch = (objects => {
20
         const storeFetch = (objects => {
24
-            let repacked = objects
21
+            let repacked = repackBySort(objects, sortType)
25
             commit('STORE_FETCHED_OBJECTS', { objects: repacked })
22
             commit('STORE_FETCHED_OBJECTS', { objects: repacked })
26
             commit('OBJECTS_LOADED', true)
23
             commit('OBJECTS_LOADED', true)
27
         })
24
         })

+ 3
- 6
vue-theme/src/store/modules/publication.js Datei anzeigen

1
 import api from '../../utils/api'
1
 import api from '../../utils/api'
2
+import { allBySlug, repackBySort } from './arrangements'
2
 
3
 
3
 const state = {
4
 const state = {
4
     all: [],
5
     all: [],
8
 
9
 
9
 const getters = {
10
 const getters = {
10
     allPublications: state => state.all,
11
     allPublications: state => state.all,
11
-    allPublicationsBySlug: state =>
12
-        Publication.values(state.all).reduce((bySlug, publication) => {
13
-            bySlug[publication.slug] = publication
14
-            return bySlug
15
-        }, {}),
12
+    allPublicationsBySlug: state => allBySlug(state),
16
     allPublicationsLoaded: state => state.loaded,
13
     allPublicationsLoaded: state => state.loaded,
17
 }
14
 }
18
 
15
 
21
         commit('CLEAR_PUBLICATIONS')
18
         commit('CLEAR_PUBLICATIONS')
22
         commit('PUBLICATIONS_LOADED', false)
19
         commit('PUBLICATIONS_LOADED', false)
23
         const storeFetch = (publications => {
20
         const storeFetch = (publications => {
24
-            let repacked = publications
21
+            let repacked = repackBySort(publications, sortType)
25
             commit('STORE_FETCHED_PUBLICATIONS', { publications: repacked })
22
             commit('STORE_FETCHED_PUBLICATIONS', { publications: repacked })
26
             commit('PUBLICATIONS_LOADED', true)
23
             commit('PUBLICATIONS_LOADED', true)
27
         })
24
         })

+ 2
- 6
vue-theme/src/store/modules/short.js Datei anzeigen

1
 import api from '../../utils/api'
1
 import api from '../../utils/api'
2
-import { repackBySort } from './arrangements'
2
+import { allBySlug, repackBySort } from './arrangements'
3
 
3
 
4
 const state = {
4
 const state = {
5
     all: [],
5
     all: [],
9
 
9
 
10
 const getters = {
10
 const getters = {
11
     allShorts: state => state.all,
11
     allShorts: state => state.all,
12
-    allShortsBySlug: state =>
13
-        Object.values(state.all).reduce((bySlug, short) => {
14
-            bySlug[short.slug] = short
15
-            return bySlug
16
-        }, {}),
12
+    allShortsBySlug: state => allBySlug(state),
17
     allShortsLoaded: state => state.loaded,
13
     allShortsLoaded: state => state.loaded,
18
 }
14
 }
19
 
15
 

+ 2
- 6
vue-theme/src/store/modules/technique.js Datei anzeigen

1
 import api from '../../utils/api'
1
 import api from '../../utils/api'
2
-import { repackBySort } from './arrangements'
2
+import { allBySlug, repackBySort } from './arrangements'
3
 
3
 
4
 const state = {
4
 const state = {
5
     all: [],
5
     all: [],
9
 
9
 
10
 const getters = {
10
 const getters = {
11
     allTechniques: state => state.all,
11
     allTechniques: state => state.all,
12
-    allTechniquesBySlug: state =>
13
-        Object.values(state.all).reduce((bySlug, technique) => {
14
-            bySlug[technique.slug] = technique
15
-            return bySlug
16
-        }, {}),
12
+    allTechniquesBySlug: state => allBySlug(state),
17
     allTechniquesLoaded: state => state.loaded,
13
     allTechniquesLoaded: state => state.loaded,
18
 }
14
 }
19
 
15
 

Laden…
Abbrechen
Speichern