Skip to content

Commit

Permalink
[web] Rename grouped list
Browse files Browse the repository at this point in the history
  • Loading branch information
hacketiwack committed Feb 22, 2024
1 parent 151af29 commit 4af4dd7
Show file tree
Hide file tree
Showing 27 changed files with 140 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,12 @@ export function byDateSinceToday(field, defaultValue = '0000') {
}
}

export class GroupByList {
export class GroupedList {
constructor({ items = [], total = 0, offset = 0, limit = -1 } = {}) {
this.items = items
this.total = total
this.offset = offset
this.limit = limit

this.count = items.length
this.indexList = []
this.group(noop())
Expand Down
6 changes: 3 additions & 3 deletions web-src/src/pages/PageAlbum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<script>
import ContentWithHero from '@/templates/ContentWithHero.vue'
import CoverArtwork from '@/components/CoverArtwork.vue'
import { GroupByList, byMedium, noop } from '@/lib/GroupByList'
import { GroupedList, byMedium, noop } from '@/lib/GroupedList'
import ListTracks from '@/components/ListTracks.vue'
import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue'
import webapi from '@/webapi'
Expand All @@ -62,7 +62,7 @@ const dataObject = {
set(vm, response) {
vm.album = response[0].data
vm.tracks = new GroupByList(response[1].data)
vm.tracks = new GroupedList(response[1].data)
vm.tracks.group(byMedium('disc_number'))
if (vm.tracks.indexList <= 1) {
vm.tracks.group(noop())
Expand Down Expand Up @@ -91,7 +91,7 @@ export default {
return {
album: {},
show_details_modal: false,
tracks: new GroupByList()
tracks: new GroupedList()
}
},
Expand Down
20 changes: 10 additions & 10 deletions web-src/src/pages/PageAlbums.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<div class="column">
<p class="heading mb-5" v-text="$t('page.albums.sort.title')" />
<control-dropdown
v-model:value="selected_groupby_option_id"
:options="groupby_options"
v-model:value="selected_grouping_option_id"
:options="grouping_options"
/>
</div>
</div>
Expand All @@ -64,7 +64,7 @@

<script>
import * as types from '@/store/mutation_types'
import { GroupByList, byName, byYear } from '@/lib/GroupByList'
import { GroupedList, byName, byYear } from '@/lib/GroupedList'
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import ControlDropdown from '@/components/ControlDropdown.vue'
import IndexButtonList from '@/components/IndexButtonList.vue'
Expand All @@ -78,7 +78,7 @@ const dataObject = {
},
set(vm, response) {
vm.albums_list = new GroupByList(response.data)
vm.albums_list = new GroupedList(response.data)
}
}
Expand Down Expand Up @@ -112,8 +112,8 @@ export default {
data() {
return {
albums_list: new GroupByList(),
groupby_options: [
albums_list: new GroupedList(),
grouping_options: [
{
id: 1,
name: this.$t('page.albums.sort.name'),
Expand All @@ -139,18 +139,18 @@ export default {
computed: {
albums() {
const groupBy = this.groupby_options.find(
(o) => o.id === this.selected_groupby_option_id
const grouping = this.grouping_options.find(
(o) => o.id === this.selected_grouping_option_id
)
this.albums_list.group(groupBy.options, [
this.albums_list.group(grouping.options, [
(album) => !this.hide_singles || album.track_count > 2,
(album) => !this.hide_spotify || album.data_kind !== 'spotify'
])
return this.albums_list
},
selected_groupby_option_id: {
selected_grouping_option_id: {
get() {
return this.$store.state.albums_sort
},
Expand Down
20 changes: 10 additions & 10 deletions web-src/src/pages/PageArtist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<div class="column">
<p class="heading mb-5" v-text="$t('page.artist.sort.title')" />
<control-dropdown
v-model:value="selected_groupby_option_id"
:options="groupby_options"
v-model:value="selected_grouping_option_id"
:options="grouping_options"
/>
</div>
</div>
Expand Down Expand Up @@ -74,7 +74,7 @@
import * as types from '@/store/mutation_types'
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import ControlDropdown from '@/components/ControlDropdown.vue'
import { GroupByList, byName, byYear } from '@/lib/GroupByList'
import { GroupedList, byName, byYear } from '@/lib/GroupedList'
import ListAlbums from '@/components/ListAlbums.vue'
import ModalDialogArtist from '@/components/ModalDialogArtist.vue'
import webapi from '@/webapi'
Expand All @@ -89,7 +89,7 @@ const dataObject = {
set(vm, response) {
vm.artist = response[0].data
vm.albums_list = new GroupByList(response[1].data)
vm.albums_list = new GroupedList(response[1].data)
}
}
Expand Down Expand Up @@ -118,8 +118,8 @@ export default {
data() {
return {
artist: {},
albums_list: new GroupByList(),
groupby_options: [
albums_list: new GroupedList(),
grouping_options: [
{
id: 1,
name: this.$t('page.artist.sort.name'),
Expand All @@ -139,10 +139,10 @@ export default {
computed: {
albums() {
const groupBy = this.groupby_options.find(
(o) => o.id === this.selected_groupby_option_id
const grouping = this.grouping_options.find(
(o) => o.id === this.selected_grouping_option_id
)
this.albums_list.group(groupBy.options, [
this.albums_list.group(grouping.options, [
(album) => !this.hide_spotify || album.data_kind !== 'spotify'
])
return this.albums_list
Expand All @@ -155,7 +155,7 @@ export default {
this.$store.commit(types.HIDE_SPOTIFY, value)
}
},
selected_groupby_option_id: {
selected_grouping_option_id: {
get() {
return this.$store.state.artist_albums_sort
},
Expand Down
20 changes: 10 additions & 10 deletions web-src/src/pages/PageArtistTracks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
<div class="column">
<p class="heading mb-5" v-text="$t('page.artist.sort.title')" />
<control-dropdown
v-model:value="selected_groupby_option_id"
:options="groupby_options"
v-model:value="selected_grouping_option_id"
:options="grouping_options"
/>
</div>
</div>
Expand Down Expand Up @@ -73,7 +73,7 @@

<script>
import * as types from '@/store/mutation_types'
import { GroupByList, byName, byRating } from '@/lib/GroupByList'
import { GroupedList, byName, byRating } from '@/lib/GroupedList'
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import ControlDropdown from '@/components/ControlDropdown.vue'
import IndexButtonList from '@/components/IndexButtonList.vue'
Expand All @@ -91,7 +91,7 @@ const dataObject = {
set(vm, response) {
vm.artist = response[0].data
vm.tracks_list = new GroupByList(response[1].data.tracks)
vm.tracks_list = new GroupedList(response[1].data.tracks)
}
}
Expand Down Expand Up @@ -121,7 +121,7 @@ export default {
data() {
return {
artist: {},
groupby_options: [
grouping_options: [
{
id: 1,
name: this.$t('page.artist.sort.name'),
Expand All @@ -136,7 +136,7 @@ export default {
}
],
show_details_modal: false,
tracks_list: new GroupByList()
tracks_list: new GroupedList()
}
},
Expand All @@ -156,7 +156,7 @@ export default {
this.$store.commit(types.HIDE_SPOTIFY, value)
}
},
selected_groupby_option_id: {
selected_grouping_option_id: {
get() {
return this.$store.state.artist_tracks_sort
},
Expand All @@ -168,10 +168,10 @@ export default {
return this.$store.state.spotify.webapi_token_valid
},
tracks() {
const groupBy = this.groupby_options.find(
(o) => o.id === this.selected_groupby_option_id
const grouping = this.grouping_options.find(
(o) => o.id === this.selected_grouping_option_id
)
this.tracks_list.group(groupBy.options, [
this.tracks_list.group(grouping.options, [
(track) => !this.hide_spotify || track.data_kind !== 'spotify'
])
return this.tracks_list
Expand Down
22 changes: 11 additions & 11 deletions web-src/src/pages/PageArtists.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
<div class="column">
<p class="heading mb-5" v-text="$t('page.artists.sort.title')" />
<control-dropdown
v-model:value="selected_groupby_option_id"
:options="groupby_options"
v-model:value="selected_grouping_option_id"
:options="grouping_options"
/>
</div>
</div>
Expand All @@ -64,7 +64,7 @@

<script>
import * as types from '@/store/mutation_types'
import { GroupByList, byName, byYear } from '@/lib/GroupByList'
import { GroupedList, byName, byYear } from '@/lib/GroupedList'
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import ControlDropdown from '@/components/ControlDropdown.vue'
import IndexButtonList from '@/components/IndexButtonList.vue'
Expand All @@ -78,7 +78,7 @@ const dataObject = {
},
set(vm, response) {
vm.artists_list = new GroupByList(response.data)
vm.artists_list = new GroupedList(response.data)
}
}
Expand Down Expand Up @@ -112,8 +112,8 @@ export default {
data() {
return {
artists_list: new GroupByList(),
groupby_options: [
artists_list: new GroupedList(),
grouping_options: [
{
id: 1,
name: this.$t('page.artists.sort.name'),
Expand All @@ -131,16 +131,16 @@ export default {
},
computed: {
// Wraps GroupByList and updates it if filter or sort changes
// Wraps GroupedList and updates it if filter or sort changes
artists() {
if (!this.artists_list) {
return []
}
const groupBy = this.groupby_options.find(
(o) => o.id === this.selected_groupby_option_id
const grouping = this.grouping_options.find(
(o) => o.id === this.selected_grouping_option_id
)
this.artists_list.group(groupBy.options, [
this.artists_list.group(grouping.options, [
(artist) =>
!this.hide_singles || artist.track_count > artist.album_count * 2,
(artist) => !this.hide_spotify || artist.data_kind !== 'spotify'
Expand All @@ -149,7 +149,7 @@ export default {
return this.artists_list
},
selected_groupby_option_id: {
selected_grouping_option_id: {
get() {
return this.$store.state.artists_sort
},
Expand Down
6 changes: 3 additions & 3 deletions web-src/src/pages/PageAudiobooksAlbum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<script>
import ContentWithHero from '@/templates/ContentWithHero.vue'
import CoverArtwork from '@/components/CoverArtwork.vue'
import { GroupByList } from '@/lib/GroupByList'
import { GroupedList } from '@/lib/GroupedList'
import ListTracks from '@/components/ListTracks.vue'
import ModalDialogAlbum from '@/components/ModalDialogAlbum.vue'
import webapi from '@/webapi'
Expand All @@ -67,7 +67,7 @@ const dataObject = {
set(vm, response) {
vm.album = response[0].data
vm.tracks = new GroupByList(response[1].data)
vm.tracks = new GroupedList(response[1].data)
}
}
Expand All @@ -92,7 +92,7 @@ export default {
return {
album: {},
show_details_modal: false,
tracks: new GroupByList()
tracks: new GroupedList()
}
},
Expand Down
6 changes: 3 additions & 3 deletions web-src/src/pages/PageAudiobooksAlbums.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<script>
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import { GroupByList, byName } from '@/lib/GroupByList'
import { GroupedList, byName } from '@/lib/GroupedList'
import IndexButtonList from '@/components/IndexButtonList.vue'
import ListAlbums from '@/components/ListAlbums.vue'
import TabsAudiobooks from '@/components/TabsAudiobooks.vue'
Expand All @@ -33,7 +33,7 @@ const dataObject = {
},
set(vm, response) {
vm.albums = new GroupByList(response.data)
vm.albums = new GroupedList(response.data)
vm.albums.group(byName('name_sort', true))
}
}
Expand Down Expand Up @@ -67,7 +67,7 @@ export default {
data() {
return {
albums: new GroupByList()
albums: new GroupedList()
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions web-src/src/pages/PageAudiobooksArtist.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

<script>
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
import { GroupByList } from '@/lib/GroupByList'
import { GroupedList } from '@/lib/GroupedList'
import ListAlbums from '@/components/ListAlbums.vue'
import ModalDialogArtist from '@/components/ModalDialogArtist.vue'
import webapi from '@/webapi'
Expand All @@ -55,7 +55,7 @@ const dataObject = {
set(vm, response) {
vm.artist = response[0].data
vm.albums = new GroupByList(response[1].data)
vm.albums = new GroupedList(response[1].data)
}
}
Expand Down Expand Up @@ -84,7 +84,7 @@ export default {
data() {
return {
artist: {},
albums: new GroupByList(),
albums: new GroupedList(),
show_details_modal: false
}
},
Expand Down
Loading

0 comments on commit 4af4dd7

Please sign in to comment.