@mapomodule/uikit 1.0.0-alpha.2 → 1.0.0-alpha.22

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +406 -0
  2. package/components/Detail/Detail.vue +288 -260
  3. package/components/Detail/DetailLangSwitch.vue +1 -1
  4. package/components/DropArea.vue +3 -3
  5. package/components/Form/Form.vue +224 -0
  6. package/components/Form/FormField.vue +185 -0
  7. package/components/Form/FormGroup.vue +88 -0
  8. package/components/Form/FormTabs.vue +134 -0
  9. package/components/Form/defaults.js +58 -0
  10. package/components/{fields → Form/fields}/DateField.vue +9 -3
  11. package/components/Form/fields/FileField.vue +125 -0
  12. package/components/Form/fields/FksField.vue +88 -0
  13. package/components/{fields → Form/fields}/MediaField.vue +36 -6
  14. package/components/{fields → Form/fields}/MediaM2mField.vue +8 -3
  15. package/components/Form/fields/Repeater.vue +562 -0
  16. package/components/Form/fields/SeoPreview.vue +89 -0
  17. package/components/{fields/TinyMce → Form/fields/wygEditor}/defaults.js +7 -5
  18. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
  19. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
  20. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/script.injector.js +0 -0
  21. package/components/Form/fields/wygEditor/wygEditor.vue +256 -0
  22. package/components/List/List.vue +120 -42
  23. package/components/List/ListActions.vue +56 -17
  24. package/components/List/ListFilters.vue +158 -113
  25. package/components/List/ListHead.vue +30 -12
  26. package/components/List/ListQuickEdit.vue +128 -59
  27. package/components/List/ListTable.vue +293 -80
  28. package/components/Login.vue +14 -5
  29. package/components/MediaManager/MediaEditor.vue +253 -107
  30. package/components/MediaManager/MediaFolders.vue +134 -43
  31. package/components/MediaManager/MediaGallery.vue +56 -52
  32. package/components/MediaManager/MediaManager.vue +127 -83
  33. package/components/MediaManager/MediaManagerDialog.vue +19 -22
  34. package/components/MediaManager/MediaPreview.vue +180 -0
  35. package/components/MediaManager/MediaUploader.vue +35 -32
  36. package/components/SnackBar.vue +3 -4
  37. package/components/ThemeToggle.vue +13 -0
  38. package/components/layout/Sidebar/Sidebar.vue +35 -32
  39. package/components/layout/Sidebar/SidebarFooter.vue +42 -46
  40. package/components/layout/Sidebar/SidebarList.vue +13 -14
  41. package/components/layout/Sidebar/SidebarListItem.vue +99 -38
  42. package/components/layout/Sidebar/SidebarProfile.vue +42 -0
  43. package/components/layout/Topbar/Topbar.vue +3 -35
  44. package/components/layout/routebuilder.js +3 -3
  45. package/defaults.js +2 -2
  46. package/layouts/default.vue +20 -18
  47. package/layouts/empty.vue +10 -0
  48. package/module.js +1 -1
  49. package/package.json +5 -4
  50. package/pages/index.vue +1 -2
  51. package/components/Detail/DetailField.vue +0 -129
  52. package/components/Detail/defaults.js +0 -50
  53. package/components/fields/M2mField.vue +0 -95
  54. package/components/fields/TinyMce/TinyMce.vue +0 -177
  55. package/layouts/error.vue +0 -45
@@ -3,68 +3,137 @@
3
3
  <v-data-table
4
4
  v-model="selection"
5
5
  v-bind="$attrs"
6
- :items="httpEnabled ? items : filteredItems"
6
+ :headers="headers"
7
+ :show-select="!dragOrderingActive && $attrs['show-select']"
8
+ :items="serverPaginationEnabled ? items : filteredItems"
7
9
  :loading="loading"
8
10
  :options.sync="options"
9
- :server-items-length="httpPaginator.count || -1"
11
+ :search="searchString"
12
+ :server-items-length="serverItemsLength"
13
+ :class="{ mapo__listtable__all_selected: selectAll }"
14
+ :item-key="lookup"
15
+ :disable-sort="dragOrderingActive"
16
+ v-sortable-data-table
17
+ @sorted="changeOrder"
10
18
  >
