@mapomodule/uikit 1.0.0-alpha.5 → 1.0.0-alpha.50

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 (90) hide show
  1. package/CHANGELOG.md +873 -0
  2. package/components/ConfirmDialog.vue +58 -37
  3. package/components/Detail/Detail.vue +450 -243
  4. package/components/Detail/DetailLangSwitch.vue +9 -2
  5. package/components/DropArea.vue +63 -56
  6. package/components/Form/Form.vue +218 -0
  7. package/components/Form/FormField.vue +214 -0
  8. package/components/Form/FormGroup.vue +146 -0
  9. package/components/Form/FormTabs.vue +188 -0
  10. package/components/Form/defaults.js +97 -0
  11. package/components/Form/fields/ColorField.vue +79 -0
  12. package/components/{fields → Form/fields}/DateField.vue +20 -11
  13. package/components/Form/fields/DateTimeField.vue +271 -0
  14. package/components/Form/fields/EnhancedMediaField.vue +224 -0
  15. package/components/Form/fields/FileField.vue +125 -0
  16. package/components/Form/fields/FksField.vue +88 -0
  17. package/components/Form/fields/MediaField.vue +159 -0
  18. package/components/Form/fields/MediaM2mField.vue +149 -0
  19. package/components/Form/fields/Repeater.vue +596 -0
  20. package/components/Form/fields/SeoPreview.vue +89 -0
  21. package/components/Form/fields/TimeField.vue +154 -0
  22. package/components/Form/fields/mapField/leaflet.injector.js +39 -0
  23. package/components/Form/fields/mapField/mapField.vue +348 -0
  24. package/components/Form/fields/wygEditor/defaults.js +25 -0
  25. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
  26. package/components/Form/fields/wygEditor/wygEditor.vue +285 -0
  27. package/components/LangSwitcher.vue +44 -0
  28. package/components/List/List.vue +103 -51
  29. package/components/List/ListActions.vue +23 -5
  30. package/components/List/ListFilters.vue +166 -114
  31. package/components/List/ListHead.vue +30 -12
  32. package/components/List/ListQuickEdit.vue +130 -61
  33. package/components/List/ListTable.vue +210 -66
  34. package/components/Login.vue +17 -7
  35. package/components/LogoutButton.vue +43 -28
  36. package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
  37. package/components/MediaManager/MediaEditor.vue +297 -120
  38. package/components/MediaManager/MediaFileChanger.vue +78 -0
  39. package/components/MediaManager/MediaFolders.vue +224 -116
  40. package/components/MediaManager/MediaGallery.vue +224 -145
  41. package/components/MediaManager/MediaManager.vue +125 -159
  42. package/components/MediaManager/MediaManagerDialog.vue +36 -31
  43. package/components/MediaManager/MediaPreview.vue +258 -0
  44. package/components/MediaManager/MediaUploader.vue +91 -90
  45. package/components/MenuManager/MenuManager.vue +332 -0
  46. package/components/MenuManager/MenuNodeEditor.vue +255 -0
  47. package/components/MenuManager/MenuTreeview.vue +237 -0
  48. package/components/MenuManager/MenuTreeviewNode.vue +208 -0
  49. package/components/PagePreview.vue +58 -0
  50. package/components/SnackBar.vue +5 -7
  51. package/components/ThemeToggle.vue +13 -0
  52. package/components/layout/Sidebar/Sidebar.vue +61 -30
  53. package/components/layout/Sidebar/SidebarList.vue +19 -15
  54. package/components/layout/Sidebar/SidebarListItem.vue +122 -38
  55. package/components/layout/Sidebar/SidebarProfile.vue +42 -0
  56. package/components/layout/Sidebar/SidebarTitle.vue +45 -0
  57. package/components/layout/Topbar/Topbar.vue +11 -42
  58. package/components/layout/routebuilder.js +3 -3
  59. package/defaults/i18n.js +37 -0
  60. package/defaults/vuetify.js +34 -0
  61. package/layouts/default.vue +33 -18
  62. package/layouts/empty.vue +10 -0
  63. package/module.js +7 -5
  64. package/package.json +6 -4
  65. package/pages/index.vue +19 -18
  66. package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
  67. package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
  68. package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
  69. package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
  70. package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
  71. package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
  72. package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
  73. package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
  74. package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
  75. package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
  76. package/translations/en-US.js +177 -0
  77. package/translations/it-IT.js +180 -0
  78. package/components/Detail/DetailField.vue +0 -129
  79. package/components/Detail/defaults.js +0 -50
  80. package/components/fields/M2mField.vue +0 -95
  81. package/components/fields/MediaField.vue +0 -195
  82. package/components/fields/MediaM2mField.vue +0 -238
  83. package/components/fields/TinyMce/TinyMce.vue +0 -177
  84. package/components/fields/TinyMce/defaults.js +0 -55
  85. package/components/layout/Sidebar/SidebarFooter.vue +0 -75
  86. package/defaults.js +0 -29
  87. package/layouts/error.vue +0 -45
  88. /package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
  89. /package/components/{fields/TinyMce/utils/script.injector.js → Form/fields/wygEditor/utils/tinymce.injector.js} +0 -0
  90. /package/static/{favicon.ico → mapo/favicon.ico} +0 -0
