This repository has been archived by the owner on Jun 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract Empty.vue from ProductList.vue
- Loading branch information
Showing
2 changed files
with
95 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<template> | ||
<div class="empty"> | ||
<div class="text-body-1 font-weight-medium"> | ||
Empty. No {{ productType.plural }} are found. | ||
</div> | ||
<v-btn | ||
depressed | ||
variant="flat" | ||
:to="{ | ||
name: 'ProductAdd', | ||
params: { productTypeName: productType.name }, | ||
}" | ||
prepend-icon="mdi-plus-thick" | ||
text="Add the first entry" | ||
> | ||
</v-btn> | ||
<v-dialog v-model="deleteDialog" max-width="400"> | ||
<template v-slot:activator="{ props }"> | ||
<v-btn | ||
v-bind="props" | ||
variant="outlined" | ||
color="secondary" | ||
:disabled="disableDelete" | ||
prepend-icon="mdi-delete" | ||
text="Delete this product type" | ||
> | ||
</v-btn> | ||
</template> | ||
<product-type-delete-form | ||
v-if="deleteDialog" | ||
:node="node" | ||
@cancel="onDeleteFormCancelled" | ||
@finished="onDeleteFormFinished" | ||
></product-type-delete-form> | ||
</v-dialog> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref, computed } from "vue"; | ||
import { useRouter } from "vue-router"; | ||
import { useConfigStore } from "@/stores/config"; | ||
import { QueryForProductListQuery } from "@/generated/graphql"; | ||
import ProductTypeDeleteForm from "@/components/product-type/ProductTypeDeleteForm.vue"; | ||
type ProductType = NonNullable<QueryForProductListQuery["productType"]>; | ||
interface Props { | ||
productType: ProductType; | ||
} | ||
const prop = defineProps<Props>(); | ||
const node = computed(() => ({ | ||
typeId: Number(prop.productType.typeId), | ||
plural: prop.productType.plural ?? prop.productType.name, | ||
})); | ||
const router = useRouter(); | ||
const configStore = useConfigStore(); | ||
const disableDelete = computed(() => !configStore.config.productDeletionDialog); | ||
const deleteDialog = ref(false); | ||
function onDeleteFormCancelled() { | ||
closeDeleteForm(); | ||
} | ||
function onDeleteFormFinished() { | ||
closeDeleteForm(); | ||
onDeleted(); | ||
} | ||
function closeDeleteForm() { | ||
deleteDialog.value = false; | ||
} | ||
function onDeleted() { | ||
router.push({ name: "Dashboard" }); | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.empty { | ||
margin-top: 16px; | ||
display: grid; | ||
block-size: 100%; | ||
place-items: center; | ||
gap: 24px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters