@mapomodule/uikit 1.0.0-alpha.7 → 1.0.0-alpha.8

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 (29) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/components/Detail/Detail.vue +28 -12
  3. package/components/Detail/DetailField.vue +7 -6
  4. package/components/Detail/DetailLangSwitch.vue +1 -1
  5. package/components/Detail/defaults.js +28 -27
  6. package/components/DropArea.vue +2 -2
  7. package/components/List/ListActions.vue +18 -0
  8. package/components/List/ListHead.vue +9 -1
  9. package/components/List/ListQuickEdit.vue +192 -58
  10. package/components/List/ListTable.vue +11 -5
  11. package/components/Login.vue +14 -5
  12. package/components/MediaManager/MediaEditor.vue +8 -2
  13. package/components/MediaManager/MediaFolders.vue +3 -3
  14. package/components/MediaManager/MediaManager.vue +1 -1
  15. package/components/SnackBar.vue +3 -4
  16. package/components/fields/DateField.vue +8 -3
  17. package/components/fields/FksField.vue +60 -0
  18. package/components/fields/MediaField.vue +13 -5
  19. package/components/fields/MediaM2mField.vue +8 -3
  20. package/components/fields/{TinyMce → wygEditor}/defaults.js +0 -0
  21. package/components/fields/{TinyMce → wygEditor}/utils/events.js +0 -0
  22. package/components/fields/{TinyMce → wygEditor}/utils/mapomedia.plugin.js +0 -0
  23. package/components/fields/{TinyMce → wygEditor}/utils/script.injector.js +0 -0
  24. package/components/fields/{TinyMce/TinyMce.vue → wygEditor/wygEditor.vue} +11 -11
  25. package/components/layout/Sidebar/SidebarFooter.vue +1 -0
  26. package/components/layout/Sidebar/SidebarList.vue +1 -0
  27. package/components/layout/Sidebar/SidebarListItem.vue +17 -1
  28. package/package.json +3 -3
  29. package/components/fields/M2mField.vue +0 -95
@@ -1,36 +1,99 @@
1
1
  <template>
2
2
  <div>
3
3
  <slot v-bind="{ on, attrs }" name="activator"></slot>
4
- <v-dialog v-model="dialog" width="600">
4
+ <v-dialog v-model="dialog" width="600" scrollable>
5
5
  <v-card v-bind="$attrs">
6
- <v-card-title>
7
- <slot name="title" v-bind="{ formTitle, editedItem }">
8
- <span class="headline">{{ formTitle }}</span>
6
+ <v-card-title class="pa-0 mb-3">
7
+ <div style="max-width: calc(100% - 40px)">
8
+ <slot name="lang" v-bind="slotBindings">
9
+ <!-- [`DetailLangSwitch`](/components/detail/DetailLangSwitch/) -->
10
+ <DetailLangSwitch
11
+ v-if="langs.length > 1"
12
+ v-model="currentLang"
13
+ :langs="langs"
14
+ :errors="errors"
15
+ /></slot>
16
+ </div>
17
+ <v-spacer></v-spacer>
18
+ <slot name="title" v-bind="slotBindings">
19
+ <v-hover v-slot="{ hover }">
20
+ <v-icon @click="hover && close()" class="mr-4" :class="{'mt-4': !langs.length}">{{
21
+ hover ? "mdi-close" : isNew ? "mdi-plus-circle-outline" : "mdi-pencil-outline"
22
+ }}</v-icon>
23
+ </v-hover>
9
24
  </slot>
10
25
  </v-card-title>
11
- <v-card-text>
26
+ <v-card-text class="pa-0 px-2">
12
27
  <v-container>
13
- <v-form v-if="editedItem" ref="form">
14
- <slot name="body" v-bind="{ editedItem }">
28
+ <v-form v-if="model" ref="form">
29
+ <!-- Use this to add content on top of body. -->
30
+ <slot name="body.top" v-bind="slotBindings"></slot>
31
+
32
+ <slot name="body" v-bind="slotBindings">
15
33
  <v-row>
16
- <v-col
17
- v-for="field in computedFields"
18
- :key="field.value"
19
- cols="12"
20
- :md="editFields.length > 1 ? 6 : 12"
34
+ <div
35
+ class="col-12"
36
+ :class="field.class"
37
+ v-for="(field, index) in computedFields"
38
+ :key="index"
21
39
  >