@@ -3,45 +3,63 @@
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
- :search="searchable && !httpEnabled ? searchValue : ''"
10
- :server-items-length="httpPaginator.count || -1"
11
- :class="{ 'mapo__listtable__all_selected': selectAll }"
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"
12
18
  >
13
19
  <template v-slot:top>
14
20
  <v-toolbar flat>
15
21
  <v-text-field
16
22
  v-if="searchable"
17
- v-model="searchValue"
18
- @input="loadingSearch = true; changeSearch()"
23
+ v-model="searchString"
24
+ @input="
25
+ loadingSearch = serverPaginationEnabled;
26
+ search();
27
+ "
19
28
  prepend-inner-icon="mdi-magnify"
20
- label="Search"
29
+ :label="$t('mapo.search')"
21
30
  single-line
22
31
  hide-details
23
32
  outlined
24
33
  dense
25
34
  clearable
26
35
  :loading="loadingSearch"
27
- style="max-width: 300px"
36
+ class="search-input rounded-0"
28
37
  ></v-text-field>
29
38
  <v-spacer></v-spacer>
30
39
  <slot name="dtable.top.center"></slot>
31
40
  <v-spacer></v-spacer>
32
- <v-btn text v-if="shouldEdit" @click="editItem()">
33
- <v-icon small left class="mr-2"> mdi-plus </v-icon>
34
- Quick add
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">{{ $t("mapo.listTable.quickAdd") }}</span>
35
44
  </v-btn>
36
- <v-btn class="ma-2" @click="getDataFromApi(false)" icon>
45
+ <v-btn v-if="serverPaginationEnabled" class=" mx-sm-2 ma-2 mx-0" @click="getDataFromApi(false)" icon>
37
46
  <v-icon>mdi-update</v-icon>
38
47
  </v-btn>
39
48
  </v-toolbar>
40
49
  <slot name="dtable.top.under"></slot>
41
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>{{ $t("mapo.listTable.toggleOrder") }}</span>
58
+ </v-tooltip>
59
+ </template>
42
60
  <template v-if="navigable" v-slot:[`item.${firstColName}`]="{ item }">
43
61
  <NuxtLink :to="detailLink(item)">
44
- {{ item[firstColName] }}
62
+ {{ getPointed(item, firstColName, "") || "Unknown" }}
45
63
  </NuxtLink>
46
64
  </template>
47
65
  <template v-slot:item.data-table-select="{ isSelected, select }" v-if="selectAll">
@@ -51,47 +69,71 @@
51
69
  <v-simple-checkbox v-model="selectAll" @input="on.input"></v-simple-checkbox>
52
70
  </template>
53
71
  <template v-slot:[`item.actions`]="{ item }">
54
- <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)">
55
73
  mdi-pencil
56
74
  </v-icon>
57
- <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>
58
79
  </template>
59
- <template v-for="slot in filterSlots($slots, 'dtable.')" :slot="slot">
80
+ <template v-for="slot in nameSpacedSlots($slots, 'dtable.')" :slot="slot">
60
81
  <slot :name="`dtable.${slot}`"></slot>
61
82
  </template>
62
83
  <template
63
- v-for="slot in filterSlots($scopedSlots, 'dtable.')"
84
+ v-for="slot in nameSpacedSlots($scopedSlots, 'dtable.')"
64
85
  v-slot:[slot]="props"
65
86
  >
66
87
  <slot :name="`dtable.${slot}`" v-bind="props" />
67
88
  </template>
68
89
  </v-data-table>
69
90
  <list-quick-edit
70
- v-if="shouldEdit"
91
+ v-if="quickModeEnabled"
71
92
  ref="editModal"
