add more users and description field
continuous-integration/drone/push Build is passing Details

master
adb-sh 2 years ago
parent 42a82a2b31
commit 0d754f93f5

@ -11,6 +11,7 @@ const item = reactive({
name: '', name: '',
price: 0.99, price: 0.99,
user: '', user: '',
description: '',
}); });
const form = ref(null); const form = ref(null);
@ -20,6 +21,7 @@ const submit = () => {
name: item.name, name: item.name,
price: item.price * 100, price: item.price * 100,
user: store.users.find(user => user.name === item.user), user: store.users.find(user => user.name === item.user),
description: item.description,
}); });
router.push('/shopping-list'); router.push('/shopping-list');
}; };
@ -38,6 +40,11 @@ const submit = () => {
required required
v-model="item.price" v-model="item.price"
/> />
<v-text-field
label="Description"
required
v-model="item.description"
/>
<v-select <v-select
label="User" label="User"
:items="store.users.map(user => user.name)" :items="store.users.map(user => user.name)"

@ -15,6 +15,7 @@ const item = reactive({
name: props.item.name, name: props.item.name,
price: props.item.price / 100, price: props.item.price / 100,
user: props.item.user.name, user: props.item.user.name,
description: props.item.description,
}); });
const form = ref(null); const form = ref(null);
@ -23,6 +24,7 @@ const submit = () => {
props.item.name = item.name; props.item.name = item.name;
props.item.price = item.price * 100; props.item.price = item.price * 100;
props.item.user = store.users.find(user => user.name === item.user); props.item.user = store.users.find(user => user.name === item.user);
props.item.description = item.description;
router.push('/shopping-list'); router.push('/shopping-list');
}; };
</script> </script>
@ -40,6 +42,11 @@ const submit = () => {
required required
v-model="item.price" v-model="item.price"
/> />
<v-text-field
label="Description"
required
v-model="item.description"
/>
<v-select <v-select
label="User" label="User"
:items="store.users.map(user => user.name)" :items="store.users.map(user => user.name)"

@ -14,7 +14,7 @@ defineProps({
<div v-for="item in items"> <div v-for="item in items">
<v-list-item> <v-list-item>
<v-list-item-title>{{ item.name }}</v-list-item-title> <v-list-item-title>{{ item.name }}</v-list-item-title>
<v-list-item-subtitle>{{ item.price / 100 }} </v-list-item-subtitle> <v-list-item-subtitle>{{ item.description }} - {{ item.price / 100 }} </v-list-item-subtitle>
<template v-slot:append> <template v-slot:append>
<v-btn icon="mdi-pencil" variant="text" :to="`/edit-item/${ item.id }`"/> <v-btn icon="mdi-pencil" variant="text" :to="`/edit-item/${ item.id }`"/>
<v-btn icon="mdi-check" variant="text" @click="item.isBought = !item.isBought"/> <v-btn icon="mdi-check" variant="text" @click="item.isBought = !item.isBought"/>

@ -3,10 +3,18 @@ const lukas = {
}; };
const laura = { const laura = {
name: 'laura' name: 'laura',
}; };
export const users = [ lukas, laura ]; const niklas = {
name: 'niklas',
};
const lisa = {
name: 'lisa',
};
export const users = [ lukas, laura, niklas, lisa ];
export const dummyList = [ export const dummyList = [
{ {
@ -14,6 +22,7 @@ export const dummyList = [
price: 200, price: 200,
user: lukas, user: lukas,
isBought: false, isBought: false,
description: 'the yellow ones',
id: 0, id: 0,
}, },
{ {
@ -21,6 +30,7 @@ export const dummyList = [
price: 150, price: 150,
user: lukas, user: lukas,
isBought: false, isBought: false,
description: 'six or so',
id: 1, id: 1,
}, },
{ {
@ -28,6 +38,15 @@ export const dummyList = [
price: 149, price: 149,
user: laura, user: laura,
isBought: false, isBought: false,
description: 'one pack',
id: 2, id: 2,
}, },
{
name: 'Coffee',
price: 149,
user: laura,
isBought: false,
description: 'the one for espresso',
id: 3,
},
]; ];

@ -12,7 +12,7 @@ const item = ref(store.items.find(item => item.id === Number(route.params.id)));
</script> </script>
<template> <template>
<DefaultPage title="Add Item"> <DefaultPage title="Edit Item">
<v-container> <v-container>
<EditItemForm v-if="item" :item="item"/> <EditItemForm v-if="item" :item="item"/>
<div v-else> <div v-else>

@ -23,7 +23,7 @@ const tabs = [
</v-window-item> </v-window-item>
</v-window> </v-window>
</v-container> </v-container>
<v-card-text style="display: flex; justify-content: end"> <v-card-text style="position: absolute; right: 0;">
<v-btn <v-btn
icon="mdi-plus" icon="mdi-plus"
color="red" color="red"

Loading…
Cancel
Save