Explorar el Código

:recycle: loading all artists on material sort

tags/0.9.0
J hace 4 años
padre
commit
0b8306ff26

+ 1
- 0
plugins/cia-endpoints/includes/class.make-sortby.php Ver fichero

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

+ 6
- 2
vue-theme/src/pages/list.vue Ver fichero

@@ -33,7 +33,7 @@ import card from '@/components/card'
33 33
 import sidebar from '@/components/sidebars/sidebar'
34 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 38
 const TIMEOUT = 1
39 39
 const INTERSECT_SELECTOR = '.page--list > article footer'
@@ -117,7 +117,11 @@ export default {
117 117
             await this._getAll('episode', this.$store)
118 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 125
             let res = null
122 126
             if(this.pType && !ignore.includes(dispatchAction)) {
123 127
                 res = await this.$store.dispatch(

+ 17
- 0
vue-theme/src/store/modules/artist.js Ver fichero

@@ -1,4 +1,5 @@
1 1
 import api from '../../utils/api'
2
+import { sortTypes } from '../../utils/helpers'
2 3
 
3 4
 const state = {
4 5
     all: [],
@@ -16,11 +17,27 @@ const getters = {
16 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 32
 const actions = {
20 33
     getAllArtists({ commit }, { sortType, params }) {
21 34
         commit('CLEAR_ARTISTS')
22 35
         commit('ARTISTS_LOADED', false)
23 36
         const storeFetch = (artists => {
37
+            let repacked = artists
38
+            if(sortType == sortTypes.material) {
39
+                repacked = _arrangeByMaterial(artists)
40
+            }
24 41
             commit('STORE_FETCHED_ARTISTS', { artists })
25 42
             commit('ARTISTS_LOADED', true)
26 43
         })

Loading…
Cancelar
Guardar