22
- <v-text-field
23
- v-bind="field.attrs"
24
- v-model="editedItem[field.value]"
25
- ></v-text-field>
26
- </v-col>
40
+ <v-card v-if="field.group" class="my-2">
41
+ <v-card-title>
42
+ <v-icon left> {{ field.group.icon }} </v-icon>
43
+ <span>{{ field.group.name }}</span>
44
+ </v-card-title>
45
+ <div class="container">
46
+ <div class="row">
47
+ <div
48
+ v-for="(fields, fieldsI) in field.fields"
49
+ :key="fieldsI"
50
+ class="col-12"
51
+ :class="fields.class"
52
+ >
53
+ <!-- This is a dynamic slot. You can use it to override a field component. For example use `qedit.fields.title` to override the component of the field with value `title`. -->
54
+ <slot
55
+ :name="fields.slotName"
56
+ v-bind="{
57
+ conf: fields,
58
+ ...slotBindings,
59
+ }"
60
+ >
61
+ <!-- A [`DetailField`](/components/detail/DetailField/) configured by a [`FieldConfiguration`](#fieldconfiguration). -->
62
+ <DetailField
63
+ v-model="model"
64
+ :conf="fields"
65
+ :errors="errors"
66
+ />
67
+ </slot>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </v-card>
72
+ <slot
73
+ v-else
74
+ :name="field.slotName"
75
+ v-bind="{
76
+ conf: field,
77
+ ...slotBindings,
78
+ }"
79
+ >
80
+ <DetailField
81
+ v-model="model"
82
+ :conf="field"
83
+ :errors="errors"
84
+ />
85
+ </slot>
86
+ </div>
27
87
  </v-row>
28
88
  </slot>
89
+ <!-- Use this to add content under the main body. -->
90
+ <slot name="body.bottom" v-bind="slotBindings"></slot>
29
91
  </v-form>
30
92
  </v-container>
31
93
  </v-card-text>
32
94
  <v-card-actions>
33
- <slot name="actions" v-bind="{ close, save }">
95
+ <v-messages v-if="nonFieldErrors.length" v-model="nonFieldErrors" color="error"></v-messages>
96
+ <slot name="actions" v-bind="slotBindings">
34
97
  <v-spacer></v-spacer>
35
98
  <v-btn text @click="close()"> Cancel </v-btn>
36
99
  <v-btn text @click="save"> Save </v-btn>
@@ -41,7 +104,7 @@
41
104
  </div>
42
105
  </template>
43
106
  <script>
