added netzgebiet copy button
This commit is contained in:
@@ -23,7 +23,6 @@ class ADBNetzgebietController extends mfBaseController {
|
||||
Helper::renderVue3($this, $this->mod, "Netzgebietverwaltung", [
|
||||
"GET_URL" => $this::getUrl("ADBNetzgebiet/getNetzgebiete"),
|
||||
"SAVE_URL" => $this::getUrl("ADBNetzgebiet/save"),
|
||||
"COPY_URL" => $this::getUrl("ADBNetzgebiet/copy"),
|
||||
"HISTORY_URL" => $this::getUrl("ADBNetzgebiet/getHistory"),
|
||||
"NETWORK_URL" => $this::getUrl("Network/Index"),
|
||||
"NETWORK_CREATE_URL" => $this::getUrl("Network/add"),
|
||||
@@ -131,41 +130,6 @@ class ADBNetzgebietController extends mfBaseController {
|
||||
self::returnJson(['success' => true, 'data' => $history]);
|
||||
}
|
||||
|
||||
protected function copyAction(): void {
|
||||
$data = $this->postData;
|
||||
if (empty($data['id'])) {
|
||||
self::sendError("ID of the Netzgebiet to be copied is missing.");
|
||||
return;
|
||||
}
|
||||
|
||||
$original = ADBNetzgebiet::get($data['id']);
|
||||
if (!$original) {
|
||||
self::sendError("Netzgebiet not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
$copy = new ADBNetzgebiet();
|
||||
$copy->name = null;
|
||||
$copy->extref = null;
|
||||
$copy->rimo_id = $original->rimo_id;
|
||||
$copy->source = $original->source;
|
||||
$copy->source_id = null;
|
||||
$copy->borderpoly = $original->borderpoly;
|
||||
$copy->freigabe = $original->freigabe;
|
||||
$copy->options = $original->options;
|
||||
|
||||
if (!$copy->save()) {
|
||||
self::sendError("Failed to copy Netzgebiet.");
|
||||
return;
|
||||
}
|
||||
|
||||
self::returnJson([
|
||||
'success' => true,
|
||||
'message' => 'Netzgebiet copied.',
|
||||
'id' => $copy->getId()
|
||||
]);
|
||||
}
|
||||
|
||||
// TODO: Implement RIMO API check
|
||||
protected function checkRimoSourceIdAction(): void {
|
||||
self::returnJson(['success' => false, 'message' => "RIMO API check not available."]);
|
||||
|
||||
@@ -473,23 +473,24 @@ const ADBNetzgebiet = {
|
||||
this.copyFromId = '';
|
||||
},
|
||||
async copyNetzgebiet(item) {
|
||||
if (!confirm(`Wollen Sie das Netzgebiet "${item.netzgebiet.name}" kopieren?`)) return;
|
||||
|
||||
this.isSaving = true;
|
||||
try {
|
||||
const response = await axios.post(window.TT_CONFIG.COPY_URL, { id: item.netzgebiet.id });
|
||||
if (response.data.success) {
|
||||
window.notify?.('success', response.data.message);
|
||||
await this.fetchNetzgebiete();
|
||||
} else {
|
||||
window.notify?.('error', response.data.message || 'Fehler beim Kopieren.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Fehler:', error);
|
||||
window.notify?.('error', 'Netzwerkfehler beim Kopieren.');
|
||||
} finally {
|
||||
this.isSaving = false;
|
||||
}
|
||||
this.copyFromId = '';
|
||||
const n = item.netzgebiet;
|
||||
let options = {};
|
||||
try { options = JSON.parse(n.options || '{}'); } catch {}
|
||||
let freigabeArr = [];
|
||||
try { freigabeArr = JSON.parse(n.freigabe || '[]') || []; } catch {}
|
||||
const freigabeObj = {};
|
||||
['interest', 'provision', 'order', 'reorder'].forEach(f => freigabeObj[f] = freigabeArr.includes(f));
|
||||
this.editItem = {
|
||||
id: null,
|
||||
name: '',
|
||||
extref: '',
|
||||
source: n.source || '',
|
||||
source_id: '',
|
||||
freigabe: freigabeObj,
|
||||
options: { ...this.defaultOptions, ...options }
|
||||
};
|
||||
this.showEditModal = true;
|
||||
},
|
||||
async saveNetzgebiet() {
|
||||
if (!this.editItem?.name) return;
|
||||
|
||||
Reference in New Issue
Block a user