Merge branch 'ADBNetzgebiet/fix-copy-button' into 'master'

fixed the second copy button

See merge request fronk/thetool!1997
This commit is contained in:
Luca Haid
2026-01-08 09:36:11 +00:00

View File

@@ -124,8 +124,7 @@ const ADBNetzgebiet = {
<template v-if="item.related.consent_projects.length">
<a v-for="cons in item.related.consent_projects.slice(0, 1)" :key="cons.id"
:href="window.TT_CONFIG.CONSENT_URL + '?id=' + cons.id"
target="_blank" class="related-link">
{{ cons.name }}
target="_blank" class="related-link" v-html="formatConsentName(cons.name)">
</a>
<span v-if="item.related.consent_projects.length > 1" class="more-badge">+{{ item.related.consent_projects.length - 1 }}</span>
</template>
@@ -176,24 +175,6 @@ const ADBNetzgebiet = {
<!-- Edit/Create Modal -->
<tt-dialog :show="showEditModal" :title="editItem && editItem.id ? 'Netzgebiet bearbeiten' : 'Neues Netzgebiet'" size="wide" @close="showEditModal = false">
<div v-if="editItem" class="modal-form">
<!-- Copy From Section -->
<div class="copy-from-section">
<div class="copy-from-row">
<div class="select copy-select">
<select v-model="copyFromId">
<option value="">Kopieren von...</option>
<option v-for="item in copyableNetzgebiete" :key="item.netzgebiet.id" :value="item.netzgebiet.id">
{{ item.netzgebiet.name }} {{ item.netzgebiet.extref ? '(' + item.netzgebiet.extref + ')' : '' }}
</option>
</select>
</div>
<button class="ghost-btn copy-btn" @click="copyFromNetzgebiet" :disabled="!copyFromId" title="Felder kopieren">
<i class="fa-duotone fa-copy"></i> Kopieren
</button>
</div>
<div class="copy-hint">Kopiert: Quelle, Freigaben und Optionen</div>
</div>
<hr class="form-divider" />
<div class="form-grid">
<div class="field span-2">
<label>Name *</label>
@@ -308,7 +289,6 @@ const ADBNetzgebiet = {
filterDebounce: null,
showEditModal: false,
editItem: null,
copyFromId: '',
showHistoryModal: false,
historyLoading: false,
historyItems: [],
@@ -380,13 +360,6 @@ const ADBNetzgebiet = {
paginationEnd() { return Math.min(this.currentPage * this.pageSize, this.filteredNetzgebiete.length); },
filteredHistory() {
return this.historyItems.filter(e => !['edit', 'create'].includes(e.field));
},
copyableNetzgebiete() {
return this.netzgebiete.filter(item => {
if (!item.netzgebiet?.id) return false;
if (this.editItem?.id && item.netzgebiet.id === this.editItem.id) return false;
return true;
});
}
},
@@ -397,6 +370,12 @@ const ADBNetzgebiet = {
async mounted() { await this.fetchNetzgebiete(); },
methods: {
formatConsentName(name) {
if (name && name.startsWith('Glasfaserprojekt')) {
return name.replace('Glasfaserprojekt', 'Glasfaserprojekt<br>');
}
return name;
},
debouncedFilter() {
clearTimeout(this.filterDebounce);
this.filterDebounce = setTimeout(() => this.currentPage = 1, 300);
@@ -423,7 +402,6 @@ const ADBNetzgebiet = {
catch { return []; }
},
openCreateModal() {
this.copyFromId = '';
this.editItem = {
id: null, name: '', extref: '', source: '', source_id: '',
freigabe: { interest: true, provision: true, order: true, reorder: true },
@@ -432,7 +410,6 @@ const ADBNetzgebiet = {
this.showEditModal = true;
},
openEditModal(item) {
this.copyFromId = '';
const n = item.netzgebiet;
let options = {};
try { options = JSON.parse(n.options || '{}'); } catch {}
@@ -448,32 +425,7 @@ const ADBNetzgebiet = {
};
this.showEditModal = true;
},
copyFromNetzgebiet() {
if (!this.copyFromId || !this.editItem) return;
const source = this.netzgebiete.find(item => item.netzgebiet?.id == this.copyFromId);
if (!source) return;
const n = source.netzgebiet;
// Copy source
if (n.source) this.editItem.source = n.source;
// Copy freigabe
let freigabeArr = [];
try { freigabeArr = JSON.parse(n.freigabe || '[]') || []; } catch {}
['interest', 'provision', 'order', 'reorder'].forEach(f => {
this.editItem.freigabe[f] = freigabeArr.includes(f);
});
// Copy options
let options = {};
try { options = JSON.parse(n.options || '{}'); } catch {}
this.editItem.options = { ...this.defaultOptions, ...options };
window.notify?.('success', `Felder von "${n.name}" kopiert.`);
this.copyFromId = '';
},
async copyNetzgebiet(item) {
this.copyFromId = '';
const n = item.netzgebiet;
let options = {};
try { options = JSON.parse(n.options || '{}'); } catch {}