From e374b601ecbb3a008cc826026ce4e22d438fdaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Fri, 20 May 2022 06:27:23 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=92=9A=20unify=20url=20strings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Müller --- src/main.js | 20 ++++++++++++++++++++ src/modals/SetlistSet.vue | 19 +------------------ src/modals/SongSet.vue | 19 +------------------ 3 files changed, 22 insertions(+), 36 deletions(-) diff --git a/src/main.js b/src/main.js index d8037984..4a39a346 100644 --- a/src/main.js +++ b/src/main.js @@ -328,6 +328,26 @@ Vue.mixin({ pass += String.fromCharCode(rdm62 + (rdm62 < 10 ? 48 : rdm62 < 36 ? 55 : 61)) } return pass; + }, + // make a given string url friendly + urlify: (s) => { + return s.trim().toLowerCase() + .replace(/\s/g, '-') + .replace(/\//g, '-') + .replace(/\_/g, '-') + .replace(/'/g, '') + .replace(/"/g, '') + .replace(/,/g, '') + .replace(/;/g, '') + .replace(/\./g, '') + .replace(/:/g, '') + .replace(/#/g, '') + .replace(/ä/g, 'ae') + .replace(/ö/g, 'oe') + .replace(/ü/g, 'ue') + .replace(/ß/g, 'ss') + .replace(/²/g, '2') + .replace(/³/g, '3'); } } }) diff --git a/src/modals/SetlistSet.vue b/src/modals/SetlistSet.vue index f3258880..01f1642a 100644 --- a/src/modals/SetlistSet.vue +++ b/src/modals/SetlistSet.vue @@ -372,24 +372,7 @@ export default { }, // create a human readable record key of format YYYYMMDD-the-setlist-title createSlug () { - return this.setlist.date.replace(/-/g, '') + '-' + this.slug(this.setlist.title); - }, - slug (s) { - return s - .trim() - .toLowerCase() - .replace(/\s/g, '-') - .replace(/\//g, '-') - .replace(/'/g, '') - .replace(/"/g, '') - .replace(/,/g, '') - .replace(/;/g, '') - .replace(/\./g, '') - .replace(/:/g, '') - .replace(/ä/g, 'ae') - .replace(/ö/g, 'oe') - .replace(/ü/g, 'ue') - .replace(/ß/g, 'ss'); + return this.setlist.date.replace(/-/g, '') + '-' + this.urlify(this.setlist.title); }, cancel () { this.$emit('closed'); diff --git a/src/modals/SongSet.vue b/src/modals/SongSet.vue index 9972627b..ab94f9fc 100644 --- a/src/modals/SongSet.vue +++ b/src/modals/SongSet.vue @@ -518,25 +518,8 @@ export default { }, // create a human readable record key of format YYYYMMDD-the-setlist-title createSlug () { - return this.slug(this.song.title) + '-' + this.song.language; + return this.urlify(this.song.title) + '-' + this.song.language; }, - slug (s) { - return s - .trim() - .toLowerCase() - .replace(/\s/g, '-') - .replace(/\//g, '-') - .replace(/'/g, '') - .replace(/"/g, '') - .replace(/,/g, '') - .replace(/;/g, '') - .replace(/\./g, '') - .replace(/:/g, '') - .replace(/ä/g, 'ae') - .replace(/ö/g, 'oe') - .replace(/ü/g, 'ue') - .replace(/ß/g, 'ss'); - } }, computed: { // filter song list by search query From 9dd645518c3dbe1bb25a6c08b5e424aea5a50071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Fri, 20 May 2022 18:16:23 +0200 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=94=A8=20remove=20song=20from=20its?= =?UTF-8?q?=20own=20translation=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Müller --- src/modals/SongSet.vue | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/modals/SongSet.vue b/src/modals/SongSet.vue index ab94f9fc..6b244333 100644 --- a/src/modals/SongSet.vue +++ b/src/modals/SongSet.vue @@ -443,6 +443,7 @@ export default { // new song should be created if (!this.existing) { this.$db.collection('songs').doc(slug).set(processedSong).then(() => { + // TODO: add translation references this.$emit('closed'); this.$emit('reset'); processedSong = {}; @@ -459,8 +460,9 @@ export default { else { // check if key remained (no title or language changes) if (this.id == slug) { - // just update the existing setlist + // just update the existing song this.$db.collection('songs').doc(this.id).update(processedSong).then(() => { + // TODO: update translation references this.$emit('closed'); this.$emit('reset'); processedSong = {}; @@ -504,6 +506,7 @@ export default { this.$db.collection('songs').doc(songId).update({ translations: updatedTranslationsList }); } } + // TODO: update translation references this.$router.push({ name: 'song-show', params: { id: slug }}); // toast success update message this.$notify({ @@ -548,9 +551,11 @@ export default { if (this.search.translations != '') { for (const key in this.songs) { if (this.songs.hasOwnProperty(key)) { + // exclude self assignment + if (this.existing && this.id == key) continue; + // search in title and subtitle const song = this.songs[key]; let search = this.search.translations.toLowerCase(); - // search in title and subtitle if ( song.title.toLowerCase().indexOf(search) !== -1 || song.subtitle.toLowerCase().indexOf(search) !== -1 || @@ -562,7 +567,9 @@ export default { } return songs; } else { - return this.songs; + let songs = JSON.parse(JSON.stringify(this.songs)); + if (this.existing) delete songs[this.id]; + return songs; } }, // calculate wether form errors occured From 10da4a083bb148a12aaf855c6e249fa60c8936ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sat, 21 May 2022 11:18:43 +0200 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=94=A8=20persist=20translation=20refe?= =?UTF-8?q?rences=20when=20adding=20song=20translation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Müller --- src/modals/SongSet.vue | 44 +++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/src/modals/SongSet.vue b/src/modals/SongSet.vue index 6b244333..af511c98 100644 --- a/src/modals/SongSet.vue +++ b/src/modals/SongSet.vue @@ -443,7 +443,17 @@ export default { // new song should be created if (!this.existing) { this.$db.collection('songs').doc(slug).set(processedSong).then(() => { - // TODO: add translation references + // persist translation references + if (processedSong.translations.length > 0) { + processedSong.translations.forEach(t => { + if (t in this.songs) { + let tsong = this.songs[t]; + if (!tsong.translations.includes(slug)) { + this.$db.collection('songs').doc(t).update({ translations: tsong.translations.concat([slug]) }); + } + } + }); + } this.$emit('closed'); this.$emit('reset'); processedSong = {}; @@ -461,8 +471,18 @@ export default { // check if key remained (no title or language changes) if (this.id == slug) { // just update the existing song - this.$db.collection('songs').doc(this.id).update(processedSong).then(() => { - // TODO: update translation references + this.$db.collection('songs').doc(slug).update(processedSong).then(() => { + // persist translation references + if (processedSong.translations.length > 0) { + processedSong.translations.forEach(t => { + if (t in this.songs) { + let tsong = this.songs[t]; + if (!tsong.translations.includes(slug)) { + this.$db.collection('songs').doc(t).update({ translations: tsong.translations.concat([slug]) }); + } + } + }); + } this.$emit('closed'); this.$emit('reset'); processedSong = {}; @@ -477,9 +497,6 @@ export default { // update key by adding a new song, removing the old one and update references in other fields this.$db.collection('songs').doc(slug).set(processedSong).then(() => { this.$db.collection('songs').doc(this.id).delete(); - this.$emit('closed'); - this.$emit('reset'); - processedSong = {}; // check existing setlists for this song id and update to new slug for (const setlistId in this.setlists) { const setlist = this.setlists[setlistId]; @@ -506,7 +523,20 @@ export default { this.$db.collection('songs').doc(songId).update({ translations: updatedTranslationsList }); } } - // TODO: update translation references + // persist translation references + if (processedSong.translations.length > 0) { + processedSong.translations.forEach(t => { + if (t in this.songs) { + let tsong = this.songs[t]; + if (!tsong.translations.includes(slug)) { + this.$db.collection('songs').doc(t).update({ translations: tsong.translations.concat([slug]) }); + } + } + }); + } + this.$emit('closed'); + this.$emit('reset'); + processedSong = {}; this.$router.push({ name: 'song-show', params: { id: slug }}); // toast success update message this.$notify({ From a833bbc851353db6826bb0ab640ce341a9ead156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sat, 21 May 2022 14:28:14 +0200 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=93=9C=20updated=20docs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed5b2882..79d935b0 100644 --- a/README.md +++ b/README.md @@ -33,9 +33,9 @@ This is how the SongDrive Dashboard currently looks like. - UI supports multiple languages (currently: EN, DE) - Export and Import of complete SongDrive data -## Installation +## Installation for developers -1. Get all files +1. Get all files from repository ```bash git clone https://github.com/devmount/SongDrive From 1b62f72a9ec5d2308a15e23ca94eee39611afe38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sun, 22 May 2022 06:09:45 +0200 Subject: [PATCH 5/5] =?UTF-8?q?=E2=9E=95=20persist=20translation=20refs=20?= =?UTF-8?q?on=20deleting=20song=20translations?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Müller --- src/modals/SongSet.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/modals/SongSet.vue b/src/modals/SongSet.vue index af511c98..828b3da7 100644 --- a/src/modals/SongSet.vue +++ b/src/modals/SongSet.vue @@ -468,11 +468,18 @@ export default { } // existing song should be updated else { + let initialSong = this.initialSong; // remember initial song data before update // check if key remained (no title or language changes) if (this.id == slug) { // just update the existing song this.$db.collection('songs').doc(slug).update(processedSong).then(() => { - // persist translation references + // persist translation references by removing and adding them + let translationDiff = initialSong.translations.filter(t => !processedSong.translations.includes(t)); + if (translationDiff.length > 0) { + translationDiff.forEach(s => { + this.$db.collection('songs').doc(s).update({ translations: this.songs[s].translations.filter(t => t != slug) }); + }); + } if (processedSong.translations.length > 0) { processedSong.translations.forEach(t => { if (t in this.songs) { @@ -523,7 +530,13 @@ export default { this.$db.collection('songs').doc(songId).update({ translations: updatedTranslationsList }); } } - // persist translation references + // persist translation references by removing and adding them + let translationDiff = initialSong.translations.filter(t => !processedSong.translations.includes(t)); + if (translationDiff.length > 0) { + translationDiff.forEach(s => { + this.$db.collection('songs').doc(s).update({ translations: this.songs[s].translations.filter(t => t != slug) }); + }); + } if (processedSong.translations.length > 0) { processedSong.translations.forEach(t => { if (t in this.songs) {