11
19
  <template v-slot:top>
12
20
  <v-toolbar flat>
13
- <v-btn text v-if="shouldEdit" @click="editItem()">
14
- <v-icon small left class="mr-2"> mdi-plus </v-icon>
15
- Quick add
16
- </v-btn>
21
+ <v-text-field
22
+ v-if="searchable"
23
+ v-model="searchString"
24
+ @input="
25
+ loadingSearch = serverPaginationEnabled;
26
+ search();
27
+ "
28
+ prepend-inner-icon="mdi-magnify"
29
+ label="Search"
30
+ single-line
31
+ hide-details
32
+ outlined
33
+ dense
34
+ clearable
35
+ :loading="loadingSearch"
36
+ class="search-input rounded-0"
37
+ ></v-text-field>
17
38
  <v-spacer></v-spacer>
18
39
  <slot name="dtable.top.center"></slot>
19
40
  <v-spacer></v-spacer>
20
- <v-btn class="ma-2" @click="getDataFromApi" icon>
41
+ <v-btn text v-if="quickModeEnabled && userCan('add')" class="ml-2" @click="quickAction()">
42
+ <v-icon small left class="d-none d-sm-block mr-2"> mdi-plus </v-icon>
43
+ <span class="d-none d-sm-block">Quick</span> add
44
+ </v-btn>
45
+ <v-btn v-if="serverPaginationEnabled" class=" mx-sm-2 ma-2 mx-0" @click="getDataFromApi(false)" icon>
21
46
  <v-icon>mdi-update</v-icon>
22
47
  </v-btn>
23
48
  </v-toolbar>
24
49
  <slot name="dtable.top.under"></slot>
25
50
  </template>
51
+ <template v-if="dragReorder" v-slot:footer.prepend>
52
+ <v-tooltip right>
53
+ <template v-slot:activator="{ on, attrs }">
54
+ <v-btn v-bind="attrs" v-on="on" style="margin-left: 2px;" :class="{'primary--text': dragOrderingActive}" @click="dragOrderingActive = !dragOrderingActive" icon>
55
+ <v-icon>mdi-order-bool-ascending</v-icon></v-btn>
56
+ </template>
57
+ <span>Toggle reordering</span>
58
+ </v-tooltip>
59
+ </template>
26
60
  <template v-if="navigable" v-slot:[`item.${firstColName}`]="{ item }">
27
61
  <NuxtLink :to="detailLink(item)">
28
- {{ item[firstColName] }}
62
+ {{ getPointed(item, firstColName, "Unknown") }}
29
63
  </NuxtLink>
30
64
  </template>
65
+ <template v-slot:item.data-table-select="{ isSelected, select }" v-if="selectAll">
66
+ <v-simple-checkbox v-model="selectAll" @input="select"></v-simple-checkbox>
67
+ </template>
68
+ <template v-slot:header.data-table-select="{ on, props }" v-if="selectAll">
69
+ <v-simple-checkbox v-model="selectAll" @input="on.input"></v-simple-checkbox>
70
+ </template>
31
71
  <template v-slot:[`item.actions`]="{ item }">
32
- <v-icon v-if="shouldEdit" small class="mr-2" @click="editItem(item)">
72
+ <v-icon :disabled="!userCan('change')" v-if="quickModeEnabled" small class="mr-2" @click="quickAction(item)">
33
73
  mdi-pencil
34
74
  </v-icon>
35
- <v-icon small @click="deleteItem(item)"> mdi-delete </v-icon>
75
+ <v-icon :disabled="!userCan('delete')" small @click="deleteItem(item)"> mdi-delete </v-icon>
76
+ </template>
77
+ <template v-slot:item.drag-column>
78
+ <v-icon class="handle-drag">mdi-drag</v-icon>
36
79
  </template>
37
- <template v-for="slot in filterSlots($slots, 'dtable.')" :slot="slot">
80
+ <template v-for="slot in nameSpacedSlots($slots, 'dtable.')" :slot="slot">
38
81
  <slot :name="`dtable.${slot}`"></slot>
