@mapomodule/uikit 1.0.0-alpha.26 → 1.0.0-alpha.29
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 +63 -0
- package/components/ConfirmDialog.vue +1 -0
- package/components/Detail/Detail.vue +19 -9
- package/components/Form/Form.vue +26 -35
- package/components/Form/FormField.vue +33 -9
- package/components/Form/FormGroup.vue +3 -1
- package/components/Form/FormTabs.vue +11 -9
- package/components/Form/defaults.js +6 -1
- package/components/Form/fields/ColorField.vue +76 -0
- package/components/Form/fields/EnhancedMediaField.vue +224 -0
- package/components/Form/fields/FksField.vue +1 -1
- package/components/Form/fields/MediaField.vue +1 -1
- package/components/Form/fields/Repeater.vue +29 -19
- package/components/LogoutButton.vue +0 -1
- package/components/MediaManager/MediaPreview.vue +1 -0
- package/package.json +2 -2
- package/translations/en-US.js +2 -0
- package/translations/it-IT.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,69 @@
|
|
|
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.29](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.28...v1.0.0-alpha.29) (2022-09-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **form-field:** debounce the entire setter not only emitter to preserve the most fresh data from parents components ([31449e2](https://github.com/lotrekagency/mapo/commit/31449e2f759de23e993ef7679c8c5bf515dd347f))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Performance Improvements
|
|
15
|
+
|
|
16
|
+
* **detail:** remove unused console logs ([3bef461](https://github.com/lotrekagency/mapo/commit/3bef461828ef1c6e076929776b1e4e76c224a67e))
|
|
17
|
+
* **form:** move translations logic to from field to prevent field config manipulations and reduce rendering cycles ([06038ef](https://github.com/lotrekagency/mapo/commit/06038ef00654e85b43aa628891d4662f2b18c1c3))
|
|
18
|
+
* **form:** prevent inputs if value has no changes and defer inputs if not immediate flag on form ([e3da2d8](https://github.com/lotrekagency/mapo/commit/e3da2d8265d275cfe63bbdaa382f2ab4fed1f91f))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# [1.0.0-alpha.28](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.27...v1.0.0-alpha.28) (2022-09-01)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* **form debounce:** fix form debounce not correctly updating model ([04b392d](https://github.com/lotrekagency/mapo/commit/04b392df7021534c4f30cee6ab3593946dd29414))
|
|
30
|
+
* fixed repeater remaining close on model fetch ([3a30136](https://github.com/lotrekagency/mapo/commit/3a301364ffe26107d890a9100c939a3c32cfc7c2))
|
|
31
|
+
* **repeater:** fix row expansion in nested repeater ([4ed22cd](https://github.com/lotrekagency/mapo/commit/4ed22cd3b0fe8593d1c87e43cbf92bbba8198ae2))
|
|
32
|
+
* **tabs:** show correct label in nested tabs ([30f50b2](https://github.com/lotrekagency/mapo/commit/30f50b277596304b99018e7132a8403c4c2c5639))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Features
|
|
36
|
+
|
|
37
|
+
* **detail:** give feedback for all http actions in detail components and prevent interaction during the request ([ceec206](https://github.com/lotrekagency/mapo/commit/ceec206fe50b23e784f9528fe41c02ec11c91e66))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Performance Improvements
|
|
41
|
+
|
|
42
|
+
* **repeater:** prevent collapsed repeater from rendering hidden forms ([1ae7d18](https://github.com/lotrekagency/mapo/commit/1ae7d1836f8ff8625f21a2be5fbaf5acef6ef404))
|
|
43
|
+
* increase form performances debouncing the emit events ([5e0bb30](https://github.com/lotrekagency/mapo/commit/5e0bb30f1e660d5b81319f213730c217eb6752a5))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# [1.0.0-alpha.27](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.26...v1.0.0-alpha.27) (2022-08-25)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Bug Fixes
|
|
53
|
+
|
|
54
|
+
* **colorfield:** return string in colorfield ([3acbd5c](https://github.com/lotrekagency/mapo/commit/3acbd5caa6555835c168718303f1ca555e8efc75))
|
|
55
|
+
* **detail:** added force option to languages ([8ed4b69](https://github.com/lotrekagency/mapo/commit/8ed4b69f746b136755cbda17cdab176632869cdf))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* **fields:** added color field ([ead7448](https://github.com/lotrekagency/mapo/commit/ead744861be2c9c24ea2911e68c8b4d1259cab15))
|
|
61
|
+
* **mediapreview:** added title tag to medias ([d063162](https://github.com/lotrekagency/mapo/commit/d063162036a4294fbd3c5ed347dfde78061a1f33))
|
|
62
|
+
* implemented enhanced media compomentent ([fe336e1](https://github.com/lotrekagency/mapo/commit/fe336e170d42a67562c8e4abfa387b806e7c7a6a))
|
|
63
|
+
* implemented media preview through MediaPreview component ([575c285](https://github.com/lotrekagency/mapo/commit/575c2853eb774ca4c635ce099302a429cc479be5))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
6
69
|
# [1.0.0-alpha.26](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.25...v1.0.0-alpha.26) (2022-08-11)
|
|
7
70
|
|
|
8
71
|
|
|
@@ -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
|
},
|
|
@@ -296,7 +305,7 @@ export default {
|
|
|
296
305
|
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
|
297
306
|
return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change");
|
|
298
307
|
}
|
|
299
|
-
return
|
|
308
|
+
return !!this.buttonClicked;
|
|
300
309
|
},
|
|
301
310
|
canDelete() {
|
|
302
311
|
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
|
@@ -320,7 +329,7 @@ export default {
|
|
|
320
329
|
return !Object.keys(this.model).length;
|
|
321
330
|
},
|
|
322
331
|
langs() {
|
|
323
|
-
return (this.modelLanguages || []).length ? this.modelLanguages : this.languages;
|
|
332
|
+
return (!this.forceLanguages && (this.modelLanguages || []).length) ? this.modelLanguages : this.languages;
|
|
324
333
|
},
|
|
325
334
|
slotBindings() {
|
|
326
335
|
return {
|
|
@@ -410,6 +419,7 @@ Here the list of the FieldConfiguration type association.
|
|
|
410
419
|
- `file` ==> [file-field](/components/Form/fields/FileField/),
|
|
411
420
|
- `editor` ==> [wyg-editor](/components/Form/fields/wygEditor/wygEditor/),
|
|
412
421
|
- `media` ==> [media-field](/components/Form/fields/MediaField/),
|
|
422
|
+
- `enhancedMedia` ==> [enhanced-media-field](/components/Form/fields/EnhancedMediaField/),
|
|
413
423
|
- `mediaList` ==> [media-m2m-field](/components/Form/fields/MediaM2mField/)
|
|
414
424
|
- `m2m` or `fks` ==> [fks-field](/components/Form/fields/FksField/),
|
|
415
425
|
- `repeater` ==> [repeater](/components/Form/fields/Repeater/),
|
package/components/Form/Form.vue
CHANGED
|
@@ -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, }" />
|
|
@@ -83,14 +83,13 @@
|
|
|
83
83
|
<script>
|
|
84
84
|
import { nameSpacedSlots } from "@mapomodule/utils/helpers/slots";
|
|
85
85
|
import { slugify, titleCase } from "@mapomodule/utils/helpers/formatters";
|
|
86
|
-
import {
|
|
86
|
+
import { debounce } from "@mapomodule/utils/helpers/debounce";
|
|
87
87
|
|
|
88
88
|
export default {
|
|
89
89
|
name: "Form",
|
|
90
90
|
data() {
|
|
91
91
|
return {
|
|
92
|
-
model:
|
|
93
|
-
internalFields: []
|
|
92
|
+
model: this.value,
|
|
94
93
|
};
|
|
95
94
|
},
|
|
96
95
|
props: {
|
|
@@ -121,20 +120,25 @@ export default {
|
|
|
121
120
|
type: Array,
|
|
122
121
|
default: () => [],
|
|
123
122
|
},
|
|
123
|
+
// Removes debounce from the emitter.
|
|
124
|
+
immediate: Boolean
|
|
124
125
|
},
|
|
125
126
|
watch: {
|
|
126
127
|
value(val) {
|
|
127
|
-
this.model
|
|
128
|
-
|
|
128
|
+
if (JSON.stringify(this.model) !== JSON.stringify(val)){
|
|
129
|
+
this.model = val;
|
|
130
|
+
this.initLang();
|
|
131
|
+
}
|
|
129
132
|
},
|
|
130
133
|
model(val) {
|
|
131
|
-
this
|
|
134
|
+
if (JSON.stringify(this.value) !== JSON.stringify(val))
|
|
135
|
+
this.immediate ? this.$emit("input", val) : this.debouncedEmit("input", val);
|
|
132
136
|
},
|
|
133
|
-
fields(val){
|
|
134
|
-
this.internalFields = this.cloneFields(val)
|
|
135
|
-
}
|
|
136
137
|
},
|
|
137
138
|
methods: {
|
|
139
|
+
debouncedEmit: debounce(function (...args) {
|
|
140
|
+
this.$emit(...args);
|
|
141
|
+
}, 300),
|
|
138
142
|
nameSpacedSlots,
|
|
139
143
|
initLang(lang = this.currentLang) {
|
|
140
144
|
if (lang && !this.model.translations) {
|
|
@@ -145,14 +149,9 @@ export default {
|
|
|
145
149
|
}
|
|
146
150
|
},
|
|
147
151
|
parseConf(field, i) {
|
|
148
|
-
const conf = typeof field === "string" ? { value: field } : field;
|
|
152
|
+
const conf = typeof field === "string" ? { value: field } : { ...field };
|
|
149
153
|
conf.value = conf.value || "";
|
|
150
|
-
conf.value = conf.value.replace(new RegExp(`^translations\.(${this.languages.join("|")})\.?`), "");
|
|
151
154
|
conf.slotName = `fields.${conf.value || i}`;
|
|
152
|
-
if (this.currentLang && !field.synci18n) {
|
|
153
|
-
const base = `translations.${this.currentLang}`;
|
|
154
|
-
conf.value = (conf.value && `${base}.${conf.value}`) || base;
|
|
155
|
-
}
|
|
156
155
|
if (this.isReadonly) {
|
|
157
156
|
conf.attrs = { ...conf.attrs, readonly: true };
|
|
158
157
|
}
|
|
@@ -166,11 +165,9 @@ export default {
|
|
|
166
165
|
parseTabs(tabs) {
|
|
167
166
|
return Object.keys(tabs).map(key => {
|
|
168
167
|
const tab = tabs[key]
|
|
169
|
-
return {
|
|
170
|
-
label: titleCase(key.replace(/_/, " ")),
|
|
171
|
-
|
|
172
|
-
...tab.tab,
|
|
173
|
-
fields: this.mapConf(Array.isArray(tab) && tab || tab.fields || [])
|
|
168
|
+
return {
|
|
169
|
+
tab: {label: titleCase(key.replace(/_/, " ")), slug: key, ...tab.tab},
|
|
170
|
+
fields: this.mapConf(Array.isArray(tab) && tab || tab.fields || [])
|
|
174
171
|
}
|
|
175
172
|
})
|
|
176
173
|
},
|
|
@@ -182,7 +179,7 @@ export default {
|
|
|
182
179
|
mapConf(fields) {
|
|
183
180
|
return fields.map((f, i) =>
|
|
184
181
|
f.tabs
|
|
185
|
-
? { group: this.parseTagsGroup(f), tabs: this.parseTabs(f.tabs) }
|
|
182
|
+
? { group: this.parseTagsGroup(f), tabs: this.parseTabs(f.tabs) }
|
|
186
183
|
: f.group
|
|
187
184
|
? { group: this.parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
188
185
|
: this.parseConf(f, i)
|
|
@@ -191,7 +188,7 @@ export default {
|
|
|
191
188
|
show(conf, type = "display"){
|
|
192
189
|
const prop = type == "visibility" ? "vVisible" : "vShow"
|
|
193
190
|
if (typeof conf[prop] == "function") {
|
|
194
|
-
return conf[prop]({
|
|
191
|
+
return conf[prop]({
|
|
195
192
|
model: this.model,
|
|
196
193
|
errors: this.errors,
|
|
197
194
|
languages: this.languages,
|
|
@@ -200,10 +197,6 @@ export default {
|
|
|
200
197
|
}
|
|
201
198
|
return true
|
|
202
199
|
},
|
|
203
|
-
cloneFields(fields){
|
|
204
|
-
return process.browser ? deepClone(fields) : fields
|
|
205
|
-
}
|
|
206
|
-
|
|
207
200
|
},
|
|
208
201
|
computed: {
|
|
209
202
|
slotBindings() {
|
|
@@ -216,13 +209,11 @@ export default {
|
|
|
216
209
|
};
|
|
217
210
|
},
|
|
218
211
|
computedFields() {
|
|
219
|
-
return this.mapConf(this.
|
|
212
|
+
return this.mapConf(this.fields);
|
|
220
213
|
},
|
|
221
214
|
},
|
|
222
215
|
created(){
|
|
223
|
-
this.internalFields = this.cloneFields(this.fields)
|
|
224
|
-
this.model = this.value
|
|
225
216
|
this.initLang();
|
|
226
217
|
}
|
|
227
218
|
};
|
|
228
|
-
</script>
|
|
219
|
+
</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,
|
|
@@ -88,16 +92,26 @@ export default {
|
|
|
88
92
|
this.setModel(val);
|
|
89
93
|
},
|
|
90
94
|
},
|
|
91
|
-
|
|
95
|
+
kpointed(newValue, oldValue) {
|
|
92
96
|
if (newValue !== oldValue) {
|
|
93
97
|
this.setModel();
|
|
94
98
|
}
|
|
95
99
|
},
|
|
96
100
|
model(val) {
|
|
101
|
+
var model = this.extractValue(val);
|
|
102
|
+
if (JSON.stringify(val) !== JSON.stringify(model))
|
|
103
|
+
this.debouncedSetValue(val);
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
methods: {
|
|
107
|
+
debouncedSetValue: debounce(function (...args) {
|
|
108
|
+
this.setValue(...args);
|
|
109
|
+
}, 300),
|
|
110
|
+
setValue(val){
|
|
97
111
|
const dump = { ...this.value }; // since we cannot directly edit a prop
|
|
98
112
|
setPointed(
|
|
99
113
|
dump,
|
|
100
|
-
this.
|
|
114
|
+
this.kpointed,
|
|
101
115
|
this.accessor.set({ model: dump, val })
|
|
102
116
|
);
|
|
103
117
|
if (typeof this.conf.onChange == "function")
|
|
@@ -106,25 +120,35 @@ export default {
|
|
|
106
120
|
model: dump,
|
|
107
121
|
currentLang: this.currentLang,
|
|
108
122
|
languages: this.langs,
|
|
109
|
-
conf: this.conf
|
|
123
|
+
conf: this.conf,
|
|
124
|
+
kpointed: this.kpointed
|
|
110
125
|
})
|
|
111
126
|
|
|
112
127
|
// Fired when the v-model changes.
|
|
113
128
|
// @arg Emits the entire payload modified.
|
|
114
129
|
this.$emit("input", dump);
|
|
115
130
|
},
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
setModel(val = this.value) {
|
|
119
|
-
var model = this.accessor.get({
|
|
131
|
+
extractValue(val = this.value){
|
|
132
|
+
return this.accessor.get({
|
|
120
133
|
model: { ...val },
|
|
121
|
-
val: getPointed({ ...val }, this.
|
|
134
|
+
val: getPointed({ ...val }, this.kpointed),
|
|
122
135
|
});
|
|
136
|
+
},
|
|
137
|
+
setModel(val = this.value) {
|
|
138
|
+
var model = this.extractValue(val)
|
|
123
139
|
if (val && JSON.stringify(this.model) !== JSON.stringify(model))
|
|
124
140
|
this.model = model;
|
|
125
141
|
},
|
|
126
142
|
},
|
|
127
143
|
computed: {
|
|
144
|
+
kpointed(){
|
|
145
|
+
let kpointed = this.conf.value
|
|
146
|
+
if (this.currentLang && !this.conf.synci18n) {
|
|
147
|
+
const base = `translations.${this.currentLang}`;
|
|
148
|
+
kpointed = kpointed ? `${base}.${kpointed}` : base;
|
|
149
|
+
}
|
|
150
|
+
return kpointed;
|
|
151
|
+
},
|
|
128
152
|
accessor() {
|
|
129
153
|
let func = function ({ val }) {
|
|
130
154
|
return val;
|
|
@@ -139,7 +163,7 @@ export default {
|
|
|
139
163
|
fieldAttrs() {
|
|
140
164
|
return {
|
|
141
165
|
label: this.label,
|
|
142
|
-
errorMessages: this.
|
|
166
|
+
errorMessages: this.kpointed
|
|
143
167
|
.split(".")
|
|
144
168
|
.map((_, i, a) => a.slice(0, i + 1).join("."))
|
|
145
169
|
.reduce((acc, next) => {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
v-bind="{ currentLang, errors, languages, readonly }"
|
|
15
15
|
:fields="conf.fields"
|
|
16
16
|
:moreSlotBindings="slotBindings"
|
|
17
|
+
immediate
|
|
17
18
|
>
|
|
18
19
|
<template v-for="(_, slot) in $slots" :slot="slot">
|
|
19
20
|
<!-- @vuese-ignore -->
|
|
@@ -73,7 +74,8 @@ export default {
|
|
|
73
74
|
this.model = val;
|
|
74
75
|
},
|
|
75
76
|
model(val) {
|
|
76
|
-
this
|
|
77
|
+
if (this.value !== val)
|
|
78
|
+
this.$emit("input", val);
|
|
77
79
|
},
|
|
78
80
|
},
|
|
79
81
|
computed: {
|
|
@@ -12,33 +12,34 @@
|
|
|
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 }"
|
|
25
25
|
:fields="tab.fields"
|
|
26
26
|
:moreSlotBindings="slotBindings"
|
|
27
|
+
immediate
|
|
27
28
|
>
|
|
28
29
|
<template
|
|
29
|
-
v-for="slot in nameSpacedSlots($slots, `tab.${tab.slug}.`)"
|
|
30
|
+
v-for="slot in nameSpacedSlots($slots, `tab.${tab.tab.slug}.`)"
|
|
30
31
|
:slot="slot"
|
|
31
32
|
>
|
|
32
|
-
<slot :name="`tab.${tab.slug}.${slot}`"></slot>
|
|
33
|
+
<slot :name="`tab.${tab.tab.slug}.${slot}`"></slot>
|
|
33
34
|
</template>
|
|
34
35
|
<template
|
|
35
36
|
v-for="slot in nameSpacedSlots(
|
|
36
37
|
$scopedSlots,
|
|
37
|
-
`tab.${tab.slug}.`
|
|
38
|
+
`tab.${tab.tab.slug}.`
|
|
38
39
|
)"
|
|
39
40
|
v-slot:[slot]="props"
|
|
40
41
|
>
|
|
41
|
-
<slot :name="`tab.${tab.slug}.${slot}`" v-bind="props" />
|
|
42
|
+
<slot :name="`tab.${tab.tab.slug}.${slot}`" v-bind="props" />
|
|
42
43
|
</template>
|
|
43
44
|
</Form>
|
|
44
45
|
</slot>
|
|
@@ -101,7 +102,8 @@ export default {
|
|
|
101
102
|
this.model = val;
|
|
102
103
|
},
|
|
103
104
|
model(val) {
|
|
104
|
-
this
|
|
105
|
+
if (this.value !== val)
|
|
106
|
+
this.$emit("input", val);
|
|
105
107
|
},
|
|
106
108
|
},
|
|
107
109
|
computed: {
|
|
@@ -134,7 +136,7 @@ export default {
|
|
|
134
136
|
show(conf, type = "display"){
|
|
135
137
|
const prop = type == "visibility" ? "vVisible" : "vShow"
|
|
136
138
|
if (typeof conf[prop] == "function") {
|
|
137
|
-
return conf[prop]({
|
|
139
|
+
return conf[prop]({
|
|
138
140
|
model: this.model,
|
|
139
141
|
errors: this.errors,
|
|
140
142
|
languages: this.languages,
|
|
@@ -148,4 +150,4 @@ export default {
|
|
|
148
150
|
this.model = this.value;
|
|
149
151
|
},
|
|
150
152
|
};
|
|
151
|
-
</script>
|
|
153
|
+
</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>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
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="
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
|
|
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
|
|
414
|
+
this.collapsedStack = this.collapsedStack.map(() => true)
|
|
405
415
|
},
|
|
406
416
|
},
|
|
407
417
|
computed: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/uikit",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.29",
|
|
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": "
|
|
18
|
+
"gitHead": "2a60a65a7baa45b0961ca2efb750828ad4a3d218"
|
|
19
19
|
}
|
package/translations/en-US.js
CHANGED
|
@@ -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",
|
package/translations/it-IT.js
CHANGED
|
@@ -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",
|