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

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 (40) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/components/ConfirmDialog.vue +10 -14
  3. package/components/Detail/Detail.vue +23 -15
  4. package/components/DropArea.vue +17 -33
  5. package/components/Form/Form.vue +15 -11
  6. package/components/Form/FormField.vue +3 -0
  7. package/components/Form/FormGroup.vue +23 -3
  8. package/components/Form/FormTabs.vue +20 -3
  9. package/components/Form/fields/DateField.vue +3 -3
  10. package/components/Form/fields/FksField.vue +2 -2
  11. package/components/Form/fields/MediaField.vue +10 -5
  12. package/components/Form/fields/MediaM2mField.vue +3 -3
  13. package/components/Form/fields/Repeater.vue +23 -10
  14. package/components/Form/fields/SeoPreview.vue +10 -10
  15. package/components/LangSwitcher.vue +44 -0
  16. package/components/List/List.vue +14 -15
  17. package/components/List/ListActions.vue +5 -5
  18. package/components/List/ListFilters.vue +9 -2
  19. package/components/List/ListHead.vue +1 -1
  20. package/components/List/ListQuickEdit.vue +4 -4
  21. package/components/List/ListTable.vue +11 -12
  22. package/components/Login.vue +5 -4
  23. package/components/LogoutButton.vue +43 -28
  24. package/components/MediaManager/MediaEditor.vue +20 -18
  25. package/components/MediaManager/MediaFolders.vue +14 -19
  26. package/components/MediaManager/MediaGallery.vue +1 -1
  27. package/components/MediaManager/MediaManager.vue +22 -15
  28. package/components/MediaManager/MediaManagerDialog.vue +2 -1
  29. package/components/MediaManager/MediaUploader.vue +6 -7
  30. package/components/SnackBar.vue +2 -3
  31. package/components/layout/Sidebar/SidebarFooter.vue +6 -25
  32. package/components/layout/Sidebar/SidebarListItem.vue +2 -2
  33. package/components/layout/Sidebar/SidebarProfile.vue +2 -2
  34. package/defaults/i18n.js +37 -0
  35. package/{defaults.js → defaults/vuetify.js} +16 -12
  36. package/module.js +6 -4
  37. package/package.json +4 -3
  38. package/pages/index.vue +1 -1
  39. package/translations/en-US.js +129 -0
  40. package/translations/it-IT.js +131 -0
@@ -40,7 +40,7 @@ export default {
40
40
  chips: this.$attrs.multiple === false ? false : true,
41
41
  multiple: true,
42
42
  loading: this.loading,
43
- noDataText: this.loading ? "Fetching data.." : undefined,
43
+ noDataText: this.loading ? this.$t("mapo.fetchingData") : undefined,
44
44
  ...this.$attrs,
45
45
  };
46
46
  },
@@ -85,4 +85,4 @@ export default {
85
85
  }
86
86
  },
87
87
  };
88
- </script>
88
+ </script>
@@ -14,7 +14,6 @@
14
14
  v-if="mediaExists"
15
15
  :src="internalValue.is_image && internalValue.file || null"
16
16
  :lazy-src="internalValue.is_image && internalValue.thumbnail || null"
17
-
18
17
  :class="{'grey lighten-2': !internalValue.is_image}"
19
18
  v-bind="{
20
19
  aspectRatio,
@@ -200,12 +199,17 @@ export default {
200
199
  confirmDelete() {
201
200
  this.$mapo.$confirm
202
201
  .open({
203
- title: "Remove",
204
- question: "Are you sure to want to remove this media?",
205
- approveButton: { text: "Remove", attrs: { color: "red", text: true } }
202
+ title: this.$t("mapo.remove"),
203
+ question: this.$t("mapo.mediaField.confirmRemove"),
204
+ approveButton: { text: this.$t("mapo.remove"), attrs: { color: "red", text: true } }
206
205
  })
207
206
  .then((res) => (res ? (this.internalValue = null) : null));
208
207
  },
208
+ isImage(val) {
209
+ if (!val?.is_image && val?.mime_type.includes("image")) {
210
+ Object.assign(val, { is_image: true });
211
+ }
212
+ },
209
213
  },
210
214
 
211
215
  watch: {
@@ -215,6 +219,7 @@ export default {
215
219
  }
216
220
  },