39
82
  </template>
40
83
  <template
41
- v-for="slot in filterSlots($scopedSlots, 'dtable.')"
84
+ v-for="slot in nameSpacedSlots($scopedSlots, 'dtable.')"
42
85
  v-slot:[slot]="props"
43
86
  >
44
87
  <slot :name="`dtable.${slot}`" v-bind="props" />
45
88
  </template>
46
89
  </v-data-table>
47
90
  <list-quick-edit
48
- v-if="shouldEdit"
91
+ v-if="quickModeEnabled"
49
92
  ref="editModal"
50
- v-bind="{ ...$attrs, value: false, crud }"
93
+ :offline="offlineMode"
94
+ v-bind="{ ...$attrs, value: false, crud, lookup: lookup }"
51
95
  >
52
- <template v-for="slot in filterSlots($slots, 'qedit.')" :slot="slot">
96
+ <template v-for="slot in nameSpacedSlots($slots, 'qedit.')" :slot="slot">
53
97
  <slot :name="`qedit.${slot}`"></slot>
54
98
  </template>
55
- <template
56
- v-for="slot in filterSlots($scopedSlots, 'qedit.')"
57
- v-slot:[slot]="props"
58
- >
99
+ <template v-for="slot in nameSpacedSlots($scopedSlots, 'qedit.')" v-slot:[slot]="props">
59
100
  <slot :name="`qedit.${slot}`" v-bind="props" />
60
101
  </template>
61
102
  </list-quick-edit>
62
103
  </div>
63
104
  </template>
64
105
 
106
+ <style lang="scss" scoped>
107
+ .mapo__listtable__all_selected {
108
+ .v-data-table__selected {
109
+ background: none !important;
110
+ }
111
+ }
112
+ .search-input{
113
+ max-width: 300px;
114
+ @media (max-width: 400px) {
115
+ &.v-input--is-focused{
116
+ position: absolute;
117
+ z-index: 1;
118
+ width: calc(100% - 32px);
119
+ &.theme--dark{
120
+ background: #272727;
121
+ }
122
+ &.theme--light{
123
+ background: #fff;
124
+ }
125
+ }
126
+ }
127
+ }
128
+ .handle-drag{ cursor: grab; }
129
+ </style>
65
130
 
66
131
  <script>
67
132
  import { getPointed } from "@mapomodule/utils/helpers/objHelpers";
133
+ import { debounce } from "@mapomodule/utils/helpers/debounce";
134
+ import { nameSpacedSlots } from "@mapomodule/utils/helpers/slots";
135
+
136
+ import Sortable from "sortablejs"
68
137
 
69
138
  export default {
70
139
  name: "ListTable",
@@ -72,16 +141,20 @@ export default {
72
141
  items: [],
73
142
  loading: true,
74
143
  selection: [],
144
+ selectAll: false,
75
145
  options: {},
76
146
  httpPaginator: {},
77
- disableHttp: false
147
+ searchString: "",
148
+ loadingSearch: false,
149
+ noPagination: false,
150
+ dragOrderingActive: false
78
151
  }),