44
- import { filterObj } from "@mapomodule/utils/helpers/objHelpers";
107
+ import { diffObjs, deepClone } from "@mapomodule/utils/helpers/objHelpers";
45
108
  /**
46
109
  * This components renders a dialog that let the user quick edit (or add) an element of the list.
47
110
  * The dialog provides several fields that will edit a payload that will be sent to the server. <br>
@@ -53,9 +116,11 @@ export default {
53
116
  return {
54
117
  dialog: false,
55
118
  attrs: { ...this.$attrs },
56
- itemRef: null,
57
- editedItem: null,
58
- newItem: false,
119
+ modelBkp: null,
120
+ model: null,
121
+ isNew: false,
122
+ currentLang: null,
123
+ errors: null,
59
124
  on: {
60
125
  click: (event) => {
61
126
  event.preventDefault();
@@ -70,23 +135,25 @@ export default {
70
135
  value: {
71
136
  type: Boolean,
72
137
  },
73
- editTitle: {
74
- type: String,
75
- default: "",
76
- },
138
+ // The main configuration that determines the arrangement of the fields in the detail layout.
77
139
  editFields: {
78
140
  type: Array,
79
141
  default: () => [],
80
142
  },
143
+ // A list of languages into which the payload needs to be translated.
144
+ languages: {
145
+ type: Array,
146
+ default: () => [],
147
+ },
81
148
  lookup: {
82
149
  type: String,
83
150
  default: "id",
84
151
  },
85
152
  crud: {
86
153
  type: Object,
87
- required: true
154
+ required: true,
88
155
  },
89
- offline: Boolean
156
+ offline: Boolean,
90
157
  },
91
158
  watch: {
92
159
  value(val) {
@@ -99,37 +166,43 @@ export default {
99
166
  this.close();
100
167
  }
101
168
  },
169
+ currentLang() {
170
+ this.initLang();
171
+ },
102
172
  },
103
173
  computed: {
104
- formTitle() {
105
- return `${this.newItem ? "Quick add" : "Quick edit"} ${this.editTitle}`;
106
- },
107
174
  computedFields() {
108
- return this.editFields.map((field, i) => {
109
- if (typeof field == "object") {
110
- return {
111
- ...field,
112
- attrs: {
113
- ...field.attrs,
114
- label: (field.attrs || {}).label || field.value.toUpperCase(),
115
- },
116
- };
117
- } else if (typeof field == "string") {
118
- return { attrs: { label: field.toUpperCase() }, value: field };
119
- } else {
120
- throw `editFields must me string or objects, error at index ${i}!`;
121
- }
122
- });
175
+ return this.mapConf(this.editFields || []);
176
+ },
177
+ langs() {
178
+ return this.model?.lang_info?.site_languages.map((l) => l.id) || this.languages || [];
123
179
  },
124
- fieldNames() {
125
- return this.computedFields.map(({ value }) => value);
180
+ loading() {
181
+ return this.isNew ? false : !Object.keys(this.model || {}).length;
182
+ },
183
+ nonFieldErrors(){
184
+ return this.errors?.non_field_errors || []
185
+ },
186
+ slotBindings() {
187
+ return {
188
+ model: this.model,
189
+ currentLang: this.currentLang,
190
+ crud: this.crud,
191
+ isNew: this.isNew,
192
+ langs: this.langs,
193
+ loading: this.loading,
194
+ form: this.$refs.form,
195
+ save: this.save,
196
+ close: this.close,
197
+ };
126
198
  },
127
199
  },
128
200
  methods: {
129
- open(item) {
130
- this.newItem = !item;
131
- this.itemRef = item;
132
- this.editedItem = filterObj(item, this.fieldNames);
201
+ async open(item) {
202
+ this.isNew = !item;
203
+ this.modelBkp = await this.fetchItem(item);
204
+ this.model = deepClone(this.modelBkp);
205
+ this.initLang();
133
206
  this.dialog = true;
134
207
  this.$refs.form?.resetValidation();
135
208
  return new Promise((resolve, reject) => {
@@ -139,30 +212,91 @@ export default {
139
212
  },
140
213
  async save() {
141
214
  if (this.$refs.form?.validate()) {
142
- return await (this.newItem ? this.apiCreate() : this.apiEdit());
215
+ return await (this.isNew ? this.apiCreate() : this.apiEdit());
143
216
  }
144
217
  },
145
218
  close(res) {
219
+ this.errors = null;
220
+ this.currentLang = null;
146
221
  this.$refs.form?.resetValidation();
147
222
  this.resolve && this.resolve(res);
148
223
  this.dialog = false;
149
224
  },
225
+ parseConf(field, i) {
226
+ const conf = typeof field === "string" ? { value: field } : field;
227
+ conf.value = conf.value || "";
228
+ conf.value = conf.value.replace(
229
+ new RegExp(`^translations\.(${this.langs.join("|")})\.?`),
230
+ ""
231
+ );
232
+ conf.slotName = `fields.${conf.value || i}`;
233
+ if (this.currentLang && !field.synci18n) {
234
+ const base = `translations.${this.currentLang}`;
235
+ conf.value = (conf.value && `${base}.${conf.value}`) || base;
236
+ }
237
+ return conf;
238
+ },
239
+ mapConf(fields) {
240
+ const icon = "mdi-cube-outline";
241
+ const parseGroup = (group) =>
242
+ typeof group === "string"
243
+ ? { name: group, icon }
244
+ : { ...group, icon: group.icon || icon };
245
+ return fields.map((f, i) =>
246
+ f.group
247
+ ? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
248
+ : this.parseConf(f, i)
249
+ );
250
+ },
251
+ initLang(lang = this.currentLang) {
252
+ if (lang && !this.model.translations) {
253
+ this.model.translations = {};
254
+ }
255
+ if (lang && !this.model.translations[lang]) {
256
+ this.model.translations[lang] = {};
257
+ }
258
+ },
259
+ async fetchItem(item) {
260
+ if (!this.offline && item && item[this.lookup]) {
261
+ return await this.crud.detail(item[this.lookup]);
262
+ } else {
263
+ return item;
264
+ }
265
+ },
150
266
  apiEdit() {
151
267
  if (!this.offline) {
152
268
  return this.crud
153
- .partialUpdate(this.itemRef[this.lookup], this.editedItem)
154
- .then((res) => this.close(res));
269
+ .partialUpdate(
270
+ this.modelBkp[this.lookup],
271
+ // diffObjs(this.modelBkp, this.model) disabled since it creates some errors in translations
272
+ this.model
273
+ )
274
+ .then((res) => this.close(res))
275
+ .catch(this.handleError);
155
276
  } else {
156
- this.close(this.editedItem);
277
+ this.close(this.model);
157
278
  }
158
279
  },
159
280
  apiCreate() {
160
281
  if (!this.offline) {
161
- return this.crud.create(this.editedItem).then((res) => this.close(res));
282
+ return this.crud
283
+ .create(this.model)
284
+ .then((res) => this.close(res))
285
+ .catch(this.handleError);
162
286
  } else {
163
- return this.close(this.editedItem);
287
+ return this.close(this.model);
164
288
  }
165
289
  },
290
+ handleError(error) {
291
+ const badRequest = error.response.status == 400;
292
+ this.errors = (badRequest && error.response.data) || null;
293
+ this.$mapo.$snack.open({
294
+ message: badRequest
295
+ ? "Bad input, correct wrong fields."
296
+ : error.response?.data?.detail || "Something whent bad, please try again later...",
297
+ color: "error",
298
+ });
299
+ },
166
300
  },
167
301
  };
168
302
  </script>
@@ -28,12 +28,12 @@
28
28
  dense
29
29
  clearable
30
30
  :loading="loadingSearch"
31
- class="search-input"
31
+ class="search-input rounded-0"
32
32
  ></v-text-field>
33
33
  <v-spacer></v-spacer>
34
34
  <slot name="dtable.top.center"></slot>
35
35
  <v-spacer></v-spacer>
36
- <v-btn text v-if="quickModeEnabled" class="ml-2" @click="quickAction()">
36
+ <v-btn text v-if="quickModeEnabled && userCan('add')" class="ml-2" @click="quickAction()">
37
37
  <v-icon small left class="d-none d-sm-block mr-2"> mdi-plus </v-icon>
38
38
  <span class="d-none d-sm-block">Quick</span> add
39
39
  </v-btn>
@@ -55,10 +55,10 @@
55
55
  <v-simple-checkbox v-model="selectAll" @input="on.input"></v-simple-checkbox>
56
56
  </template>
57
57
  <template v-slot:[`item.actions`]="{ item }">
58
- <v-icon v-if="quickModeEnabled" small class="mr-2" @click="quickAction(item)">
58
+ <v-icon :disabled="!userCan('change')" v-if="quickModeEnabled" small class="mr-2" @click="quickAction(item)">
59
59
  mdi-pencil
60
60
  </v-icon>
61
- <v-icon small @click="deleteItem(item)"> mdi-delete </v-icon>
61
+ <v-icon :disabled="!userCan('delete')" small @click="deleteItem(item)"> mdi-delete </v-icon>
62
62
  </template>
63
63
  <template v-for="slot in nameSpacedSlots($slots, 'dtable.')" :slot="slot">
64
64
  <slot :name="`dtable.${slot}`"></slot>
@@ -316,7 +316,7 @@ export default {
316
316
  .open({
317
317
  title: "Delete",
318
318
  question: "Are you sure you want to delete this item?",
319
- approveButton: { text: "Delete", attrs: { color: "red" } },
319
+ approveButton: { text: "Delete", attrs: { color: "red", text: true } },
320
320
  })
321
321
  .then((res) => (res ? callback(item) : null));
322
322
  },
@@ -339,6 +339,12 @@ export default {
339
339
  this.serverPaginationEnabled && this.getDataFromApi();
340
340
  this.loadingSearch = false;
341
341
  }, 1000),
342
+ userCan(action) {
343
+ if (this.$mapo.$auth.routeMiddlewares.includes("permissions")){
344
+ return this.$mapo.$auth.user.permissions.includes(action)
345
+ }
346
+ return true
347
+ },
342
348
  },
343
349
  computed: {
344
350
  filteredItems() {
@@ -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
  },
@@ -56,7 +56,13 @@
56
56
  </tr>
57
57
  <tr>
58
58
  <td class="pr-3"><b>Linked models:</b></td>
59
- <td>{{ media.liks }}</td>
59
+ <td>
60
+ <ul>
61
+ <li v-for="link in media.links" :key="link.id">
62
+ <b>{{link.model}} (id:{{link.id}})</b> - {{link.name}}
63
+ </li>
64
+ </ul>
65
+ </td>
60
66
  </tr>
61
67
  </table>
62
68
  </v-col>
@@ -291,7 +297,7 @@ export default {
291
297
  .open({
292
298
  title: "Delete",
293
299
  question: "Are you sure you want to delete this media?",
294
- approveButton: { text: "Delete", attrs: { color: "red" } },
300
+ approveButton: { text: "Delete", attrs: { color: "red", text: true } },
295
301
  })
296
302
  .then((res) => res && this.$emit("deleteMedia", this.media));
297
303
  },
@@ -112,8 +112,8 @@
112
112
 
113
113
  <v-card-actions>
114
114
  <v-spacer></v-spacer>
115
- <v-btn color="green darken-1" text @click="closeEdit"> Cancel </v-btn>
116
- <v-btn color="green darken-1" text @click="saveFolder"> Save </v-btn>
115
+ <v-btn color="primary" text @click="closeEdit"> Cancel </v-btn>
116
+ <v-btn color="primary" text @click="saveFolder"> Save </v-btn>
117
117
  </v-card-actions>
118
118
  </v-card>
119
119
  </v-dialog>
@@ -202,7 +202,7 @@ export default {
202
202
  .open({
203
203
  title: "Delete",
204
204
  question: "Are you sure to delelete this folder and all its content?",
205
- approveButton: { text: "Delete", attrs: { color: "red" } }
205
+ approveButton: { text: "Delete", attrs: { color: "red", text: true } }
206
206
  })
207
207
  .then(res => res && this.$emit("deleteFolder", folder));
208
208
  },
@@ -201,7 +201,7 @@ export default {
201
201
  }
202
202
  this.editMedia = res
203
203
  this.$mapo.$snack.open({
204
- message: "file info succesfully updated."
204
+ message: "File info succesfully updated."
205
205
  })
206
206
  return res
207
207
  },
@@ -2,7 +2,7 @@
2
2
  <v-snackbar v-model="snackbar">
3
3
  {{ message }}
4
4
  <template v-slot:action="{ attrs }">
5
- <v-btn color="green" text v-bind="attrs" @click="closeSnack">
5
+ <v-btn :color="color" text v-bind="attrs" @click="closeSnack">
6
6
  Close
7
7
  </v-btn>
8
8
  </template>
@@ -23,7 +23,7 @@ export default {
23
23
  data: () => ({
24
24
  snackbar: false,
25
25
  message: null,
26
- color: "green",
26
+ color: "primary",
27
27
  }),
28
28
  computed: {
29
29
  ...mapGetters({
@@ -34,7 +34,6 @@ export default {
34
34
  closeSnack() {
35
35
  this.snackbar = false;
36
36
  this.message = null;
37
- this.color = "green";
38
37
  },
39
38
  },
40
39
 
@@ -48,7 +47,7 @@ export default {
48
47
  if (val) {
49
48
  this.snackbar = true;
50
49
  this.message = val.message;
51
- this.color = val.color || this.color;
50
+ this.color = val.color || "primary";
52
51
  } else {
53
52
  this.closeSnack();
54
53
  }
@@ -15,8 +15,8 @@
15
15
  prepend-inner-icon="mdi-calendar"
16
16
  readonly
17
17
  v-bind="{ ...$attrs, ...attrs }"
18
- v-on="on"
19
- clearable
18
+ v-on="readonly ? undefined : on"
19
+ :clearable="!readonly"
20
20
  ></v-text-field>
21
21
  </template>
22
22
  <v-date-picker v-model="model" :range="range" no-title>
@@ -49,7 +49,12 @@ export default {
49
49
  range: {
50
50
  type: Boolean,
51
51
  default: false
52
- }
52
+ },
53
+ // This set the component status to readonly, stopping the user interaction.
54
+ readonly: {
55
+ type: Boolean,
56
+ default: false,
57
+ },
53
58
  },
54
59
  watch: {
55
60
  value(val) {
@@ -0,0 +1,60 @@
1
+ <template>
2
+ <v-autocomplete v-bind="fieldAttrs" v-model="model" :items="options"></v-autocomplete>
3
+ </template>
4
+
5
+ <script>
6
+ /**
7
+ * This component is made to simplify Many To Many associations. With this component you can modify an array selecting items from a list of checkboxes.
8
+ */
9
+
10
+ export default {
11
+ name: "FksField",
12
+ data() {
13
+ return {
14
+ model: null,
15
+ options: [],
16
+ };
17
+ },
18
+ props: {
19
+ // V-model property. It is the array to be modified.
20
+ value: {
21
+ type: Object | Array | null,
22
+ required: true,
23
+ },
24
+ // This is the array of options from which you can choose.
25
+ items: {
26
+ type: Array,
27
+ default: () => [],
28
+ },
29
+ endpoint: String,
30
+ },
31
+ computed: {
32
+ fieldAttrs() {
33
+ return {
34
+ chips: this.$attrs.multiple === false ? false : true,
35
+ multiple: true,
36
+ ...this.$attrs,
37
+ };
38
+ },
39
+ },
40
+ watch: {
41
+ items(val) {
42
+ this.options = val || [];
43
+ },
44
+ value(val) {
45
+ this.model = val;
46
+ },
47
+ model(val) {
48
+ this.$emit("input", val);
49
+ },
50
+ },
51
+ mounted() {
52
+ if (this.endpoint) {
53
+ this.$mapo.$api
54
+ .crud(this.endpoint)
55
+ .list()
56
+ .then((res) => (this.options = res));
57
+ }
58
+ },
59
+ };
60
+ </script>
@@ -14,7 +14,8 @@
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
- :class="{'grey lighten-2 rounded': !internalValue.is_image}"
17
+
18
+ :class="{'grey lighten-2': !internalValue.is_image}"
18
19
  v-bind="{