217
221
  internalValue(val) {
222
+ this.isImage(val)
218
223
  this.$emit("input", val);
219
224
  },
220
225
  },
@@ -222,4 +227,4 @@ export default {
222
227
  this.internalValue = this.val
223
228
  }
224
229
  };
225
- </script>
230
+ </script>
@@ -13,7 +13,7 @@
13
13
  light: !dark,
14
14
  }"
15
15
  >
16
- <v-card-title v-if="!pages">Media Carousel</v-card-title>
16
+ <v-card-title v-if="!pages">{{ $t("mapo.mediaM2MField.mediaCarousel") }}</v-card-title>
17
17
  <v-card-actions>
18
18
  <v-row justify="center" class="ma-1" no-gutters>
19
19
  <v-col>
@@ -23,7 +23,7 @@
23
23
  outlined
24
24
  :min-height="pages ? undefined : minHeight"
25
25
  >
26
- <div v-if="pages">New Selection</div>
26
+ <div v-if="pages">{{ $t("mapo.mediaM2MField.newSelection") }}</div>
27
27
  <v-icon v-else size="80"> mdi-plus-circle-outline </v-icon>
28
28
  </v-btn>
29
29
  </v-col>
@@ -240,4 +240,4 @@ export default {
240
240
  },
241
241
  },
242
242
  };
243
- </script>
243
+ </script>
@@ -3,15 +3,15 @@
3
3
  <div class="d-flex justify-space-between">
4
4
  <span class="repeater-label">{{ label }}:</span>
5
5
  <v-btn v-if="collapsable" outlined tile text small @click="collapseAll"
6
- >Collapse all</v-btn
6
+ >{{ $t("mapo.collapse") }}</v-btn
7
7
  >
8
8
  </div>
9
- <v-divider />
10
9
  <draggable
11
10
  v-model="items"
12
11
  handle=".repeater-handle-sort"
13
12
  animation="150"
14
13
  @change="sortCallback({ ...$event, items, eventType: 'move' })"
14
+ :style="maxHeightStyle"
15
15
  >
16
16
  <div
17
17
  class="repeater-line-wrapper"
@@ -20,7 +20,6 @@
20
20
  :key="index"
21
21
  >
22
22
  <div class="d-flex">
23
- <v-divider vertical />
24
23
  <div v-if="collapsable" class="collapsed-preview">
25
24
  <v-icon class="expand-icon" @click.native="toggleExpand($event)"
26
25
  >mdi-chevron-down</v-icon
@@ -38,6 +37,7 @@
38
37
  :languages="langs"
39
38
  :fields="getFields(model)"
40
39
  :errors="getErrors(index)"
40
+ :readonly="readonly"
41
41
  >
42
42
  <template
43
43
  v-for="(slot, name) in templateSlots(model, $slots)"
@@ -70,7 +70,7 @@
70
70
  >mdi-plus-circle-outline</v-icon
71
71
  >
72
72
  </template>
73
- <span>Add here</span>
73
+ <span>{{ $t("mapo.repeater.addHere") }}</span>
74
74
  </v-tooltip>
75
75
  <v-tooltip right>
76
76
  <template v-slot:activator="{ on, attrs }">
@@ -86,7 +86,7 @@
86
86
  >
87
87
  </v-hover>
88
88
  </template>
89
- <span>Remove</span>
89
+ <span>{{ $t("mapo.remove") }}</span>
90
90
  </v-tooltip>
91
91
  <v-icon
92
92
  v-if="!readonly && sortable"
@@ -96,9 +96,9 @@
96
96
  >
97
97
  </div>
98
98
  </div>
99
- <v-divider />
100
99
  </div>
101
100
  </draggable>
101
+ <v-divider/>
102
102
  <div class="d-flex justify-end">
103
103
  <v-btn
104
104
  class="repeater-add-line"
@@ -108,12 +108,12 @@
108
108
  tile
109
109
  text
110
110
  >
111
- <v-icon>mdi-plus</v-icon> Add</v-btn
111
+ <v-icon>mdi-plus</v-icon> {{ $t("mapo.add") }}</v-btn
112
112
  >
113
113
  </div>
114
114
  <v-dialog v-if="hasTemplates" v-model="tModalOpen" width="600" scrollable>
115
115
  <v-card>
