Skip to content

Commit

Permalink
ordering by song number
Browse files Browse the repository at this point in the history
  • Loading branch information
thes01 committed Dec 3, 2023
1 parent 40cd97d commit 8d78c37
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions resources/assets/js/admin/pages/list/SongsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@
<song-name :song="props.item" />
</a>
</td>
<td>
<span v-if="filter_songbook_id === ''">
{{ props.item.id }}
</span>
<span v-else>
<!-- find the songbook number in songbook_records given the filtered songbook id -->
{{
props.item.number
}}
</span>
</td>
<td>
<span v-if="props.item.type === 0"
>Orig.</span
Expand Down Expand Up @@ -254,6 +265,12 @@ const fetch_items = gql`
arrangement_source {
name
}
songbook_records {
songbook {
id
}
number
}
}
}
`;
Expand Down Expand Up @@ -291,6 +308,7 @@ export default {
return {
headers: [
{ text: 'Název písničky', value: 'name' },
{ text: 'ID', value: 'number' },
{ text: 'Typ', value: 'type' },
{ text: 'Autoři', value: 'authors', sortable: false },
{ text: 'Naposledy upraveno', value: 'updated_at' },
Expand All @@ -313,6 +331,15 @@ export default {
window.location.hash = val != 'no-filter' ? val : '';
this.dtPagination.page = 1;
},
filter_songbook_id(val) {
this.dtPagination.page = 1;
if (val === '') {
this.headers[1].text = 'ID';
} else {
this.headers[1].text = 'Č.';
}
}
},
apollo: {
Expand Down Expand Up @@ -345,6 +372,15 @@ export default {
},
result(result) {
this.buildSearchIndex();
for (const song_lyric of this.song_lyrics) {
if (this.filter_songbook_id !== '') {
song_lyric.number = song_lyric.songbook_records.find(
r => r.songbook.id == this.filter_songbook_id
).number;
} else {
song_lyric.number = song_lyric.id;
}
}
}
},
Expand Down Expand Up @@ -402,8 +438,16 @@ export default {
for (var item of this.song_lyrics) {
const types = ['original', 'preklad', 'autorizovany preklad'];
let number = item.id;
if (this.filter_songbook_id !== '') {
number = item.songbook_records.find(
r => r.songbook.id == this.filter_songbook_id
).number;
}
let searchableItems = [
item.name,
number,
item.secondary_name_1,
item.secondary_name_2,
item.authors.map(a => a.name).join(' ') ||
Expand Down

0 comments on commit 8d78c37

Please sign in to comment.