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

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,62 @@
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.28](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.27...v1.0.0-alpha.28) (2022-09-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **form debounce:** fix form debounce not correctly updating model ([04b392d](https://github.com/lotrekagency/mapo/commit/04b392df7021534c4f30cee6ab3593946dd29414))
12
+ * fixed repeater remaining close on model fetch ([3a30136](https://github.com/lotrekagency/mapo/commit/3a301364ffe26107d890a9100c939a3c32cfc7c2))
13
+ * **repeater:** fix row expansion in nested repeater ([4ed22cd](https://github.com/lotrekagency/mapo/commit/4ed22cd3b0fe8593d1c87e43cbf92bbba8198ae2))
14
+ * **tabs:** show correct label in nested tabs ([30f50b2](https://github.com/lotrekagency/mapo/commit/30f50b277596304b99018e7132a8403c4c2c5639))
15
+
16
+
17
+ ### Features
18
+
19
+ * **detail:** give feedback for all http actions in detail components and prevent interaction during the request ([ceec206](https://github.com/lotrekagency/mapo/commit/ceec206fe50b23e784f9528fe41c02ec11c91e66))
20
+
21
+
22
+ ### Performance Improvements
23
+
24
+ * **repeater:** prevent collapsed repeater from rendering hidden forms ([1ae7d18](https://github.com/lotrekagency/mapo/commit/1ae7d1836f8ff8625f21a2be5fbaf5acef6ef404))
25
+ * increase form performances debouncing the emit events ([5e0bb30](https://github.com/lotrekagency/mapo/commit/5e0bb30f1e660d5b81319f213730c217eb6752a5))
26
+
27
+
28
+
29
+
30
+
31
+ # [1.0.0-alpha.27](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.26...v1.0.0-alpha.27) (2022-08-25)
32
+
33
+
34
+ ### Bug Fixes
35
+
36
+ * **colorfield:** return string in colorfield ([3acbd5c](https://github.com/lotrekagency/mapo/commit/3acbd5caa6555835c168718303f1ca555e8efc75))
37
+ * **detail:** added force option to languages ([8ed4b69](https://github.com/lotrekagency/mapo/commit/8ed4b69f746b136755cbda17cdab176632869cdf))
38
+
39
+
40
+ ### Features
41
+
42
+ * **fields:** added color field ([ead7448](https://github.com/lotrekagency/mapo/commit/ead744861be2c9c24ea2911e68c8b4d1259cab15))
43
+ * **mediapreview:** added title tag to medias ([d063162](https://github.com/lotrekagency/mapo/commit/d063162036a4294fbd3c5ed347dfde78061a1f33))
44
+ * implemented enhanced media compomentent ([fe336e1](https://github.com/lotrekagency/mapo/commit/fe336e170d42a67562c8e4abfa387b806e7c7a6a))
45
+ * implemented media preview through MediaPreview component ([575c285](https://github.com/lotrekagency/mapo/commit/575c2853eb774ca4c635ce099302a429cc479be5))
46
+
47
+
48
+
49
+
50
+
51
+ # [1.0.0-alpha.26](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.25...v1.0.0-alpha.26) (2022-08-11)
52
+
53
+
54
+ ### Bug Fixes
55
+
56
+ * correct langDir path on i18n defaults ([100239f](https://github.com/lotrekagency/mapo/commit/100239fb11b268baa67e6549a0a68e98348e8301))
57
+
58
+
59
+
60
+
61
+
6
62
  # [1.0.0-alpha.25](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.24...v1.0.0-alpha.25) (2022-08-02)
7
63
 
8
64
 
@@ -141,6 +141,7 @@ export default {
141
141
  this.resolve(this.response);
142
142
  }
143
143
  this.dialog = false;
144
+ this.response = false;
144
145
  this.options = { ...this.optionsBk };
145
146
  }
146
147
  }
@@ -73,14 +73,14 @@
73
73
  <!-- Use this to override the Save button. -->
74
74
  <slot name="button.save" v-bind="slotBindings">
75
75
  <!-- The Save button. -->
76
- <v-btn v-show="canGoBack" :disabled="isReadonly" class="mb-2" tile block @click="saveItem(true)">{{
76
+ <v-btn v-show="canGoBack" :loading="buttonClicked == 'saveAndBackBtn'" :disabled="isReadonly" class="mb-2" tile block @click="saveItem(true)">{{
77
77
  isNew ? $t("mapo.create") : $t("mapo.save")
78
78
  }}</v-btn>
79
79
  </slot>
80
80
  <!-- Use this to override the Save and continue button. -->
81
81
  <slot name="button.savecontinue" v-bind="slotBindings">
82
82
  <!-- The Save and continue button. -->
83
- <v-btn :disabled="isReadonly" class="mb-2" tile block @click="saveItem(false)"
83
+ <v-btn :loading="buttonClicked == 'saveBtn'" :disabled="isReadonly" class="mb-2" tile block @click="saveItem(false)"
84
84
  >{{ isNew ? $t("mapo.createContinue") : $t("mapo.saveContinue") }}</v-btn
85
85
  >
86
86
  </slot>
@@ -92,7 +92,7 @@
92
92
  >
93
93
  </slot>
94
94
  <!-- Use this to override the Delete button. -->
95
- <slot name="button.delete" v-bind="slotBindings">
95
+ <slot name="button.delete" :loading="buttonClicked == 'deleteBtn'" v-bind="slotBindings">
96
96
  <!-- The Delete button. -->
97
97
  <v-btn
98
98
  v-if="!isNew"
@@ -161,7 +161,8 @@ export default {
161
161
  model: {},
162
162
  modelLanguages: [],
163
163
  currentLang: this.lang,
164
- errors: null
164
+ errors: null,
165
+ buttonClicked: null
165
166
  };
166
167
  },
167
168
  props: {
@@ -186,6 +187,11 @@ export default {
186
187
  type: Array,
187
188
  default: () => []
188
189
  },
190
+ // Forces use of languages passed as prop, instead of those loaded with model
191
+ forceLanguages: {
192
+ type: Boolean,
193
+ default: false
194
+ },
189
195
  // The url of the endpoint to which the payload is to be sent. From this url a complete crud (See [this.$mapo.$api.crud](/core/#$api.crud)) will be created.
190
196
  endpoint: {
191
197
  type: String,
@@ -219,6 +225,7 @@ export default {
219
225
  this.$nuxt.context?.from?.name == "login" ? this.$router.go(-3) : this.$router.back();
220
226
  },
221
227
  saveItem(back = false) {
228
+ this.buttonClicked = back ? "saveAndBackBtn" : "saveBtn";
222
229
  this.errors = null;
223
230
  this.$refs.form?.resetValidation();
224
231
  this.crud
@@ -228,6 +235,7 @@ export default {
228
235
  this.back()
229
236
  } else {
230
237
  this.model = resp;
238
+ this.$mapo.$snack.open({ message: this.isNew ? this.$t("mapo.createSuccess") : this.$t("mapo.saveSuccess"), color: "success" })
231
239
  this.isNew && this.$router.replace({ params: { detail: resp.id } })
232
240
  }
233
241
  })
@@ -237,8 +245,8 @@ export default {
237
245
  this.$mapo.$snack.open({
238
246
  message: error.response?.data?.detail || this.$t("mapo.genericError"),
239
247
  color: "error"
240
- });
241
- });
248
+ })
249
+ }).finally(() => {this.buttonClicked = null;});;
242
250
  },
243
251
  deleteItem() {
244
252
  this.$mapo.$confirm
@@ -249,13 +257,14 @@ export default {
249
257
  })
250
258
  .then(res => {
251
259
  if (res) {
260
+ this.buttonClicked = "deleteBtn";
252
261
  this.crud
253
262
  .delete(this.identifier)
254
263
  .then(() => this.back())
255
264
  .catch(error => this.$mapo.$snack.open({
256
265
  message: error.response?.data?.detail || this.$t("mapo.genericError"),
257
266
  color: "error"
258
- }));
267
+ })).finally(()=> {this.buttonClicked = null;});
259
268
  }
260
269
  });
261
270
  },
@@ -269,6 +278,7 @@ export default {
269
278
  model(val) {
270
279
  // Fired when the v-model changes.
271
280
  // @arg Emits the entire payload modified.
281
+ console.log(val, "model")
272
282
  this.$emit("input", val);
273
283
  },
274
284
  lang(val) {
@@ -277,6 +287,7 @@ export default {
277
287
  }
278
288
  },
279
289
  value(val) {
290
+ console.log(val, "value")
280
291
  if (val) {
281
292
  this.model = val;
282
293
  }
@@ -296,7 +307,7 @@ export default {
296
307
  if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
297
308
  return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change");
298
309
  }
299
- return false;
310
+ return !!this.buttonClicked;
300
311
  },
301
312
  canDelete() {
302
313
  if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
@@ -320,7 +331,7 @@ export default {
320
331
  return !Object.keys(this.model).length;
321
332
  },
322
333
  langs() {
323
- return (this.modelLanguages || []).length ? this.modelLanguages : this.languages;
334
+ return (!this.forceLanguages && (this.modelLanguages || []).length) ? this.modelLanguages : this.languages;
324
335
  },
325
336
  slotBindings() {
326
337
  return {
@@ -410,6 +421,7 @@ Here the list of the FieldConfiguration type association.
410
421
  - `file` ==> [file-field](/components/Form/fields/FileField/),
411
422
  - `editor` ==> [wyg-editor](/components/Form/fields/wygEditor/wygEditor/),
412
423
  - `media` ==> [media-field](/components/Form/fields/MediaField/),
424
+ - `enhancedMedia` ==> [enhanced-media-field](/components/Form/fields/EnhancedMediaField/),
413
425
  - `mediaList` ==> [media-m2m-field](/components/Form/fields/MediaM2mField/)
414
426
  - `m2m` or `fks` ==> [fks-field](/components/Form/fields/FksField/),
415
427
  - `repeater` ==> [repeater](/components/Form/fields/Repeater/),
@@ -8,7 +8,7 @@
8
8
  v-show="show(field)"
9
9
  :style="show(field, 'visibility') ? '' : 'opacity: 0; visibility: hidden;'"
10
10
  >
11
- <FormTabs
11
+ <FormTabs
12
12
  v-if="field.tabs"
13
13
  v-model="model"
14
14
  v-bind="{ currentLang, errors, languages, readonly }"
@@ -26,7 +26,7 @@
26
26
  v-slot:[slot]="props"
27
27
  >
28
28
  <slot :name="`group.${field.group.slug}.${slot}`" v-bind="props" />
29
- </template>
29
+ </template>
30
30
  </FormTabs>
31
31
  <FormGroup
32
32
  v-else-if="field.group"
@@ -46,9 +46,9 @@
46
46
  v-slot:[slot]="props"
47
47
  >
48
48
  <slot :name="`group.${field.group.slug}.${slot}`" v-bind="props" />
49
- </template>
49
+ </template>
50
50
  </FormGroup>
51
-
51
+
52
52
  <div v-else>
53
53
  <slot :name="field.slotName + '.before'" v-bind="{ conf: field, ...slotBindings, }" />
54
54
  <slot
@@ -72,7 +72,7 @@
72
72
  v-slot:[slot]="props"
73
73
  >
74
74
  <slot :name="`fields.${field.value}.${slot}`" v-bind="props" />
75
- </template>
75
+ </template>
76
76
  </FormField>
77
77
  </slot>
78
78
  <slot :name="field.slotName + '.after'" v-bind="{ conf: field, ...slotBindings, }" />
@@ -84,6 +84,7 @@
84
84
  import { nameSpacedSlots } from "@mapomodule/utils/helpers/slots";
85
85
  import { slugify, titleCase } from "@mapomodule/utils/helpers/formatters";
86
86
  import { deepClone } from "@mapomodule/utils/helpers/objHelpers";
87
+ import { debounce } from "@mapomodule/utils/helpers/debounce";
87
88
 
88
89
  export default {
89
90
  name: "Form",
@@ -128,13 +129,17 @@ export default {
128
129
  this.initLang();
129
130
  },
130
131
  model(val) {
131
- this.$emit("input", val);
132
+ if (this.value !== val)
133
+ this.debouncedEmit("input", val);
132
134
  },
133
135
  fields(val){
134
136
  this.internalFields = this.cloneFields(val)
135
137
  }
136
138
  },
137
139
  methods: {
140
+ debouncedEmit: debounce(function (...args) {
141
+ this.$emit(...args);
142
+ }, 300),
138
143
  nameSpacedSlots,
139
144
  initLang(lang = this.currentLang) {
140
145
  if (lang && !this.model.translations) {
@@ -166,11 +171,9 @@ export default {
166
171
  parseTabs(tabs) {
167
172
  return Object.keys(tabs).map(key => {
168
173
  const tab = tabs[key]
169
- return {
170
- label: titleCase(key.replace(/_/, " ")),
171
- slug: key,
172
- ...tab.tab,
173
- fields: this.mapConf(Array.isArray(tab) && tab || tab.fields || [])
174
+ return {
175
+ tab: {label: titleCase(key.replace(/_/, " ")), slug: key, ...tab.tab},
176
+ fields: this.mapConf(Array.isArray(tab) && tab || tab.fields || [])
174
177
  }
175
178
  })
176
179
  },
@@ -182,7 +185,7 @@ export default {
182
185
  mapConf(fields) {
183
186
  return fields.map((f, i) =>
184
187
  f.tabs
185
- ? { group: this.parseTagsGroup(f), tabs: this.parseTabs(f.tabs) }
188
+ ? { group: this.parseTagsGroup(f), tabs: this.parseTabs(f.tabs) }
186
189
  : f.group
187
190
  ? { group: this.parseGroup(f.group), fields: this.mapConf(f.fields) }
188
191
  : this.parseConf(f, i)
@@ -191,7 +194,7 @@ export default {
191
194
  show(conf, type = "display"){
192
195
  const prop = type == "visibility" ? "vVisible" : "vShow"
193
196
  if (typeof conf[prop] == "function") {
194
- return conf[prop]({
197
+ return conf[prop]({
195
198
  model: this.model,
196
199
  errors: this.errors,
197
200
  languages: this.languages,
@@ -225,4 +228,4 @@ export default {
225
228
  this.initLang();
226
229
  }
227
230
  };
228
- </script>
231
+ </script>
@@ -26,6 +26,8 @@ import DateField from "@mapomodule/uikit/components/Form/fields/DateField.vue";
26
26
  import FksField from "@mapomodule/uikit/components/Form/fields/FksField.vue";
27
27
  import MediaM2mField from "@mapomodule/uikit/components/Form/fields/MediaM2mField.vue";
28
28
  import MediaField from "@mapomodule/uikit/components/Form/fields/MediaField.vue";
29
+ import EnhancedMediaField from "@mapomodule/uikit/components/Form/fields/EnhancedMediaField.vue";
30
+
29
31
  import SeoPreview from "@mapomodule/uikit/components/Form/fields/SeoPreview.vue";
30
32
  import FileField from "@mapomodule/uikit/components/Form/fields/FileField.vue";
31
33
  import Repeater from "@mapomodule/uikit/components/Form/fields/Repeater.vue"
@@ -34,6 +36,7 @@ import { getPointed, setPointed } from "@mapomodule/utils/helpers/objHelpers";
34
36
  import { titleCase } from "@mapomodule/utils/helpers/formatters";
35
37
 
36
38
  import defaults from "./defaults";
39
+ import { debounce } from "@mapomodule/utils/helpers/debounce";
37
40
 
38
41
  /**
39
42
  * This is mainly an internal component. It is used by the [`DetailComponent`](/components/detail/Detail/) in order to render dinamic fields inside the main form.
@@ -46,6 +49,7 @@ export default {
46
49
  FksField,
47
50
  MediaM2mField,
48
51
  MediaField,
52
+ EnhancedMediaField,
49
53
  SeoPreview,
50
54
  FileField,
51
55
  Repeater,
@@ -111,10 +115,13 @@ export default {
111
115
 
112
116
  // Fired when the v-model changes.
113
117
  // @arg Emits the entire payload modified.
114
- this.$emit("input", dump);
118
+ this.debouncedEmit("input", dump);
115
119
  },
116
120
  },
117
121
  methods: {
122
+ debouncedEmit: debounce(function (...args) {
123
+ this.$emit(...args);
124
+ }, 300),
118
125
  setModel(val = this.value) {
119
126
  var model = this.accessor.get({
120
127
  model: { ...val },
@@ -73,7 +73,8 @@ export default {
73
73
  this.model = val;
74
74
  },
75
75
  model(val) {
76
- this.$emit("input", val);
76
+ if (this.value !== val)
77
+ this.$emit("input", val);
77
78
  },
78
79
  },
79
80
  computed: {
@@ -12,13 +12,13 @@
12
12
  <v-tabs v-model="tabIndex" class="tab-wrapper">
13
13
  <v-tab v-for="(tab, index) in conf.tabs" :key="index" v-show="show(tab)">
14
14
  <v-badge :value="hasErrors(tab)" color="error" dot>
15
- {{ tab.label }} <v-icon v-if="tab.icon">{{ tab.icon }}</v-icon>
15
+ {{ tab.tab.label }} <v-icon v-if="tab.tab.icon">{{ tab.tab.icon }}</v-icon>
16
16
  </v-badge>
17
17
  </v-tab>
18
18
  </v-tabs>
19
19
  <v-tabs-items v-model="tabIndex">
20
20
  <v-tab-item v-for="(tab, index) in conf.tabs" :key="index" class="pt-8">
21
- <slot :name="`tab.${tab.slug}`" v-bind="slotBindings">
21
+ <slot :name="`tab.${tab.tab.slug}`" v-bind="slotBindings">
22
22
  <Form
23
23
  v-model="model"
24
24
  v-bind="{ currentLang, errors, languages, readonly }"
@@ -26,19 +26,19 @@
26
26
  :moreSlotBindings="slotBindings"
27
27
  >
28
28
  <template
29
- v-for="slot in nameSpacedSlots($slots, `tab.${tab.slug}.`)"
29
+ v-for="slot in nameSpacedSlots($slots, `tab.${tab.tab.slug}.`)"
30
30
  :slot="slot"
31
31
  >
32
- <slot :name="`tab.${tab.slug}.${slot}`"></slot>
32
+ <slot :name="`tab.${tab.tab.slug}.${slot}`"></slot>
33
33
  </template>
34
34
  <template
35
35
  v-for="slot in nameSpacedSlots(
36
36
  $scopedSlots,
37
- `tab.${tab.slug}.`
37
+ `tab.${tab.tab.slug}.`
38
38
  )"
39
39
  v-slot:[slot]="props"
40
40
  >
41
- <slot :name="`tab.${tab.slug}.${slot}`" v-bind="props" />
41
+ <slot :name="`tab.${tab.tab.slug}.${slot}`" v-bind="props" />
42
42
  </template>
43
43
  </Form>
44
44
  </slot>
@@ -101,7 +101,8 @@ export default {
101
101
  this.model = val;
102
102
  },
103
103
  model(val) {
104
- this.$emit("input", val);
104
+ if (this.value !== val)
105
+ this.$emit("input", val);
105
106
  },
106
107
  },
107
108
  computed: {
@@ -134,7 +135,7 @@ export default {
134
135
  show(conf, type = "display"){
135
136
  const prop = type == "visibility" ? "vVisible" : "vShow"
136
137
  if (typeof conf[prop] == "function") {
137
- return conf[prop]({
138
+ return conf[prop]({
138
139
  model: this.model,
139
140
  errors: this.errors,
140
141
  languages: this.languages,
@@ -148,4 +149,4 @@ export default {
148
149
  this.model = this.value;
149
150
  },
150
151
  };
151
- </script>
152
+ </script>
@@ -8,11 +8,13 @@ const mapping = {
8
8
  file: "FileField",
9
9
  editor: "wygEditor",
10
10
  media: "MediaField",
11
+ enhancedMedia: "EnhancedMediaField",
11
12
  fks: "FksField",
12
13
  m2m: "FksField",
13
14
  mediaList: "MediaM2mField",
14
15
  seoPreview: "SeoPreview",
15
16
  repeater: "Repeater",
17
+ color: "ColorField"
16
18
  }
17
19
 
18
20
  const props = {
@@ -23,6 +25,9 @@ const props = {
23
25
  MediaField: {
24
26
  outlined: false
25
27
  },
28
+ EnhancedMediaField: {
29
+ outlined: false
30
+ },
26
31
  vSwitch: {
27
32
  inset: true,
28
33
  ripple: false
@@ -55,4 +60,4 @@ const accessor = {
55
60
  }
56
61
  export default {
57
62
  mapping, props, accessor
58
- }
63
+ }
@@ -0,0 +1,76 @@
1
+ <template>
2
+ <div>
3
+ <v-menu
4
+ v-model="menu"
5
+ :close-on-content-click="false"
6
+ transition="scale-transition"
7
+ offset-y
8
+ min-width="auto"
9
+ >
10
+ <template v-slot:activator="{ on, attrs }">
11
+ <v-text-field
12
+ v-model="model"
13
+ readonly
14
+ v-bind="{ ...$attrs, ...attrs }"
15
+ v-on="readonly ? undefined : on"
16
+ class="rounded-0"
17
+ >
18
+ <template v-slot:prepend-inner>
19
+ <div class="color-picker-inner-icon" :style="`background-color: ${model}`"></div>
20
+ </template>
21
+ </v-text-field>
22
+ </template>
23
+ <v-card>
24
+ <v-color-picker
25
+ v-model="model"
26
+ mode="hexa"
27
+ hide-mode-switch
28
+ v-bind="$attrs"
29
+ v-on="$listeners"
30
+ ></v-color-picker>
31
+ </v-card>
32
+ </v-menu>
33
+ </div>
34
+ </template>
35
+
36
+ <style scoped>
37
+ .color-picker-inner-icon {
38
+ width: 20px;
39
+ height: 20px;
40
+ border-radius: 20px;
41
+ }
42
+ </style>
43
+
44
+ <script>
45
+ /**
46
+ * This component wraps vuetify's color picker as a Mapo field.
47
+ */
48
+ export default {
49
+ name: "ColorField",
50
+ data() {
51
+ return {
52
+ model: this.value || "",
53
+ menu: null,
54
+ };
55
+ },
56
+ props: {
57
+ // V-model property. Color must be hex codified.
58
+ value: {
59
+ type: String,
60
+ },
61
+ // This set the component status to readonly, stopping the user interaction.
62
+ readonly: {
63
+ type: Boolean,
64
+ default: false,
65
+ },
66
+ },
67
+ watch: {
68
+ value(val) {
69
+ this.model = val || "";
70
+ },
71
+ model(val) {
72
+ this.$emit("input", val);
73
+ },
74
+ },
75
+ };
76
+ </script>
@@ -0,0 +1,224 @@
1
+ <template>
2
+ <div>
3
+ <v-text-field
4
+ v-if="title"
5
+ v-model="title"
6
+ class="mb-n8 pb-0"
7
+ solo
8
+ readonly
9
+ v-bind="$attrs"
10
+ ></v-text-field>
11
+
12
+ <!-- If the media is not avaible, it shows a btn to add new media -->
13
+ <v-card
14
+ class="rounded-0"
15
+ v-bind="{
16
+ height,
17
+ width,
18
+ maxWidth,
19
+ maxHeight,
20
+ minWidth,
21
+ minHeight,
22
+ ...$attrs,
23
+ }"
24
+ >
25
+ <MediaPreview
26
+ class="media-preview"
27
+ :key="childKey"
28
+ v-if="mediaExists"
29
+ :media="internalValue"
30
+ :video-preview="internalValue.is_image ? false : true"
31
+ />
32
+
33
+ <v-card-title>{{ label }}</v-card-title>
34
+ <v-card-text v-show="internalValue">
35
+ <h4>{{ $t("mapo.fileName") }}:</h4>
36
+ {{ fileName }}
37
+ <h4>{{ $t("mapo.created") }}:</h4>
38
+ {{ fileInfo.created }}
39
+ </v-card-text>
40
+ <v-card-actions>
41
+ <template v-if="!internalValue && !rmAddBtn">
42
+ <v-btn
43
+ tile
44
+ :disabled="readonly"
45
+ @click="editing = true"
46
+ block
47
+ :min-height="minHeight"
48
+ >
49
+ <v-icon size="80"> mdi-plus-circle-outline </v-icon>
50
+ </v-btn>
51
+ </template>
52
+ <template v-else>
53
+ <v-row >
54
+ <v-col align="center">
55
+ <v-btn
56
+ :disabled="readonly"
57
+ @click="editing = true"
58
+ block
59
+ >
60
+ <v-icon>mdi-pencil</v-icon>
61
+ </v-btn>
62
+ </v-col>
63
+ <v-col align="center">
64
+ <v-btn
65
+ :disabled="readonly"
66
+ @click="confirmDelete"
67
+ color="error"
68
+ block
69
+ >
70
+ <v-icon>mdi-delete</v-icon>
71
+ </v-btn>
72
+ </v-col>
73
+ </v-row>
74
+ </template>
75
+ </v-card-actions>
76
+ </v-card>
77
+ <!-- Select media dialog -->
78
+ <media-manager-dialog
79
+ v-model="editing"
80
+ select="single"
81
+ v-on:selectionChange="update"
82
+ v-bind="$attrs"
83
+ >
84
+ </media-manager-dialog>
85
+
86
+ <v-messages v-model="errorMessages" color="error" class="mt-2" />
87
+ </div>
88
+ </template>
89
+
90
+ <style scoped>
91
+ .media-preview {
92
+ cursor: pointer;
93
+ }
94
+ </style>
95
+
96
+ <script>
97
+ export default {
98
+ name: "EnhancedMediaField",
99
+ data() {
100
+ return {
101
+ internalValue: null,
102
+ editing: false,
103
+ childKey: 0,
104
+ };
105
+ },
106
+
107
+ props: {
108
+ value: Object,
109
+ label: String,
110
+ title: {
111
+ type: String,
112
+ default: () => "",
113
+ },
114
+ errorMessages: {
115
+ type: String | Array,
116
+ default: () => [],
117
+ },
118
+ rmAddBtn: {
119
+ type: Boolean,
120
+ default: false,
121
+ },
122
+ //image reflections
123
+ aspectRatio: {
124
+ type: String | Number,
125
+ default: undefined,
126
+ },
127
+ contain: {
128
+ type: Boolean,
129
+ default: false,
130
+ },
131
+ height: {
132
+ type: String | Number,
133
+ default: "100%",
134
+ },
135
+ width: {
136
+ type: String | Number,
137
+ default: "100%",
138
+ },
139
+ maxWidth: {
140
+ type: String | Number,
141
+ default: undefined,
142
+ },
143
+ maxHeight: {
144
+ type: String | Number,
145
+ default: undefined,
146
+ },
147
+ minWidth: {
148
+ type: String | Number,
149
+ default: undefined,
150
+ },
151
+ minHeight: {
152
+ type: String | Number,
153
+ default: 300,
154
+ },
155
+ // This set the component status to readonly, stopping the user interaction.
156
+ readonly: {
157
+ type: Boolean,
158
+ default: false,
159
+ },
160
+ },
161
+
162
+ computed: {
163
+ mediaExists() {
164
+ return !!this.internalValue?.file;
165
+ },
166
+ fileInfo() {
167
+ return {
168
+ title: this.internalValue?.title,
169
+ created: new Date(this.internalValue?.created).toLocaleDateString(
170
+ this.internalValue?.language_code
171
+ ),
172
+ };
173
+ },
174
+ fileName() {
175
+ return (
176
+ this.internalValue &&
177
+ this.internalValue.file &&
178
+ this.internalValue.file.split("/").pop()
179
+ );
180
+ },
181
+ },
182
+
183
+ methods: {
184
+ update(val) {
185
+ this.updateChild();
186
+ this.internalValue = val;
187
+ },
188
+ confirmDelete() {
189
+ this.$mapo.$confirm
190
+ .open({
191
+ title: this.$t("mapo.remove"),
192
+ question: this.$t("mapo.mediaField.confirmRemove"),
193
+ approveButton: {
194
+ text: this.$t("mapo.remove"),
195
+ attrs: { color: "red", text: true },
196
+ },
197
+ })
198
+ .then((res) => (res ? (this.internalValue = null) : null));
199
+ },
200
+ updateChild() {
201
+ this.childKey += 1;
202
+ },
203
+ isImage(val) {
204
+ if (!val?.is_image && val?.mime_type.includes("image")) {
205
+ Object.assign(val, { is_image: true });
206
+ }
207
+ },
208
+ },
209
+ watch: {
210
+ value(val) {
211
+ if (val !== this.internalValue) {
212
+ this.internalValue = val;
213
+ }
214
+ },
215
+ internalValue(val) {
216
+ this.isImage(val);
217
+ this.$emit("input", val);
218
+ },
219
+ },
220
+ mounted() {
221
+ this.internalValue = this.value;
222
+ },
223
+ };
224
+ </script>
@@ -16,7 +16,7 @@ export default {
16
16
  data() {
17
17
  return {
18
18
  model: null,
19
- options: [],
19
+ options: this.items || [],
20
20
  loading: false,
21
21
  };
22
22
  },
@@ -224,7 +224,7 @@ export default {
224
224
  },
225
225
  },
226
226
  mounted(){
227
- this.internalValue = this.val
227
+ this.internalValue = this.value
228
228
  }
229
229
  };
230
230
  </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div ref="repeater" class="container pa-0">
2
+ <div class="container pa-0">
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"
@@ -10,27 +10,27 @@
10
10
  v-model="items"
11
11
  handle=".repeater-handle-sort"
12
12
  animation="150"
13
- @change="sortCallback({ ...$event, items, eventType: 'move' })"
13
+ @change="draggableReorder($event)"
14
14
  :style="maxHeightStyle"
15
15
  >
16
16
  <div
17
17
  class="repeater-line-wrapper"
18
- :class="{ expanded: !collapsable }"
18
+ :class="{ expanded: !collapsable || isExpanded(index) }"
19
19
  v-for="(model, index) in items"
20
20
  :key="index"
21
21
  >
22
22
  <div class="d-flex">
23
23
  <div v-if="collapsable" class="collapsed-preview">
24
- <v-icon class="expand-icon" @click.native="toggleExpand($event)"
24
+ <v-icon class="expand-icon" @click.native="toggleExpand(index)"
25
25
  >mdi-chevron-down</v-icon
26
26
  >
27
27
  <span
28
28
  class="v-label collapsed-label"
29
- @click="toggleExpand($event, true)"
29
+ @click="toggleExpand(index, true)"
30
30
  v-html="getCollapsedLabel(model, index)"
31
31
  ></span>
32
32
  </div>
33
- <div class="repeater-fields container">
33
+ <div v-if="isExpanded(index)" class="repeater-fields container">
34
34
  <Form
35
35
  v-model="items[index]"
36
36
  :currentLang="translatable ? currentLang : null"
@@ -189,16 +189,16 @@
189
189
  }
190
190
  }
191
191
  &.expanded {
192
- .expand-icon {
192
+ > div > div >.expand-icon {
193
193
  transform: rotate(180deg);
194
194
  }
195
- .collapsed-label {
195
+ > div > div > .collapsed-label {
196
196
  display: none;
197
197
  }
198
- .repeater-fields {
198
+ > div > .repeater-fields {
199
199
  display: flex;
200
200
  }
201
- .collapsed-preview {
201
+ > div > .collapsed-preview {
202
202
  flex-basis: 0;
203
203
  }
204
204
  }
@@ -265,6 +265,7 @@ export default {
265
265
  items: null,
266
266
  tModalOpen: false,
267
267
  tModalCallback: () => {},
268
+ collapsedStack: (this.value || []).map(() => !!this.collapsable)
268
269
  };
269
270
  },
270
271
  props: {
@@ -317,6 +318,8 @@ export default {
317
318
  watch: {
318
319
  value(val) {
319
320
  this.items = val;
321
+ if (val.length != this.collapsedStack.length)
322
+ this.collapsedStack = (val || []).map(() => !!this.collapsable)
320
323
  },
321
324
  items(val) {
322
325
  this.$emit("input", val);
@@ -326,6 +329,9 @@ export default {
326
329
  },
327
330
  },
328
331
  methods: {
332
+ isExpanded(index){
333
+ return !this.collapsedStack[index];
334
+ },
329
335
  async addItem(index) {
330
336
  const element = {};
331
337
  if (this.hasTemplates) {
@@ -335,10 +341,7 @@ export default {
335
341
  }
336
342
  const newIndex = typeof index == "number" ? index : this.items.length;
337
343
  this.items.splice(newIndex, 0, element);
338
- this.$nextTick(() => {
339
- const line = this.$refs.repeater.querySelectorAll(".repeater-line-wrapper")[newIndex];
340
- line && line.classList.add("expanded");
341
- });
344
+ this.collapsedStack.splice(newIndex, 0, false)
342
345
  this.sortable &&
343
346
  this.sortCallback({
344
347
  moved: { element, newIndex },
@@ -349,6 +352,7 @@ export default {
349
352
  removeItem(index) {
350
353
  const element = this.items[index];
351
354
  this.items.splice(index, 1);
355
+ this.collapsedStack.splice(index, 1);
352
356
  this.sortable &&
353
357
  this.sortCallback({
354
358
  moved: { element, oldIndex: index },
@@ -395,13 +399,19 @@ export default {
395
399
  return getPointed(model, field.value, fallback);
396
400
  }
397
401
  },
398
- toggleExpand(event, forceValue) {
399
- const action = forceValue == undefined ? "toggle" : forceValue ? "add" : "remove";
400
- const target = event.target.closest(".repeater-line-wrapper");
401
- target && target.classList[action]("expanded");
402
+ draggableReorder(event) {
403
+ const { newIndex, oldIndex } = event.moved;
404
+ const stackItem = this.collapsedStack[oldIndex];
405
+ this.collapsedStack.splice(oldIndex, 1);
406
+ this.collapsedStack.splice(newIndex, 0, stackItem);
407
+ this.sortCallback({ ...event, items: this.items, eventType: 'move' })
408
+ },
409
+ toggleExpand(index, forceValue) {
410
+ this.collapsedStack[index] = forceValue == undefined ? !this.collapsedStack[index] : !forceValue;
411
+ this.collapsedStack = [...this.collapsedStack];
402
412
  },
403
413
  collapseAll() {
404
- this.$refs.repeater.querySelectorAll(".repeater-line-wrapper").forEach((e) => e.classList.remove("expanded"));
414
+ this.collapsedStack = this.collapsedStack.map(() => true)
405
415
  },
406
416
  },
407
417
  computed: {
@@ -24,7 +24,6 @@
24
24
  .darker__item {
25
25
  &.theme--light {
26
26
  background: #ffffffd6;
27
- filter: invert(1);
28
27
  }
29
28
  &.theme--dark {
30
29
  background: #121212;
@@ -11,6 +11,7 @@
11
11
  }"
12
12
  v-bind="$attrs"
13
13
  v-on="videoListeners"
14
+ :title="media.title || media.name"
14
15
  >
15
16
  <template v-slot:placeholder>
16
17
  <v-row class="fill-height ma-0" align="center" justify="center">
package/defaults/i18n.js CHANGED
@@ -19,7 +19,7 @@ export default {
19
19
  },
20
20
  ],
21
21
  lazy: true,
22
- langDir: __dirname + "/translations/",
22
+ langDir: __dirname + "/../translations/",
23
23
  defaultLocale: "en",
24
24
  strategy: "no_prefix",
25
25
  onBeforeLanguageSwitch: (oldLocale, newLocale, isInitialSetup, context) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/uikit",
3
- "version": "1.0.0-alpha.25",
3
+ "version": "1.0.0-alpha.28",
4
4
  "license": "MIT",
5
5
  "description": "This is part of Mapo nuxt module. Injects Mapo ui components in the nuxt component discovery system.",
6
6
  "author": "bnznamco <gabriele.baldi.01@gmail.com>",
@@ -15,5 +15,5 @@
15
15
  "publishConfig": {
16
16
  "access": "public"
17
17
  },
18
- "gitHead": "eadf1c2835aa6aba84870dc8d98308f10b257527"
18
+ "gitHead": "5d5b4490d8025f6f2740eed7a4c3b31ab58ec2c6"
19
19
  }
@@ -20,6 +20,8 @@ export default {
20
20
  saveContinue: "Save and continue",
21
21
  back: "Back",
22
22
  genericError: "Something whent bad, please try again later...",
23
+ saveSuccess: "Item saved succesfully!",
24
+ createSuccess: "Item succesfully created!",
23
25
  confirmDelete: "Are you sure you want to delete this item?",
24
26
  fetchingData: "Fetching data...",
25
27
  login: "Login",
@@ -20,6 +20,8 @@ export default {
20
20
  saveContinue: "Salva e continua",
21
21
  back: "Indietro",
22
22
  genericError: "Qualcosa è andato storto, riprova più tardi...",
23
+ saveSuccess: "Elemento salvato con successo!",
24
+ createSuccess: "Elemento creato con successo!",
23
25
  confirmDelete: "Vuoi veramente eliminare questo elemento?",
24
26
  fetchingData: "Caricamento in corso...",
25
27
  login: "Login",