@mapomodule/uikit 1.0.0-alpha.4 → 1.0.0-alpha.41
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 +749 -0
- package/components/ConfirmDialog.vue +12 -16
- package/components/Detail/Detail.vue +406 -272
- package/components/Detail/DetailLangSwitch.vue +7 -2
- package/components/DropArea.vue +63 -56
- package/components/Form/Form.vue +218 -0
- package/components/Form/FormField.vue +213 -0
- package/components/Form/FormGroup.vue +146 -0
- package/components/Form/FormTabs.vue +188 -0
- package/components/Form/defaults.js +91 -0
- package/components/Form/fields/ColorField.vue +79 -0
- package/components/{fields → Form/fields}/DateField.vue +20 -11
- package/components/Form/fields/EnhancedMediaField.vue +224 -0
- package/components/Form/fields/FileField.vue +125 -0
- package/components/Form/fields/FksField.vue +88 -0
- package/components/Form/fields/MediaField.vue +159 -0
- package/components/Form/fields/MediaM2mField.vue +149 -0
- package/components/Form/fields/Repeater.vue +593 -0
- package/components/Form/fields/SeoPreview.vue +89 -0
- package/components/Form/fields/wygEditor/defaults.js +25 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
- package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/script.injector.js +0 -0
- package/components/Form/fields/wygEditor/wygEditor.vue +285 -0
- package/components/LangSwitcher.vue +44 -0
- package/components/List/List.vue +119 -42
- package/components/List/ListActions.vue +60 -21
- package/components/List/ListFilters.vue +166 -114
- package/components/List/ListHead.vue +30 -12
- package/components/List/ListQuickEdit.vue +130 -61
- package/components/List/ListTable.vue +292 -80
- package/components/Login.vue +17 -7
- package/components/LogoutButton.vue +43 -28
- package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
- package/components/MediaManager/MediaEditor.vue +330 -122
- package/components/MediaManager/MediaFolders.vue +169 -116
- package/components/MediaManager/MediaGallery.vue +151 -146
- package/components/MediaManager/MediaManager.vue +117 -159
- package/components/MediaManager/MediaManagerDialog.vue +36 -31
- package/components/MediaManager/MediaPreview.vue +203 -0
- package/components/MediaManager/MediaUploader.vue +55 -43
- package/components/SnackBar.vue +5 -7
- package/components/ThemeToggle.vue +13 -0
- package/components/layout/Sidebar/Sidebar.vue +61 -30
- package/components/layout/Sidebar/SidebarList.vue +19 -15
- package/components/layout/Sidebar/SidebarListItem.vue +122 -38
- package/components/layout/Sidebar/SidebarProfile.vue +42 -0
- package/components/layout/Sidebar/SidebarTitle.vue +45 -0
- package/components/layout/Topbar/Topbar.vue +11 -42
- package/components/layout/routebuilder.js +3 -3
- package/defaults/i18n.js +37 -0
- package/defaults/vuetify.js +34 -0
- package/layouts/default.vue +33 -18
- package/layouts/empty.vue +10 -0
- package/module.js +7 -5
- package/package.json +6 -4
- package/pages/index.vue +19 -18
- package/static/{favicon.ico → mapo/favicon.ico} +0 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
- package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
- package/translations/en-US.js +135 -0
- package/translations/it-IT.js +137 -0
- package/components/Detail/DetailField.vue +0 -129
- package/components/Detail/defaults.js +0 -50
- package/components/fields/M2mField.vue +0 -95
- package/components/fields/MediaField.vue +0 -195
- package/components/fields/MediaM2mField.vue +0 -238
- package/components/fields/TinyMce/TinyMce.vue +0 -177
- package/components/fields/TinyMce/defaults.js +0 -55
- package/components/layout/Sidebar/SidebarFooter.vue +0 -75
- package/defaults.js +0 -29
- package/layouts/error.vue +0 -45
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="container pa-0">
|
|
3
|
+
<div class="d-flex justify-space-between">
|
|
4
|
+
<span class="repeater-label text--secondary">{{ label }}:</span>
|
|
5
|
+
<v-btn v-if="collapsable" outlined tile text small @click="collapseAll">{{
|
|
6
|
+
$t("mapo.collapse")
|
|
7
|
+
}}</v-btn>
|
|
8
|
+
</div>
|
|
9
|
+
<draggable
|
|
10
|
+
v-model="items"
|
|
11
|
+
handle=".repeater-handle-sort"
|
|
12
|
+
animation="150"
|
|
13
|
+
@change="draggableReorder($event)"
|
|
14
|
+
:style="maxHeightStyle"
|
|
15
|
+
>
|
|
16
|
+
<div
|
|
17
|
+
class="repeater-line-wrapper"
|
|
18
|
+
:class="{ expanded: !collapsable || isExpanded(index) }"
|
|
19
|
+
v-for="(model, index) in items"
|
|
20
|
+
:key="index"
|
|
21
|
+
>
|
|
22
|
+
<div class="d-flex">
|
|
23
|
+
<div v-if="collapsable" class="collapsed-preview">
|
|
24
|
+
<v-icon class="expand-icon" @click.native="toggleExpand(index)"
|
|
25
|
+
>mdi-chevron-down</v-icon
|
|
26
|
+
>
|
|
27
|
+
<span
|
|
28
|
+
class="v-label collapsed-label"
|
|
29
|
+
@click="toggleExpand(index, true)"
|
|
30
|
+
v-html="getCollapsedLabel(model, index)"
|
|
31
|
+
></span>
|
|
32
|
+
</div>
|
|
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
|
+
immediate
|
|
43
|
+
>
|
|
44
|
+
<template
|
|
45
|
+
v-for="(slot, name) in templateSlots(model, $slots)"
|
|
46
|
+
:slot="slot"
|
|
47
|
+
>
|
|
48
|
+
<slot :name="name"></slot>
|
|
49
|
+
</template>
|
|
50
|
+
<template
|
|
51
|
+
v-for="(slot, name) in templateSlots(model, $scopedSlots)"
|
|
52
|
+
v-slot:[slot]="props"
|
|
53
|
+
>
|
|
54
|
+
<slot :name="name" v-bind="props" />
|
|
55
|
+
</template>
|
|
56
|
+
</Form>
|
|
57
|
+
</v-container>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="repeater-side-bar grey lighten-2">
|
|
60
|
+
<span class="repeater-counter grey--text text--darken-2 text-truncate">{{
|
|
61
|
+
index + 1
|
|
62
|
+
}}</span>
|
|
63
|
+
<v-tooltip right>
|
|
64
|
+
<template v-slot:activator="{ on, attrs }">
|
|
65
|
+
<v-icon
|
|
66
|
+
v-if="!readonly && sortable"
|
|
67
|
+
v-bind="attrs"
|
|
68
|
+
v-on="on"
|
|
69
|
+
color="grey darken-3"
|
|
70
|
+
class="grey lighten-2 repeater-action repeater-add-line-index"
|
|
71
|
+
@click="addItem(index)"
|
|
72
|
+
>mdi-plus-circle-outline</v-icon
|
|
73
|
+
>
|
|
74
|
+
</template>
|
|
75
|
+
<span>{{ $t("mapo.repeater.addHere") }}</span>
|
|
76
|
+
</v-tooltip>
|
|
77
|
+
<v-tooltip right>
|
|
78
|
+
<template v-slot:activator="{ on, attrs }">
|
|
79
|
+
<v-hover v-slot="{ hover }">
|
|
80
|
+
<v-icon
|
|
81
|
+
v-if="!readonly"
|
|
82
|
+
v-bind="attrs"
|
|
83
|
+
v-on="on"
|
|
84
|
+
:color="hover ? 'error' : 'grey darken-3'"
|
|
85
|
+
class="repeater-action repeater-remove-line"
|
|
86
|
+
@click="removeItem(index)"
|
|
87
|
+
>mdi-minus-circle-outline</v-icon
|
|
88
|
+
>
|
|
89
|
+
</v-hover>
|
|
90
|
+
</template>
|
|
91
|
+
<span>{{ $t("mapo.remove") }}</span>
|
|
92
|
+
</v-tooltip>
|
|
93
|
+
<v-icon
|
|
94
|
+
v-if="!readonly && sortable"
|
|
95
|
+
color="grey darken-3"
|
|
96
|
+
class="repeater-action repeater-handle-sort"
|
|
97
|
+
>mdi-drag-horizontal</v-icon
|
|
98
|
+
>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</draggable>
|
|
103
|
+
<v-divider />
|
|
104
|
+
<div class="d-flex justify-end">
|
|
105
|
+
<v-btn
|
|
106
|
+
class="repeater-add-line"
|
|
107
|
+
@click="addItem"
|
|
108
|
+
:disabled="readonly"
|
|
109
|
+
outlined
|
|
110
|
+
tile
|
|
111
|
+
text
|
|
112
|
+
>
|
|
113
|
+
<v-icon>mdi-plus</v-icon> {{ $t("mapo.add") }}</v-btn
|
|
114
|
+
>
|
|
115
|
+
</div>
|
|
116
|
+
<v-dialog v-if="hasTemplates" v-model="tModalOpen" width="600" scrollable>
|
|
117
|
+
<v-card>
|
|
118
|
+
<v-card-title class="text-h5">{{
|
|
119
|
+
$t("mapo.repeater.selectTemplate")
|
|
120
|
+
}}</v-card-title>
|
|
121
|
+
<v-card-text>
|
|
122
|
+
<div class="row mt-4">
|
|
123
|
+
<div v-for="(template, i) in templates" :key="i" class="col-12 col-md-6 pa-0">
|
|
124
|
+
<div @click="tModalCallback(template)" class="template-button">
|
|
125
|
+
<span class="text-h5">{{ template.name }}</span
|
|
126
|
+
><br />
|
|
127
|
+
<span>{{ template.description }}</span>
|
|
128
|
+
<v-img
|
|
129
|
+
v-if="template.preview"
|
|
130
|
+
max-height="150"
|
|
131
|
+
min-width="250px"
|
|
132
|
+
:src="template.preview"
|
|
133
|
+
/>
|
|
134
|
+
<v-skeleton-loader
|
|
135
|
+
v-else
|
|
136
|
+
boilerplate
|
|
137
|
+
min-width="250px"
|
|
138
|
+
type="list-item-avatar-three-line"
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</v-card-text>
|
|
144
|
+
</v-card>
|
|
145
|
+
</v-dialog>
|
|
146
|
+
</div>
|
|
147
|
+
</template>
|
|
148
|
+
|
|
149
|
+
<style lang="scss" scoped>
|
|
150
|
+
.repeater-action {
|
|
151
|
+
display: none;
|
|
152
|
+
}
|
|
153
|
+
.repeater-fields {
|
|
154
|
+
display: none;
|
|
155
|
+
overflow: hidden;
|
|
156
|
+
width: 100%;
|
|
157
|
+
}
|
|
158
|
+
.expand-icon {
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
transform: rotate(0deg);
|
|
161
|
+
transition: transform 225ms cubic-bezier(0.4, 0, 0.2, 1);
|
|
162
|
+
}
|
|
163
|
+
.collapsed-preview {
|
|
164
|
+
flex-basis: 100%;
|
|
165
|
+
display: flex;
|
|
166
|
+
align-items: flex-start;
|
|
167
|
+
}
|
|
168
|
+
.collapsed-label {
|
|
169
|
+
cursor: pointer;
|
|
170
|
+
flex-basis: 100%;
|
|
171
|
+
margin: 15px;
|
|
172
|
+
text-align: center;
|
|
173
|
+
display: -webkit-box;
|
|
174
|
+
-webkit-line-clamp: 2;
|
|
175
|
+
-webkit-box-orient: vertical;
|
|
176
|
+
overflow: hidden;
|
|
177
|
+
text-overflow: ellipsis;
|
|
178
|
+
}
|
|
179
|
+
.theme--light .repeater-line-wrapper {
|
|
180
|
+
border-color: rgba(0, 0, 0, 0.12);
|
|
181
|
+
}
|
|
182
|
+
.repeater-line-wrapper {
|
|
183
|
+
border: 1px solid;
|
|
184
|
+
border-bottom: none;
|
|
185
|
+
border-color: rgba(255, 255, 255, 0.12);
|
|
186
|
+
&:hover {
|
|
187
|
+
.repeater-action {
|
|
188
|
+
display: inline-flex;
|
|
189
|
+
}
|
|
190
|
+
.repeater-counter {
|
|
191
|
+
display: none;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
&.expanded {
|
|
195
|
+
> div > div > .expand-icon {
|
|
196
|
+
transform: rotate(180deg);
|
|
197
|
+
}
|
|
198
|
+
> div > div > .collapsed-label {
|
|
199
|
+
display: none;
|
|
200
|
+
}
|
|
201
|
+
> div > .repeater-fields {
|
|
202
|
+
display: flex;
|
|
203
|
+
}
|
|
204
|
+
> div > .collapsed-preview {
|
|
205
|
+
flex-basis: 0;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
.repeater-side-bar {
|
|
210
|
+
min-width: 24px;
|
|
211
|
+
position: relative;
|
|
212
|
+
display: flex;
|
|
213
|
+
flex-direction: column;
|
|
214
|
+
align-content: center;
|
|
215
|
+
justify-content: center;
|
|
216
|
+
.repeater-counter {
|
|
217
|
+
position: absolute;
|
|
218
|
+
align-self: center;
|
|
219
|
+
top: 10px;
|
|
220
|
+
}
|
|
221
|
+
.repeater-add-line-index {
|
|
222
|
+
position: absolute;
|
|
223
|
+
align-self: center;
|
|
224
|
+
top: -11px;
|
|
225
|
+
border-radius: 50%;
|
|
226
|
+
}
|
|
227
|
+
.repeater-handle-sort {
|
|
228
|
+
position: absolute;
|
|
229
|
+
align-self: center;
|
|
230
|
+
bottom: 0px;
|
|
231
|
+
height: 15px;
|
|
232
|
+
overflow: hidden;
|
|
233
|
+
cursor: grab;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
.repeater-add-line {
|
|
237
|
+
border-top: none;
|
|
238
|
+
}
|
|
239
|
+
.template-button {
|
|
240
|
+
padding: 0.5rem;
|
|
241
|
+
margin: 3px;
|
|
242
|
+
border: solid 1px #393939;
|
|
243
|
+
cursor: pointer;
|
|
244
|
+
}
|
|
245
|
+
.theme--light .template-button {
|
|
246
|
+
border-color: #e0e0e0;
|
|
247
|
+
}
|
|
248
|
+
</style>
|
|
249
|
+
|
|
250
|
+
<script>
|
|
251
|
+
import draggable from "vuedraggable";
|
|
252
|
+
import { getPointed, deepClone } from "@mapomodule/utils/helpers/objHelpers";
|
|
253
|
+
import { titleCase } from "@mapomodule/utils/helpers/formatters";
|
|
254
|
+
import { nameSpacedSlots } from "@mapomodule/utils/helpers/slots";
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* This component is made to manage a list of object that can be added/removed/reordered with a simple form.
|
|
258
|
+
*/
|
|
259
|
+
export default {
|
|
260
|
+
name: "Repeater",
|
|
261
|
+
components: {
|
|
262
|
+
// For recursive dynamic components is better to resolve dependencies at runtime to avoid circular deps
|
|
263
|
+
Form: () => import("@mapomodule/uikit/components/Form/Form.vue"),
|
|
264
|
+
draggable,
|
|
265
|
+
},
|
|
266
|
+
data() {
|
|
267
|
+
return {
|
|
268
|
+
items: this.value ? deepClone(this.value) : [],
|
|
269
|
+
tModalOpen: false,
|
|
270
|
+
tModalCallback: () => {},
|
|
271
|
+
collapsedStack: (this.value || []).map(() => !!this.collapsable),
|
|
272
|
+
};
|
|
273
|
+
},
|
|
274
|
+
props: {
|
|
275
|
+
// V-model of the array needed to edit the objects in realtime.
|
|
276
|
+
value: {
|
|
277
|
+
type: Array,
|
|
278
|
+
default: () => [],
|
|
279
|
+
},
|
|
280
|
+
// The main configuration that determines the arrangement of the fields in each line. It can be an array or an object. More info [here](#how-to-configure-the-repeater)
|
|
281
|
+
fields: {
|
|
282
|
+
// [`Array<FieldConfiguration>`](/components/Detail/Detail/#fieldconfiguration)
|
|
283
|
+
type: Array | Object,
|
|
284
|
+
default: () => [],
|
|
285
|
+
},
|
|
286
|
+
// Puts the input in an error state and passes through custom error messages.
|
|
287
|
+
errorMessages: {
|
|
288
|
+
type: Array,
|
|
289
|
+
default: () => [],
|
|
290
|
+
},
|
|
291
|
+
// Sets input label.
|
|
292
|
+
label: String,
|
|
293
|
+
// Makes all the repeater items readonly.
|
|
294
|
+
readonly: Boolean,
|
|
295
|
+
// Makes the repeater field sortable.
|
|
296
|
+
sortable: Boolean,
|
|
297
|
+
// Makes the repeater field collapsable.
|
|
298
|
+
collapsable: Boolean,
|
|
299
|
+
// Make the repeater multilanguage. This means that it's going to inherit the languages and the current language from the parent detail component, creating the translations for each line of the repeater.
|
|
300
|
+
translatable: Boolean,
|
|
301
|
+
// This callback is called during sort/add/remove item if the Repeater is sortable. Use this callback to change some prop of the items in the list.
|
|
302
|
+
sortCallback: {
|
|
303
|
+
type: Function,
|
|
304
|
+
default: () => {},
|
|
305
|
+
},
|
|
306
|
+
// 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.
|
|
307
|
+
collapsedLabel: {
|
|
308
|
+
type: String | Function,
|
|
309
|
+
default: null,
|
|
310
|
+
},
|
|
311
|
+
// This is mainly an internal property. It is used by DetailField to pass the list of languages inherited from the Detail component.
|
|
312
|
+
langs: {
|
|
313
|
+
// `Array<String>`
|
|
314
|
+
type: Array,
|
|
315
|
+
default() { return this.$mapo.$options?.content?.languages || []; },
|
|
316
|
+
},
|
|
317
|
+
// This is mainly an internal property. It is used by DetailField to pass the active language inherited from the Detail component.
|
|
318
|
+
currentLang: String,
|
|
319
|
+
maxHeight: String | Number,
|
|
320
|
+
},
|
|
321
|
+
watch: {
|
|
322
|
+
value(val) {
|
|
323
|
+
const isEmpty = (v) => !v || Object.keys(v).length == 0;
|
|
324
|
+
if (isEmpty(val) && isEmpty(this.items) || JSON.stringify(val) === JSON.stringify(this.items)) return;
|
|
325
|
+
this.items = (val && deepClone(val)) || [];
|
|
326
|
+
if (val.length != this.collapsedStack.length)
|
|
327
|
+
this.collapsedStack = (val || []).map(() => !!this.collapsable);
|
|
328
|
+
},
|
|
329
|
+
items(val) {
|
|
330
|
+
this.$emit("input", deepClone(val));
|
|
331
|
+
},
|
|
332
|
+
tModalOpen(val) {
|
|
333
|
+
!val && this.tModalCallback();
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
methods: {
|
|
337
|
+
isExpanded(index) {
|
|
338
|
+
return !this.collapsedStack[index];
|
|
339
|
+
},
|
|
340
|
+
async addItem(index) {
|
|
341
|
+
const element = {};
|
|
342
|
+
if (this.hasTemplates) {
|
|
343
|
+
const template = await this.chooseTemplate();
|
|
344
|
+
if (!template) return;
|
|
345
|
+
element[template.tCodeField] = template.tCode;
|
|
346
|
+
}
|
|
347
|
+
const newIndex = typeof index == "number" ? index : this.items.length;
|
|
348
|
+
this.items.splice(newIndex, 0, element);
|
|
349
|
+
this.collapsedStack.splice(newIndex, 0, false);
|
|
350
|
+
this.sortable &&
|
|
351
|
+
this.sortCallback({
|
|
352
|
+
moved: { element, newIndex },
|
|
353
|
+
items: this.items,
|
|
354
|
+
eventType: "add",
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
removeItem(index) {
|
|
358
|
+
const element = this.items[index];
|
|
359
|
+
this.items.splice(index, 1);
|
|
360
|
+
this.collapsedStack.splice(index, 1);
|
|
361
|
+
this.sortable &&
|
|
362
|
+
this.sortCallback({
|
|
363
|
+
moved: { element, oldIndex: index },
|
|
364
|
+
items: this.items,
|
|
365
|
+
eventType: "remove",
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
async chooseTemplate() {
|
|
369
|
+
this.tModalOpen = true;
|
|
370
|
+
return new Promise((resolve) => {
|
|
371
|
+
this.tModalCallback = function (template) {
|
|
372
|
+
resolve(template);
|
|
373
|
+
this.tModalCallback = () => {};
|
|
374
|
+
this.tModalOpen = false;
|
|
375
|
+
};
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
getErrors(index) {
|
|
379
|
+
return (this.errorMessages || [])[index] || {};
|
|
380
|
+
},
|
|
381
|
+
getFields(model) {
|
|
382
|
+
if (this.hasTemplates) {
|
|
383
|
+
const template = this.templates.find((t) => model[t.tCodeField] == t.tCode);
|
|
384
|
+
return template ? template.fields : [];
|
|
385
|
+
}
|
|
386
|
+
return this.fields;
|
|
387
|
+
},
|
|
388
|
+
templateSlots(model, slots) {
|
|
389
|
+
if (this.hasTemplates) {
|
|
390
|
+
const template = this.templates.find((t) => model[t.tCodeField] == t.tCode);
|
|
391
|
+
return nameSpacedSlots(slots, `template.${template.tCode}.`).reduce(
|
|
392
|
+
(acc, v) => ({ [`template.${template.tCode}.${v}`]: v, ...acc }),
|
|
393
|
+
{}
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
return Object.keys(slots).reduce((acc, v) => ({ [v]: v, ...acc }), {});
|
|
397
|
+
},
|
|
398
|
+
getCollapsedLabel(model, index) {
|
|
399
|
+
const fallback = this.$t("mapo.repeater.item", { numberItem: index + 1 });
|
|
400
|
+
switch (typeof this.collapsedLabel) {
|
|
401
|
+
case "string":
|
|
402
|
+
return getPointed(model, this.collapsedLabel, fallback);
|
|
403
|
+
case "function":
|
|
404
|
+
return this.collapsedLabel(model);
|
|
405
|
+
default:
|
|
406
|
+
const field = this.getFields(model).find(
|
|
407
|
+
(f) => !f.type || f.type.lower() == "text"
|
|
408
|
+
);
|
|
409
|
+
return getPointed(model, field.value, fallback);
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
draggableReorder(event) {
|
|
413
|
+
const { newIndex, oldIndex } = event.moved;
|
|
414
|
+
const stackItem = this.collapsedStack[oldIndex];
|
|
415
|
+
this.collapsedStack.splice(oldIndex, 1);
|
|
416
|
+
this.collapsedStack.splice(newIndex, 0, stackItem);
|
|
417
|
+
this.sortCallback({ ...event, items: this.items, eventType: "move" });
|
|
418
|
+
},
|
|
419
|
+
toggleExpand(index, forceValue) {
|
|
420
|
+
this.collapsedStack[index] =
|
|
421
|
+
forceValue == undefined ? !this.collapsedStack[index] : !forceValue;
|
|
422
|
+
this.collapsedStack = [...this.collapsedStack];
|
|
423
|
+
},
|
|
424
|
+
collapseAll() {
|
|
425
|
+
this.collapsedStack = this.collapsedStack.map(() => true);
|
|
426
|
+
},
|
|
427
|
+
},
|
|
428
|
+
computed: {
|
|
429
|
+
hasTemplates() {
|
|
430
|
+
return typeof this.fields == "object" && !Array.isArray(this.fields);
|
|
431
|
+
},
|
|
432
|
+
templates() {
|
|
433
|
+
const templates = {};
|
|
434
|
+
if (this.hasTemplates) {
|
|
435
|
+
Object.keys(this.fields).forEach((tKey) => {
|
|
436
|
+
const tValue = this.fields[tKey];
|
|
437
|
+
const { preview, description } = tValue;
|
|
438
|
+
templates[tKey] = {
|
|
439
|
+
fields: tValue.fields || tValue,
|
|
440
|
+
name: tValue.name || titleCase(tKey.replace(/_/, " ")),
|
|
441
|
+
tCode: tValue.tCode || tKey,
|
|
442
|
+
tCodeField: tValue.tCodeField || "tCode",
|
|
443
|
+
preview,
|
|
444
|
+
description,
|
|
445
|
+
};
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
return Object.values(templates);
|
|
449
|
+
},
|
|
450
|
+
maxHeightStyle() {
|
|
451
|
+
if (this.maxHeight !== undefined) {
|
|
452
|
+
const maxHeight = isNaN(this.maxHeight) ? this.maxHeight : `${this.maxHeight}px`;
|
|
453
|
+
return { maxHeight, paddingTop: "15px", overflowX: "hidden", overflowY: "auto" };
|
|
454
|
+
}
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
</script>
|
|
459
|
+
|
|
460
|
+
<docs>
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
## How to configure the repeater
|
|
464
|
+
|
|
465
|
+
In the Repeater the most important attr is the `fields` attr.
|
|
466
|
+
Through the `fields` attr you can configure your repeater. It accepts an array of [`FieldConfiguration`](/components/Detail/Detail/#fieldconfiguration) or an object.
|
|
467
|
+
In the case of the [`FieldConfiguration`](/components/Detail/Detail/#fieldconfiguration) array the result will be a **Simple Repeater**: each line will have the same fields as the previous one.
|
|
468
|
+
In case we use an object instead of the array we are configuring the Repeater to manage different templates.
|
|
469
|
+
A **Template Repeater** is a repeater that allows the user to choose a different template for each line.
|
|
470
|
+
Each key of the object represents a different template. Each value of these keys is an array of [`FieldConfiguration`](/components/Detail/Detail/#fieldconfiguration).
|
|
471
|
+
In this way we can define how many templates we want and leave the user the choice on the fields to be inserted for each line.
|
|
472
|
+
The keys of the "template" configuration can also be objects.
|
|
473
|
+
Using objects we can better specify some additional properties of the template.
|
|
474
|
+
|
|
475
|
+
#### The template configuration
|
|
476
|
+
|
|
477
|
+
|Name|Description|Type|Required|Default|
|
|
478
|
+
|---|---|---|---|---|
|
|
479
|
+
|name|The name of the template.|`String`|`false`|The key name of the template|
|
|
480
|
+
|description|The description of the template.|`String`|`false`|`null`|
|
|
481
|
+
|preview|The preview image of the template. It must be an image url.|`String`|`false`|A skeleton boilerplate placeholder|
|
|
482
|
+
|tCode|The identifier of the template.|`String`|`false`|The key name of the template|
|
|
483
|
+
|tCodeField|The key where the repeater saves the template identifier in the row|`String`|`false`|`tCode`|
|
|
484
|
+
|fields|The actual fields of the template.|[`Array<FieldConfiguration>`](/components/Detail/Detail/#fieldconfiguration)|`true`|-|
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
<br><br>
|
|
488
|
+
|
|
489
|
+
#### Example of a Simple Repeater configuration:
|
|
490
|
+
This is an example of the fields attr.
|
|
491
|
+
```js
|
|
492
|
+
[ // here we have only the list of fields
|
|
493
|
+
{ value: "sku", class: "col-md-6" },
|
|
494
|
+
{ value: "name", class: "col-md-6" },
|
|
495
|
+
]
|
|
496
|
+
```
|
|
497
|
+
#### Example of a Template Repeater configuration:
|
|
498
|
+
This is an example of the fields attr.
|
|
499
|
+
```js
|
|
500
|
+
{ // here we have the object that contains the templates
|
|
501
|
+
template_1: [ // This template prvides only the list of fields. Other configurations will falback to defaults.
|
|
502
|
+
{ value: "title", class: "col-md-6" },
|
|
503
|
+
{ value: "subtitle", class: "col-md-6" },
|
|
504
|
+
],
|
|
505
|
+
template_2: {
|
|
506
|
+
name: "Custom template", // the name of the template. (by default it takes the key name `temlpate_2`)
|
|
507
|
+
description: "custom description", // additional description.
|
|
508
|
+
preview: "https://blog.openreplay.com/c4052718994cbc8eb6dac8c89c23ba06/img3.gif", // Custom preview image of the template.
|
|
509
|
+
tCode: "titledatecontent", // this is the identifier of the template (by defaults it takes the key name `template_2`)
|
|
510
|
+
tCodeField: "typology", // this is the key where the repeater saves the template type in the row. (by default `tCode`)
|
|
511
|
+
fields: [ // the actual fields of the template.
|
|
512
|
+
{ value: "title", class: "col-md-6" },
|
|
513
|
+
{ value: "date", type: "date", class: "col-md-6" },
|
|
514
|
+
{ value: "content", type: "editor" },
|
|
515
|
+
],
|
|
516
|
+
},
|
|
517
|
+
}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
## Live Demo
|
|
521
|
+
|
|
522
|
+
<br>
|
|
523
|
+
|
|
524
|
+
::: warning LIVE DEMO 🎉🎉🎉
|
|
525
|
+
This is an interactive example. You can play with it but remember that all http features are disabled since there is no backend server.
|
|
526
|
+
:::
|
|
527
|
+
|
|
528
|
+
|
|
529
|
+
::: demo
|
|
530
|
+
<template>
|
|
531
|
+
<v-app>
|
|
532
|
+
<div class="d-flex justify-end"><ThemeToggle/></div>
|
|
533
|
+
<div>
|
|
534
|
+
<h3>Simple Repeater:</h3>
|
|
535
|
+
<Repeater v-model="data1" :fields="fields1" label="Contents" sortable />
|
|
536
|
+
<h4>Contents:</h4>
|
|
537
|
+
<pre style="background-color: unset">{{ data1 }}</pre>
|
|
538
|
+
</div>
|
|
539
|
+
<div>
|
|
540
|
+
<h3>Repeater with templates:</h3>
|
|
541
|
+
<Repeater v-model="data2" :fields="fields2" label="Contents" sortable />
|
|
542
|
+
<h4>Contents:</h4>
|
|
543
|
+
<pre style="background-color: unset">{{ data2 }}</pre>
|
|
544
|
+
</div>
|
|
545
|
+
<div>
|
|
546
|
+
<h3>Translatable Repeater:</h3>
|
|
547
|
+
<DetailLangSwitch class="mb-4" v-model="currentLanguage" :langs="languages"/>
|
|
548
|
+
<Repeater v-model="data3" :fields="fields1" :langs="languages" :currentLang="currentLanguage" label="Contents" sortable translatable />
|
|
549
|
+
<h4>Contents:</h4>
|
|
550
|
+
<pre style="background-color: unset">{{ data3 }}</pre>
|
|
551
|
+
</div>
|
|
552
|
+
</v-app>
|
|
553
|
+
</template>
|
|
554
|
+
|
|
555
|
+
<script>
|
|
556
|
+
export default {
|
|
557
|
+
data() {
|
|
558
|
+
return {
|
|
559
|
+
data1: [],
|
|
560
|
+
data2: [],
|
|
561
|
+
data3: [],
|
|
562
|
+
fields1: [
|
|
563
|
+
{ value: "sku", class: "col-md-6" },
|
|
564
|
+
{ value: "name", class: "col-md-6" },
|
|
565
|
+
],
|
|
566
|
+
fields2: {
|
|
567
|
+
template_1: [
|
|
568
|
+
{ value: "title", class: "col-md-6" },
|
|
569
|
+
{ value: "subtitle", class: "col-md-6" },
|
|
570
|
+
],
|
|
571
|
+
template_2: {
|
|
572
|
+
name: "Custom template",
|
|
573
|
+
description: "custom description",
|
|
574
|
+
preview:
|
|
575
|
+
"https://blog.openreplay.com/c4052718994cbc8eb6dac8c89c23ba06/img3.gif",
|
|
576
|
+
fields: [
|
|
577
|
+
{ value: "title", class: "col-md-6" },
|
|
578
|
+
{ value: "date", type: "date", class: "col-md-6" },
|
|
579
|
+
{ value: "content", type: "editor" },
|
|
580
|
+
],
|
|
581
|
+
},
|
|
582
|
+
},
|
|
583
|
+
languages: ['it', 'en'],
|
|
584
|
+
currentLanguage: 'it'
|
|
585
|
+
};
|
|
586
|
+
},
|
|
587
|
+
};
|
|
588
|
+
</script>
|
|
589
|
+
:::
|
|
590
|
+
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
</docs>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="container">
|
|
3
|
+
<div class="preview">
|
|
4
|
+
<span class="preview__title">{{ getTitle }}</span>
|
|
5
|
+
<br />
|
|
6
|
+
<span class="preview__url">{{domain}}{{ getPermalink }}</span>
|
|
7
|
+
<br />
|
|
8
|
+
<span class="preview__desc">{{ getDescription }}</span>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<style lang="scss" scoped>
|
|
14
|
+
.container {
|
|
15
|
+
background: #ffffff;
|
|
16
|
+
border-radius: 3px;
|
|
17
|
+
}
|
|
18
|
+
.preview {
|
|
19
|
+
display: block;
|
|
20
|
+
max-width: 32em;
|
|
21
|
+
margin: 30px 8px;
|
|
22
|
+
&__title {
|
|
23
|
+
color: #035ac6;
|
|
24
|
+
font-size: 1.2em;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
&:hover {
|
|
27
|
+
text-decoration: underline;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
&__url {
|
|
31
|
+
color: green;
|
|
32
|
+
font-size: 0.92em;
|
|
33
|
+
}
|
|
34
|
+
&__desc {
|
|
35
|
+
color: #9b9da1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
39
|
+
|
|
40
|
+
<script>
|
|
41
|
+
/**
|
|
42
|
+
* This component is used to make a preview of seo data.
|
|
43
|
+
*/
|
|
44
|
+
export default {
|
|
45
|
+
name: "SeoPreview",
|
|
46
|
+
props: {
|
|
47
|
+
// V-model for DetailField (need to be an object `{title, permalink, description}`)
|
|
48
|
+
value:{
|
|
49
|
+
type: Object,
|
|
50
|
+
default: () => {}
|
|
51
|
+
},
|
|
52
|
+
// Seo title
|
|
53
|
+
title: {
|
|
54
|
+
type: String
|
|
55
|
+
},
|
|
56
|
+
// Seo permalink
|
|
57
|
+
permalink: {
|
|
58
|
+
type: String,
|
|
59
|
+
default: "how-to-dive"
|
|
60
|
+
},
|
|
61
|
+
// Seo description
|
|
62
|
+
description: {
|
|
63
|
+
type: String
|
|
64
|
+
},
|
|
65
|
+
domain: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: process.browser ? `${window.location.origin}/` : ""
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
computed: {
|
|
71
|
+
getTitle(){
|
|
72
|
+
if (this.value && this.value.title)
|
|
73
|
+
return this.value.title
|
|
74
|
+
return this.title || this.$t("mapo.seoPreview.title")
|
|
75
|
+
},
|
|
76
|
+
getPermalink(){
|
|
77
|
+
if (this.value && this.value.permalink)
|
|
78
|
+
return this.value.permalink
|
|
79
|
+
return this.permalink
|
|
80
|
+
},
|
|
81
|
+
getDescription(){
|
|
82
|
+
if (this.value && this.value.description)
|
|
83
|
+
return this.value.description
|
|
84
|
+
return this.description || this.$t("mapo.seoPreview.description")
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
};
|
|
89
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default ({ isDark, base }) => ({
|
|
2
|
+
plugins: "mapomedia preview paste importcss searchreplace autolink directionality code visualblocks visualchars fullscreen image link media template codesample table charmap hr pagebreak nonbreaking anchor insertdatetime advlist lists wordcount textpattern noneditable help charmap quickbars emoticons",
|
|
3
|
+
menubar: "file edit view insert format tools table help",
|
|
4
|
+
menu: {
|
|
5
|
+
insert: {
|
|
6
|
+
title: "Insert",
|
|
7
|
+
items: "link mapomedia media template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor | insertdatetime",
|
|
8
|
+
},
|
|
9
|
+
},
|
|
10
|
+
toolbar: "undo redo | bold italic underline strikethrough | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview | mapomedia media template link anchor codesample | ltr rtl",
|
|
11
|
+
toolbar_sticky: true,
|
|
12
|
+
image_advtab: true,
|
|
13
|
+
importcss_append: true,
|
|
14
|
+
template_cdate_format: "[Date Created (CDATE): %m/%d/%Y : %H:%M:%S]",
|
|
15
|
+
template_mdate_format: "[Date Modified (MDATE): %m/%d/%Y : %H:%M:%S]",
|
|
16
|
+
height: 400,
|
|
17
|
+
image_caption: true,
|
|
18
|
+
quickbars_insert_toolbar: "mapomedia quicktable",
|
|
19
|
+
quickbars_selection_toolbar: "bold italic | quicklink h2 h3 blockquote mapomedia quicktable",
|
|
20
|
+
noneditable_noneditable_class: "mceNonEditable",
|
|
21
|
+
toolbar_mode: "sliding",
|
|
22
|
+
contextmenu: "link mapomedia table",
|
|
23
|
+
skin_url: isDark ? `${base}mapo/tinymce-skins/mapo-dark` : `${base}mapo/tinymce-skins/mapo-light`,
|
|
24
|
+
content_style: "body { font-family:Helvetica,Arial,sans-serif; font-size:14px }",
|
|
25
|
+
});
|