Skip to content

Commit 102a9ff

Browse files
committed
UPD user list/create func
1 parent 44a5591 commit 102a9ff

File tree

5 files changed

+52
-23
lines changed

5 files changed

+52
-23
lines changed

src/pages/E-commerce/ProductManagement/ProductManagement.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
v-on="on"
3939
>Create Product</v-btn>
4040
</template>
41-
<v-card class="edit-dialog" >
41+
<v-card class="edit-dialog">
4242
<v-card-title>
4343
<span class="headline">{{ formTitle }}</span>
4444
</v-card-title>
@@ -112,16 +112,14 @@
112112
color="success"
113113
right
114114
top
115-
style="top: 50px"
116-
>
115+
style="top: 50px">
117116
{{ text }}
118117
<template v-slot:action="{ attrs }">
119118
<v-btn
120119
dark
121120
text
122121
v-bind="attrs"
123-
@click="snackbar = false"
124-
>
122+
@click="snackbar = false">
125123
Close
126124
</v-btn>
127125
</template>
@@ -196,8 +194,10 @@
196194
val || this.close()
197195
},
198196
productMessage() {
199-
this.notification = this.productMessage;
200-
this.addSuccessNotification()
197+
if (this.productMessage !== '') {
198+
this.notification = this.productMessage
199+
this.addSuccessNotification()
200+
}
201201
}
202202
},
203203
created () {

src/pages/User/Add/Add.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,10 @@
283283
</v-btn>
284284
<v-spacer></v-spacer>
285285
<v-btn
286+
:loading="isReceiving"
286287
class="button-shadow"
287288
color="primary"
288-
@click="createUser()"
289-
290-
>
289+
@click="createUser()">
291290
Finish
292291
</v-btn>
293292
</div>
@@ -307,7 +306,7 @@
307306
</template>
308307

309308
<script>
310-
import { mapActions } from "vuex";
309+
import {mapActions, mapState} from "vuex";
311310
import router from '@/Routes';
312311
313312
export default {
@@ -332,12 +331,17 @@ export default {
332331
333332
methods: {
334333
...mapActions('usersList', [
335-
"createUserRequest"
334+
'createUserRequest',
335+
'getUsersRequest'
336336
]),
337337
createUser() {
338338
this.createUserRequest(this.user)
339+
this.getUsersRequest()
339340
router.push('/user/list')
340341
}
342+
},
343+
computed: {
344+
...mapState('usersList', ['isReceiving'])
341345
}
342346
}
343347
</script>

src/pages/User/List/List.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@
2525
background-color: transparent;
2626
}
2727
}
28+
.disabledUser {
29+
.v-label {
30+
top: 0;
31+
}
32+
}
2833
}

src/pages/User/List/List.vue

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<v-card class="ma-1">
4242
<v-card-text>
4343
<v-data-table
44-
:loading="isReceiving || isDeleting || isUpdating"
44+
:loading="isReceiving || isDeleting"
4545
loading-text="Loading... Please wait"
4646
class="users-table"
4747
show-select
@@ -65,18 +65,25 @@
6565
<v-text-field outlined v-model="editedItem.email" label="Email"></v-text-field>
6666
</v-col>
6767
<v-col cols="12" sm="4">
68-
<v-select outlined :items="role" v-model="editedItem.role" label="Role"></v-select>
68+
<v-select hide-details outlined :items="role" v-model="editedItem.role" :value="editedItem.role" label="Role"></v-select>
6969
</v-col>
7070
<v-col cols="12" sm="6" md="4">
71-
<v-text-field outlined v-model="editedItem.company" value="Flatlogic" label="Company"></v-text-field>
71+
<v-text-field hide-details outlined value="Flatlogic" label="Company"></v-text-field>
7272
</v-col>
7373
<v-col cols="12" sm="6" md="4">
74-
<v-select outlined :items="images" v-model="editedItem.img" label="Image">
74+
<v-select hide-details outlined :items="images" v-model="editedItem.img" label="Image">
7575
<template v-slot:item="{ item }">
7676
<v-img :src="item" width="50" style="margin: 2px"></v-img>
7777
</template>
7878
</v-select>
7979
</v-col>
80+
<v-col cols="12" class="d-flex align-center">
81+
<v-switch
82+
class="disabledUser"
83+
v-model="editedItem.disabled"
84+
:label="`${editedItem.firstName}: ${editedItem.disabled ? 'Inactive' : 'Active'}`"
85+
></v-switch>
86+
</v-col>
8087
</v-row>
8188
</v-container>
8289
</v-card-text>
@@ -103,14 +110,17 @@
103110
<template v-slot:item.lastName="{ item }">
104111
<a class="primaryConst--text">{{ item.lastName }}</a>
105112
</template>
113+
<template v-slot:item.role="{ item }">
114+
{{ item.role }}
115+
</template>
106116
<template v-slot:item.company>
107117
Flatlogic
108118
</template>
109119
<template v-slot:item.disabled="{ item }">
110120
<v-chip
111-
:color="item.status !== 'false' ? 'primaryConst white--text' : 'secondaryConst white--text'"
112-
small>
113-
{{ item.disabled === 'false' ? 'Inactive' : 'Active' }}
121+
:color="!item.disabled ? 'primaryConst white--text' : 'secondaryConst white--text'"
122+
small>
123+
{{ item.disabled ? 'Inactive' : 'Active' }}
114124
</v-chip>
115125
</template>
116126
<template v-slot:item.createdAt="{ item }">
@@ -177,13 +187,14 @@ export default {
177187
{ text: 'Actions', value: 'actions', sortable: false },
178188
],
179189
selected: [],
180-
role: ['Admin', 'User'],
190+
switch1: true,
191+
role: ['admin', 'user'],
181192
editedIndex: -1,
182193
editedItem: {
183194
firstName: '',
184195
image: '',
185196
role: '',
186-
company: 'Flatlogic',
197+
company: '',
187198
email: '',
188199
disabled: '',
189200
create: '',
@@ -192,7 +203,7 @@ export default {
192203
firstName: '',
193204
image: '',
194205
role: '',
195-
company: 'Flatlogic',
206+
company: '',
196207
email: '',
197208
disabled: '',
198209
create: '',
@@ -226,7 +237,6 @@ export default {
226237
this.addSuccessNotification()
227238
}
228239
},
229-
230240
created () {
231241
this.getUsersRequest()
232242
this.addSuccessNotification()

src/store/usersList.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ export default {
9595
axios.put(`/users/${id}`, {id, data: payload}).then(res => {
9696
dispatch("updateUser", res.data);
9797
});
98+
99+
dispatch("receivingUsers");
100+
axios.get('/users').then(res => {
101+
dispatch("receiveUsers", res.data.rows);
102+
})
98103
},
99104
createUserRequest({dispatch}, payload) {
100105
// We check if app runs with backend mode
@@ -103,6 +108,11 @@ export default {
103108
axios.post('/users', {data: payload}).then(res => {
104109
dispatch("receiveUser", res.data);
105110
})
111+
112+
dispatch("receivingUsers");
113+
axios.get('/users').then(res => {
114+
dispatch("receiveUsers", res.data.rows);
115+
})
106116
},
107117
deleteUserRequest({dispatch}, payload) {
108118
dispatch("deletingUser", payload);

0 commit comments

Comments
 (0)