Functionality to create, update and delete label.
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
<script setup lang="ts">
|
||||
import {useLabelEditorStore} from "~/store/labelEditorStore";
|
||||
import type {Ref} from "vue";
|
||||
import LabelCreate from "~/components/label/labelCreate.vue";
|
||||
|
||||
let store = useLabelEditorStore();
|
||||
let dialog: Ref<boolean> = ref<boolean>(false);
|
||||
let loading: Ref<boolean> = ref<boolean>(false);
|
||||
|
||||
watch(dialog, async (oldDialog) => {
|
||||
if (oldDialog) {
|
||||
loading.value = true;
|
||||
|
||||
await store.loadLabels();
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
})
|
||||
|
||||
function closeDialog() {
|
||||
dialog.value = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
:scrollable="true"
|
||||
width="800"
|
||||
max-height="750"
|
||||
height="750"
|
||||
>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-btn
|
||||
:flat="true"
|
||||
v-bind="props"
|
||||
size="small"
|
||||
>
|
||||
<v-icon>mdi-label</v-icon>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="bottom"
|
||||
>
|
||||
Etiketten Typen
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<v-row style="padding-top: 10px">
|
||||
<v-icon size="small">
|
||||
mdi-label
|
||||
</v-icon>
|
||||
|
||||
Etiketten Typen
|
||||
|
||||
<v-progress-circular v-if="loading" indeterminate :size="15" :width="2"></v-progress-circular>
|
||||
|
||||
<v-spacer/>
|
||||
<v-divider vertical/>
|
||||
|
||||
<LabelCreate/>
|
||||
</v-row>
|
||||
</v-card-title>
|
||||
|
||||
<v-divider/>
|
||||
|
||||
<v-card-text>
|
||||
<LabelRow
|
||||
v-for="(label) in store.labels"
|
||||
:key="label.id"
|
||||
v-bind:label="label"
|
||||
/>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider/>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer/>
|
||||
|
||||
<v-btn
|
||||
variant="text"
|
||||
:disabled="loading"
|
||||
@click="closeDialog()"
|
||||
>
|
||||
Schließen
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,114 @@
|
||||
<script setup lang="ts">
|
||||
import {useLabelEditorStore} from "~/store/labelEditorStore";
|
||||
import type {Ref} from "vue";
|
||||
import {Label} from "~/types/label";
|
||||
|
||||
let store = useLabelEditorStore();
|
||||
let dialog: Ref<boolean> = ref<boolean>(false);
|
||||
let loading: Ref<boolean> = ref<boolean>(false);
|
||||
|
||||
let name: Ref<string | null> = ref<string | null>(null);
|
||||
|
||||
watch(dialog, async (oldDialog) => {
|
||||
if (oldDialog) {
|
||||
loading.value = true;
|
||||
|
||||
await store.loadLabels();
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
})
|
||||
|
||||
async function create() {
|
||||
if (name.value != null && name.value.trim().length > 0){
|
||||
const label = new Label(0, name.value);
|
||||
await store.createLabel(label);
|
||||
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
dialog.value = false;
|
||||
clearVariables();
|
||||
}
|
||||
|
||||
function clearVariables() {
|
||||
name.value = null;
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-dialog
|
||||
v-model="dialog"
|
||||
:scrollable="true"
|
||||
width="800"
|
||||
max-height="750"
|
||||
>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-btn
|
||||
:flat="true"
|
||||
v-bind="props"
|
||||
size="small"
|
||||
>
|
||||
<v-icon>mdi-plus-thick</v-icon>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="bottom"
|
||||
>
|
||||
Etiketten Typ erstellen
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<v-icon size="small">
|
||||
mdi-plus-thick
|
||||
</v-icon>
|
||||
|
||||
Etiketten Typ erstellen
|
||||
|
||||
<v-progress-circular v-if="loading" indeterminate :size="15" :width="2"></v-progress-circular>
|
||||
</v-card-title>
|
||||
|
||||
<v-divider/>
|
||||
|
||||
<v-card-text>
|
||||
<v-text-field
|
||||
v-model.trim="name"
|
||||
label="Bezeichnung"
|
||||
autofocus
|
||||
/>
|
||||
</v-card-text>
|
||||
|
||||
<v-divider/>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer/>
|
||||
<v-btn
|
||||
variant="text"
|
||||
:disabled="loading"
|
||||
@click="closeDialog()"
|
||||
>
|
||||
Schließen
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
variant="text"
|
||||
:disabled="name == null || loading"
|
||||
@click="create();"
|
||||
>
|
||||
Erstellen
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,119 @@
|
||||
<script setup lang="ts">
|
||||
import {useLabelEditorStore} from "~/store/labelEditorStore";
|
||||
import type {Ref} from "vue";
|
||||
import DeleteConfirm from "~/components/ui/deleteConfirm.vue";
|
||||
import {Label} from "~/types/label";
|
||||
|
||||
let store = useLabelEditorStore();
|
||||
|
||||
const props = defineProps({
|
||||
label: {type: Object as PropType<Label>, required: true},
|
||||
});
|
||||
|
||||
let edit: Ref<boolean> = ref<boolean>(false);
|
||||
|
||||
let name: Ref<string | null> = ref<string | null>(JSON.parse(JSON.stringify(props.label.name)));
|
||||
|
||||
function toggleEdit() {
|
||||
if (edit.value) {
|
||||
disableEdit();
|
||||
} else {
|
||||
enableEdit();
|
||||
}
|
||||
}
|
||||
|
||||
function enableEdit() {
|
||||
edit.value = true;
|
||||
}
|
||||
|
||||
function disableEdit() {
|
||||
name.value = JSON.parse(JSON.stringify(props.label.name));
|
||||
}
|
||||
|
||||
async function updateLabel() {
|
||||
if (name.value != null && name.value.trim().length > 0) {
|
||||
const label = new Label(props.label.id, name.value);
|
||||
await store.updateLabel(label);
|
||||
|
||||
disableEdit();
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteLabel() {
|
||||
await store.deleteLabel(props.label.id);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<v-card>
|
||||
<v-card-title>
|
||||
<v-row style="padding-top: 10px">
|
||||
<v-text-field
|
||||
v-model.trim="name"
|
||||
:readonly="!edit"
|
||||
/>
|
||||
|
||||
<v-spacer />
|
||||
|
||||
<v-divider vertical/>
|
||||
|
||||
<DeleteConfirm
|
||||
title="Etiketten Typ löschen?"
|
||||
:disable="!edit"
|
||||
@delete="deleteLabel()"
|
||||
/>
|
||||
|
||||
<v-divider vertical/>
|
||||
|
||||
<v-btn
|
||||
:flat="true"
|
||||
:disabled="!edit"
|
||||
:hidden="edit"
|
||||
@click="disableEdit()"
|
||||
>
|
||||
<v-icon>mdi-cancel</v-icon>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="bottom"
|
||||
>
|
||||
Abbrechen
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
:flat="true"
|
||||
:disabled="!edit"
|
||||
:hidden="edit"
|
||||
@click="updateLabel()"
|
||||
>
|
||||
<v-icon>mdi-content-save</v-icon>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="bottom"
|
||||
>
|
||||
Speichern
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
|
||||
<v-divider vertical/>
|
||||
|
||||
<v-btn
|
||||
:flat="true"
|
||||
@click="toggleEdit();"
|
||||
>
|
||||
<v-icon>mdi-pencil</v-icon>
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="bottom"
|
||||
>
|
||||
Bearbeiten
|
||||
</v-tooltip>
|
||||
</v-btn>
|
||||
</v-row>
|
||||
</v-card-title>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -14,6 +14,12 @@
|
||||
:vertical="true"
|
||||
/>
|
||||
|
||||
<Label/>
|
||||
|
||||
<v-divider
|
||||
:vertical="true"
|
||||
/>
|
||||
|
||||
<PickArticle/>
|
||||
|
||||
<ArticleCreate/>
|
||||
|
||||
Reference in New Issue
Block a user