Просмотр исходного кода

:sparkles: adding flatpack titles for artist by episodes

tags/0.9.0
J 4 лет назад
Родитель
Сommit
8d80729ecb

+ 1
- 0
vue-theme/src/components/sidebars/sidebar.vue Просмотреть файл

@@ -117,6 +117,7 @@ export default {
117 117
                 case 'artist':
118 118
                     opts = [
119 119
                         Object.keys(this.sortTypes)[0],
120
+                        Object.keys(this.sortTypes)[3],
120 121
                         Object.keys(this.sortTypes)[1],
121 122
                         Object.keys(this.sortTypes)[4],
122 123
                     ]

+ 3
- 1
vue-theme/src/pages/list.vue Просмотреть файл

@@ -82,7 +82,9 @@ export default {
82 82
             return this[`all${this.pType}`]
83 83
         },
84 84
         shouldLoadAllAtOnce() {
85
-            return this.type == 'episode' || this.type == 'artist' && this.sortBy == sortTypes.material
85
+            return this.type == 'episode' ||
86
+                this.type == 'artist' && this.sortBy == sortTypes.material ||
87
+                this.type == 'artist' && this.sortBy == sortTypes.episode
86 88
         }
87 89
     },
88 90
     methods: {

+ 19
- 0
vue-theme/src/store/modules/artist.js Просмотреть файл

@@ -59,6 +59,23 @@ const _arrangeByAlpha = artistsList => {
59 59
     return flatPacked
60 60
 }
61 61
 
62
+const _arrangeByEpisode = artistsList => {
63
+    const byEpisode = {}
64
+    artistsList.forEach(artist => {
65
+        const relatedEpisode = artist.related_episode
66
+        if(!Object.keys(byEpisode).includes(relatedEpisode)) {
67
+            byEpisode[relatedEpisode] = []
68
+        }
69
+        byEpisode[relatedEpisode].push(artist)
70
+    })
71
+    const flatPacked = []
72
+    Object.keys(byEpisode).forEach(episode => {
73
+        flatPacked.push({ slug: byEpisode, title: byEpisode, inbetween: true })
74
+        byEpisode[episode].forEach(artist => flatPacked.push(artist))
75
+    })
76
+    return flatPacked
77
+}
78
+
62 79
 const actions = {
63 80
     getAllArtists({ commit }, { sortType, params }) {
64 81
         commit('CLEAR_ARTISTS')
@@ -67,6 +84,8 @@ const actions = {
67 84
             let repacked = artists
68 85
             if(sortType == sortTypes.material) {
69 86
                 repacked = _arrangeByMaterial(artists)
87
+            } else if(sortType == sortTypes.episode) {
88
+                repacked = _arrangeByEpisode(artists)
70 89
             }
71 90
             commit('STORE_FETCHED_ARTISTS', { artists: repacked })
72 91
             commit('ARTISTS_LOADED', true)

Загрузка…
Отмена
Сохранить