@mapomodule/uikit 1.0.0-alpha.42 → 1.0.0-alpha.44

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 CHANGED
@@ -3,6 +3,54 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.44](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.43...v1.0.0-alpha.44) (2023-06-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * added bottom padding to menu treeview draggable ([6c10dcb](https://github.com/lotrekagency/mapo/commit/6c10dcbd9c5be34cba448692e39ee61494205e61))
12
+ * added missing tranlations to detail component ([c099319](https://github.com/lotrekagency/mapo/commit/c09931963b5f6c9425bb905b958b13ed44df3b06))
13
+ * better double clik node edit catcher ([78ec053](https://github.com/lotrekagency/mapo/commit/78ec053be801f6da49019c1bd371948a1eaf3a15))
14
+ * fix media edit folder typo ([aba1d15](https://github.com/lotrekagency/mapo/commit/aba1d15807edcb10941e3b051e75d20c86e6670e))
15
+ * fix search value update in media manager ([c38b530](https://github.com/lotrekagency/mapo/commit/c38b5304bec5438bfa74b1fed9fe083457189fc1))
16
+
17
+
18
+ ### Features
19
+
20
+ * add click callback to menuNode breadcrums to help navigation ([0b73718](https://github.com/lotrekagency/mapo/commit/0b73718402a306c66a20e04e7d77201a53a16875))
21
+ * added css classes and translations to menu-manager ([e1f46c0](https://github.com/lotrekagency/mapo/commit/e1f46c0347ad3cd56bb44ecec810692daf57aad2))
22
+ * added del keyboard input to delete menu nodes ([6d376a0](https://github.com/lotrekagency/mapo/commit/6d376a05e932921d3f78eee008bd09c9ebe9a0cf))
23
+ * added delete selected to media manager ([060eaed](https://github.com/lotrekagency/mapo/commit/060eaedccc6f5761e995a889a749f3643494eb2f))
24
+ * added empty placeholder for menu treeview ([f40dfc3](https://github.com/lotrekagency/mapo/commit/f40dfc36e6a80f6f2f532d1580b59a5ed5e686f6))
25
+ * added keyboard inputs for confirm dialog ([e9e4058](https://github.com/lotrekagency/mapo/commit/e9e4058020ce240a7f4877e384931a02da8a69bd))
26
+ * added media editor translation fields ([87ed691](https://github.com/lotrekagency/mapo/commit/87ed691da08d6e06ff0f960d5e6592ace349cce6))
27
+ * added MenuManager component ([25107a9](https://github.com/lotrekagency/mapo/commit/25107a9cbfd75fcacf485163b96a793fe788cb4b))
28
+ * added old value to onChange in formField ([b53c86e](https://github.com/lotrekagency/mapo/commit/b53c86e392aee9a197df56c5c99c943ecb3895b9))
29
+ * added readonly props to detail component ([4c8c79f](https://github.com/lotrekagency/mapo/commit/4c8c79fc41839f7e8398d6adc9a6191306c54742))
30
+ * added slots to menu editor component to sobstitute the entire form ([239727c](https://github.com/lotrekagency/mapo/commit/239727cc1da9938511bac551b5a91f6c94b39539))
31
+ * added title field in menu node editor ([bd62662](https://github.com/lotrekagency/mapo/commit/bd62662d4afb85b46a8f7185203b916aab8fe713))
32
+ * added type folders to media manager ([63cd551](https://github.com/lotrekagency/mapo/commit/63cd551d33278e0e23a52d3ac234f58dbe56eb91))
33
+
34
+
35
+ ### Performance Improvements
36
+
37
+ * EXPERIMENTAL: use Vue.set in setpointed and directly manipulate js object in FormField ([1c384e9](https://github.com/lotrekagency/mapo/commit/1c384e9d7c922b0e876512de874a3f9832ac30f1))
38
+
39
+
40
+
41
+
42
+
43
+ # [1.0.0-alpha.43](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.42...v1.0.0-alpha.43) (2023-02-02)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * allow overflow on media dialog container ([705a3be](https://github.com/lotrekagency/mapo/commit/705a3be3100e22b7ec043415c0cca8dff8973144))
49
+
50
+
51
+
52
+
53
+
6
54
  # [1.0.0-alpha.42](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.41...v1.0.0-alpha.42) (2023-02-01)
7
55
 
8
56
 
@@ -2,14 +2,22 @@
2
2
  <div>
3
3
  <!-- Activator slot, this follows the logics of <a href="https://vuetifyjs.com/en/api/v-dialog/#api-slots" target="__blank">vuetify activator</a>.-->
4
4
  <slot v-bind="{ on, attrs: options.attrs }" name="activator"></slot>
5
- <v-dialog v-model="dialog" v-bind="{ width: 350, ...options.attrs }">
5
+ <v-dialog
6
+ @keydown="onKeyDown"
7
+ v-model="dialog"
8
+ v-bind="{ width: 350, ...options.attrs }"
9
+ >
6
10
  <v-card v-bind="options.attrs">
7
11
  <v-card-title>{{ options.title }}</v-card-title>
8
12
  <v-card-text class="headline">{{ options.question }}</v-card-text>
9
13
  <v-card-actions>
10
14
  <v-spacer></v-spacer>
11
- <v-btn v-bind="dismissAttrs" @click="close">{{ dismissTxt }}</v-btn>
12
- <v-btn @click="accept" v-bind="approveAttrs">{{ approveTxt }}</v-btn>
15
+ <v-btn v-bind="dismissAttrs" ref="close" @click="close">{{
16
+ dismissTxt
17
+ }}</v-btn>
18
+ <v-btn @click="accept" ref="accept" v-bind="approveAttrs">{{
19
+ approveTxt
20
+ }}</v-btn>
13
21
  </v-card-actions>
14
22
  </v-card>
15
23
  </v-dialog>
@@ -33,24 +41,30 @@ export default {
33
41
  options: {
34
42
  title: this.title || this.$t("mapo.confirm"),
35
43
  question: this.question || this.$t("mapo.confirmDialog.areYouSure"),
36
- dismissButton: this.dismissButton || { text: this.$t("mapo.cancel"), attrs: { text: true } },
37
- approveButton: this.approveButton || { text: this.$t("mapo.ok"), attrs: { color: "primary", text: true } },
38
- attrs: { ...this.$attrs }
44
+ dismissButton: this.dismissButton || {
45
+ text: this.$t("mapo.cancel"),
46
+ attrs: { text: true },
47
+ },
48
+ approveButton: this.approveButton || {
49
+ text: this.$t("mapo.ok"),
50
+ attrs: { color: "primary", text: true },
51
+ },
52
+ attrs: { ...this.$attrs },
39
53
  },
40
54
  on: {
41
- click: event => {
55
+ click: (event) => {
42
56
  event.preventDefault();
43
57
  event.stopPropagation();
44
58
  this.dialog = !this.dialog;
45
- }
46
- }
59
+ },
60
+ },
47
61
  };
48
62
  },
49
63
  props: {
50
64
  // v-model boolean that controll the status of the dialog (opened/closed)
51
65
  value: {
52
66
  type: Boolean,
53
- default: false
67
+ default: false,
54
68
  },
55
69
  // The text in the body of the dialog.
56
70
  question: {
@@ -69,7 +83,7 @@ export default {
69
83
  approveButton: {
70
84
  // `{ text: String, attrs: Object }`
71
85
  type: Object,
72
- }
86
+ },
73
87
  },
74
88
  computed: {
75
89
  approveTxt() {
@@ -83,7 +97,7 @@ export default {
83
97
  },
84
98
  dismissAttrs() {
85
99
  return this.options.dismissButton?.attrs || {};
86
- }
100
+ },
87
101
  },
88
102
  watch: {
89
103
  value(val) {
@@ -95,23 +109,26 @@ export default {
95
109
  this.$emit("input", val);
96
110
  if (val) {
97
111
  // Fired when the dialog opens
98
- this.$emit("open")
112
+ this.$emit("open");
113
+ this.$nextTick(() =>
114
+ this.$nextTick(() => this.$refs.accept.$el.focus())
115
+ );
99
116
  } else {
100
117
  // Fired when the dialog closes
101
- this.$emit("close")
118
+ this.$emit("close");
102
119
  }
103
120
  if (!val && this.resolve) {
104
121
  this.resolve(null);
105
122
  }
106
- }
123
+ },
107
124
  },
108
125
  methods: {
109
- /**
110
- * @vuese
111
- * This open the Confirm dialog component showing to the user a question. Returns a promise with the user response.
112
- * See [this.$mapo.$confirm.open](/core/#confirm)
113
- * @arg The payload containing the information to show to the user in the confirm dialog.
114
- */
126
+ /**
127
+ * @vuese
128
+ * This open the Confirm dialog component showing to the user a question. Returns a promise with the user response.
129
+ * See [this.$mapo.$confirm.open](/core/#confirm)
130
+ * @arg The payload containing the information to show to the user in the confirm dialog.
131
+ */
115
132
  open(options) {
116
133
  this.optionsBk = { ...this.options };
117
134
  this.options = { ...this.options, ...options };
@@ -141,8 +158,16 @@ export default {
141
158
  }
142
159
  this.dialog = false;
143
160
  this.response = false;
144
- setTimeout(() => this.options = { ...this.optionsBk }, 300);
145
- }
146
- }
161
+ setTimeout(() => (this.options = { ...this.optionsBk }), 300);
162
+ },
163
+ onKeyDown({ keyCode }) {
164
+ switch (keyCode) {
165
+ case 39:
166
+ return this.$refs.accept.$el.focus();
167
+ case 37:
168
+ return this.$refs.close.$el.focus();
169
+ }
170
+ },
171
+ },
147
172
  };
148
173
  </script>
@@ -127,6 +127,7 @@
127
127
  :errors="errors"
128
128
  :fields="sideFields"
129
129
  :moreSlotBindings="slotBindings"
130
+ :readonly="isReadonly"
130
131
  >
131
132
  <template v-for="(_, slot) in $slots" :slot="slot">
132
133
  <!-- @vuese-ignore -->
@@ -280,6 +281,8 @@ export default {
280
281
  return ["auto", "force", "disable"].indexOf(value) !== -1;
281
282
  },
282
283
  },
284
+ // This forces the detail page to be readonly.
285
+ readonly: Boolean
283
286
  },
284
287
  methods: {
285
288
  back() {
@@ -318,7 +321,7 @@ export default {
318
321
  deleteItem() {
319
322
  this.$mapo.$confirm
320
323
  .open({
321
- title: "Delete",
324
+ title: this.$t("mapo.delete"),
322
325
  question: this.$t("mapo.confirmDelete"),
323
326
  approveButton: {
324
327
  text: this.$t("mapo.delete"),
@@ -427,12 +430,14 @@ export default {
427
430
  return async () => method(...args);
428
431
  },
429
432
  isReadonly() {
433
+ if (this.readonly) return this.readonly;
430
434
  if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
431
435
  return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change");
432
436
  }
433
437
  return !!this.buttonClicked;
434
438
  },
435
439
  canDelete() {
440
+ if (this.readonly) return false;
436
441
  if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
437
442
  return this.$mapo.$auth.user.permissions.includes("delete");
438
443
  }
@@ -33,6 +33,7 @@ export default {
33
33
  type: Array,
34
34
  default() { return this.$mapo.$options?.content?.languages || []; }
35
35
  },
36
+ noRouteChange: Boolean,
36
37
  // An object representing all the errors of all fields. This component will find errors in each language and will display a little dot in the tab if there are any errors.
37
38
  errors: Object,
38
39
  },
@@ -54,6 +55,7 @@ export default {
54
55
  },
55
56
  methods: {
56
57
  saveQparams() {
58
+ if (this.noRouteChange) return;
57
59
  const { lang } = this.$route.query;
58
60
  if (lang !== this.currentLang) {
59
61
  this.$router.replace({
@@ -76,12 +76,13 @@ export default {
76
76
  this.setValue(...args);
77
77
  }, 300),
78
78
  setValue(val) {
79
- const dump = { ...this.value }; // since we cannot directly edit a prop
80
- setPointed(dump, this.kpointed, this.accessor.set({ model: dump, val }));
79
+ const old = this.extractValue(this.value);
80
+ setPointed(this.value, this.kpointed, this.accessor.set({ model: this.value, val }));
81
81
  if (typeof this.conf.onChange == "function")
82
82
  this.conf.onChange({
83
83
  val,
84
- model: dump,
84
+ old,
85
+ model: this.value,
85
86
  currentLang: this.currentLang,
86
87
  languages: this.langs,
87
88
  conf: this.conf,
@@ -90,7 +91,7 @@ export default {
90
91
 
91
92
  // Fired when the v-model changes.
92
93
  // @arg Emits the entire payload modified.
93
- this.$emit("input", dump);
94
+ this.$emit("input", this.value);
94
95
  },
95
96
  extractValue(val = this.value) {
96
97
  return this.accessor.get({
@@ -70,7 +70,15 @@
70
70
  </style>
71
71
 
72
72
  <script>
73
- import dateFormat from "dateformat";
73
+ import {
74
+ formatLocalTime,
75
+ formatLocalDate,
76
+ formatLocalDateTime,
77
+ mergeDate,
78
+ mergeTime,
79
+ cleanDateStr,
80
+ } from "@mapomodule/utils/helpers/datetime";
81
+
74
82
  /**
75
83
  * This component is used to edit a datetime in iso format. It is a combination of "v-text-field", "v-date-picker" and "v-time-picker".
76
84
  * All dates are emitted using UTC timezone.
@@ -117,11 +125,6 @@ export default {
117
125
  value(val) {
118
126
  this.setupValue();
119
127
  },
120
- model(val) {
121
- // Fired when the v-model changes
122
- //@arg Emits the date or the date range edited.
123
- this.$emit("input", val);
124
- },
125
128
  menu(val) {
126
129
  if (val)
127
130
  setTimeout(() => {
@@ -173,8 +176,8 @@ export default {
173
176
  (typeof this.value == "string" && this.value
174
177
  ? this.value.split(",").filter((v) => v)
175
178
  : this.value) || [];
176
- this.startDateTime = dates.length > 0 ? dates[0] : null;
177
- this.endDateTime = dates.length > 1 ? dates[1] : null;
179
+ this.startDateTime = dates.length > 0 ? cleanDateStr(dates[0]) : null;
180
+ this.endDateTime = dates.length > 1 ? cleanDateStr(dates[1]) : null;
178
181
  },
179
182
  },
180
183
  computed: {
@@ -182,21 +185,12 @@ export default {
182
185
  get() {
183
186
  const time = this.isStartFocused ? this.startDateTime : this.endDateTime;
184
187
  if (!time) return null;
185
- return dateFormat(time, "HH:MM:ss");
188
+ return formatLocalTime(time);
186
189
  },
187
190
  set(value) {
188
- const mergeTime = (dateTime, time) => {
189
- let newDateTime = new Date(dateTime);
190
- const [hours, minutes, seconds] = time.split(":").map((n) => parseInt(n));
191
- if (hours) newDateTime.setHours(hours);
192
- if (minutes) newDateTime.setMinutes(minutes);
193
- if (seconds) newDateTime.setSeconds(seconds);
194
- return newDateTime.toISOString();
195
- };
196
-
197
191
  if (this.isStartFocused)
198
- this.startDateTime = mergeTime(this.startDateTime, value);
199
- else this.endDateTime = mergeTime(this.endDateTime, value);
192
+ this.startDateTime = mergeTime(this.startDateTime, value).toISOString();
193
+ else this.endDateTime = mergeTime(this.endDateTime, value).toISOString();
200
194
  this.emit();
201
195
  },
202
196
  },
@@ -204,31 +198,25 @@ export default {
204
198
  get() {
205
199
  const d = [this.startDateTime, this.endDateTime]
206
200
  .filter((d) => d)
207
- .map((d) => dateFormat(d, "yyyy-mm-dd"));
201
+ .map((d) => formatLocalDate(d));
208
202
  if (this.range) return d;
209
203
  else if (d.length > 0) return d[0];
210
204
  return null;
211
205
  },
212
206
  set(value) {
213
- const mergeDate = (dateTime, date) => {
214
- let newDateTime = new Date(dateTime);
215
- const dateObj = new Date(date);
216
- newDateTime.setFullYear(dateObj.getFullYear());
217
- newDateTime.setMonth(dateObj.getMonth());
218
- newDateTime.setDate(dateObj.getDate());
219
- return newDateTime.toISOString();
220
- };
221
-
222
207
  if (this.range && value.length == 2) {
223
- this.endDateTime = mergeDate(this.endDateTime || null, value[1]);
224
- this.startDateTime = mergeDate(this.startDateTime || null, value[0]);
208
+ this.endDateTime = mergeDate(this.endDateTime || null, value[1]).toISOString();
209
+ this.startDateTime = mergeDate(
210
+ this.startDateTime || null,
211
+ value[0]
212
+ ).toISOString();
225
213
  setTimeout(() => this.$refs.endRawInput?.focus());
226
214
  } else {
227
215
  this.endDateTime = null;
228
216
  this.startDateTime = mergeDate(
229
217
  this.startDateTime || null,
230
218
  Array.isArray(value) ? value[0] : value
231
- );
219
+ ).toISOString();
232
220
  }
233
221
  this.emit();
234
222
  },
@@ -236,7 +224,7 @@ export default {
236
224
  startRawDateTime: {
237
225
  get() {
238
226
  if (!this.startDateTime) return null;
239
- return dateFormat(this.startDateTime, "yyyy-mm-dd'T'HH:MM:ss");
227
+ return formatLocalDateTime(this.startDateTime);
240
228
  },
241
229
  set(value) {
242
230
  const oldDateTime = this.startDateTime;
@@ -248,7 +236,7 @@ export default {
248
236
  endRawDateTime: {
249
237
  get() {
250
238
  if (!this.endDateTime) return null;
251
- return dateFormat(this.endDateTime, "yyyy-mm-dd'T'HH:MM:ss");
239
+ return formatLocalDateTime(this.endDateTime);
252
240
  },
253
241
  set(value) {
254
242
  const oldDateTime = this.endDateTime;
@@ -51,7 +51,12 @@
51
51
  </style>
52
52
 
53
53
  <script>
54
- import dateFormat from "dateformat";
54
+ import {
55
+ formatLocalTime,
56
+ cleanDateStr,
57
+ formatUTCTime,
58
+ mergeTime,
59
+ } from "@mapomodule/utils/helpers/datetime";
55
60
 
56
61
  /**
57
62
  * This component is used to edit a time in iso format. It is a combination of "v-text-field" and "v-time-picker".
@@ -61,9 +66,8 @@ export default {
61
66
  name: "TimeField",
62
67
  data() {
63
68
  return {
64
- model: null,
69
+ model: { model: null, returnDate: false },
65
70
  menu: null,
66
- returnDate: false,
67
71
  };
68
72
  },
69
73
  props: {
@@ -80,15 +84,19 @@ export default {
80
84
  },
81
85
  watch: {
82
86
  value(val) {
83
- if (this.model !== val) {
84
- this.setupValue();
87
+ const model = this.setupModel(val);
88
+ if (JSON.stringify(model) != JSON.stringify(this.model)) {
89
+ this.model = model;
85
90
  }
86
91
  },
87
- model(val) {
88
- // Fired when the v-model changes
89
- //@arg Emits the time edited.
90
- if (this.returnDate) this.$emit("input", `${this.value.split("T")[0]}T${val}Z`);
91
- else this.$emit("input", val);
92
+ model: {
93
+ handler: function (val) {
94
+ // Fired when the v-model changes
95
+ //@arg Emits the time edited.
96
+ if (val.returnDate) this.$emit("input", val.model.toISOString());
97
+ else this.$emit("input", formatUTCTime(val.model));
98
+ },
99
+ deep: true,
92
100
  },
93
101
  menu(val) {
94
102
  if (val)
@@ -100,10 +108,10 @@ export default {
100
108
  computed: {
101
109
  localModel: {
102
110
  get() {
103
- return this.model && dateFormat(`2000-01-01T${this.model}Z`, "HH:MM:ss");
111
+ return this.model?.model && formatLocalTime(this.model?.model);
104
112
  },
105
113
  set(value) {
106
- this.model = dateFormat(`2000-01-01T${value}`, "UTC:HH:MM:ss");
114
+ this.model.model = mergeTime(this?.model?.model || new Date(), value);
107
115
  },
108
116
  },
109
117
  },
@@ -124,14 +132,15 @@ export default {
124
132
  }
125
133
  this.localModel = model;
126
134
  },
127
- setupValue() {
128
- const d = new Date(this.value);
129
- this.returnDate = !isNaN(d);
130
- this.model = !isNaN(d) ? dateFormat(d, "UTC:HH:MM:ss") : this.value;
135
+ setupModel(val) {
136
+ const d = new Date(cleanDateStr(val));
137
+ const returnDate = !isNaN(d);
138
+ const model = !isNaN(d) ? d : mergeTime(new Date(), cleanDateStr(val));
139
+ return { returnDate, model };
131
140
  },
132
141
  },
133
142
  mounted() {
134
- this.setupValue();
143
+ this.model = this.setupModel(this.value);
135
144
  },
136
145
  };
137
146
  </script>
@@ -86,82 +86,24 @@
86
86
  </v-col>
87
87
  <v-col md="6" cols="12">
88
88
  <v-row>
89
- <v-col sm="6" md="12" cols="12">
90
- <v-text-field
91
- dense
92
- v-model="media.name"
93
- :label="$t('mapo.name')"
94
- :readonly="!canEdit"
95
- ></v-text-field>
96
- </v-col>
97
- <v-col sm="6" md="12" cols="12">
98
- <v-text-field
99
- dense
100
- v-model="media.title"
101
- :label="$t('mapo.titleTag')"
102
- :readonly="!canEdit"
103
- ></v-text-field>
104
- </v-col>
105
- <v-col sm="6" md="12" cols="12">
106
- <v-text-field
107
- dense
108
- v-model="media.description"
109
- :label="$t('mapo.description')"
110
- :readonly="!canEdit"
111
- ></v-text-field>
112
- </v-col>
113
- <v-col sm="6" md="12" cols="12">
114
- <v-text-field
115
- dense
116
- v-model="media.alt_text"
117
- :label="$t('mapo.altTag')"
118
- :readonly="!canEdit"
119
- ></v-text-field>
120
- </v-col>
121
- <v-col
122
- sm="6"
123
- md="12"
124
- cols="12"
125
- class="d-flex align-center"
126
- v-if="canEdit"
127
- >
128
- <div class="d-flex flex-column flex-grow-1">
129
- <v-file-input
130
- v-model="newFile"
131
- :accept="accept"
132
- :label="$t('mapo.mediaEditor.changeFile')"
133
- show-size
134
- dense
135
- prepend-icon
136
- ></v-file-input>
137
- <v-checkbox
138
- v-if="newFile"
139
- v-model="sameUrl"
140
- :label="$t('mapo.mediaEditor.maintainOldUrl')"
141
- class="ma-0"
142
- hide-details
143
- dense
144
- ></v-checkbox>
145
- </div>
146
- <v-img
147
- v-if="newFile && newFilePreview"
148
- :src="newFilePreview"
149
- aspect-ratio="1"
150
- min-width="70px"
151
- max-width="110px"
152
- class="grey lighten-2 ml-3"
153
- >
154
- <template v-slot:placeholder>
155
- <v-row class="fill-height ma-0" align="center" justify="center">
156
- <v-progress-circular
157
- indeterminate
158
- color="grey lighten-5"
159
- ></v-progress-circular>
160
- </v-row>
161
- </template>
162
- </v-img>
89
+ <v-col cols="12">
90
+ <DetailLangSwitch
91
+ :langs="languages"
92
+ v-model="currentLang"
93
+ no-route-change
94
+ />
163
95
  </v-col>
164
96
  </v-row>
97
+ <Form
98
+ v-model="media"
99
+ class="menu-node-editor--form"
100
+ :currentLang="currentLang"
101
+ :languages="languages"
102
+ :fields="fields"
103
+ :moreSlotBindings="slotBindings"
104
+ :readonly="!canEdit"
105
+ />
106
+ <MediaFileChanger class="mt-6" :file.sync="newFile" :maintain-url.sync="sameUrl" :accept="accept" />
165
107
  </v-col>
166
108
  </v-row>
167
109
  </v-card-text>
@@ -269,8 +211,17 @@ export default {
269
211
  editing: false,
270
212
  newFile: null,
271
213
  sameUrl: false,
214
+ currentLang: this.$i18n.locale,
272
215
  };
273
216
  },
217
+ props: {
218
+ languages: {
219
+ type: Array,
220
+ default() {
221
+ return this.$mapo.$options?.content?.languages || [];
222
+ },
223
+ },
224
+ },
274
225
  computed: {
275
226
  ...mapGetters("mapo/media", ["editMedia"]),
276
227
  fileSize() {
@@ -296,6 +247,22 @@ export default {
296
247
  return 425;
297
248
  }
298
249
  },
250
+ fields() {
251
+ return [
252
+ { value: "title", label: this.$t('mapo.titleTag'), attrs: { dense: true } },
253
+ { value: "description", label: this.$t('mapo.description'), attrs: { dense: true } },
254
+ { value: "alt_text", label: this.$t('mapo.altTag'), attrs: { dense: true } },
255
+ ]
256
+ },
257
+ slotBindings() {
258
+ return {
259
+ model: this.media,
260
+ currentLang: this.lang,
261
+ langs: this.languages,
262
+ fields: this.fields,
263
+ readonly: !this.canEdit,
264
+ };
265
+ },
299
266
  accept() {
300
267
  switch (this.media.mime_type && this.media.mime_type.split("/")[0]) {
301
268
  case "image":
@@ -308,11 +275,6 @@ export default {
308
275
  return "*";
309
276
  }
310
277
  },
311
- newFilePreview() {
312
- return this.newFile.type.startsWith("image/")
313
- ? URL.createObjectURL(this.newFile)
314
- : null;
315
- },
316
278
  permissionsModel() {
317
279
  return this.$mapo.$options?.medias?.permissionsModel || "media";
318
280
  },
@@ -341,15 +303,11 @@ export default {
341
303
  ...mapActions("mapo/media", ["closeEditor", "deleteMedia", "updateMedia"]),
342
304
  saveMedia() {
343
305
  this.updateMedia({
344
- id: this.media.id,
345
- name: this.media.name,
346
- title: this.media.title,
347
- description: this.media.description,
348
- alt_text: this.media.alt_text,
306
+ ...this.media,
349
307
  file: this.newFile || undefined,
350
308
  same_url: (this.newFile && this.sameUrl) || undefined,
351
309
  language_code: this.$i18n.locale,
352
- }).then(() => {
310
+ }).finally(() => {
353
311
  this.newFile = null;
354
312
  this.sameUrl = false;
355
313
  });