mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-21 19:24:09 -04:00
[web] Fix for items not displaying because of their name
Albums, artists, composers, genres, and any other items listed on page where they appear sorted by names are now all displayed properly.
This commit is contained in:
parent
d6dd790569
commit
a1046f3913
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
|||||||
<section>
|
<section>
|
||||||
<nav class="buttons is-centered fd-is-square" style="margin-bottom: 16px">
|
<nav class="buttons is-centered fd-is-square" style="margin-bottom: 16px">
|
||||||
<a
|
<a
|
||||||
v-for="char in filtered_index"
|
v-for="char in index"
|
||||||
:key="char"
|
:key="char"
|
||||||
class="button is-small"
|
class="button is-small"
|
||||||
@click="nav(char)"
|
@click="nav(char)"
|
||||||
@ -16,22 +16,9 @@
|
|||||||
export default {
|
export default {
|
||||||
name: 'IndexButtonList',
|
name: 'IndexButtonList',
|
||||||
props: ['index'],
|
props: ['index'],
|
||||||
computed: {
|
|
||||||
filtered_index() {
|
|
||||||
if (!this.index) {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
const specialChars = '!"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~'
|
|
||||||
return this.index.filter((c) => !specialChars.includes(c))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
nav: function (id) {
|
nav: function (id) {
|
||||||
this.$router.push({ hash: '#index_' + id })
|
this.$router.push({ hash: '#index_' + id })
|
||||||
},
|
|
||||||
|
|
||||||
scroll_to_top: function () {
|
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,33 +10,25 @@ export function noop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
export function byName(field, keepSortOrder = false, defaultValue = '_') {
|
||||||
* Keep default sorting of item list and build index and group by given field
|
|
||||||
*/
|
|
||||||
export function bySortName(field, defaultValue = '_') {
|
|
||||||
return {
|
return {
|
||||||
// Keep the sort order of the original item list
|
compareFn: keepSortOrder
|
||||||
// Assumes that the list is already ordered by name
|
? null
|
||||||
compareFn: null,
|
: (a, b) => {
|
||||||
|
const fieldA = a[field] || defaultValue
|
||||||
|
const fieldB = b[field] || defaultValue
|
||||||
|
return fieldA.localeCompare(fieldB, locale.value)
|
||||||
|
},
|
||||||
|
|
||||||
groupKeyFn: (item) => {
|
groupKeyFn: (item) => {
|
||||||
const fieldValue = item[field] || defaultValue
|
const value = (item[field] || defaultValue).charAt(0)
|
||||||
return fieldValue.charAt(0).toUpperCase()
|
if (value.match(/\p{Letter}/gu)) {
|
||||||
}
|
return value.toUpperCase()
|
||||||
}
|
} else if (value.match(/\p{Number}/gu)) {
|
||||||
}
|
return '#'
|
||||||
|
} else {
|
||||||
export function byName(field, defaultValue = '_') {
|
return '⌘'
|
||||||
return {
|
}
|
||||||
compareFn: (a, b) => {
|
|
||||||
const fieldA = a[field] || defaultValue
|
|
||||||
const fieldB = b[field] || defaultValue
|
|
||||||
return fieldA.localeCompare(fieldB, locale.value)
|
|
||||||
},
|
|
||||||
|
|
||||||
groupKeyFn: (item) => {
|
|
||||||
const fieldValue = item[field] || defaultValue
|
|
||||||
return fieldValue.charAt(0).toUpperCase()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ import ListAlbums from '@/components/ListAlbums.vue'
|
|||||||
import DropdownMenu from '@/components/DropdownMenu.vue'
|
import DropdownMenu from '@/components/DropdownMenu.vue'
|
||||||
import webapi from '@/webapi'
|
import webapi from '@/webapi'
|
||||||
import * as types from '@/store/mutation_types'
|
import * as types from '@/store/mutation_types'
|
||||||
import { bySortName, byYear, GroupByList } from '@/lib/GroupByList'
|
import { byName, byYear, GroupByList } from '@/lib/GroupByList'
|
||||||
|
|
||||||
const dataObject = {
|
const dataObject = {
|
||||||
load: function (to) {
|
load: function (to) {
|
||||||
@ -123,28 +123,24 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
albums_list: new GroupByList(),
|
albums_list: new GroupByList(),
|
||||||
|
|
||||||
// List of group by/sort options for itemsGroupByList
|
|
||||||
groupby_options: [
|
groupby_options: [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: this.$t('page.albums.sort-by.name'),
|
name: this.$t('page.albums.sort-by.name'),
|
||||||
options: bySortName('name_sort')
|
options: byName('name_sort', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: this.$t('page.albums.sort-by.recently-added'),
|
name: this.$t('page.albums.sort-by.recently-added'),
|
||||||
options: byYear('time_added', {
|
options: byYear('time_added', {
|
||||||
direction: 'desc',
|
direction: 'desc'
|
||||||
defaultValue: '0000'
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 3,
|
id: 3,
|
||||||
name: this.$t('page.albums.sort-by.recently-released'),
|
name: this.$t('page.albums.sort-by.recently-released'),
|
||||||
options: byYear('date_released', {
|
options: byYear('date_released', {
|
||||||
direction: 'desc',
|
direction: 'desc'
|
||||||
defaultValue: '0000'
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -61,7 +61,7 @@ import ModalDialogArtist from '@/components/ModalDialogArtist.vue'
|
|||||||
import DropdownMenu from '@/components/DropdownMenu.vue'
|
import DropdownMenu from '@/components/DropdownMenu.vue'
|
||||||
import webapi from '@/webapi'
|
import webapi from '@/webapi'
|
||||||
import * as types from '@/store/mutation_types'
|
import * as types from '@/store/mutation_types'
|
||||||
import { bySortName, byYear, GroupByList } from '@/lib/GroupByList'
|
import { byName, byYear, GroupByList } from '@/lib/GroupByList'
|
||||||
|
|
||||||
const dataObject = {
|
const dataObject = {
|
||||||
load: function (to) {
|
load: function (to) {
|
||||||
@ -103,24 +103,20 @@ export default {
|
|||||||
return {
|
return {
|
||||||
artist: {},
|
artist: {},
|
||||||
albums_list: new GroupByList(),
|
albums_list: new GroupByList(),
|
||||||
|
|
||||||
// List of group by/sort options for itemsGroupByList
|
|
||||||
groupby_options: [
|
groupby_options: [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: this.$t('page.artist.sort-by.name'),
|
name: this.$t('page.artist.sort-by.name'),
|
||||||
options: bySortName('name_sort')
|
options: byName('name_sort', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: this.$t('page.artist.sort-by.release-date'),
|
name: this.$t('page.artist.sort-by.release-date'),
|
||||||
options: byYear('date_released', {
|
options: byYear('date_released', {
|
||||||
direction: 'asc',
|
direction: 'asc'
|
||||||
defaultValue: '0000'
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
show_artist_details_modal: false
|
show_artist_details_modal: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -80,7 +80,7 @@ import ListArtists from '@/components/ListArtists.vue'
|
|||||||
import DropdownMenu from '@/components/DropdownMenu.vue'
|
import DropdownMenu from '@/components/DropdownMenu.vue'
|
||||||
import webapi from '@/webapi'
|
import webapi from '@/webapi'
|
||||||
import * as types from '@/store/mutation_types'
|
import * as types from '@/store/mutation_types'
|
||||||
import { bySortName, byYear, GroupByList } from '@/lib/GroupByList'
|
import { byName, byYear, GroupByList } from '@/lib/GroupByList'
|
||||||
|
|
||||||
const dataObject = {
|
const dataObject = {
|
||||||
load: function (to) {
|
load: function (to) {
|
||||||
@ -122,22 +122,18 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// Original data from API call
|
|
||||||
artists_list: new GroupByList(),
|
artists_list: new GroupByList(),
|
||||||
|
|
||||||
// List of group by/sort options for itemsGroupByList
|
|
||||||
groupby_options: [
|
groupby_options: [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: this.$t('page.artists.sort-by.name'),
|
name: this.$t('page.artists.sort-by.name'),
|
||||||
options: bySortName('name_sort')
|
options: byName('name_sort', true)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 2,
|
id: 2,
|
||||||
name: this.$t('page.artists.sort-by.recently-added'),
|
name: this.$t('page.artists.sort-by.recently-added'),
|
||||||
options: byYear('time_added', {
|
options: byYear('time_added', {
|
||||||
direction: 'desc',
|
direction: 'desc'
|
||||||
defaultValue: '0000'
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -25,7 +25,7 @@ import IndexButtonList from '@/components/IndexButtonList.vue'
|
|||||||
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
||||||
import ListAlbums from '@/components/ListAlbums.vue'
|
import ListAlbums from '@/components/ListAlbums.vue'
|
||||||
import webapi from '@/webapi'
|
import webapi from '@/webapi'
|
||||||
import { bySortName, GroupByList } from '@/lib/GroupByList'
|
import { byName, GroupByList } from '@/lib/GroupByList'
|
||||||
|
|
||||||
const dataObject = {
|
const dataObject = {
|
||||||
load: function (to) {
|
load: function (to) {
|
||||||
@ -34,7 +34,7 @@ const dataObject = {
|
|||||||
|
|
||||||
set: function (vm, response) {
|
set: function (vm, response) {
|
||||||
vm.albums = new GroupByList(response.data)
|
vm.albums = new GroupByList(response.data)
|
||||||
vm.albums.group(bySortName('name_sort'))
|
vm.albums.group(byName('name_sort', true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ import TabsAudiobooks from '@/components/TabsAudiobooks.vue'
|
|||||||
import IndexButtonList from '@/components/IndexButtonList.vue'
|
import IndexButtonList from '@/components/IndexButtonList.vue'
|
||||||
import ListArtists from '@/components/ListArtists.vue'
|
import ListArtists from '@/components/ListArtists.vue'
|
||||||
import webapi from '@/webapi'
|
import webapi from '@/webapi'
|
||||||
import { bySortName, GroupByList } from '@/lib/GroupByList'
|
import { byName, GroupByList } from '@/lib/GroupByList'
|
||||||
|
|
||||||
const dataObject = {
|
const dataObject = {
|
||||||
load: function (to) {
|
load: function (to) {
|
||||||
@ -76,7 +76,7 @@ export default {
|
|||||||
if (!this.artists_list) {
|
if (!this.artists_list) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
this.artists_list.group(bySortName('name_sort'))
|
this.artists_list.group(byName('name_sort', true))
|
||||||
return this.artists_list
|
return this.artists_list
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -36,8 +36,7 @@ const dataObject = {
|
|||||||
vm.recently_added = new GroupByList(response.data.albums)
|
vm.recently_added = new GroupByList(response.data.albums)
|
||||||
vm.recently_added.group(
|
vm.recently_added.group(
|
||||||
byDateSinceToday('time_added', {
|
byDateSinceToday('time_added', {
|
||||||
direction: 'desc',
|
direction: 'desc'
|
||||||
defaultValue: '0000'
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ import IndexButtonList from '@/components/IndexButtonList.vue'
|
|||||||
import ListAlbums from '@/components/ListAlbums.vue'
|
import ListAlbums from '@/components/ListAlbums.vue'
|
||||||
import ModalDialogGenre from '@/components/ModalDialogGenre.vue'
|
import ModalDialogGenre from '@/components/ModalDialogGenre.vue'
|
||||||
import webapi from '@/webapi'
|
import webapi from '@/webapi'
|
||||||
import { bySortName, GroupByList } from '@/lib/GroupByList'
|
import { byName, GroupByList } from '@/lib/GroupByList'
|
||||||
|
|
||||||
const dataObject = {
|
const dataObject = {
|
||||||
load: function (to) {
|
load: function (to) {
|
||||||
@ -65,7 +65,7 @@ const dataObject = {
|
|||||||
set: function (vm, response) {
|
set: function (vm, response) {
|
||||||
vm.genre = response[0].data
|
vm.genre = response[0].data
|
||||||
vm.albums_list = new GroupByList(response[1].data.albums)
|
vm.albums_list = new GroupByList(response[1].data.albums)
|
||||||
vm.albums_list.group(bySortName('name_sort'))
|
vm.albums_list.group(byName('name_sort', true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user