Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
R
reybex-educational-app
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
M. Esat Akpunar
reybex-educational-app
Commits
04d79a95
Commit
04d79a95
authored
Aug 31, 2022
by
esatakpunar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
products add and edit properties
parent
20fea156
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
2216 additions
and
2278 deletions
+2216
-2278
index.vue
client/src/modules/customers/index.vue
+1
-3
index.vue
client/src/modules/products/index.vue
+55
-55
actions.js
client/src/modules/products/store/actions.js
+21
-5
getters.js
client/src/modules/products/store/getters.js
+17
-0
mutations.js
client/src/modules/products/store/mutations.js
+6
-0
db.json
server/db.json
+2116
-2215
No files found.
client/src/modules/customers/index.vue
View file @
04d79a95
...
@@ -68,9 +68,7 @@ export default {
...
@@ -68,9 +68,7 @@ export default {
</
template
>
</
template
>
<
template
v-slot:
[`
item
.
actions
`]="{
item
}"
>
<
template
v-slot:
[`
item
.
actions
`]="{
item
}"
>
<v-icon
small
class=
"mr-2"
@
click=
"editItem(item)"
>
<v-icon
small
class=
"mr-2"
>
mdi-pencil
</v-icon>
mdi-pencil
</v-icon>
<v-icon
small
@
click=
"deleteCustomer([item.id])"
>
mdi-delete
</v-icon>
<v-icon
small
@
click=
"deleteCustomer([item.id])"
>
mdi-delete
</v-icon>
</
template
>
</
template
>
</v-data-table>
</v-data-table>
...
...
client/src/modules/products/index.vue
View file @
04d79a95
...
@@ -11,6 +11,7 @@ export default {
...
@@ -11,6 +11,7 @@ export default {
computed
:
{
computed
:
{
...
mapGetters
(
"products"
,
[
...
mapGetters
(
"products"
,
[
"headers"
,
"headers"
,
"dialogHeaders"
,
"productList"
,
"productList"
,
"singleExpand"
,
"singleExpand"
,
"expanded"
,
"expanded"
,
...
@@ -26,7 +27,8 @@ export default {
...
@@ -26,7 +27,8 @@ export default {
"closeDialog"
,
"closeDialog"
,
"deleteProduct"
,
"deleteProduct"
,
"deleteMultiProduct"
,
"deleteMultiProduct"
,
"addProduct"
,
"saveProduct"
,
"editProduct"
,
]),
]),
},
},
created
()
{
created
()
{
...
@@ -55,70 +57,68 @@ export default {
...
@@ -55,70 +57,68 @@ export default {
<v-toolbar-title>
Products
</v-toolbar-title>
<v-toolbar-title>
Products
</v-toolbar-title>
<v-divider
class=
"mx-4"
inset
vertical
></v-divider>
<v-divider
class=
"mx-4"
inset
vertical
></v-divider>
<v-dialog
v-model=
"dialog"
max-width=
"750px"
>
<v-btn
<template
v-slot:activator=
"
{ on, attrs }">
large
<v-btn
icon
large
color=
"success"
icon
class=
"white--text"
color=
"success"
@
click=
"editProduct()"
class=
"ml-4"
>
v-bind=
"attrs"
v-on=
"on"
>
<v-icon>
add
</v-icon>
</v-btn>
</
template
>
<v-card>
<v-card-title>
<span
class=
"text-h5"
>
Add Product
</span>
</v-card-title>
<v-card-text>
<v-container>
<v-row>
<
template
v-for=
"header in headers"
>
<v-flex
xs12
sm6
md4
pa-4
:key=
"header.value"
v-if=
"!(header.value === 'actions')"
>
<v-text-field
v-model=
"editedItem[header.value]"
:label=
"header.text"
></v-text-field>
</v-flex>
</
template
>
</v-row>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn
color=
"blue darken-1"
text
>
Cancel
</v-btn>
<v-btn
color=
"blue darken-1"
text
@
click=
"addProduct()"
>
Save
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- <v-btn large icon color="success" class="white--text ml-2">
<v-icon>
add
</v-icon>
<v-icon>
add
</v-icon>
</v-btn>
-->
</v-btn>
<v-btn
<v-btn
large
large
icon
icon
color=
"red"
color=
"red"
class=
"white--text
ml-2
"
class=
"white--text"
@
click=
"deleteMultiProduct(selected)"
@
click=
"deleteMultiProduct(selected)"
>
>
<v-dialog
v-model=
"dialog"
max-width=
"500px"
>
<template
v-slot:activator=
"
{}">
</
template
>
<v-card>
<v-card-title>
<span
class=
"headline"
></span>
</v-card-title>
<v-card-text>
<v-container
grid-list-md
>
<v-layout
wrap
>
<
template
v-for=
"header in dialogHeaders"
>
<v-flex
xs12
sm6
md4
:key=
"header.value"
v-if=
"!(header.value === 'actions')"
>
<v-text-field
v-model=
"editedItem[header.value]"
:label=
"header.text"
></v-text-field>
</v-flex>
</
template
>
</v-layout>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<
template
>
<v-btn
color=
"blue darken-1"
@
click=
"closeDialog()"
>
Cancel
</v-btn
>
<v-btn
color=
"blue darken-1"
@
click=
"saveProduct()"
>
Save
</v-btn
>
</
template
>
</v-card-actions>
</v-card>
</v-dialog>
<v-icon>
delete
</v-icon>
<v-icon>
delete
</v-icon>
</v-btn>
</v-btn>
<v-spacer></v-spacer>
<v-spacer></v-spacer>
<v-switch
<v-switch
v-model=
"singleExpand"
v-model=
"singleExpand"
label=
"Single expand"
label=
"Single expand"
...
@@ -133,7 +133,7 @@ export default {
...
@@ -133,7 +133,7 @@ export default {
</
template
>
</
template
>
<
template
v-slot:
[`
item
.
actions
`]="{
item
}"
>
<
template
v-slot:
[`
item
.
actions
`]="{
item
}"
>
<v-icon
small
class=
"mr-2"
@
click=
"edit
Item
(item)"
>
<v-icon
small
class=
"mr-2"
@
click=
"edit
Product
(item)"
>
mdi-pencil
mdi-pencil
</v-icon>
</v-icon>
<v-icon
small
@
click=
"deleteProduct([item.id])"
>
mdi-delete
</v-icon>
<v-icon
small
@
click=
"deleteProduct([item.id])"
>
mdi-delete
</v-icon>
...
...
client/src/modules/products/store/actions.js
View file @
04d79a95
...
@@ -31,6 +31,7 @@ export default {
...
@@ -31,6 +31,7 @@ export default {
console
.
log
(
e
);
console
.
log
(
e
);
});
});
});
});
this
.
itemList
=
[];
},
},
deleteMultiProduct
({
dispatch
},
items
)
{
deleteMultiProduct
({
dispatch
},
items
)
{
const
itemList
=
[];
const
itemList
=
[];
...
@@ -40,16 +41,31 @@ export default {
...
@@ -40,16 +41,31 @@ export default {
console
.
log
(
itemList
);
console
.
log
(
itemList
);
dispatch
(
"deleteProduct"
,
itemList
);
dispatch
(
"deleteProduct"
,
itemList
);
},
},
addProduct
({
getters
,
dispatch
})
{
const
config
=
{
saveProduct
({
getters
,
dispatch
})
{
if
(
!
getters
.
editedItem
.
image
)
{
getters
.
editedItem
.
image
=
"https://upload.wikimedia.org/wikipedia/commons/7/70/Solid_white.svg"
;
}
const
postConfig
=
{
method
:
"post"
,
method
:
"post"
,
url
:
`http://localhost:3000/products/`
,
url
:
`http://localhost:3000/products/`
,
data
:
{
products
:
getters
.
editedItem
},
data
:
getters
.
editedItem
,
};
const
putConfig
=
{
method
:
"put"
,
url
:
`http://localhost:3000/products/
${
getters
.
editedItem
.
id
}
`
,
data
:
getters
.
editedItem
,
};
};
axios
(
config
).
then
(()
=>
{
axios
(
!
getters
.
editedItem
.
id
?
postConfig
:
putConfig
).
then
(()
=>
{
console
.
log
(
"TESET"
);
dispatch
(
"fetchProductData"
);
dispatch
(
"fetchProductData"
);
});
});
dispatch
(
"closeDialog"
);
dispatch
(
"closeDialog"
);
},
},
editProduct
({
commit
,
getters
},
item
)
{
commit
(
"setEditedIndex"
,
getters
.
productList
.
indexOf
(
item
));
commit
(
"setEditedItem"
,
Object
.
assign
({},
item
));
commit
(
"setDialog"
,
true
);
},
};
};
client/src/modules/products/store/getters.js
View file @
04d79a95
...
@@ -16,6 +16,23 @@ export default {
...
@@ -16,6 +16,23 @@ export default {
{
text
:
"Actions"
,
value
:
"actions"
,
sortable
:
false
},
{
text
:
"Actions"
,
value
:
"actions"
,
sortable
:
false
},
];
];
},
},
dialogHeaders
()
{
return
[
{
text
:
"Product Name"
,
align
:
"left"
,
value
:
"productName"
,
type
:
"text"
,
},
{
text
:
"Type"
,
value
:
"type"
,
type
:
"text"
},
{
text
:
"Product Material"
,
value
:
"productMaterial"
,
type
:
"text"
},
{
text
:
"Department"
,
value
:
"department"
,
type
:
"text"
},
{
text
:
"Color"
,
value
:
"color"
,
type
:
"text"
},
{
text
:
"Price"
,
value
:
"price"
,
type
:
"text"
},
{
text
:
"Image"
,
value
:
"image"
,
type
:
"text"
},
{
text
:
"Product Description"
,
value
:
"productDescription"
},
];
},
productList
(
state
)
{
productList
(
state
)
{
return
state
.
productList
;
return
state
.
productList
;
},
},
...
...
client/src/modules/products/store/mutations.js
View file @
04d79a95
...
@@ -8,4 +8,10 @@ export default {
...
@@ -8,4 +8,10 @@ export default {
setDialog
(
state
,
value
)
{
setDialog
(
state
,
value
)
{
state
.
dialog
=
value
;
state
.
dialog
=
value
;
},
},
setEditedIndex
(
state
,
index
)
{
state
.
editedIndex
=
index
;
},
setEditedItem
(
state
,
item
)
{
state
.
editedItem
=
item
;
},
};
};
server/db.json
View file @
04d79a95
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment