diff --git a/src/content/admin/WorshipManagement.vue b/src/content/admin/WorshipManagement.vue index 0d0fff8..ef499b8 100644 --- a/src/content/admin/WorshipManagement.vue +++ b/src/content/admin/WorshipManagement.vue @@ -145,7 +145,18 @@ Gestalter: (alt: {{ getOldValue(worship, 'organizer') }}) - + addImportOrganizerTag(worship, newTag)" + @update:modelValue="(value) => setImportOrganizer(worship, value)" + /> @@ -317,6 +328,7 @@ export default { worships: [], eventPlaces: [], organizerOptions: [], + worshipLeaderOptions: [], sacristanOptions: [], selectedOrganizers: [], selectedSacristans: [], @@ -412,6 +424,7 @@ export default { await this.fetchEventPlaces(); await this.fetchWorships(); await this.fetchWorshipOptions(); + await this.fetchWorshipLeaders(); await this.fetchLiturgicalDays(); this.hasNewsletterPreview = !!localStorage.getItem('newsletter_import_last_result'); this.applyNewsletterDraft(); @@ -435,6 +448,7 @@ export default { time: w.time || '', title: w.title || '', organizer: w.organizer || '', + _selectedOrganizer: this.resolveImportOrganizerOption(w.organizer || ''), collection: w.collection || '', sacristanService: w.sacristanService || '', organPlaying: w.organPlaying || '', @@ -525,6 +539,50 @@ export default { console.error('Fehler beim Abrufen der Worship-Optionen:', error); } }, + async fetchWorshipLeaders() { + try { + const response = await axios.get('/worship-leaders'); + this.worshipLeaderOptions = (response.data || []).map((leader) => { + const name = String(leader.name || '').trim(); + const code = String(leader.code || '').trim(); + return { + id: leader.id, + name, + code, + displayName: code ? `${name} (${code})` : name, + }; + }); + } catch (error) { + console.error('Fehler beim Abrufen der Worship-Leads:', error); + this.worshipLeaderOptions = []; + } + }, + resolveImportOrganizerOption(organizerValue) { + const value = String(organizerValue || '').trim(); + if (!value) return null; + const lower = value.toLowerCase(); + const option = this.worshipLeaderOptions.find( + (o) => o.name.toLowerCase() === lower || (o.code && o.code.toLowerCase() === lower) + ); + if (option) return option; + return { id: null, name: value, code: '', displayName: value }; + }, + setImportOrganizer(worship, selected) { + if (!selected) { + worship._selectedOrganizer = null; + worship.organizer = ''; + return; + } + worship._selectedOrganizer = selected; + worship.organizer = selected.name || selected.displayName || ''; + }, + addImportOrganizerTag(worship, newTag) { + const value = String(newTag || '').trim(); + if (!value) return; + const option = { id: null, name: value, code: '', displayName: value }; + this.worshipLeaderOptions.push(option); + this.setImportOrganizer(worship, option); + }, async fetchLiturgicalDays() { try { const response = await axios.get('/liturgical-days'); @@ -845,7 +903,8 @@ export default { _replaceExistingIds: w._replaceExistingIds || [], _importChoice: w._importChoice || (w._hasDayPlaceConflict ? 'keepExisting' : 'import'), neighborInvitation: !!w.neighborInvitation, - selfInformation: !!w.selfInformation + selfInformation: !!w.selfInformation, + _selectedOrganizer: this.resolveImportOrganizerOption(w.organizer || '') }; }); this.importErrors = response.data.errors || [];