72
- v-bind="{ ...$attrs, value: false, crud }"
93
+ :offline="offlineMode"
94
+ v-bind="{ ...$attrs, value: false, crud, lookup: lookup }"
73
95
  >
74
- <template v-for="slot in filterSlots($slots, 'qedit.')" :slot="slot">
96
+ <template v-for="slot in nameSpacedSlots($slots, 'qedit.')" :slot="slot">
75
97
  <slot :name="`qedit.${slot}`"></slot>
76
98
  </template>
77
- <template v-for="slot in filterSlots($scopedSlots, 'qedit.')" v-slot:[slot]="props">
99
+ <template v-for="slot in nameSpacedSlots($scopedSlots, 'qedit.')" v-slot:[slot]="props">
78
100
  <slot :name="`qedit.${slot}`" v-bind="props" />
79
101
  </template>
80
102
  </list-quick-edit>
81
103
  </div>
82
104
  </template>
83
105
 
84
- <style lang="scss">
106
+ <style lang="scss" scoped>
85
107
  .mapo__listtable__all_selected {
86
108
  .v-data-table__selected {
87
109
  background: none !important;
88
110
  }
89
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; }
90
129
  </style>
91
130
 
92
131
  <script>
93
132
  import { getPointed } from "@mapomodule/utils/helpers/objHelpers";
94
133
  import { debounce } from "@mapomodule/utils/helpers/debounce";
134
+ import { nameSpacedSlots } from "@mapomodule/utils/helpers/slots";
135
+
136
+ import Sortable from "sortablejs"
95
137
 
96
138
  export default {
97
139
  name: "ListTable",
@@ -102,16 +144,17 @@ export default {
102
144
  selectAll: false,
103
145
  options: {},
104
146
  httpPaginator: {},
105
- searchValue: "",
147
+ searchString: "",
106
148
  loadingSearch: false,
107
- disableHttp: false
149
+ noPagination: false,
150
+ dragOrderingActive: false
108
151
  }),
