Bläddra i källkod

:recycle: loading all artists on material sort

tags/0.9.0
J 4 år sedan
förälder
incheckning
0b8306ff26

+ 1
- 0
plugins/cia-endpoints/includes/class.make-sortby.php Visa fil

34
         }
34
         }
35
         
35
         
36
         if($this->post_type == 'artist') {
36
         if($this->post_type == 'artist') {
37
+            $tax_id_array = [3, 4, 5, 6, 7, 8];
37
             $tax_id_array = explode( ',', $params['materials'] );
38
             $tax_id_array = explode( ',', $params['materials'] );
38
             // 3 clay
39
             // 3 clay
39
             // 4 fiber
40
             // 4 fiber

+ 6
- 2
vue-theme/src/pages/list.vue Visa fil

33
 import sidebar from '@/components/sidebars/sidebar'
33
 import sidebar from '@/components/sidebars/sidebar'
34
 import { postTypeGetters, scrollTop, heroUtils } from './mixin-post-types'
34
 import { postTypeGetters, scrollTop, heroUtils } from './mixin-post-types'
35
 
35
 
36
-import { postTypes, convertTitleCase, typeFromRoute } from '@/utils/helpers'
36
+import { postTypes, sortTypes, convertTitleCase, typeFromRoute } from '@/utils/helpers'
37
 
37
 
38
 const TIMEOUT = 1
38
 const TIMEOUT = 1
39
 const INTERSECT_SELECTOR = '.page--list > article footer'
39
 const INTERSECT_SELECTOR = '.page--list > article footer'
117
             await this._getAll('episode', this.$store)
117
             await this._getAll('episode', this.$store)
118
             const ignore = [`getMoreEpisodes`, 'getMorePages']
118
             const ignore = [`getMoreEpisodes`, 'getMorePages']
119
 
119
 
120
-            const dispatchAction = `getMore${this.pType}`
120
+            let dispatchAction = `getMore${this.pType}`
121
+            if(this._getSortBy() == sortTypes.material && this.type == 'artist') {
122
+                dispatchAction = `getAll${this.pType}`
123
+            }
124
+            
121
             let res = null
125
             let res = null
122
             if(this.pType && !ignore.includes(dispatchAction)) {
126
             if(this.pType && !ignore.includes(dispatchAction)) {
123
                 res = await this.$store.dispatch(
127
                 res = await this.$store.dispatch(

+ 17
- 0
vue-theme/src/store/modules/artist.js Visa fil

1
 import api from '../../utils/api'
1
 import api from '../../utils/api'
2
+import { sortTypes } from '../../utils/helpers'
2
 
3
 
3
 const state = {
4
 const state = {
4
     all: [],
5
     all: [],
16
     allArtistsLoaded: state => state.loaded,
17
     allArtistsLoaded: state => state.loaded,
17
 }
18
 }
18
 
19
 
20
+const _arrangeByMaterial = artistsList => {
21
+    byMaterial = {}
22
+    artistsList.forEach(artist => {
23
+        artist.materials.forEach(mat => {
24
+            if(!byMaterial[mat]) byMaterial[mat] = []
25
+            byMaterial[mat].push(artist)
26
+        })
27
+    })
28
+    console.log(byMaterial)
29
+    return Object.values(byMaterial).flat()
30
+}
31
+
19
 const actions = {
32
 const actions = {
20
     getAllArtists({ commit }, { sortType, params }) {
33
     getAllArtists({ commit }, { sortType, params }) {
21
         commit('CLEAR_ARTISTS')
34
         commit('CLEAR_ARTISTS')
22
         commit('ARTISTS_LOADED', false)
35
         commit('ARTISTS_LOADED', false)
23
         const storeFetch = (artists => {
36
         const storeFetch = (artists => {
37
+            let repacked = artists
38
+            if(sortType == sortTypes.material) {
39
+                repacked = _arrangeByMaterial(artists)
40
+            }
24
             commit('STORE_FETCHED_ARTISTS', { artists })
41
             commit('STORE_FETCHED_ARTISTS', { artists })
25
             commit('ARTISTS_LOADED', true)
42
             commit('ARTISTS_LOADED', true)
26
         })
43
         })

Laddar…
Avbryt
Spara