added copy button
This commit is contained in:
@@ -524,6 +524,54 @@
|
|||||||
border: 1px solid #c9e6d8;
|
border: 1px solid #c9e6d8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ===== Copy From Section ===== */
|
||||||
|
.tt-scope .copy-from-section {
|
||||||
|
background: #f8fafc;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border: 1px dashed var(--tt-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .copy-from-row {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .copy-select {
|
||||||
|
flex: 1;
|
||||||
|
max-width: 350px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .copy-select select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .copy-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .copy-btn:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .copy-hint {
|
||||||
|
font-size: 11px;
|
||||||
|
color: var(--tt-muted);
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tt-scope .form-divider {
|
||||||
|
border: none;
|
||||||
|
height: 1px;
|
||||||
|
background: var(--tt-border);
|
||||||
|
margin: 4px 0 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* ===== Utilities ===== */
|
/* ===== Utilities ===== */
|
||||||
.tt-scope .mono { font-family: var(--tt-mono); }
|
.tt-scope .mono { font-family: var(--tt-mono); }
|
||||||
.tt-scope .muted { color: var(--tt-muted); }
|
.tt-scope .muted { color: var(--tt-muted); }
|
||||||
|
|||||||
@@ -175,6 +175,24 @@ const ADBNetzgebiet = {
|
|||||||
<!-- Edit/Create Modal -->
|
<!-- Edit/Create Modal -->
|
||||||
<tt-dialog :show="showEditModal" :title="editItem && editItem.id ? 'Netzgebiet bearbeiten' : 'Neues Netzgebiet'" size="wide" @close="showEditModal = false">
|
<tt-dialog :show="showEditModal" :title="editItem && editItem.id ? 'Netzgebiet bearbeiten' : 'Neues Netzgebiet'" size="wide" @close="showEditModal = false">
|
||||||
<div v-if="editItem" class="modal-form">
|
<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="form-grid">
|
||||||
<div class="field span-2">
|
<div class="field span-2">
|
||||||
<label>Name *</label>
|
<label>Name *</label>
|
||||||
@@ -289,6 +307,7 @@ const ADBNetzgebiet = {
|
|||||||
filterDebounce: null,
|
filterDebounce: null,
|
||||||
showEditModal: false,
|
showEditModal: false,
|
||||||
editItem: null,
|
editItem: null,
|
||||||
|
copyFromId: '',
|
||||||
showHistoryModal: false,
|
showHistoryModal: false,
|
||||||
historyLoading: false,
|
historyLoading: false,
|
||||||
historyItems: [],
|
historyItems: [],
|
||||||
@@ -360,6 +379,13 @@ const ADBNetzgebiet = {
|
|||||||
paginationEnd() { return Math.min(this.currentPage * this.pageSize, this.filteredNetzgebiete.length); },
|
paginationEnd() { return Math.min(this.currentPage * this.pageSize, this.filteredNetzgebiete.length); },
|
||||||
filteredHistory() {
|
filteredHistory() {
|
||||||
return this.historyItems.filter(e => !['edit', 'create'].includes(e.field));
|
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;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -396,6 +422,7 @@ const ADBNetzgebiet = {
|
|||||||
catch { return []; }
|
catch { return []; }
|
||||||
},
|
},
|
||||||
openCreateModal() {
|
openCreateModal() {
|
||||||
|
this.copyFromId = '';
|
||||||
this.editItem = {
|
this.editItem = {
|
||||||
id: null, name: '', extref: '', source: '', source_id: '',
|
id: null, name: '', extref: '', source: '', source_id: '',
|
||||||
freigabe: { interest: true, provision: true, order: true, reorder: true },
|
freigabe: { interest: true, provision: true, order: true, reorder: true },
|
||||||
@@ -404,6 +431,7 @@ const ADBNetzgebiet = {
|
|||||||
this.showEditModal = true;
|
this.showEditModal = true;
|
||||||
},
|
},
|
||||||
openEditModal(item) {
|
openEditModal(item) {
|
||||||
|
this.copyFromId = '';
|
||||||
const n = item.netzgebiet;
|
const n = item.netzgebiet;
|
||||||
let options = {};
|
let options = {};
|
||||||
try { options = JSON.parse(n.options || '{}'); } catch {}
|
try { options = JSON.parse(n.options || '{}'); } catch {}
|
||||||
@@ -419,6 +447,30 @@ const ADBNetzgebiet = {
|
|||||||
};
|
};
|
||||||
this.showEditModal = true;
|
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 saveNetzgebiet() {
|
async saveNetzgebiet() {
|
||||||
if (!this.editItem?.name) return;
|
if (!this.editItem?.name) return;
|
||||||
this.isSaving = true;
|
this.isSaving = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user