79
152
  props: {
80
153
  crud: {
81
154
  type: Object,
82
- required: true,
155
+ required: true
83
156
  },
84
- http: Boolean,
157
+ serverPagination: Boolean,
85
158
  navigable: Boolean,
86
159
  lookup: {
87
160
  type: String,
@@ -97,44 +170,100 @@ export default {
97
170
  type: Array,
98
171
  default: () => [],
99
172
  },
173
+ searchable: {
174
+ type: Boolean,
175
+ default: false,
176
+ },
177
+ data: {
178
+ type: Array,
179
+ required: false
180
+ },
181
+ dragReorder: {
182
+ type: Boolean,
183
+ default: false,
184
+ },
185
+ },
186
+ directives: {
187
+ sortableDataTable: {
188
+ bind (el, binding, vnode) {
189
+ const options = {
190
+ animation: 150,
191
+ handle: '.handle-drag',
192
+ onUpdate: function (event) {
193
+ vnode.child.$emit('sorted', event)
194
+ },
195
+ }
196
+ Sortable.create(el.getElementsByTagName('tbody')[0], options)
197
+ }
198
+ }
100
199
  },
101
200
  watch: {
102
201
  selection(val) {
103
202
  this.$emit("input", val);
104
203
  },
105
- filters:{
106
- deep: true,
107
- handler(){
108
- this.httpEnabled && this.getDataFromApi();
204
+ selectAll(val) {
205
+ this.$emit("input", val ? "all" : this.selection);
206
+ },
207
+ dragOrderingActive(val) {
208
+ if (val) {
209
+ this.searchString = ""
210
+ this.options = {...this.options, sortBy: []}
109
211
  }
212
+ this.$emit("drag-order-change", val)
213
+ },
214
+ filters: {
215
+ deep: true,
216
+ handler() {
217
+ this.serverPaginationEnabled && this.getDataFromApi();
218
+ },
110
219
  },
111
220
  options: {
112
221
  deep: true,
113
222
  handler(options) {
114
- this.disableHttp = options.itemsPerPage === -1;
223
+ this.noPagination = options.itemsPerPage === -1;
115
224
  this.setQparams(options);
116
- this.httpEnabled && this.getDataFromApi();
225
+ this.serverPaginationEnabled && this.getDataFromApi(false);
117
226
  },
118
227
  },
119
- disableHttp(){
228
+ noPagination() {
120
229
  this.getDataFromApi();
230
+ },
231
+ data: {
232
+ deep: true,
233
+ handler(data) {
234
+ if (data) this.items = data;
235
+ },
121
236
  }
122
237
  },
123
238
  methods: {
124
- getDataFromApi() {
239
+ nameSpacedSlots,
240
+ getPointed,
241
+ getDataFromApi(clearSelection = true) {
242
+ if (clearSelection) {
243
+ this.selection = [];
244
+ this.selectAll = false;
245
+ }
246
+ this.loading = !this.offlineMode;
247
+ !this.offlineMode && this.debouncedDataFromApi();
248
+ },
249
+ debouncedDataFromApi: debounce(function () {
125
250
  return new Promise((resolve, reject) => {
126
251
  this.selection = [];
127
- this.loading = true;
128
- if (!this.httpEnabled) {
129
- this.crud.list().then((data) => {
252
+ if (!this.serverPaginationEnabled) {
253
+ this.crud
254
+ .list()
255
+ .then((data) => {
130
256
  this.items = data;
131
257
  this.loading = false;
258
+ this.httpPaginator = {};
132
259
  resolve(data);
133
260
  })
134
261
  .catch((error) => reject(error));
135
262
  } else {
136
- const params = this.getHttpParams()
137
- this.crud.list({ params }).then((data) => {
263
+ const params = this.getHttpParams();
264
+ this.crud
265
+ .list({ params })
266
+ .then((data) => {
138
267
  this.items = data.items;
139
268
  this.httpPaginator = data.paginator;
140
269
  this.loading = false;
@@ -143,6 +272,23 @@ export default {
143
272
  .catch((error) => reject(error));
144
273
  }
145
274
  });
275
+ }, 500),
276
+ changeOrder(event){
277
+ if (this.offlineMode) {
278
+ const element = this.items[event.oldIndex]
279
+ this.items.splice(event.oldIndex, 1, )
280
+ this.items.splice(event.newIndex, 0, element);
281
+ } else {
282
+ this.crud.update_order(this.items[event.oldIndex][this.lookup], this.items[event.newIndex][this.lookup]).then(
283
+ res => res.reordered && this.getDataFromApi()
284
+ ).catch(error => {
285
+ this.getDataFromApi()
286
+ this.$mapo.$snack.open({
287
+ message: error.response?.data?.detail || "Reorder failed",
288
+ color: "error",
289
+ })
290
+ });
291
+ }
146
292
  },
147
293
  setQparams(options) {
148
294
  this.$router.push({
@@ -152,59 +298,113 @@ export default {
152
298
  },
153
299
  });
154
300
  },
155
- restoreFromQparams(){
301
+ restoreFromQparams() {
156
302
  this.options = {
157
303
  ...this.options,
158
- sortBy: this.$route.query.sort?.split(".") || [],
159
- sortDesc: this.$route.query.order?.split(".").map((e) => e == "desc") || [],
160
- itemsPerPage: parseInt(this.$route.query.items) || this.options.itemsPerPage || 10,
304
+ sortBy:
305
+ this.$route.query.sort?.split(",").map((p) => p.replace(/^-/, "")) ||
306
+ this.options.sortBy ||
307
+ [],
308
+ sortDesc:
309
+ this.$route.query.order?.split(",").map((p) => p.startsWith("-")) ||
310
+ this.options.sortDesc ||
311
+ [],
312
+ itemsPerPage:
313
+ parseInt(this.$route.query.items) || this.options.itemsPerPage || 10,
314
+ page: parseInt(this.$route.query.page) || this.options.page || 1,
161
315
  };
316
+ this.searchString = this.$route.query.search;
162
317
  },
163
318
  getOrderParams(options) {
164
319
  const { sortBy, sortDesc, page, itemsPerPage } = options;
165
- const sort = sortBy.length ? sortBy.join(".") : undefined;
166
- const order = sortDesc.length
167
- ? sortDesc.map((e) => (e ? "desc" : "asc")).join(".")
168
- : undefined;
169
- return { sort, order, items: itemsPerPage, page: page !== 1 ? page : undefined };
320
+ const sort =
321
+ sortBy.map((field, i) => (sortDesc[i] ? "-" : "") + field).join(",") || undefined;
322
+ return { sort, items: itemsPerPage, page: page !== 1 ? page : undefined };
170
323
  },
171
324
  getHttpParams() {
172
325
  const params = new URLSearchParams();
173
326
  for (const [key, value] of Object.entries(this.getOrderParams(this.options))) {
174
- value !== undefined && params.append(key, value)
327
+ value !== undefined && params.append(key, value);
175
328
  }
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(`${format(fi.value)}__gte=${dates[0]}`, `${format(fi.value)}__lte=${dates[1]}`)
329
+ this.filters.forEach((fi) => {
330
+ const query = [];
331
+ const format = (val) => val.replaceAll(".", "__");
332
+ if (fi.datepicker) {
333
+ const dates = fi.active[0].value.split(",");
334
+ query.push(
335
+ `${format(fi.value)}__gte=${dates[0]}`,
336
+ `${format(fi.value)}__lte=${dates[1]}`
337
+ );
182
338
  } else if (fi.active.length > 1) {
183
- query.push(`${format(fi.value)}=[${ fi.active.map(a=>a.value).join(",")}]`)
339
+ query.push(`${format(fi.value)}=[${fi.active.map((a) => a.value).join(",")}]`);
184
340
  } else {
185
- query.push(`${format(fi.value)}=${ fi.active[0].value}`)
341
+ query.push(`${format(fi.value)}=${fi.active[0].value}`);
186
342
  }
187
- query.forEach(q => params.append('fltr', q))
188
- })
343
+ query.forEach((q) => params.append("fltr", q));
344
+ });
345
+ if (this.searchString && this.searchable) params.append("search", this.searchString);
189
346
  return params;
190
347
  },
191
- editItem(item) {
192
- this.$refs.editModal.open(item).then((r) => r && this.getDataFromApi());
348
+ quickAction(item) {
349
+ this.$refs.editModal.open(item).then((r) => {
350
+ if (!r) return;
351
+ if (!this.offlineMode) {
352
+ this.getDataFromApi();
353
+ } else {
354
+ let index = item ? this.items.findIndex((i) => i[this.lookup] === item[this.lookup]) : -1;
355
+ let update = true;
356
+
357
+ if (index !== -1) {
358
+ this.items.splice(index, 1, r);
359
+ } else {
360
+ index = this.items.push(r);
361
+ update = false;
362
+ }
363
+ this.$emit("update:data", this.items, r, index);
364
+ }
365
+ });
193
366
  },
194
367
  deleteItem(item) {
195
- const callback = (item) =>
196
- this.crud.delete(item[this.lookup]).then(this.getDataFromApi);
197
- this.$mapo.$confirm
198
- .open({
199
- title: "Delete",
200
- question: "Are you sure you want to delete this item?",
201
- approveButton: { text: "Delete", attrs: { color: "red" } }
202
- }).then((res) => (res ? callback(item) : null));
368
+ const callback = (item) => {
369
+ if (!this.offlineMode) {
370
+ this.crud.delete(item[this.lookup]).then(this.getDataFromApi);
371
+ } else {
372
+ const index = this.items.findIndex((i) => i[this.lookup] === item[this.lookup]);
373
+
374
+ if (index !== -1) {
375
+ this.items.splice(index, 1);
376
+ this.$emit("update:data", this.items, r, index);
377
+ }
378
+ }
379
+ };
380
+
381
+ this.$mapo.$confirm
382
+ .open({
383
+ title: "Delete",
384
+ question: "Are you sure you want to delete this item?",
385
+ approveButton: { text: "Delete", attrs: { color: "red", text: true } },
386
+ })
387
+ .then((res) => (res ? callback(item) : null));
203
388
  },
204
- filterSlots(slots, scope) {
205
- return Object.keys(slots)
206
- .filter((name) => name.startsWith(scope))
207
- .map((name) => name.replace(scope, ""));
389
+ toggleSelectAll() {
390
+ this.selectAll = !this.selectAll;
391
+ },
392
+ search: debounce(function () {
393
+ this.$router.push({
394
+ query: {
395
+ ...this.$route.query,
396
+ search: this.searchString || undefined,
397
+ },
398
+ });
399
+
400
+ this.serverPaginationEnabled && this.getDataFromApi();
401
+ this.loadingSearch = false;
402
+ }, 1000),
403
+ userCan(action) {
404
+ if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
405
+ return this.$mapo.$auth.user.permissions.includes(action)
406
+ }
407
+ return true
208
408
  },
209
409
  },
210
410
  computed: {
@@ -234,25 +434,38 @@ export default {
234
434
  },
235
435
  firstColName() {
236
436
  return (
237
- this.$attrs.headers &&
238
- this.$attrs.headers.length &&
239
- this.$attrs.headers[0].value
437
+ this.$attrs.headers && this.$attrs.headers.length && this.$attrs.headers[0].value
240
438
  );
241
439
  },
242
- shouldEdit() {
440
+ headers() {
441
+ const dragColumn = { sortable: false, value: 'drag-column', width: '64px' }
442
+ return this.dragOrderingActive ? [ dragColumn,...this.$attrs.headers ] : this.$attrs.headers
443
+ },
444
+ quickModeEnabled() {
243
445
  return (
244
- this.filterSlots(this.$slots, "qedit.body").length ||
245
- this.filterSlots(this.$scopedSlots, "qedit.body").length ||
446
+ this.nameSpacedSlots(this.$slots, "qedit.body").length ||
447
+ this.nameSpacedSlots(this.$scopedSlots, "qedit.body").length ||
246
448
  (this.$attrs.editFields && this.$attrs.editFields.length)
247
449
  );
248
450
  },
249
- httpEnabled(){
250
- return this.http && !this.disableHttp
251
- }
451
+ serverPaginationEnabled() {
452
+ return this.serverPagination && !this.noPagination && !this.offlineMode;
453
+ },
454
+ offlineMode() {
455
+ return !!this.data;
456
+ },
457
+ serverItemsLength() {
458
+ return this.httpPaginator.count || (this.serverPaginationEnabled && (this.options.page * this.options.itemsPerPage)) || -1;
459
+ },
252
460
  },
253
461
  mounted() {
254
- this.restoreFromQparams()
255
- this.httpEnabled || this.getDataFromApi();
462
+ this.restoreFromQparams();
463
+ if (!this.offlineMode) {
464
+ this.getDataFromApi();
465
+ } else {
466
+ this.items = this.data;
467
+ this.loading = false;
468
+ }
256
469
  },
257
470
  };
258
471
  </script>
@@ -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((err) => {
81
- console.log(err)
82
- this.$mapo.$snack.open({message: err})
83
- this.hasErr = true;
84
- this.errMsg = err.message;
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
  },