116
- <v-card-title class="text-h5"> Select template </v-card-title>
116
+ <v-card-title class="text-h5">{{ $t("mapo.repeater.selectTemplate") }}</v-card-title>
117
117
  <v-card-text>
118
118
  <div class="row mt-4">
119
119
  <div
@@ -175,7 +175,11 @@
175
175
  overflow: hidden;
176
176
  text-overflow: ellipsis;
177
177
  }
178
+ .theme--light .repeater-line-wrapper { border-color: rgba(0, 0, 0, 0.12); }
178
179
  .repeater-line-wrapper {
180
+ border: 1px solid;
181
+ border-bottom: none;
182
+ border-color: rgba(255, 255, 255, 0.12);
179
183
  &:hover {
180
184
  .repeater-action {
181
185
  display: inline-flex;
@@ -220,7 +224,9 @@
220
224
  .repeater-handle-sort {
221
225
  position: absolute;
222
226
  align-self: center;
223
- bottom: -4px;
227
+ bottom: 0px;
228
+ height: 15px;
229
+ overflow: hidden;
224
230
  cursor: grab;
225
231
  }
226
232
  }
@@ -306,6 +312,7 @@ export default {
306
312
  },
307
313
  // This is mainly an internal property. It is used by DetailField to pass the active language inherited from the Detail component.
308
314
  currentLang: String,
315
+ maxHeight: String | Number
309
316
  },
310
317
  watch: {
311
318
  value(val) {
@@ -377,7 +384,7 @@ export default {
377
384
  return Object.keys(slots).reduce((acc, v) => ({ [v]: v, ...acc }), {});
378
385
  },
379
386
  getCollapsedLabel(model, index) {
380
- const fallback = `Item ${index + 1}`;
387
+ const fallback = this.$t("mapo.repeater.item", {numberItem: index + 1});
381
388
  switch (typeof this.collapsedLabel) {
382
389
  case "string":
383
390
  return getPointed(model, this.collapsedLabel, fallback);
@@ -418,6 +425,12 @@ export default {
418
425
  }
419
426
  return Object.values(templates);
420
427
  },
428
+ maxHeightStyle(){
429
+ if (this.maxHeight !== undefined){
430
+ const maxHeight = isNaN(this.maxHeight) ? this.maxHeight : `${this.maxHeight}px`
431
+ return { maxHeight, paddingTop: '15px', overflowX: 'hidden', overflowY: 'auto' }
432
+ }
433
+ }
421
434
  },
422
435
  mounted() {
423
436
  this.items = this.value;
@@ -3,7 +3,7 @@
3
3
  <div class="preview">
4
4
  <span class="preview__title">{{ getTitle }}</span>
5
5
  <br />
6
- <span class="preview__url">{{ getPermalink }}</span>
6
+ <span class="preview__url">{{domain}}{{ getPermalink }}</span>
7
7
  <br />
8
8
  <span class="preview__desc">{{ getDescription }}</span>
9
9
  </div>
@@ -51,27 +51,27 @@ export default {
51
51
  },
52
52
  // Seo title
53
53
  title: {
54
- type: String,
55
- default:
56
- "It was the best of times, it was the blurst of times, it was the ..."
54
+ type: String
57
55
  },
58
56
  // Seo permalink
59
57
  permalink: {
60
58
  type: String,
61
- default: "example.com/how_to_dive"
59
+ default: "how-to-dive"
62
60
  },
63
61
  // Seo description
64
62
  description: {
63
+ type: String
64
+ },
65
+ domain: {
65
66
  type: String,
66
- default:
67
- "This is an example description that will get replaced when you start typing. Make sure to keep descriptions mobile-friendly and keyword-rich!"
67
+ default: process.browser ? `${window.location.origin}/` : ""
68
68
  }
69
69
  },
70
70
  computed: {
71
71
  getTitle(){
72
72
  if (this.value && this.value.title)
73
73
  return this.value.title
74
- return this.title
74
+ return this.title || this.$t("mapo.seoPreview.title")
75
75
  },
76
76
  getPermalink(){
77
77
  if (this.value && this.value.permalink)
@@ -81,9 +81,9 @@ export default {
81
81
  getDescription(){
82
82
  if (this.value && this.value.description)
83
83
  return this.value.description
84
- return this.description
84
+ return this.description || this.$t("mapo.seoPreview.description")
85
85
  }
86
86
  },
87
87
 
88
88
  };
89
- </script>
89
+ </script>
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <v-select
3
+ :items="$i18n.locales"
4
+ :value="$i18n.locale"
5
+ @input="$i18n.setLocale($event)"
6
+ dense
7
+ flat
8
+ hide-details
9
+ solo
10
+ background-color="transparent"
11
+ item-value="code"
12
+ >
13
+ <template v-slot:selection="{ item }">
14
+ {{ item.iso ? getFlag(item.iso) : item.name }}
15
+ </template>
16
+ <template v-slot:item="{ item, on, attrs }">
17
+ <v-list-item v-on="on" v-bind="attrs">
18
+ <v-list-item-icon class="mr-2">
19
+ {{ item.iso ? getFlag(item.iso) : item.name }}
20
+ </v-list-item-icon>
21
+ <v-list-item-title>
22
+ {{ item.name }}
23
+ </v-list-item-title>
24
+ </v-list-item>
25
+ </template>
26
+ </v-select>
27
+ </template>
28
+
29
+ <script>
30
+ export default {
31
+ name: "LangSwitcher",
32
+ methods: {
33
+ getFlag(isoCode) {
34
+ const codePoints = isoCode
35
+ .split("-")
36
+ .slice(-1)[0]
37
+ .toUpperCase()
38
+ .split("")
39
+ .map((char) => 127397 + char.charCodeAt());
40
+ return String.fromCodePoint(...codePoints);
41
+ },
42
+ },
43
+ };
44
+ </script>
@@ -30,18 +30,18 @@
30
30
  <!-- Overrides counter for selected items. -->
31
31
  <slot name="item-counter" v-bind="{ selection, canSelectAll, allSelected, toggleSelectAll }">
32
32
  <div v-if="selection" class="caption mr-1 mb-1">
33
- <b v-if="allSelected">All items selected</b>
33
+ <b v-if="allSelected">{{ $t("mapo.list.allSelected") }}</b>
34
34
  <span v-else-if="selection.length">
35
- {{ selection.length }} items selected
36
- <v-btn
37
- v-if="selection != 'all' && canSelectAll"
38
- @click="toggleSelectAll"
39
- outlined
40
- tile
41
- x-small
42
- class="ml-1 d-inline-flex"
43
- >Select all</v-btn
44
- >
35
+ {{ $t("mapo.list.NSelected", {numberItems: selection.length}) }}
36
+ <v-btn
37
+ v-if="selection != 'all' && canSelectAll"
38
+ @click="toggleSelectAll"
39
+ outlined
40
+ tile
41
+ x-small
42
+ class="ml-1 d-inline-flex"
43
+ >{{ $t("mapo.list.selectAll") }}</v-btn
44
+ >
45
45
  </span>
46
46
  </div>
47
47
  </slot>
@@ -84,7 +84,8 @@ export default {
84
84
  selection: [],
85
85
  allSelected: false,
86
86
  filters: [],
87
- dragOrderingActive: false
87
+ dragOrderingActive: false,
88
+ selectionQuery: null,
88
89
  };
89
90
  },
90
91
  props: {
@@ -99,13 +100,11 @@ export default {
99
100
  crud() {
100
101
  return this.$mapo.$api.crud(this.endpoint);
101
102
  },
102
- selectionQuery() {
103
- return this.$refs?.dtable?.getHttpParams();
104
- }
105
103
  },
106
104
  watch: {
107
105
  selection(val) {
108
106
  this.allSelected = val == 'all';
107
+ this.selectionQuery = this.$refs.dtable.getHttpParams();
109
108
  // Fires when you select some row of the table.
110
109
  // @arg Emit "all" if all items are selected, else the list of the selected rows.
111
110
  this.$emit("selectionChange", val);
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div v-if="isActive" class="d-flex flex-row align-center fill-height">
3
3
  <v-select
4
- label="Group Actions"
4
+ :label="$t('mapo.listActions.groupActions')"
5
5
  v-bind="$attrs"
6
6
  v-model="action"
7
7
  :items="filteredActions"
@@ -21,7 +21,7 @@
21
21
  color="primary"
22
22
  :disabled="!action"
23
23
  @click="handleAction"
24
- >Apply</v-btn
24
+ >{{ $t("mapo.apply") }}</v-btn
25
25
  >
26
26
  </div>
27
27
  </template>
@@ -51,7 +51,7 @@ export default {
51
51
  default() {
52
52
  return [
53
53
  {
54
- label: "Permanent delete",
54
+ label: this.$t("mapo.listActions.permanentDelete"),
55
55
  handler: function ({ selection, lookup, crud }) {
56
56
  return Promise.all(selection.map((i) => crud && crud.delete(i[lookup])));
57
57
  },
@@ -92,7 +92,7 @@ export default {
92
92
  }
93
93
  },
94
94
  methods: {
95
- isDisabled(action){
95
+ isDisabled(action){
96
96
  const p = typeof action.permissions == "string" ? [action.permissions] : action.permissions || []
97
97
  if (p.length){
98
98
  return !p.every(a => this.userCan(a))
@@ -108,7 +108,7 @@ export default {
108
108
  handleAction() {
109
109
  if (!this.selectAll && !this.selection.length) {
110
110
  return this.$mapo.$snack.open({
111
- message: "You need to select at least one item.",
111
+ message: this.$t("mapo.listActions.selectionRequired"),
112
112
  color: "error",
113
113
  });
114
114
  }
@@ -5,7 +5,7 @@
5
5
  <v-menu offset-y min-width="250px" max-width="400px" nudge-top="-5px" tile :close-on-content-click="false" v-bind="{ ...$attrs, value: null }" >
6
6
  <template v-slot:activator="{ on }">
7
7
  <v-btn v-bind="$attrs" v-on="on" text>
8
- filter <v-icon>mdi-filter-variant</v-icon>
8
+ {{ $t("mapo.listFilters.filter") }} <v-icon>mdi-filter-variant</v-icon>
9
9
  </v-btn>
10
10
  </template>
11
11
 
@@ -65,7 +65,7 @@
65
65
  @click="removeFilter(filter)"
66
66
  small
67
67
  tile
68
- >clear</v-btn
68
+ >{{ $t("mapo.clear") }}</v-btn
69
69
  >
70
70
  </div>
71
71
  <v-list v-else class="overflow-y-auto pa-0" max-height="200" dense>
@@ -310,6 +310,13 @@ export default {
310
310
  this.cleanActiveFilters()
311
311
  }
312
312
  }
313
+ },
314
+ filters: {
315
+ deep: true,
316
+ handler(val) {
317
+ this.loadFilters();
318
+ this.restoreFromQparams();
319
+ }
313
320
  }
314
321
  },
315
322
  created() {
@@ -7,7 +7,7 @@
7
7
  class="rounded-0 elevation-0"
8
8
  color="primary"
9
9
  :to="{ path: `${$route.path}/new` }"
10
- >Add new &emsp; <v-icon>mdi-plus</v-icon></v-btn
10
+ >{{ $t("mapo.listHead.addNew") }} &emsp; <v-icon>mdi-plus</v-icon></v-btn
11
11
  >
12
12
  </div>
13
13
  </div>
@@ -57,8 +57,8 @@
57
57
  <v-messages v-if="nonFieldErrors.length" v-model="nonFieldErrors" color="error"></v-messages>
58
58
  <slot name="actions" v-bind="slotBindings">
59
59
  <v-spacer></v-spacer>
60
- <v-btn text @click="close()"> Cancel </v-btn>
61
- <v-btn text @click="save"> Save </v-btn>
60
+ <v-btn text @click="close()">{{ $t("mapo.cancel") }}</v-btn>
61
+ <v-btn text @click="save">{{ $t("mapo.save") }}</v-btn>
62
62
  </slot>
63
63
  </v-card-actions>
64
64
  </v-card>
@@ -218,8 +218,8 @@ export default {
218
218
  this.errors = (badRequest && error.response.data) || null;
219
219
  this.$mapo.$snack.open({
220
220
  message: badRequest
221
- ? "Bad input, correct wrong fields."
222
- : error.response?.data?.detail || "Something whent bad, please try again later...",
221
+ ? this.$t("mapo.listQuickEdit.badInput")
222
+ : error.response?.data?.detail || this.$t("mapo.genericError"),
223
223
  color: "error",
224
224
  });
225
225
  },
@@ -26,7 +26,7 @@
26
26
  search();
27
27
  "
28
28
  prepend-inner-icon="mdi-magnify"
29
- label="Search"
29
+ :label="$t('mapo.search')"
30
30
  single-line
31
31
  hide-details
32
32
  outlined
@@ -40,7 +40,7 @@
40
40
  <v-spacer></v-spacer>
41
41
  <v-btn text v-if="quickModeEnabled && userCan('add')" class="ml-2" @click="quickAction()">
42
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
43
+ <span class="d-none d-sm-block">{{ $t("mapo.listTable.quickAdd") }}</span>
44
44
  </v-btn>
45
45
  <v-btn v-if="serverPaginationEnabled" class=" mx-sm-2 ma-2 mx-0" @click="getDataFromApi(false)" icon>
46
46
  <v-icon>mdi-update</v-icon>
@@ -54,7 +54,7 @@
54
54
  <v-btn v-bind="attrs" v-on="on" style="margin-left: 2px;" :class="{'primary--text': dragOrderingActive}" @click="dragOrderingActive = !dragOrderingActive" icon>
55
55
  <v-icon>mdi-order-bool-ascending</v-icon></v-btn>
56
56
  </template>
57
- <span>Toggle reordering</span>
57
+ <span>{{ $t("mapo.listTable.toggleOrder") }}</span>
58
58
  </v-tooltip>
59
59
  </template>
60
60
  <template v-if="navigable" v-slot:[`item.${firstColName}`]="{ item }">
@@ -274,21 +274,20 @@ export default {
274
274
  });
275
275
  }, 500),
276
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 {
277
+ if (!this.offlineMode) {
282
278
  this.crud.update_order(this.items[event.oldIndex][this.lookup], this.items[event.newIndex][this.lookup]).then(
283
279
  res => res.reordered && this.getDataFromApi()
284
280
  ).catch(error => {
285
281
  this.getDataFromApi()
286
282
  this.$mapo.$snack.open({
287
- message: error.response?.data?.detail || "Reorder failed",
283
+ message: error.response?.data?.detail || this.$t("mapo.listTable.errorOrder"),
288
284
  color: "error",
289
285
  })
290
286
  });
291
287
  }
288
+ const element = this.items[event.oldIndex]
289
+ this.items.splice(event.oldIndex, 1, )
290
+ this.items.splice(event.newIndex, 0, element);
292
291
  },
293
292
  setQparams(options) {
294
293
  this.$router.push({
@@ -380,9 +379,9 @@ export default {
380
379
 
381
380
  this.$mapo.$confirm
382
381
  .open({
383
- title: "Delete",
384
- question: "Are you sure you want to delete this item?",
385
- approveButton: { text: "Delete", attrs: { color: "red", text: true } },
382
+ title: this.$t("mapo.delete"),
383
+ question: this.$t("mapo.confirmDelete"),
384
+ approveButton: { text: this.$t("mapo.delete"), attrs: { color: "red", text: true } },
386
385
  })
387
386
  .then((res) => (res ? callback(item) : null));
388
387
  },
@@ -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
@@ -35,7 +35,7 @@
35
35
  ></v-text-field>
36
36
  <div class="text-center">
37
37
  <v-btn type="submit" class="rounded-0" elevation="0" dark>
38
- Log In
38
+ {{ $t("mapo.login") }}
39
39
  </v-btn>
40
40
  <v-messages
41
41
  v-model="errors.non_field_errors"
@@ -43,12 +43,12 @@
43
43
  class="mt-4 text-center"
44
44
  />
45
45
  </div>
46
-
47
46
  </v-form>
48
47
  </div>
49
48
  </div>
50
49
  </div>
51
50
  </template>
51
+
52
52
  <script>
53
53
  export default {
54
54
  data() {
@@ -89,13 +89,14 @@ export default {
89
89
  .catch((error) => {
90
90
  this.errors = error.response?.data || {}
91
91
  if (!Object.keys(this.errors).length){
92
- this.$mapo.$snack.open({message: "Cannot login right now. Try again later.", color: "error"})
92
+ this.$mapo.$snack.open({message: this.$t("mapo.loginError"), color: "error"})
93
93
  }
94
94
  });
95
95
  },
96
96
  },
97
97
  };
98
98
  </script>
99
+
99
100
  <style lang="scss">
100
101
  @import "@mapomodule/uikit/assets/variables.scss";
101
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
+ filter: invert(1);
28
+ }
29
+ &.theme--dark {
30
+ background: #121212;
31
+ }
32
+ }
33
+ .lang__selector {
34
+ max-width: 70px;
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>