109
152
  props: {
110
153
  crud: {
111
154
  type: Object,
112
- required: true,
155
+ required: true
113
156
  },
114
- http: Boolean,
157
+ serverPagination: Boolean,
115
158
  navigable: Boolean,
116
159
  lookup: {
117
160
  type: String,
@@ -131,6 +174,28 @@ export default {
131
174
  type: Boolean,
132
175
  default: false,
133
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
+ }
134
199
  },
135
200
  watch: {
136
201
  selection(val) {
@@ -139,42 +204,58 @@ export default {
139
204
  selectAll(val) {
140
205
  this.$emit("input", val ? "all" : this.selection);
141
206
  },
207
+ dragOrderingActive(val) {
208
+ if (val) {
209
+ this.searchString = ""
210
+ this.options = {...this.options, sortBy: []}
211
+ }
212
+ this.$emit("drag-order-change", val)
213
+ },
142
214
  filters: {
143
215
  deep: true,
144
216
  handler() {
145
- this.httpEnabled && this.getDataFromApi();
217
+ this.serverPaginationEnabled && this.getDataFromApi();
146
218
  },
147
219
  },
148
220
  options: {
149
221
  deep: true,
150
222
  handler(options) {
151
- this.disableHttp = options.itemsPerPage === -1;
223
+ this.noPagination = options.itemsPerPage === -1;
152
224
  this.setQparams(options);
153
- this.httpEnabled && this.getDataFromApi(false);
225
+ this.serverPaginationEnabled && this.getDataFromApi(false);
154
226
  },
155
227
  },
156
- disableHttp() {
228
+ noPagination() {
157
229
  this.getDataFromApi();
158
230
  },
231
+ data: {
232
+ deep: true,
233
+ handler(data) {
234
+ if (data) this.items = data;
235
+ },
236
+ }
159
237
  },
160
238
  methods: {
239
+ nameSpacedSlots,
240
+ getPointed,
161
241
  getDataFromApi(clearSelection = true) {
162
242
  if (clearSelection) {
163
243
  this.selection = [];
164
244
  this.selectAll = false;
165
245
  }
166
- this.loading = true;
167
- this.debouncedDataFromApi();
246
+ this.loading = !this.offlineMode;
247
+ !this.offlineMode && this.debouncedDataFromApi();
168
248
  },
169
249
  debouncedDataFromApi: debounce(function () {
170
250
  return new Promise((resolve, reject) => {
171
251
  this.selection = [];
172
- if (!this.httpEnabled) {
252
+ if (!this.serverPaginationEnabled) {
173
253
  this.crud
174
254
  .list()
175
255
  .then((data) => {
176
256
  this.items = data;
177
257
  this.loading = false;
258
+ this.httpPaginator = {};
178
259
  resolve(data);
179
260
  })
180
261
  .catch((error) => reject(error));
@@ -192,6 +273,22 @@ export default {
192
273
  }
193
274
  });
194
275
  }, 500),
276
+ changeOrder(event){
277
+ if (!this.offlineMode) {
278
+ this.crud.update_order(this.items[event.oldIndex][this.lookup], this.items[event.newIndex][this.lookup]).then(
279
+ res => res.reordered && this.getDataFromApi()
280
+ ).catch(error => {
281
+ this.getDataFromApi()
282
+ this.$mapo.$snack.open({
283
+ message: error.response?.data?.detail || this.$t("mapo.listTable.errorOrder"),
284
+ color: "error",
285
+ })
286
+ });
287
+ }
288
+ const element = this.items[event.oldIndex]
289
+ this.items.splice(event.oldIndex, 1, )
290
+ this.items.splice(event.newIndex, 0, element);
291
+ },
195
292
  setQparams(options) {
196
293
  this.$router.push({
197
294
  query: {
@@ -203,20 +300,25 @@ export default {
203
300
  restoreFromQparams() {
204
301
  this.options = {
205
302
  ...this.options,
206
- sortBy: this.$route.query.sort?.split(".") || [],
207
- sortDesc: this.$route.query.order?.split(".").map((e) => e == "desc") || [],
303
+ sortBy:
304
+ this.$route.query.sort?.split(",").map((p) => p.replace(/^-/, "")) ||
305
+ this.options.sortBy ||
306
+ [],
307
+ sortDesc:
308
+ this.$route.query.order?.split(",").map((p) => p.startsWith("-")) ||
309
+ this.options.sortDesc ||
310
+ [],
208
311
  itemsPerPage:
209
312
  parseInt(this.$route.query.items) || this.options.itemsPerPage || 10,
313
+ page: parseInt(this.$route.query.page) || this.options.page || 1,
210
314
  };
211
- this.searchValue = this.$route.query.search;
315
+ this.searchString = this.$route.query.search;
212
316
  },
213
317
  getOrderParams(options) {
214
318
  const { sortBy, sortDesc, page, itemsPerPage } = options;
215
- const sort = sortBy.length ? sortBy.join(".") : undefined;
216
- const order = sortDesc.length
217
- ? sortDesc.map((e) => (e ? "desc" : "asc")).join(".")
218
- : undefined;
219
- return { sort, order, items: itemsPerPage, page: page !== 1 ? page : undefined };
319
+ const sort =
320
+ sortBy.map((field, i) => (sortDesc[i] ? "-" : "") + field).join(",") || undefined;
321
+ return { sort, items: itemsPerPage, page: page !== 1 ? page : undefined };
220
322
  },
221
323
  getHttpParams() {
222
324
  const params = new URLSearchParams();
@@ -237,45 +339,72 @@ export default {
237
339
  } else {
238
340
  query.push(`${format(fi.value)}=${fi.active[0].value}`);
239
341
  }
240
- query.forEach(q => params.append('fltr', q))
342
+ query.forEach((q) => params.append("fltr", q));
241
343
  });
242
- if (this.searchValue && this.searchable)
243
- params.append("search", this.searchValue);
344
+ if (this.searchString && this.searchable) params.append("search", this.searchString);
244
345
  return params;
245
346
  },
246
- editItem(item) {
247
- this.$refs.editModal.open(item).then((r) => r && this.getDataFromApi());
347
+ quickAction(item) {
348
+ this.$refs.editModal.open(item).then((r) => {
349
+ if (!r) return;
350
+ if (!this.offlineMode) {
351
+ this.getDataFromApi();
352
+ } else {
353
+ let index = item ? this.items.findIndex((i) => i[this.lookup] === item[this.lookup]) : -1;
354
+ let update = true;
355
+
356
+ if (index !== -1) {
357
+ this.items.splice(index, 1, r);
358
+ } else {
359
+ index = this.items.push(r);
360
+ update = false;
361
+ }
362
+ this.$emit("update:data", this.items, r, index);
363
+ }
364
+ });
248
365
  },
249
366
  deleteItem(item) {
250
- const callback = (item) =>
251
- this.crud.delete(item[this.lookup]).then(this.getDataFromApi);
367
+ const callback = (item) => {
368
+ if (!this.offlineMode) {
369
+ this.crud.delete(item[this.lookup]).then(this.getDataFromApi);
370
+ } else {
371
+ const index = this.items.findIndex((i) => i[this.lookup] === item[this.lookup]);
372
+
373
+ if (index !== -1) {
374
+ this.items.splice(index, 1);
375
+ this.$emit("update:data", this.items, r, index);
376
+ }
377
+ }
378
+ };
379
+
252
380
  this.$mapo.$confirm
253
381
  .open({
254
- title: "Delete",
255
- question: "Are you sure you want to delete this item?",
256
- approveButton: { text: "Delete", attrs: { color: "red" } },
382
+ title: this.$t("mapo.delete"),
383
+ question: this.$t("mapo.confirmDelete"),
384
+ approveButton: { text: this.$t("mapo.delete"), attrs: { color: "red", text: true } },
257
385
  })
258
386
  .then((res) => (res ? callback(item) : null));
259
387
  },
260
- filterSlots(slots, scope) {
261
- return Object.keys(slots)
262
- .filter((name) => name.startsWith(scope))
263
- .map((name) => name.replace(scope, ""));
264
- },
265
388
  toggleSelectAll() {
266
389
  this.selectAll = !this.selectAll;
267
390
  },
268
- changeSearch: debounce(function () {
391
+ search: debounce(function () {
269
392
  this.$router.push({
270
393
  query: {
271
394
  ...this.$route.query,
272
- search: this.searchValue,
395
+ search: this.searchString || undefined,
273
396
  },
274
397
  });
275
398
 
276
- this.httpEnabled && this.getDataFromApi();
399
+ this.serverPaginationEnabled && this.getDataFromApi();
277
400
  this.loadingSearch = false;
278
- }, 1000)
401
+ }, 1000),
402
+ userCan(action) {
403
+ if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
404
+ return this.$mapo.$auth.user.permissions.includes(action)
405
+ }
406
+ return true
407
+ },
279
408
  },
280
409
  computed: {
281
410
  filteredItems() {
@@ -307,20 +436,35 @@ export default {
307
436
  this.$attrs.headers && this.$attrs.headers.length && this.$attrs.headers[0].value
308
437
  );
309
438
  },
310
- shouldEdit() {
439
+ headers() {
440
+ const dragColumn = { sortable: false, value: 'drag-column', width: '64px' }
441
+ return this.dragOrderingActive ? [ dragColumn,...this.$attrs.headers ] : this.$attrs.headers
442
+ },
443
+ quickModeEnabled() {
311
444
  return (
312
- this.filterSlots(this.$slots, "qedit.body").length ||
313
- this.filterSlots(this.$scopedSlots, "qedit.body").length ||
445
+ this.nameSpacedSlots(this.$slots, "qedit.body").length ||
446
+ this.nameSpacedSlots(this.$scopedSlots, "qedit.body").length ||
314
447
  (this.$attrs.editFields && this.$attrs.editFields.length)
315
448
  );
316
449
  },
317
- httpEnabled() {
318
- return this.http && !this.disableHttp;
450
+ serverPaginationEnabled() {
451
+ return this.serverPagination && !this.noPagination && !this.offlineMode;
452
+ },
453
+ offlineMode() {
454
+ return !!this.data;
455
+ },
456
+ serverItemsLength() {
457
+ return this.httpPaginator.count || (this.serverPaginationEnabled && (this.options.page * this.options.itemsPerPage)) || -1;
319
458
  },
320
459
  },
321
460
  mounted() {
322
461
  this.restoreFromQparams();
323
- this.httpEnabled || this.getDataFromApi();
462
+ if (!this.offlineMode) {
463
+ this.getDataFromApi();
464
+ } else {
465
+ this.items = this.data;
466
+ this.loading = false;
467
+ }
324
468
  },
325
469
  };
326
470
  </script>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="login__wrapper">
3
3
  <div class="login__inner">
4
- <h2 class="login__inner__title">Login</h2>
4
+ <h2 class="login__inner__title">{{ $t("mapo.login") }}</h2>
5
5
 
6
6
  <div class="login__form__outer">
7
7
  <v-form
@@ -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,18 +30,25 @@
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
- Log In
38
+ {{ $t("mapo.login") }}
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>
39
46
  </v-form>
40
47
  </div>
41
48
  </div>
42
49
  </div>
43
50
  </template>
51
+
44
52
  <script>
45
53
  export default {
46
54
  data() {
@@ -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,16 +86,17 @@ 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: this.$t("mapo.loginError"), color: "error"})
93
+ }
85
94
  });
86
95
  },
87
96
  },
88
97
  };
89
98
  </script>
99
+
90
100
  <style lang="scss">
91
101
  @import "@mapomodule/uikit/assets/variables.scss";
92
102
  .login {
@@ -1,39 +1,54 @@
1
1
  <template>
2
- <v-btn @click.native="logout" class="logout__btn">
3
- <v-icon class="logout__icon">mdi-logout</v-icon>
4
- <span class="logout__text">Logout</span>
5
- </v-btn>
2
+ <div class="d-flex">
3
+ <v-list-item dense class="darker__item" link @click.native="login">
4
+ <v-list-item-icon>
5
+ <v-icon v-if="$mapo.$auth.user.isLoggedIn">mdi-logout</v-icon>
6
+ <v-icon v-else>mdi-login</v-icon>
7
+ </v-list-item-icon>
8
+ <v-list-item-title>{{
9
+ $mapo.$auth.user.isLoggedIn ? $t("mapo.logout") : $t("mapo.login")
10
+ }}</v-list-item-title>
11
+ </v-list-item>
12
+ <v-list-item
13
+ dense
14
+ link
15
+ v-if="$i18n.locales.length > 1"
16
+ class="lang__selector darker__item"
17
+ >
18
+ <LangSwitcher></LangSwitcher>
19
+ </v-list-item>
20
+ </div>
6
21
  </template>
7
22
 
23
+ <style lang="scss" scoped>
24
+ .darker__item {
25
+ &.theme--light {
26
+ background: #ffffffd6;
27
+ }
28
+ &.theme--dark {
29
+ background: #121212;
30
+ }
31
+ }
32
+ .lang__selector {
33
+ max-width: 70px;
34
+ flex-basis: content;
35
+ overflow: hidden;
36
+ padding: 0;
37
+ v-select {
38
+ border-radius: 0px;
39
+ }
40
+ }
41
+ </style>
42
+
8
43
  <script>
9
44
  export default {
10
45
  name: "LogoutButton",
11
46
  methods: {
12
- logout() {
13
- this.$store.dispatch("mapo/user/logout");
47
+ login() {
48
+ this.$mapo.$auth.user.isLoggedIn
49
+ ? this.$store.dispatch("mapo/user/logout")
50
+ : this.$router.push("/login");
14
51
  },
15
52
  },
16
53
  };
17
54
  </script>
18
-
19
- <style lang="scss" scoped>
20
- .logout {
21
- &__btn {
22
- padding: 0.5rem 1rem!important;
23
- height: auto!important;
24
- }
25
- &__icon {
26
- margin-right: 0.5rem;
27
- font-size: 1rem;
28
- }
29
- &__text {
30
- text-align: left;
31
- display: block;
32
- width: 100%;
33
- font-size: 1rem;
34
- text-transform: capitalize;
35
- font-weight: 400;
36
- letter-spacing: initial;
37
- }
38
- }
39
- </style>
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <div
3
+ v-if="parentFolders && parentFolders.length"
4
+ class="media-breadcrumbs--wrapper"
5
+ >
6
+ <span class="mx-2 mt-1 d-flex flex-wrap align-center">
7
+ <span class="mb-1">
8
+ <v-icon @click="getRoot({ folder: null })" small>mdi-home</v-icon></span
9
+ >
10
+ <span
11
+ class="media-breadcrumbs--button"
12
+ v-for="(folder, i) in parentFolders"
13
+ :key="i"
14
+ >/<a @click="getRoot({ folder })">{{ folder.slug }}</a>
15
+ </span>
16
+ </span>
17
+ </div>
18
+ </template>
19
+
20
+ <style lang="scss" scoped>
21
+ .media-breadcrumbs--button {
22
+ padding-left: 7px;
23
+ color: grey;
24
+ a {
25
+ margin-left: 7px;
26
+ }
27
+ &:last-child {
28
+ a {
29
+ color: unset;
30
+ cursor: auto;
31
+ pointer-events: none;
32
+ }
33
+ }
34
+ }
35
+ </style>
36
+
37
+ <script>
38
+ import { mapGetters, mapActions } from "vuex";
39
+
40
+ export default {
41
+ name: "MediaBreadcrumbs",
42
+ computed: {...mapGetters("mapo/media", ["parentFolders"])},
43
+ methods: {...mapActions("mapo/media", ["getRoot"])},
44
+ };
45
+ </script>