@mapomodule/uikit 1.0.0-alpha.27 → 1.0.0-alpha.30
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 +56 -0
- package/components/Detail/Detail.vue +12 -8
- package/components/Form/Form.vue +26 -35
- package/components/Form/FormField.vue +30 -9
- package/components/Form/FormGroup.vue +3 -1
- package/components/Form/FormTabs.vue +11 -9
- package/components/Form/fields/MediaM2mField.vue +1 -1
- package/components/Form/fields/Repeater.vue +89 -72
- package/components/Form/fields/wygEditor/wygEditor.vue +2 -2
- package/package.json +3 -3
- package/translations/en-US.js +2 -0
- package/translations/it-IT.js +2 -0
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.30](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.29...v1.0.0-alpha.30) (2022-09-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **repeater:** added v-container to form repeater to prevent field size expansion ([82af78e](https://github.com/lotrekagency/mapo/commit/82af78e7f74a7bc197ebae9ad7e72b1bb126729f))
|
|
12
|
+
* **repeater:** handle null values ([6cea5c4](https://github.com/lotrekagency/mapo/commit/6cea5c43de6af8647714b06bcd34325acb61f466))
|
|
13
|
+
* **wygEditor:** handle null values ([18477da](https://github.com/lotrekagency/mapo/commit/18477da45803697eabe5d8167f446e2c21ef64f8))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# [1.0.0-alpha.29](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.28...v1.0.0-alpha.29) (2022-09-03)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **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))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Performance Improvements
|
|
28
|
+
|
|
29
|
+
* **detail:** remove unused console logs ([3bef461](https://github.com/lotrekagency/mapo/commit/3bef461828ef1c6e076929776b1e4e76c224a67e))
|
|
30
|
+
* **form:** move translations logic to from field to prevent field config manipulations and reduce rendering cycles ([06038ef](https://github.com/lotrekagency/mapo/commit/06038ef00654e85b43aa628891d4662f2b18c1c3))
|
|
31
|
+
* **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))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# [1.0.0-alpha.28](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.27...v1.0.0-alpha.28) (2022-09-01)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* **form debounce:** fix form debounce not correctly updating model ([04b392d](https://github.com/lotrekagency/mapo/commit/04b392df7021534c4f30cee6ab3593946dd29414))
|
|
43
|
+
* fixed repeater remaining close on model fetch ([3a30136](https://github.com/lotrekagency/mapo/commit/3a301364ffe26107d890a9100c939a3c32cfc7c2))
|
|
44
|
+
* **repeater:** fix row expansion in nested repeater ([4ed22cd](https://github.com/lotrekagency/mapo/commit/4ed22cd3b0fe8593d1c87e43cbf92bbba8198ae2))
|
|
45
|
+
* **tabs:** show correct label in nested tabs ([30f50b2](https://github.com/lotrekagency/mapo/commit/30f50b277596304b99018e7132a8403c4c2c5639))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
* **detail:** give feedback for all http actions in detail components and prevent interaction during the request ([ceec206](https://github.com/lotrekagency/mapo/commit/ceec206fe50b23e784f9528fe41c02ec11c91e66))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### Performance Improvements
|
|
54
|
+
|
|
55
|
+
* **repeater:** prevent collapsed repeater from rendering hidden forms ([1ae7d18](https://github.com/lotrekagency/mapo/commit/1ae7d1836f8ff8625f21a2be5fbaf5acef6ef404))
|
|
56
|
+
* increase form performances debouncing the emit events ([5e0bb30](https://github.com/lotrekagency/mapo/commit/5e0bb30f1e660d5b81319f213730c217eb6752a5))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
6
62
|
# [1.0.0-alpha.27](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.26...v1.0.0-alpha.27) (2022-08-25)
|
|
7
63
|
|
|
8
64
|
|
|
@@ -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: {
|
|
@@ -224,6 +225,7 @@ export default {
|
|
|
224
225
|
this.$nuxt.context?.from?.name == "login" ? this.$router.go(-3) : this.$router.back();
|
|
225
226
|
},
|
|
226
227
|
saveItem(back = false) {
|
|
228
|
+
this.buttonClicked = back ? "saveAndBackBtn" : "saveBtn";
|
|
227
229
|
this.errors = null;
|
|
228
230
|
this.$refs.form?.resetValidation();
|
|
229
231
|
this.crud
|
|
@@ -233,6 +235,7 @@ export default {
|
|
|
233
235
|
this.back()
|
|
234
236
|
} else {
|
|
235
237
|
this.model = resp;
|
|
238
|
+
this.$mapo.$snack.open({ message: this.isNew ? this.$t("mapo.createSuccess") : this.$t("mapo.saveSuccess"), color: "success" })
|
|
236
239
|
this.isNew && this.$router.replace({ params: { detail: resp.id } })
|
|
237
240
|
}
|
|
238
241
|
})
|
|
@@ -242,8 +245,8 @@ export default {
|
|
|
242
245
|
this.$mapo.$snack.open({
|
|
243
246
|
message: error.response?.data?.detail || this.$t("mapo.genericError"),
|
|
244
247
|
color: "error"
|
|
245
|
-
})
|
|
246
|
-
});
|
|
248
|
+
})
|
|
249
|
+
}).finally(() => {this.buttonClicked = null;});;
|
|
247
250
|
},
|
|
248
251
|
deleteItem() {
|
|
249
252
|
this.$mapo.$confirm
|
|
@@ -254,13 +257,14 @@ export default {
|
|
|
254
257
|
})
|
|
255
258
|
.then(res => {
|
|
256
259
|
if (res) {
|
|
260
|
+
this.buttonClicked = "deleteBtn";
|
|
257
261
|
this.crud
|
|
258
262
|
.delete(this.identifier)
|
|
259
263
|
.then(() => this.back())
|
|
260
264
|
.catch(error => this.$mapo.$snack.open({
|
|
261
265
|
message: error.response?.data?.detail || this.$t("mapo.genericError"),
|
|
262
266
|
color: "error"
|
|
263
|
-
}));
|
|
267
|
+
})).finally(()=> {this.buttonClicked = null;});
|
|
264
268
|
}
|
|
265
269
|
});
|
|
266
270
|
},
|
|
@@ -301,7 +305,7 @@ export default {
|
|
|
301
305
|
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
|
302
306
|
return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change");
|
|
303
307
|
}
|
|
304
|
-
return
|
|
308
|
+
return !!this.buttonClicked;
|
|
305
309
|
},
|
|
306
310
|
canDelete() {
|
|
307
311
|
if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
|
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>
|
|
@@ -36,6 +36,7 @@ import { getPointed, setPointed } from "@mapomodule/utils/helpers/objHelpers";
|
|
|
36
36
|
import { titleCase } from "@mapomodule/utils/helpers/formatters";
|
|
37
37
|
|
|
38
38
|
import defaults from "./defaults";
|
|
39
|
+
import { debounce } from "@mapomodule/utils/helpers/debounce";
|
|
39
40
|
|
|
40
41
|
/**
|
|
41
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.
|
|
@@ -91,16 +92,26 @@ export default {
|
|
|
91
92
|
this.setModel(val);
|
|
92
93
|
},
|
|
93
94
|
},
|
|
94
|
-
|
|
95
|
+
kpointed(newValue, oldValue) {
|
|
95
96
|
if (newValue !== oldValue) {
|
|
96
97
|
this.setModel();
|
|
97
98
|
}
|
|
98
99
|
},
|
|
99
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){
|
|
100
111
|
const dump = { ...this.value }; // since we cannot directly edit a prop
|
|
101
112
|
setPointed(
|
|
102
113
|
dump,
|
|
103
|
-
this.
|
|
114
|
+
this.kpointed,
|
|
104
115
|
this.accessor.set({ model: dump, val })
|
|
105
116
|
);
|
|
106
117
|
if (typeof this.conf.onChange == "function")
|
|
@@ -109,25 +120,35 @@ export default {
|
|
|
109
120
|
model: dump,
|
|
110
121
|
currentLang: this.currentLang,
|
|
111
122
|
languages: this.langs,
|
|
112
|
-
conf: this.conf
|
|
123
|
+
conf: this.conf,
|
|
124
|
+
kpointed: this.kpointed
|
|
113
125
|
})
|
|
114
126
|
|
|
115
127
|
// Fired when the v-model changes.
|
|
116
128
|
// @arg Emits the entire payload modified.
|
|
117
129
|
this.$emit("input", dump);
|
|
118
130
|
},
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
setModel(val = this.value) {
|
|
122
|
-
var model = this.accessor.get({
|
|
131
|
+
extractValue(val = this.value){
|
|
132
|
+
return this.accessor.get({
|
|
123
133
|
model: { ...val },
|
|
124
|
-
val: getPointed({ ...val }, this.
|
|
134
|
+
val: getPointed({ ...val }, this.kpointed),
|
|
125
135
|
});
|
|
136
|
+
},
|
|
137
|
+
setModel(val = this.value) {
|
|
138
|
+
var model = this.extractValue(val)
|
|
126
139
|
if (val && JSON.stringify(this.model) !== JSON.stringify(model))
|
|
127
140
|
this.model = model;
|
|
128
141
|
},
|
|
129
142
|
},
|
|
130
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
|
+
},
|
|
131
152
|
accessor() {
|
|
132
153
|
let func = function ({ val }) {
|
|
133
154
|
return val;
|
|
@@ -142,7 +163,7 @@ export default {
|
|
|
142
163
|
fieldAttrs() {
|
|
143
164
|
return {
|
|
144
165
|
label: this.label,
|
|
145
|
-
errorMessages: this.
|
|
166
|
+
errorMessages: this.kpointed
|
|
146
167
|
.split(".")
|
|
147
168
|
.map((_, i, a) => a.slice(0, i + 1).join("."))
|
|
148
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>
|
|
@@ -1,63 +1,64 @@
|
|
|
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
|
-
<v-btn v-if="collapsable" outlined tile text small @click="collapseAll"
|
|
6
|
-
|
|
7
|
-
>
|
|
5
|
+
<v-btn v-if="collapsable" outlined tile text small @click="collapseAll">{{
|
|
6
|
+
$t("mapo.collapse")
|
|
7
|
+
}}</v-btn>
|
|
8
8
|
</div>
|
|
9
9
|
<draggable
|
|
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
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
33
|
+
<div v-if="isExpanded(index)" class="repeater-fields">
|
|
34
|
+
<v-container>
|
|
35
|
+
<Form
|
|
36
|
+
v-model="items[index]"
|
|
37
|
+
:currentLang="translatable ? currentLang : null"
|
|
38
|
+
:languages="langs"
|
|
39
|
+
:fields="getFields(model)"
|
|
40
|
+
:errors="getErrors(index)"
|
|
41
|
+
:readonly="readonly"
|
|
42
|
+
>
|
|
43
|
+
<template
|
|
44
|
+
v-for="(slot, name) in templateSlots(model, $slots)"
|
|
45
|
+
:slot="slot"
|
|
46
|
+
>
|
|
47
|
+
<slot :name="name"></slot>
|
|
48
|
+
</template>
|
|
49
|
+
<template
|
|
50
|
+
v-for="(slot, name) in templateSlots(model, $scopedSlots)"
|
|
51
|
+
v-slot:[slot]="props"
|
|
52
|
+
>
|
|
53
|
+
<slot :name="name" v-bind="props" />
|
|
54
|
+
</template>
|
|
55
|
+
</Form>
|
|
56
|
+
</v-container>
|
|
55
57
|
</div>
|
|
56
58
|
<div class="repeater-side-bar grey lighten-2">
|
|
57
|
-
<span
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
>
|
|
59
|
+
<span class="repeater-counter grey--text text--darken-2 text-truncate">{{
|
|
60
|
+
index + 1
|
|
61
|
+
}}</span>
|
|
61
62
|
<v-tooltip right>
|
|
62
63
|
<template v-slot:activator="{ on, attrs }">
|
|
63
64
|
<v-icon
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
</div>
|
|
99
100
|
</div>
|
|
100
101
|
</draggable>
|
|
101
|
-
<v-divider/>
|
|
102
|
+
<v-divider />
|
|
102
103
|
<div class="d-flex justify-end">
|
|
103
104
|
<v-btn
|
|
104
105
|
class="repeater-add-line"
|
|
@@ -113,14 +114,12 @@
|
|
|
113
114
|
</div>
|
|
114
115
|
<v-dialog v-if="hasTemplates" v-model="tModalOpen" width="600" scrollable>
|
|
115
116
|
<v-card>
|
|
116
|
-
<v-card-title class="text-h5">{{
|
|
117
|
+
<v-card-title class="text-h5">{{
|
|
118
|
+
$t("mapo.repeater.selectTemplate")
|
|
119
|
+
}}</v-card-title>
|
|
117
120
|
<v-card-text>
|
|
118
121
|
<div class="row mt-4">
|
|
119
|
-
<div
|
|
120
|
-
v-for="(template, i) in templates"
|
|
121
|
-
:key="i"
|
|
122
|
-
class="col-12 col-md-6 pa-0"
|
|
123
|
-
>
|
|
122
|
+
<div v-for="(template, i) in templates" :key="i" class="col-12 col-md-6 pa-0">
|
|
124
123
|
<div @click="tModalCallback(template)" class="template-button">
|
|
125
124
|
<span class="text-h5">{{ template.name }}</span
|
|
126
125
|
><br />
|
|
@@ -175,7 +174,9 @@
|
|
|
175
174
|
overflow: hidden;
|
|
176
175
|
text-overflow: ellipsis;
|
|
177
176
|
}
|
|
178
|
-
.theme--light .repeater-line-wrapper {
|
|
177
|
+
.theme--light .repeater-line-wrapper {
|
|
178
|
+
border-color: rgba(0, 0, 0, 0.12);
|
|
179
|
+
}
|
|
179
180
|
.repeater-line-wrapper {
|
|
180
181
|
border: 1px solid;
|
|
181
182
|
border-bottom: none;
|
|
@@ -189,16 +190,16 @@
|
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
&.expanded {
|
|
192
|
-
.expand-icon {
|
|
193
|
+
> div > div > .expand-icon {
|
|
193
194
|
transform: rotate(180deg);
|
|
194
195
|
}
|
|
195
|
-
.collapsed-label {
|
|
196
|
+
> div > div > .collapsed-label {
|
|
196
197
|
display: none;
|
|
197
198
|
}
|
|
198
|
-
.repeater-fields {
|
|
199
|
+
> div > .repeater-fields {
|
|
199
200
|
display: flex;
|
|
200
201
|
}
|
|
201
|
-
.collapsed-preview {
|
|
202
|
+
> div > .collapsed-preview {
|
|
202
203
|
flex-basis: 0;
|
|
203
204
|
}
|
|
204
205
|
}
|
|
@@ -265,6 +266,7 @@ export default {
|
|
|
265
266
|
items: null,
|
|
266
267
|
tModalOpen: false,
|
|
267
268
|
tModalCallback: () => {},
|
|
269
|
+
collapsedStack: (this.value || []).map(() => !!this.collapsable),
|
|
268
270
|
};
|
|
269
271
|
},
|
|
270
272
|
props: {
|
|
@@ -302,7 +304,7 @@ export default {
|
|
|
302
304
|
// With this you can define the output of the collapsed label. You can enter the pointed path of a value in the row or a callback function to extract the label from the row.
|
|
303
305
|
collapsedLabel: {
|
|
304
306
|
type: String | Function,
|
|
305
|
-
default: null
|
|
307
|
+
default: null,
|
|
306
308
|
},
|
|
307
309
|
// This is mainly an internal property. It is used by DetailField to pass the list of languages inherited from the Detail component.
|
|
308
310
|
langs: {
|
|
@@ -312,11 +314,13 @@ export default {
|
|
|
312
314
|
},
|
|
313
315
|
// This is mainly an internal property. It is used by DetailField to pass the active language inherited from the Detail component.
|
|
314
316
|
currentLang: String,
|
|
315
|
-
maxHeight: String | Number
|
|
317
|
+
maxHeight: String | Number,
|
|
316
318
|
},
|
|
317
319
|
watch: {
|
|
318
320
|
value(val) {
|
|
319
|
-
this.items = val;
|
|
321
|
+
this.items = val || [];
|
|
322
|
+
if (val.length != this.collapsedStack.length)
|
|
323
|
+
this.collapsedStack = (val || []).map(() => !!this.collapsable);
|
|
320
324
|
},
|
|
321
325
|
items(val) {
|
|
322
326
|
this.$emit("input", val);
|
|
@@ -326,6 +330,9 @@ export default {
|
|
|
326
330
|
},
|
|
327
331
|
},
|
|
328
332
|
methods: {
|
|
333
|
+
isExpanded(index) {
|
|
334
|
+
return !this.collapsedStack[index];
|
|
335
|
+
},
|
|
329
336
|
async addItem(index) {
|
|
330
337
|
const element = {};
|
|
331
338
|
if (this.hasTemplates) {
|
|
@@ -335,10 +342,7 @@ export default {
|
|
|
335
342
|
}
|
|
336
343
|
const newIndex = typeof index == "number" ? index : this.items.length;
|
|
337
344
|
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
|
-
});
|
|
345
|
+
this.collapsedStack.splice(newIndex, 0, false);
|
|
342
346
|
this.sortable &&
|
|
343
347
|
this.sortCallback({
|
|
344
348
|
moved: { element, newIndex },
|
|
@@ -349,6 +353,7 @@ export default {
|
|
|
349
353
|
removeItem(index) {
|
|
350
354
|
const element = this.items[index];
|
|
351
355
|
this.items.splice(index, 1);
|
|
356
|
+
this.collapsedStack.splice(index, 1);
|
|
352
357
|
this.sortable &&
|
|
353
358
|
this.sortCallback({
|
|
354
359
|
moved: { element, oldIndex: index },
|
|
@@ -371,37 +376,49 @@ export default {
|
|
|
371
376
|
},
|
|
372
377
|
getFields(model) {
|
|
373
378
|
if (this.hasTemplates) {
|
|
374
|
-
const template = this.templates.find(t => model[t.tCodeField] == t.tCode)
|
|
379
|
+
const template = this.templates.find((t) => model[t.tCodeField] == t.tCode);
|
|
375
380
|
return template ? template.fields : [];
|
|
376
381
|
}
|
|
377
382
|
return this.fields;
|
|
378
383
|
},
|
|
379
|
-
templateSlots(model, slots){
|
|
384
|
+
templateSlots(model, slots) {
|
|
380
385
|
if (this.hasTemplates) {
|
|
381
|
-
const template = this.templates.find(t => model[t.tCodeField] == t.tCode)
|
|
382
|
-
return nameSpacedSlots(slots, `template.${template.tCode}.`).reduce(
|
|
386
|
+
const template = this.templates.find((t) => model[t.tCodeField] == t.tCode);
|
|
387
|
+
return nameSpacedSlots(slots, `template.${template.tCode}.`).reduce(
|
|
388
|
+
(acc, v) => ({ [`template.${template.tCode}.${v}`]: v, ...acc }),
|
|
389
|
+
{}
|
|
390
|
+
);
|
|
383
391
|
}
|
|
384
392
|
return Object.keys(slots).reduce((acc, v) => ({ [v]: v, ...acc }), {});
|
|
385
393
|
},
|
|
386
394
|
getCollapsedLabel(model, index) {
|
|
387
|
-
const fallback = this.$t("mapo.repeater.item", {numberItem: index + 1});
|
|
395
|
+
const fallback = this.$t("mapo.repeater.item", { numberItem: index + 1 });
|
|
388
396
|
switch (typeof this.collapsedLabel) {
|
|
389
397
|
case "string":
|
|
390
398
|
return getPointed(model, this.collapsedLabel, fallback);
|
|
391
399
|
case "function":
|
|
392
400
|
return this.collapsedLabel(model);
|
|
393
401
|
default:
|
|
394
|
-
const field = this.getFields(model).find(
|
|
402
|
+
const field = this.getFields(model).find(
|
|
403
|
+
(f) => !f.type || f.type.lower() == "text"
|
|
404
|
+
);
|
|
395
405
|
return getPointed(model, field.value, fallback);
|
|
396
406
|
}
|
|
397
407
|
},
|
|
398
|
-
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
|
|
408
|
+
draggableReorder(event) {
|
|
409
|
+
const { newIndex, oldIndex } = event.moved;
|
|
410
|
+
const stackItem = this.collapsedStack[oldIndex];
|
|
411
|
+
this.collapsedStack.splice(oldIndex, 1);
|
|
412
|
+
this.collapsedStack.splice(newIndex, 0, stackItem);
|
|
413
|
+
this.sortCallback({ ...event, items: this.items, eventType: "move" });
|
|
414
|
+
},
|
|
415
|
+
toggleExpand(index, forceValue) {
|
|
416
|
+
this.collapsedStack[index] =
|
|
417
|
+
forceValue == undefined ? !this.collapsedStack[index] : !forceValue;
|
|
418
|
+
this.collapsedStack = [...this.collapsedStack];
|
|
402
419
|
},
|
|
403
420
|
collapseAll() {
|
|
404
|
-
this
|
|
421
|
+
this.collapsedStack = this.collapsedStack.map(() => true);
|
|
405
422
|
},
|
|
406
423
|
},
|
|
407
424
|
computed: {
|
|
@@ -419,26 +436,26 @@ export default {
|
|
|
419
436
|
name: tValue.name || titleCase(tKey.replace(/_/, " ")),
|
|
420
437
|
tCode: tValue.tCode || tKey,
|
|
421
438
|
tCodeField: tValue.tCodeField || "tCode",
|
|
422
|
-
preview,
|
|
439
|
+
preview,
|
|
440
|
+
description,
|
|
423
441
|
};
|
|
424
442
|
});
|
|
425
443
|
}
|
|
426
444
|
return Object.values(templates);
|
|
427
445
|
},
|
|
428
|
-
maxHeightStyle(){
|
|
429
|
-
if (this.maxHeight !== undefined){
|
|
430
|
-
const maxHeight = isNaN(this.maxHeight) ? this.maxHeight : `${this.maxHeight}px
|
|
431
|
-
return { maxHeight, paddingTop:
|
|
446
|
+
maxHeightStyle() {
|
|
447
|
+
if (this.maxHeight !== undefined) {
|
|
448
|
+
const maxHeight = isNaN(this.maxHeight) ? this.maxHeight : `${this.maxHeight}px`;
|
|
449
|
+
return { maxHeight, paddingTop: "15px", overflowX: "hidden", overflowY: "auto" };
|
|
432
450
|
}
|
|
433
|
-
}
|
|
451
|
+
},
|
|
434
452
|
},
|
|
435
453
|
mounted() {
|
|
436
|
-
this.items = this.value;
|
|
454
|
+
this.items = this.value || [];
|
|
437
455
|
},
|
|
438
456
|
};
|
|
439
457
|
</script>
|
|
440
458
|
|
|
441
|
-
|
|
442
459
|
<docs>
|
|
443
460
|
|
|
444
461
|
|
|
@@ -20,7 +20,7 @@ import defaults from "./defaults.js";
|
|
|
20
20
|
import validEvents from "./utils/events.js";
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* This component wraps a [wygEditor](https://www.tiny.cloud/) instance. With the use of the v-model you can use this component to edit any content you like.
|
|
23
|
+
* This component wraps a [wygEditor](https://www.tiny.cloud/) instance. With the use of the v-model you can use this component to edit any content you like.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
26
|
export default {
|
|
@@ -144,7 +144,7 @@ export default {
|
|
|
144
144
|
value(val) {
|
|
145
145
|
if (this.editor && this.editor.initialized && val !== this.editorContent) {
|
|
146
146
|
this.editorContent = val
|
|
147
|
-
this.editor.setContent(val);
|
|
147
|
+
this.editor.setContent(val || "");
|
|
148
148
|
}
|
|
149
149
|
},
|
|
150
150
|
readonly(val) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/uikit",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.30",
|
|
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>",
|
|
7
7
|
"repository": "https://github.com/lotrekagency/mapo",
|
|
8
8
|
"main": "./module.js",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@mapomodule/utils": "^1.0.0-alpha.
|
|
10
|
+
"@mapomodule/utils": "^1.0.0-alpha.30",
|
|
11
11
|
"@nuxtjs/i18n": "^7.2.2",
|
|
12
12
|
"@nuxtjs/vuetify": "^1.12.3",
|
|
13
13
|
"vuedraggable": "^2.24.3"
|
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
|
-
"gitHead": "
|
|
18
|
+
"gitHead": "f648aac2fc02b28e687f4631cfbaf4cde6999a8b"
|
|
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",
|