Sfoglia il codice sorgente

:sparkles: repacking by subtype for artist module

tags/0.9.0
J 4 anni fa
parent
commit
feac472c74
1 ha cambiato i file con 20 aggiunte e 1 eliminazioni
  1. 20
    1
      vue-theme/src/store/modules/artist.js

+ 20
- 1
vue-theme/src/store/modules/artist.js Vedi File

37
     return flatPacked
37
     return flatPacked
38
 }
38
 }
39
 
39
 
40
+const _arrangeByType = artistsList => {
41
+    const byType = {}
42
+    artistsList.forEach(artist => {
43
+        const subtypes = artist.subtypes
44
+        subtypes.forEach(type => {
45
+            if(!byType[type]) byType[type] = []
46
+            byType[type].push(artist)
47
+        })
48
+    })
49
+    const flatPacked = []
50
+    Object.keys(byType).forEach(type => {
51
+        flatPacked.push({ slug: type, title: type, inbetween: true })
52
+        byType[type].forEach(artist => flatPacked.push(artist))
53
+    })
54
+    console.log('flatPacked :', flatPacked)
55
+    return flatPacked
56
+}
57
+
40
 const _arrangeByAlpha = artistsList => {
58
 const _arrangeByAlpha = artistsList => {
41
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
59
     const alphabet = [...'9abcdefghijklmnopqrstuvwxyz']
42
     const flatPacked = []
60
     const flatPacked = []
71
         flatPacked.push({ slug: episode, title: episode, inbetween: true })
89
         flatPacked.push({ slug: episode, title: episode, inbetween: true })
72
         byEpisode[episode].forEach(artist => flatPacked.push(artist))
90
         byEpisode[episode].forEach(artist => flatPacked.push(artist))
73
     })
91
     })
74
-    console.log('flatPacked :', flatPacked)
75
     return flatPacked
92
     return flatPacked
76
 }
93
 }
77
 
94
 
85
                 repacked = _arrangeByMaterial(artists)
102
                 repacked = _arrangeByMaterial(artists)
86
             } else if(sortType == sortTypes.episode) {
103
             } else if(sortType == sortTypes.episode) {
87
                 repacked = _arrangeByEpisode(artists)
104
                 repacked = _arrangeByEpisode(artists)
105
+            } else if(sortType == sortTypes.subtype) {
106
+                repacked = _arrangeByType(artists)
88
             }
107
             }
89
             commit('STORE_FETCHED_ARTISTS', { artists: repacked })
108
             commit('STORE_FETCHED_ARTISTS', { artists: repacked })
90
             commit('ARTISTS_LOADED', true)
109
             commit('ARTISTS_LOADED', true)

Loading…
Annulla
Salva