Working on product detail dialog

This commit is contained in:
2024-09-08 20:35:10 +02:00
parent f82f6ce9af
commit 20e8ce1024
5 changed files with 85 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ export class ProductModel {
id: number = -1
brand: string = ""
name: string = ""
description: string = ""
categoryId: number = 0
price: number = 0
discount: number = 0

View File

@@ -1,5 +1,6 @@
<script setup lang="ts">
import productCard from "./productCard.vue"
import productDetails from "./productDetails.vue"
import filterBar from "./filterBar.vue"
import axios from "axios";
import { Ref, ref, watch } from "vue";
@@ -13,6 +14,8 @@ const categories: Ref<Array<CategoryModel>> = ref<Array<CategoryModel>>([new Cat
const selectedCategory: Ref<CategoryModel> = ref<CategoryModel>(new CategoryModel())
const sortedBy: Ref<FilterModel> = ref<FilterModel>()
const onlyDiscounts: Ref<boolean> = ref(false)
const showProductDetails = ref(false)
const dialogProduct = ref(new ProductModel())
const sortBy: Array<FilterModel> = [
{ icon: "mdi-sort-ascending", name: "Price: Low to high" },
@@ -100,6 +103,11 @@ function filterProducts() {
}
}
function showProductDialog(product: ProductModel) {
dialogProduct.value = product
showProductDetails.value = true
}
watch(() => selectedCategory.value, () => { filterProducts() })
watch(() => sortedBy.value, () => { sortProducts() })
watch(() => onlyDiscounts.value, () => { filterProducts() })
@@ -123,6 +131,7 @@ watch(() => onlyDiscounts.value, () => { filterProducts() })
<product-card
:product="product"
:category="getCategoryById(product.categoryId)"
@click="showProductDialog(product)"
/>
</v-col>
@@ -133,4 +142,6 @@ watch(() => onlyDiscounts.value, () => { filterProducts() })
/>
</v-col>
</v-row>
<product-details v-model="showProductDetails" :product="dialogProduct" :productCategory="getCategoryById(dialogProduct.categoryId)" />
</template>

View File

@@ -1,6 +1,57 @@
<script setup lang="ts">
import { VNumberInput } from 'vuetify/labs/VNumberInput'
import { ProductModel } from '@/data/models/productModel';
import { CategoryModel } from '@/data/models/categoryModel';
import { ref } from 'vue';
const showDialog = defineModel("showDialog", { type: Boolean })
const nrOfArticles = ref(1)
defineProps({
product: ProductModel,
productCategory: CategoryModel
})
</script>
<template>
<v-dialog max-width="800" v-model="showDialog">
<v-card :title="product.name" :subtitle="product.brand" >
<v-img :src="product.imageUrl" max-height="300" />
<v-card-text>
<v-row>
<v-col>
<v-icon :icon="productCategory.icon" />
{{ productCategory.name }}
</v-col>
</v-row>
<v-row>
<v-col>
{{ product.description }}
</v-col>
</v-row>
<v-row>
<v-col>
<v-number-input
:reverse="false"
controlVariant="default"
label="Anzahl"
:hideInput="false"
:inset="false"
v-model="nrOfArticles"
/>
</v-col>
<v-col>
{{ nrOfArticles * product.price }}
</v-col>
</v-row>
</v-card-text>
<v-card-actions>
<v-btn prepend-icon="mdi-cart-plus" >Zum Einkaufswagen hinzufügen</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>