2023-03-30 10:54:18 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: 2023 Andreas Palm
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
|
|
|
-->
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import axios from "axios";
|
|
|
|
import {ref} from 'vue';
|
|
|
|
import {reloadDataTables} from "@res/js/jqueryBridge";
|
|
|
|
import AddGlobalToArticle from "./AddGlobalToArticle.vue";
|
|
|
|
import GroupEdit from "./GroupEdit.vue";
|
|
|
|
import OptionEdit from "./OptionEdit.vue";
|
|
|
|
import Variant from "./Variant.vue";
|
2023-12-11 22:13:37 +01:00
|
|
|
import Translation from "./Translation.vue";
|
2024-04-24 15:14:35 +02:00
|
|
|
import CreateMissing from "./CreateMissing.vue";
|
2023-03-30 10:54:18 +02:00
|
|
|
|
|
|
|
const model = ref(null);
|
|
|
|
|
|
|
|
document.getElementById('main').addEventListener('click', async (ev) => {
|
|
|
|
const target = ev.target;
|
|
|
|
if (!target || !target.classList.contains('vueAction'))
|
|
|
|
return;
|
|
|
|
const ds = target.dataset;
|
|
|
|
if (ds.action.endsWith('Delete')) {
|
|
|
|
const cnf = confirm('Wirklich löschen?');
|
|
|
|
if (!cnf)
|
|
|
|
return;
|
|
|
|
let url;
|
|
|
|
switch (ds.action) {
|
|
|
|
case 'groupDelete':
|
|
|
|
url = ds.articleId > 0
|
|
|
|
? 'index.php?module=matrixprodukt&action=artikel&cmd=groupdelete'
|
|
|
|
: 'index.php?module=matrixprodukt&action=list&cmd=delete';
|
|
|
|
await axios.post(url, {groupId: ds.groupId});
|
|
|
|
break;
|
|
|
|
case 'optionDelete':
|
|
|
|
url = ds.articleId > 0
|
|
|
|
? 'index.php?module=matrixprodukt&action=artikel&cmd=optiondelete'
|
|
|
|
: 'index.php?module=matrixprodukt&action=optionenlist&cmd=delete';
|
|
|
|
await axios.post(url, {optionId: ds.optionId});
|
|
|
|
break;
|
|
|
|
case 'variantDelete':
|
|
|
|
url = 'index.php?module=matrixprodukt&action=artikel&cmd=variantdelete';
|
|
|
|
await axios.post(url, {variantId: ds.variantId});
|
|
|
|
break;
|
2023-12-11 22:13:37 +01:00
|
|
|
case 'translationDelete':
|
|
|
|
url = 'index.php?module=matrixprodukt&action=translation&cmd=delete';
|
|
|
|
await axios.post(url, {id: ds.id, type: ds.type});
|
|
|
|
break;
|
2023-03-30 10:54:18 +02:00
|
|
|
}
|
|
|
|
onSave();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
model.value = ds;
|
|
|
|
});
|
|
|
|
|
|
|
|
function onSave() {
|
|
|
|
reloadDataTables();
|
|
|
|
onClose();
|
|
|
|
}
|
|
|
|
|
2024-03-15 22:22:27 +01:00
|
|
|
function onGroupSave() {
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
|
2023-03-30 10:54:18 +02:00
|
|
|
function onClose() {
|
|
|
|
model.value = null;
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template v-if="model">
|
2024-03-15 22:22:27 +01:00
|
|
|
<AddGlobalToArticle v-if="model.action === 'addGlobalToArticle'" v-bind="model" @close="onClose" @save="onGroupSave" />
|
|
|
|
<GroupEdit v-else-if="model.action === 'groupEdit'" v-bind="model" @close="onClose" @save="onGroupSave" />
|
2023-03-30 10:54:18 +02:00
|
|
|
<OptionEdit v-else-if="model.action === 'optionEdit'" v-bind="model" @close="onClose" @save="onSave" />
|
|
|
|
<Variant v-else-if="model.action === 'variantEdit'" v-bind="model" @close="onClose" @save="onSave" />
|
2024-04-24 15:14:35 +02:00
|
|
|
<CreateMissing v-else-if="model.action === 'createMissing'" v-bind="model" @close="onClose" @save="onSave" />
|
2023-12-11 22:13:37 +01:00
|
|
|
<Translation v-else-if="model.action === 'translationEdit'" v-bind="model" @close="onClose" @save="onSave" />
|
2023-03-30 10:54:18 +02:00
|
|
|
</template>
|
|
|
|
</template>
|