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
d1cdf9ed
Commit
d1cdf9ed
authored
Sep 01, 2022
by
esatakpunar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add pagination server side
parent
5a0feaa9
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
53 deletions
+42
-53
index.vue
client/src/modules/customers/index.vue
+14
-4
actions.js
client/src/modules/customers/store/actions.js
+14
-20
getters.js
client/src/modules/customers/store/getters.js
+5
-2
mutations.js
client/src/modules/customers/store/mutations.js
+7
-3
state.js
client/src/modules/customers/store/state.js
+2
-1
index.vue
client/src/modules/products/index.vue
+0
-1
db.json
server/db.json
+0
-22
No files found.
client/src/modules/customers/index.vue
View file @
d1cdf9ed
...
...
@@ -14,29 +14,38 @@ export default {
...
mapGetters
(
"customers"
,
[
"headers"
,
"customerList"
,
"filteredCustomerList"
,
"dialog"
,
"loading"
,
"dialogHeaders"
,
"editedItem"
,
"editedIndex"
,
"getOptions"
,
"totalCustomers"
,
]),
indexofColumn
()
{
return
this
.
dialogHeaders
.
findIndex
(
(
header
)
=>
this
.
column
==
header
.
value
);
},
options
:
{
get
()
{
return
this
.
getOptions
;
},
set
(
data
)
{
this
.
setOptions
(
data
);
},
},
},
methods
:
{
...
mapActions
(
"customers"
,
[
"fetchCustomerData"
,
"toggleSingleExpand"
,
"closeDialog"
,
"deleteCustomer"
,
"deleteMultiCustomer"
,
"saveCustomer"
,
"editCustomer"
,
"
filterCustomer
"
,
"
setOptions
"
,
]),
},
created
()
{
...
...
@@ -55,6 +64,8 @@ export default {
:headers=
"headers"
:items=
"customerList"
:loading=
"loading"
:options
.
sync=
"options"
:server-items-length=
"Number(totalCustomers)"
show-select
class=
"evation-1"
>
...
...
@@ -62,7 +73,6 @@ export default {
<v-toolbar
flat
>
<v-toolbar-title>
Customers
</v-toolbar-title>
<v-divider
class=
"mx-4"
inset
vertical
></v-divider>
<v-btn
large
icon
...
...
client/src/modules/customers/store/actions.js
View file @
d1cdf9ed
import
axios
from
"axios"
;
export
default
{
fetchCustomerData
({
dispatch
,
commit
},
data
=
{})
{
fetchCustomerData
({
commit
,
getters
},
data
=
{})
{
let
query
;
if
(
data
.
filterColumn
==
"all"
)
{
query
=
"q="
+
data
.
searchInput
;
}
else
if
(
data
.
filterColumn
)
{
query
=
data
.
filterColumn
+
"_like="
+
data
.
searchInput
;
}
let
pageLimit
=
`&_page=
${
getters
.
getOptions
.
page
}
&_limit=
${
getters
.
getOptions
.
itemsPerPage
}
`
;
let
sort
=
`&_sort=
${
getters
.
getOptions
.
sortBy
}
&_order=
${
getters
.
getOptions
.
sortDesc
}
`
;
commit
(
"setLoading"
,
true
);
axios
.
get
(
`http://localhost:3000/customers?
${
query
}
`
)
.
get
(
`http://localhost:3000/customers?
${
query
}
${
pageLimit
}${
sort
}
`
)
.
then
((
response
)
=>
{
commit
(
"setTotalCustomers"
,
response
.
headers
[
"x-total-count"
]);
commit
(
"setCustomerList"
,
response
.
data
);
dispatch
(
"filterCustomer"
,
{
searchInput
:
""
});
commit
(
"setLoading"
,
false
);
})
.
catch
((
e
)
=>
{
console
.
log
(
e
);
});
},
setOptions
({
commit
,
dispatch
},
data
)
{
commit
(
"setOptions"
,
data
);
dispatch
(
"fetchCustomerData"
);
},
closeDialog
({
commit
})
{
commit
(
"setDialog"
,
false
);
},
deleteCustomer
({
dispatch
,
commit
},
idList
)
{
confirm
(
"Are you sure you want to delete this item?"
)
&&
idList
.
forEach
((
id
)
=>
{
...
...
@@ -72,20 +82,4 @@ export default {
commit
(
"setEditedItem"
,
Object
.
assign
({},
item
));
commit
(
"setDialog"
,
true
);
},
filterCustomer
({
getters
,
commit
},
data
)
{
let
x
;
if
(
!
data
.
searchInput
)
{
x
=
getters
.
customerList
;
}
else
{
x
=
getters
.
customerList
.
filter
((
customer
)
=>
{
if
(
customer
[
data
.
filterColumn
])
{
return
customer
[
data
.
filterColumn
]
.
toLowerCase
()
.
includes
(
data
.
searchInput
.
toLowerCase
());
}
});
}
commit
(
"setfilteredCustomerList"
,
x
);
},
};
client/src/modules/customers/store/getters.js
View file @
d1cdf9ed
...
...
@@ -46,7 +46,10 @@ export default {
loading
(
state
)
{
return
state
.
loading
;
},
filteredCustomerList
(
state
)
{
return
state
.
filteredCustomerList
;
getOptions
(
state
)
{
return
state
.
options
;
},
totalCustomers
(
state
)
{
return
state
.
totalCustomers
;
},
};
client/src/modules/customers/store/mutations.js
View file @
d1cdf9ed
export
default
{
setCustomerList
(
state
,
data
)
{
state
.
customerList
=
data
;
console
.
log
(
"data"
,
state
.
customerList
);
},
setEditedIndex
(
state
,
index
)
{
state
.
editedIndex
=
index
;
...
...
@@ -13,9 +14,12 @@ export default {
},
setLoading
(
state
,
value
)
{
state
.
loading
=
value
;
console
.
log
(
value
);
},
setfilteredCustomerList
(
state
,
data
)
{
state
.
filteredCustomerList
=
data
;
setOptions
(
state
,
data
)
{
state
.
options
=
data
;
},
setTotalCustomers
(
state
,
data
)
{
state
.
totalCustomers
=
data
;
console
.
log
(
state
.
totalCustomers
);
},
};
client/src/modules/customers/store/state.js
View file @
d1cdf9ed
export
default
()
=>
({
customerList
:
[],
filteredCustomerList
:
[],
editedIndex
:
-
1
,
editedItem
:
{},
dialog
:
false
,
loading
:
false
,
options
:
{},
totalCustomers
:
0
,
});
client/src/modules/products/index.vue
View file @
d1cdf9ed
...
...
@@ -62,7 +62,6 @@ export default {
methods
:
{
...
mapActions
(
"products"
,
[
"fetchProductData"
,
"toggleSingleExpand"
,
"closeDialog"
,
"deleteProduct"
,
"deleteMultiProduct"
,
...
...
server/db.json
View file @
d1cdf9ed
...
...
@@ -345,28 +345,6 @@
}
],
"products"
:
[
{
"id"
:
"018ac742-5c12-4cf1-998c-28ea47a4169d"
,
"color"
:
"maroon"
,
"department"
:
"Health"
,
"price"
:
"78.00"
,
"productName"
:
"Gorgeous Frozen Sausages"
,
"type"
:
"Unbranded"
,
"productDescription"
:
"Ergonomic executive chair upholstered in bonded black leather and PVC padded seat and back for all-day comfort and support"
,
"productMaterial"
:
"Steel"
,
"image"
:
"http://loremflickr.com/640/480/food"
},
{
"id"
:
"507f36d9-3f8d-4b51-954a-20ec632fb972"
,
"color"
:
"ivory"
,
"department"
:
"Beauty"
,
"price"
:
"176.00"
,
"productName"
:
"Tasty Granite Shoes"
,
"type"
:
"Gorgeous"
,
"productDescription"
:
"Carbonite web goalkeeper gloves are ergonomically designed to give easy fit"
,
"productMaterial"
:
"Steel"
,
"image"
:
"http://loremflickr.com/640/480/food"
},
{
"id"
:
"fb4d2408-751f-4e07-856e-322dbed6f728"
,
"color"
:
"azure"
,
...
...
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