@mapomodule/uikit 1.0.0-alpha.0 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +228 -0
- package/LICENSE.md +20 -0
- package/components/Detail/Detail.vue +209 -120
- package/components/Detail/DetailField.vue +57 -30
- package/components/Detail/DetailLangSwitch.vue +1 -1
- package/components/Detail/defaults.js +32 -25
- package/components/DropArea.vue +3 -3
- package/components/List/List.vue +100 -40
- package/components/List/ListActions.vue +56 -17
- package/components/List/ListFilters.vue +127 -113
- package/components/List/ListHead.vue +30 -12
- package/components/List/ListQuickEdit.vue +198 -55
- package/components/List/ListTable.vue +227 -78
- package/components/Login.vue +14 -5
- package/components/MediaManager/MediaEditor.vue +253 -107
- package/components/MediaManager/MediaFolders.vue +125 -41
- package/components/MediaManager/MediaGallery.vue +56 -52
- package/components/MediaManager/MediaManager.vue +114 -74
- package/components/MediaManager/MediaManagerDialog.vue +19 -22
- package/components/MediaManager/MediaPreview.vue +180 -0
- package/components/MediaManager/MediaUploader.vue +35 -32
- package/components/SnackBar.vue +3 -4
- package/components/fields/DateField.vue +9 -3
- package/components/fields/FileField.vue +108 -0
- package/components/fields/FksField.vue +60 -0
- package/components/fields/MediaField.vue +24 -6
- package/components/fields/MediaM2mField.vue +8 -3
- package/components/fields/SeoPreview.vue +89 -0
- package/components/fields/{TinyMce → wygEditor}/defaults.js +6 -4
- package/components/fields/{TinyMce → wygEditor}/utils/events.js +0 -0
- package/components/fields/{TinyMce → wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/fields/{TinyMce → wygEditor}/utils/script.injector.js +0 -0
- package/components/fields/{TinyMce/TinyMce.vue → wygEditor/wygEditor.vue} +43 -21
- package/components/layout/Sidebar/Sidebar.vue +46 -24
- package/components/layout/Sidebar/SidebarFooter.vue +42 -46
- package/components/layout/Sidebar/SidebarList.vue +13 -14
- package/components/layout/Sidebar/SidebarListItem.vue +81 -38
- package/components/layout/Topbar/Topbar.vue +3 -36
- package/components/layout/routebuilder.js +1 -1
- package/defaults.js +2 -2
- package/layouts/default.vue +3 -14
- package/package.json +3 -3
- package/pages/index.vue +15 -78
- package/components/fields/M2mField.vue +0 -95
|
@@ -3,21 +3,41 @@
|
|
|
3
3
|
<v-data-table
|
|
4
4
|
v-model="selection"
|
|
5
5
|
v-bind="$attrs"
|
|
6
|
-
:items="
|
|
6
|
+
:items="serverPaginationEnabled ? items : filteredItems"
|
|
7
7
|
:loading="loading"
|
|
8
8
|
:options.sync="options"
|
|
9
|
-
:
|
|
9
|
+
:search="searchString"
|
|
10
|
+
:server-items-length="serverItemsLength"
|
|
11
|
+
:class="{ mapo__listtable__all_selected: selectAll }"
|
|
12
|
+
:item-key="lookup"
|
|
10
13
|
>
|
|
11
14
|
<template v-slot:top>
|
|
12
15
|
<v-toolbar flat>
|
|
13
|
-
<v-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
<v-text-field
|
|
17
|
+
v-if="searchable"
|
|
18
|
+
v-model="searchString"
|
|
19
|
+
@input="
|
|
20
|
+
loadingSearch = serverPaginationEnabled;
|
|
21
|
+
search();
|
|
22
|
+
"
|
|
23
|
+
prepend-inner-icon="mdi-magnify"
|
|
24
|
+
label="Search"
|
|
25
|
+
single-line
|
|
26
|
+
hide-details
|
|
27
|
+
outlined
|
|
28
|
+
dense
|
|
29
|
+
clearable
|
|
30
|
+
:loading="loadingSearch"
|
|
31
|
+
class="search-input rounded-0"
|
|
32
|
+
></v-text-field>
|
|
17
33
|
<v-spacer></v-spacer>
|
|
18
34
|
<slot name="dtable.top.center"></slot>
|
|
19
35
|
<v-spacer></v-spacer>
|
|
20
|
-
<v-btn class="
|
|
36
|
+
<v-btn text v-if="quickModeEnabled && userCan('add')" class="ml-2" @click="quickAction()">
|
|
37
|
+
<v-icon small left class="d-none d-sm-block mr-2"> mdi-plus </v-icon>
|
|
38
|
+
<span class="d-none d-sm-block">Quick</span> add
|
|
39
|
+
</v-btn>
|
|
40
|
+
<v-btn v-if="serverPaginationEnabled" class=" mx-sm-2 ma-2 mx-0" @click="getDataFromApi(false)" icon>
|
|
21
41
|
<v-icon>mdi-update</v-icon>
|
|
22
42
|
</v-btn>
|
|
23
43
|
</v-toolbar>
|
|
@@ -25,46 +45,74 @@
|
|
|
25
45
|
</template>
|
|
26
46
|
<template v-if="navigable" v-slot:[`item.${firstColName}`]="{ item }">
|
|
27
47
|
<NuxtLink :to="detailLink(item)">
|
|
28
|
-
{{ item
|
|
48
|
+
{{ getPointed(item, firstColName, "Unknown") }}
|
|
29
49
|
</NuxtLink>
|
|
30
50
|
</template>
|
|
51
|
+
<template v-slot:item.data-table-select="{ isSelected, select }" v-if="selectAll">
|
|
52
|
+
<v-simple-checkbox v-model="selectAll" @input="select"></v-simple-checkbox>
|
|
53
|
+
</template>
|
|
54
|
+
<template v-slot:header.data-table-select="{ on, props }" v-if="selectAll">
|
|
55
|
+
<v-simple-checkbox v-model="selectAll" @input="on.input"></v-simple-checkbox>
|
|
56
|
+
</template>
|
|
31
57
|
<template v-slot:[`item.actions`]="{ item }">
|
|
32
|
-
<v-icon v-if="
|
|
58
|
+
<v-icon :disabled="!userCan('change')" v-if="quickModeEnabled" small class="mr-2" @click="quickAction(item)">
|
|
33
59
|
mdi-pencil
|
|
34
60
|
</v-icon>
|
|
35
|
-
<v-icon small @click="deleteItem(item)"> mdi-delete </v-icon>
|
|
61
|
+
<v-icon :disabled="!userCan('delete')" small @click="deleteItem(item)"> mdi-delete </v-icon>
|
|
36
62
|
</template>
|
|
37
|
-
<template v-for="slot in
|
|
63
|
+
<template v-for="slot in nameSpacedSlots($slots, 'dtable.')" :slot="slot">
|
|
38
64
|
<slot :name="`dtable.${slot}`"></slot>
|
|
39
65
|
</template>
|
|
40
66
|
<template
|
|
41
|
-
v-for="slot in
|
|
67
|
+
v-for="slot in nameSpacedSlots($scopedSlots, 'dtable.')"
|
|
42
68
|
v-slot:[slot]="props"
|
|
43
69
|
>
|
|
44
70
|
<slot :name="`dtable.${slot}`" v-bind="props" />
|
|
45
71
|
</template>
|
|
46
72
|
</v-data-table>
|
|
47
73
|
<list-quick-edit
|
|
48
|
-
v-if="
|
|
74
|
+
v-if="quickModeEnabled"
|
|
49
75
|
ref="editModal"
|
|
50
|
-
|
|
76
|
+
:offline="offlineMode"
|
|
77
|
+
v-bind="{ ...$attrs, value: false, crud, lookup: lookup }"
|
|
51
78
|
>
|
|
52
|
-
<template v-for="slot in
|
|
79
|
+
<template v-for="slot in nameSpacedSlots($slots, 'qedit.')" :slot="slot">
|
|
53
80
|
<slot :name="`qedit.${slot}`"></slot>
|
|
54
81
|
</template>
|
|
55
|
-
<template
|
|
56
|
-
v-for="slot in filterSlots($scopedSlots, 'qedit.')"
|
|
57
|
-
v-slot:[slot]="props"
|
|
58
|
-
>
|
|
82
|
+
<template v-for="slot in nameSpacedSlots($scopedSlots, 'qedit.')" v-slot:[slot]="props">
|
|
59
83
|
<slot :name="`qedit.${slot}`" v-bind="props" />
|
|
60
84
|
</template>
|
|
61
85
|
</list-quick-edit>
|
|
62
86
|
</div>
|
|
63
87
|
</template>
|
|
64
88
|
|
|
89
|
+
<style lang="scss" scoped>
|
|
90
|
+
.mapo__listtable__all_selected {
|
|
91
|
+
.v-data-table__selected {
|
|
92
|
+
background: none !important;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
.search-input{
|
|
96
|
+
max-width: 300px;
|
|
97
|
+
@media (max-width: 400px) {
|
|
98
|
+
&.v-input--is-focused{
|
|
99
|
+
position: absolute;
|
|
100
|
+
z-index: 1;
|
|
101
|
+
width: calc(100% - 32px);
|
|
102
|
+
&.theme--dark{
|
|
103
|
+
background: #272727;
|
|
104
|
+
}
|
|
105
|
+
&.theme--light{
|
|
106
|
+
background: #fff;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
</style>
|
|
65
112
|
|
|
66
113
|
<script>
|
|
67
114
|
import { getPointed } from "@mapomodule/utils/helpers/objHelpers";
|
|
115
|
+
import { debounce } from "@mapomodule/utils/helpers/debounce";
|
|
68
116
|
|
|
69
117
|
export default {
|
|
70
118
|
name: "ListTable",
|
|
@@ -72,16 +120,19 @@ export default {
|
|
|
72
120
|
items: [],
|
|
73
121
|
loading: true,
|
|
74
122
|
selection: [],
|
|
123
|
+
selectAll: false,
|
|
75
124
|
options: {},
|
|
76
125
|
httpPaginator: {},
|
|
77
|
-
|
|
126
|
+
searchString: "",
|
|
127
|
+
loadingSearch: false,
|
|
128
|
+
noPagination: false,
|
|
78
129
|
}),
|
|
79
130
|
props: {
|
|
80
131
|
crud: {
|
|
81
132
|
type: Object,
|
|
82
|
-
required: true
|
|
133
|
+
required: true
|
|
83
134
|
},
|
|
84
|
-
|
|
135
|
+
serverPagination: Boolean,
|
|
85
136
|
navigable: Boolean,
|
|
86
137
|
lookup: {
|
|
87
138
|
type: String,
|
|
@@ -97,44 +148,74 @@ export default {
|
|
|
97
148
|
type: Array,
|
|
98
149
|
default: () => [],
|
|
99
150
|
},
|
|
151
|
+
searchable: {
|
|
152
|
+
type: Boolean,
|
|
153
|
+
default: false,
|
|
154
|
+
},
|
|
155
|
+
data: {
|
|
156
|
+
type: Array,
|
|
157
|
+
required: false
|
|
158
|
+
},
|
|
100
159
|
},
|
|
101
160
|
watch: {
|
|
102
161
|
selection(val) {
|
|
103
162
|
this.$emit("input", val);
|
|
104
163
|
},
|
|
105
|
-
|
|
164
|
+
selectAll(val) {
|
|
165
|
+
this.$emit("input", val ? "all" : this.selection);
|
|
166
|
+
},
|
|
167
|
+
filters: {
|
|
106
168
|
deep: true,
|
|
107
|
-
handler(){
|
|
108
|
-
this.
|
|
109
|
-
}
|
|
169
|
+
handler() {
|
|
170
|
+
this.serverPaginationEnabled && this.getDataFromApi();
|
|
171
|
+
},
|
|
110
172
|
},
|
|
111
173
|
options: {
|
|
112
174
|
deep: true,
|
|
113
175
|
handler(options) {
|
|
114
|
-
this.
|
|
176
|
+
this.noPagination = options.itemsPerPage === -1;
|
|
115
177
|
this.setQparams(options);
|
|
116
|
-
this.
|
|
178
|
+
this.serverPaginationEnabled && this.getDataFromApi(false);
|
|
117
179
|
},
|
|
118
180
|
},
|
|
119
|
-
|
|
181
|
+
noPagination() {
|
|
120
182
|
this.getDataFromApi();
|
|
183
|
+
},
|
|
184
|
+
data: {
|
|
185
|
+
deep: true,
|
|
186
|
+
handler(data) {
|
|
187
|
+
if (data) this.items = data;
|
|
188
|
+
},
|
|
121
189
|
}
|
|
122
190
|
},
|
|
123
191
|
methods: {
|
|
124
|
-
|
|
192
|
+
getPointed: getPointed,
|
|
193
|
+
getDataFromApi(clearSelection = true) {
|
|
194
|
+
if (clearSelection) {
|
|
195
|
+
this.selection = [];
|
|
196
|
+
this.selectAll = false;
|
|
197
|
+
}
|
|
198
|
+
this.loading = !this.offlineMode;
|
|
199
|
+
!this.offlineMode && this.debouncedDataFromApi();
|
|
200
|
+
},
|
|
201
|
+
debouncedDataFromApi: debounce(function () {
|
|
125
202
|
return new Promise((resolve, reject) => {
|
|
126
203
|
this.selection = [];
|
|
127
|
-
this.
|
|
128
|
-
|
|
129
|
-
|
|
204
|
+
if (!this.serverPaginationEnabled) {
|
|
205
|
+
this.crud
|
|
206
|
+
.list()
|
|
207
|
+
.then((data) => {
|
|
130
208
|
this.items = data;
|
|
131
209
|
this.loading = false;
|
|
210
|
+
this.httpPaginator = {};
|
|
132
211
|
resolve(data);
|
|
133
212
|
})
|
|
134
213
|
.catch((error) => reject(error));
|
|
135
214
|
} else {
|
|
136
|
-
const params = this.getHttpParams()
|
|
137
|
-
this.crud
|
|
215
|
+
const params = this.getHttpParams();
|
|
216
|
+
this.crud
|
|
217
|
+
.list({ params })
|
|
218
|
+
.then((data) => {
|
|
138
219
|
this.items = data.items;
|
|
139
220
|
this.httpPaginator = data.paginator;
|
|
140
221
|
this.loading = false;
|
|
@@ -143,7 +224,7 @@ export default {
|
|
|
143
224
|
.catch((error) => reject(error));
|
|
144
225
|
}
|
|
145
226
|
});
|
|
146
|
-
},
|
|
227
|
+
}, 500),
|
|
147
228
|
setQparams(options) {
|
|
148
229
|
this.$router.push({
|
|
149
230
|
query: {
|
|
@@ -152,60 +233,119 @@ export default {
|
|
|
152
233
|
},
|
|
153
234
|
});
|
|
154
235
|
},
|
|
155
|
-
restoreFromQparams(){
|
|
236
|
+
restoreFromQparams() {
|
|
156
237
|
this.options = {
|
|
157
238
|
...this.options,
|
|
158
|
-
sortBy:
|
|
159
|
-
|
|
160
|
-
|
|
239
|
+
sortBy:
|
|
240
|
+
this.$route.query.sort?.split(",").map((p) => p.replace(/^-/, "")) ||
|
|
241
|
+
this.options.sortBy ||
|
|
242
|
+
[],
|
|
243
|
+
sortDesc:
|
|
244
|
+
this.$route.query.order?.split(",").map((p) => p.startsWith("-")) ||
|
|
245
|
+
this.options.sortDesc ||
|
|
246
|
+
[],
|
|
247
|
+
itemsPerPage:
|
|
248
|
+
parseInt(this.$route.query.items) || this.options.itemsPerPage || 10,
|
|
249
|
+
page: parseInt(this.$route.query.page) || this.options.page || 1,
|
|
161
250
|
};
|
|
251
|
+
this.searchString = this.$route.query.search;
|
|
162
252
|
},
|
|
163
253
|
getOrderParams(options) {
|
|
164
254
|
const { sortBy, sortDesc, page, itemsPerPage } = options;
|
|
165
|
-
const sort =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
: undefined;
|
|
169
|
-
return { sort, order, items: itemsPerPage, page: page !== 1 ? page : undefined };
|
|
255
|
+
const sort =
|
|
256
|
+
sortBy.map((field, i) => (sortDesc[i] ? "-" : "") + field).join(",") || undefined;
|
|
257
|
+
return { sort, items: itemsPerPage, page: page !== 1 ? page : undefined };
|
|
170
258
|
},
|
|
171
259
|
getHttpParams() {
|
|
172
260
|
const params = new URLSearchParams();
|
|
173
261
|
for (const [key, value] of Object.entries(this.getOrderParams(this.options))) {
|
|
174
|
-
value !== undefined && params.append(key, value)
|
|
262
|
+
value !== undefined && params.append(key, value);
|
|
175
263
|
}
|
|
176
|
-
this.filters.forEach(fi => {
|
|
177
|
-
const query = []
|
|
178
|
-
const format = (val) => val.replaceAll(
|
|
179
|
-
if (fi.datepicker){
|
|
180
|
-
const dates = fi.active[0].value.split(
|
|
181
|
-
query.push(
|
|
264
|
+
this.filters.forEach((fi) => {
|
|
265
|
+
const query = [];
|
|
266
|
+
const format = (val) => val.replaceAll(".", "__");
|
|
267
|
+
if (fi.datepicker) {
|
|
268
|
+
const dates = fi.active[0].value.split(",");
|
|
269
|
+
query.push(
|
|
270
|
+
`${format(fi.value)}__gte=${dates[0]}`,
|
|
271
|
+
`${format(fi.value)}__lte=${dates[1]}`
|
|
272
|
+
);
|
|
182
273
|
} else if (fi.active.length > 1) {
|
|
183
|
-
query.push(`${format(fi.value)}=[${
|
|
274
|
+
query.push(`${format(fi.value)}=[${fi.active.map((a) => a.value).join(",")}]`);
|
|
184
275
|
} else {
|
|
185
|
-
query.push(`${format(fi.value)}=${
|
|
276
|
+
query.push(`${format(fi.value)}=${fi.active[0].value}`);
|
|
186
277
|
}
|
|
187
|
-
query.forEach(q => params.append(
|
|
188
|
-
})
|
|
278
|
+
query.forEach((q) => params.append("fltr", q));
|
|
279
|
+
});
|
|
280
|
+
if (this.searchString && this.searchable) params.append("search", this.searchString);
|
|
189
281
|
return params;
|
|
190
282
|
},
|
|
191
|
-
|
|
192
|
-
this.$refs.editModal.open(item).then((r) =>
|
|
283
|
+
quickAction(item) {
|
|
284
|
+
this.$refs.editModal.open(item).then((r) => {
|
|
285
|
+
if (!r) return;
|
|
286
|
+
if (!this.offlineMode) {
|
|
287
|
+
this.getDataFromApi();
|
|
288
|
+
} else {
|
|
289
|
+
let index = item ? this.items.findIndex((i) => i[this.lookup] === item[this.lookup]) : -1;
|
|
290
|
+
let update = true;
|
|
291
|
+
|
|
292
|
+
if (index !== -1) {
|
|
293
|
+
this.items.splice(index, 1, r);
|
|
294
|
+
} else {
|
|
295
|
+
index = this.items.push(r);
|
|
296
|
+
update = false;
|
|
297
|
+
}
|
|
298
|
+
this.$emit("update:data", this.items, r, index);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
193
301
|
},
|
|
194
302
|
deleteItem(item) {
|
|
195
|
-
const callback = (item) =>
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
303
|
+
const callback = (item) => {
|
|
304
|
+
if (!this.offlineMode) {
|
|
305
|
+
this.crud.delete(item[this.lookup]).then(this.getDataFromApi);
|
|
306
|
+
} else {
|
|
307
|
+
const index = this.items.findIndex((i) => i[this.lookup] === item[this.lookup]);
|
|
308
|
+
|
|
309
|
+
if (index !== -1) {
|
|
310
|
+
this.items.splice(index, 1);
|
|
311
|
+
this.$emit("update:data", this.items, r, index);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
this.$mapo.$confirm
|
|
317
|
+
.open({
|
|
318
|
+
title: "Delete",
|
|
319
|
+
question: "Are you sure you want to delete this item?",
|
|
320
|
+
approveButton: { text: "Delete", attrs: { color: "red", text: true } },
|
|
321
|
+
})
|
|
322
|
+
.then((res) => (res ? callback(item) : null));
|
|
203
323
|
},
|
|
204
|
-
|
|
324
|
+
nameSpacedSlots(slots, scope) {
|
|
205
325
|
return Object.keys(slots)
|
|
206
326
|
.filter((name) => name.startsWith(scope))
|
|
207
327
|
.map((name) => name.replace(scope, ""));
|
|
208
328
|
},
|
|
329
|
+
toggleSelectAll() {
|
|
330
|
+
this.selectAll = !this.selectAll;
|
|
331
|
+
},
|
|
332
|
+
search: debounce(function () {
|
|
333
|
+
this.$router.push({
|
|
334
|
+
query: {
|
|
335
|
+
...this.$route.query,
|
|
336
|
+
search: this.searchString || undefined,
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
this.serverPaginationEnabled && this.getDataFromApi();
|
|
341
|
+
this.loadingSearch = false;
|
|
342
|
+
}, 1000),
|
|
343
|
+
userCan(action) {
|
|
344
|
+
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
|
|
345
|
+
return this.$mapo.$auth.user.permissions.includes(action)
|
|
346
|
+
}
|
|
347
|
+
return true
|
|
348
|
+
},
|
|
209
349
|
},
|
|
210
350
|
computed: {
|
|
211
351
|
filteredItems() {
|
|
@@ -234,25 +374,34 @@ export default {
|
|
|
234
374
|
},
|
|
235
375
|
firstColName() {
|
|
236
376
|
return (
|
|
237
|
-
this.$attrs.headers &&
|
|
238
|
-
this.$attrs.headers.length &&
|
|
239
|
-
this.$attrs.headers[0].value
|
|
377
|
+
this.$attrs.headers && this.$attrs.headers.length && this.$attrs.headers[0].value
|
|
240
378
|
);
|
|
241
379
|
},
|
|
242
|
-
|
|
380
|
+
quickModeEnabled() {
|
|
243
381
|
return (
|
|
244
|
-
this.
|
|
245
|
-
this.
|
|
382
|
+
this.nameSpacedSlots(this.$slots, "qedit.body").length ||
|
|
383
|
+
this.nameSpacedSlots(this.$scopedSlots, "qedit.body").length ||
|
|
246
384
|
(this.$attrs.editFields && this.$attrs.editFields.length)
|
|
247
385
|
);
|
|
248
386
|
},
|
|
249
|
-
|
|
250
|
-
return this.
|
|
251
|
-
}
|
|
387
|
+
serverPaginationEnabled() {
|
|
388
|
+
return this.serverPagination && !this.noPagination && !this.offlineMode;
|
|
389
|
+
},
|
|
390
|
+
offlineMode() {
|
|
391
|
+
return !!this.data;
|
|
392
|
+
},
|
|
393
|
+
serverItemsLength() {
|
|
394
|
+
return this.httpPaginator.count || (this.serverPaginationEnabled && (this.options.page * this.options.itemsPerPage)) || -1;
|
|
395
|
+
},
|
|
252
396
|
},
|
|
253
397
|
mounted() {
|
|
254
|
-
this.restoreFromQparams()
|
|
255
|
-
|
|
398
|
+
this.restoreFromQparams();
|
|
399
|
+
if (!this.offlineMode) {
|
|
400
|
+
this.getDataFromApi();
|
|
401
|
+
} else {
|
|
402
|
+
this.items = this.data;
|
|
403
|
+
this.loading = false;
|
|
404
|
+
}
|
|
256
405
|
},
|
|
257
406
|
};
|
|
258
407
|
</script>
|
package/components/Login.vue
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
filled
|
|
18
18
|
dense
|
|
19
19
|
light
|
|
20
|
+
:error-messages="errors.username"
|
|
20
21
|
></v-text-field>
|
|
21
22
|
<v-text-field
|
|
22
23
|
class="rounded-0"
|
|
@@ -29,13 +30,20 @@
|
|
|
29
30
|
dense
|
|
30
31
|
filled
|
|
31
32
|
light
|
|
33
|
+
:error-messages="errors.password"
|
|
32
34
|
:type="showPass ? 'text' : 'password'"
|
|
33
35
|
></v-text-field>
|
|
34
36
|
<div class="text-center">
|
|
35
37
|
<v-btn type="submit" class="rounded-0" elevation="0" dark>
|
|
36
38
|
Log In
|
|
37
39
|
</v-btn>
|
|
40
|
+
<v-messages
|
|
41
|
+
v-model="errors.non_field_errors"
|
|
42
|
+
color="error"
|
|
43
|
+
class="mt-4 text-center"
|
|
44
|
+
/>
|
|
38
45
|
</div>
|
|
46
|
+
|
|
39
47
|
</v-form>
|
|
40
48
|
</div>
|
|
41
49
|
</div>
|
|
@@ -48,6 +56,7 @@ export default {
|
|
|
48
56
|
username: "",
|
|
49
57
|
password: null,
|
|
50
58
|
showPass: false,
|
|
59
|
+
errors: {}
|
|
51
60
|
};
|
|
52
61
|
},
|
|
53
62
|
watch: {
|
|
@@ -77,11 +86,11 @@ export default {
|
|
|
77
86
|
query: this.otherQuery,
|
|
78
87
|
})
|
|
79
88
|
)
|
|
80
|
-
.catch((
|
|
81
|
-
|
|
82
|
-
this
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
.catch((error) => {
|
|
90
|
+
this.errors = error.response?.data || {}
|
|
91
|
+
if (!Object.keys(this.errors).length){
|
|
92
|
+
this.$mapo.$snack.open({message: "Cannot login right now. Try again later.", color: "error"})
|
|
93
|
+
}
|
|
85
94
|
});
|
|
86
95
|
},
|
|
87
96
|
},
|