19
20
  aspectRatio,
20
21
  contain,
@@ -50,6 +51,7 @@
50
51
  <!-- If the media is not avaible, it shows a btn to add new media -->
51
52
  <v-card
52
53
  v-else-if="!rmAddBtn"
54
+ class="rounded-0"
53
55
  v-bind="{
54
56
  height,
55
57
  width,
@@ -63,7 +65,7 @@
63
65
  <v-card-title>{{ label }}</v-card-title>
64
66
 
65
67
  <v-card-actions>
66
- <v-btn @click="editing = true" block :min-height="minHeight">
68
+ <v-btn tile :disabled="readonly" @click="editing = true" block :min-height="minHeight">
67
69
  <v-icon size="80"> mdi-plus-circle-outline </v-icon>
68
70
  </v-btn>
69
71
  </v-card-actions>
@@ -78,13 +80,13 @@
78
80
  </v-row>
79
81
  <v-row>
80
82
  <v-col cols="6">
81
- <v-btn @click="editing = true" fab v-bind="$attrs">
83
+ <v-btn :disabled="readonly" @click="editing = true" fab v-bind="$attrs">
82
84
  <v-icon>mdi-pencil</v-icon>
83
85
  </v-btn>
84
86
  </v-col>
85
87
 
86
88
  <v-col cols="6">
87
- <v-btn @click="confirmDelete" fab v-bind="$attrs">
89
+ <v-btn :disabled="readonly" @click="confirmDelete" fab v-bind="$attrs">
88
90
  <v-icon>mdi-delete</v-icon>
89
91
  </v-btn>
90
92
  </v-col>
@@ -163,6 +165,11 @@ export default {
163
165
  type: String | Number,
164
166
  default: 300,
165
167
  },
168
+ // This set the component status to readonly, stopping the user interaction.
169
+ readonly: {
170
+ type: Boolean,
171
+ default: false,
172
+ },
166
173
  },
167
174
 
168
175
  computed: {
@@ -185,7 +192,8 @@ export default {
185
192
  this.$mapo.$confirm
186
193
  .open({
187
194
  title: "Remove",
188
- question: "Are you sure to want to remove this media?"
195
+ question: "Are you sure to want to remove this media?",
196
+ approveButton: { text: "Remove", attrs: { color: "red", text: true } }
189
197
  })
190
198
  .then((res) => (res ? (this.internalValue = null) : null));
191
199
  },