@mapomodule/uikit 1.0.0-alpha.21 → 1.0.0-alpha.24
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 +80 -0
- package/components/ConfirmDialog.vue +10 -14
- package/components/Detail/Detail.vue +246 -365
- package/components/DropArea.vue +17 -33
- package/components/Form/Form.vue +228 -0
- package/components/{Detail/DetailField.vue → Form/FormField.vue} +35 -15
- package/components/Form/FormGroup.vue +108 -0
- package/components/Form/FormTabs.vue +151 -0
- package/components/{Detail → Form}/defaults.js +0 -0
- package/components/{fields → Form/fields}/DateField.vue +3 -3
- package/components/{fields → Form/fields}/FileField.vue +0 -0
- package/components/{fields → Form/fields}/FksField.vue +2 -2
- package/components/{fields → Form/fields}/MediaField.vue +4 -5
- package/components/{fields → Form/fields}/MediaM2mField.vue +3 -3
- package/components/Form/fields/Repeater.vue +575 -0
- package/components/{fields → Form/fields}/SeoPreview.vue +10 -10
- package/components/{fields → Form/fields}/wygEditor/defaults.js +0 -0
- package/components/{fields → Form/fields}/wygEditor/utils/events.js +0 -0
- package/components/{fields → Form/fields}/wygEditor/utils/mapomedia.plugin.js +0 -0
- package/components/{fields → Form/fields}/wygEditor/utils/script.injector.js +0 -0
- package/components/{fields → Form/fields}/wygEditor/wygEditor.vue +0 -0
- package/components/LangSwitcher.vue +44 -0
- package/components/List/List.vue +14 -15
- package/components/List/ListActions.vue +5 -5
- package/components/List/ListFilters.vue +9 -2
- package/components/List/ListHead.vue +1 -1
- package/components/List/ListQuickEdit.vue +21 -104
- package/components/List/ListTable.vue +15 -18
- package/components/Login.vue +5 -4
- package/components/LogoutButton.vue +43 -28
- package/components/MediaManager/MediaEditor.vue +20 -18
- package/components/MediaManager/MediaFolders.vue +14 -19
- package/components/MediaManager/MediaGallery.vue +1 -1
- package/components/MediaManager/MediaManager.vue +22 -15
- package/components/MediaManager/MediaManagerDialog.vue +2 -1
- package/components/MediaManager/MediaUploader.vue +6 -7
- package/components/SnackBar.vue +2 -3
- package/components/layout/Sidebar/SidebarFooter.vue +6 -25
- package/components/layout/Sidebar/SidebarListItem.vue +2 -2
- package/components/layout/Sidebar/SidebarProfile.vue +2 -2
- package/defaults.js +70 -24
- package/module.js +12 -4
- package/package.json +4 -3
- package/pages/index.vue +1 -1
- package/translations/en-US.js +129 -0
- package/translations/it-IT.js +131 -0
- package/components/fields/Repeater.vue +0 -338
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
mapo: {
|
|
3
|
+
// Generics
|
|
4
|
+
cancel: "Cancel",
|
|
5
|
+
save: "Save",
|
|
6
|
+
apply: "Apply",
|
|
7
|
+
confirm: "Confirm",
|
|
8
|
+
ok: "OK",
|
|
9
|
+
close: "Close",
|
|
10
|
+
edit: "Edit",
|
|
11
|
+
delete: "Delete",
|
|
12
|
+
add: "Add",
|
|
13
|
+
remove: "Remove",
|
|
14
|
+
clear: "Clear",
|
|
15
|
+
expand: "Expand",
|
|
16
|
+
collapse: "Collapse",
|
|
17
|
+
search: "Search...",
|
|
18
|
+
create: "Create",
|
|
19
|
+
createContinue: "Create and continue",
|
|
20
|
+
saveContinue: "Save and continue",
|
|
21
|
+
back: "Back",
|
|
22
|
+
genericError: "Something whent bad, please try again later...",
|
|
23
|
+
confirmDelete: "Are you sure you want to delete this item?",
|
|
24
|
+
fetchingData: "Fetching data...",
|
|
25
|
+
login: "Login",
|
|
26
|
+
loginError: "Cannot login right now. Try again later.",
|
|
27
|
+
logout: "Logout",
|
|
28
|
+
// Elements
|
|
29
|
+
name: "Name",
|
|
30
|
+
description: "Description",
|
|
31
|
+
mime: "MIME Type",
|
|
32
|
+
fileName: "File name",
|
|
33
|
+
folder: "Folder",
|
|
34
|
+
created: "Created at",
|
|
35
|
+
size: "Size",
|
|
36
|
+
altTag: "Alt Tag",
|
|
37
|
+
titleTag: "Title Tag",
|
|
38
|
+
linkedModels: "Linked Models",
|
|
39
|
+
|
|
40
|
+
// pages/index.vue
|
|
41
|
+
index: {
|
|
42
|
+
welcomeMessage:
|
|
43
|
+
"Congratulations!! 🥳 You successfully installed Mapo!",
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// ConfirmDialog.vue
|
|
47
|
+
confirmDialog: {
|
|
48
|
+
areYouSure: "Are you sure of what you are doing?",
|
|
49
|
+
},
|
|
50
|
+
// DropArea.vue
|
|
51
|
+
dropArea: {
|
|
52
|
+
dropOrClick: "Drop your file(s) here, or click to select them.",
|
|
53
|
+
onlyOneFile: "Only one file can be uploaded at a time...",
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
// Form/fields/MediaField.vue
|
|
57
|
+
mediaField: {
|
|
58
|
+
confirmRemove: "Are you sure to want to remove this media?",
|
|
59
|
+
},
|
|
60
|
+
// Form/fields/MediaM2mField.vue
|
|
61
|
+
mediaM2MField: {
|
|
62
|
+
mediaCarousel: "Media Carousel",
|
|
63
|
+
newSelection: "New Selection",
|
|
64
|
+
},
|
|
65
|
+
// Form/fields/Repeater.vue
|
|
66
|
+
repeater: {
|
|
67
|
+
addHere: "Add here",
|
|
68
|
+
selectTemplate: "Select template",
|
|
69
|
+
item: "Item {numberItem}",
|
|
70
|
+
},
|
|
71
|
+
// Form/fields/SeoPreview.vue
|
|
72
|
+
seoPreview: {
|
|
73
|
+
title: "It was the best of times, it was the blurst of times, it was the ...",
|
|
74
|
+
description:
|
|
75
|
+
"This is an example description that will get replaced when you start typing. Make sure to keep descriptions mobile-friendly and keyword-rich!",
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// List/List.vue
|
|
79
|
+
list: {
|
|
80
|
+
allSelected: "All items selected",
|
|
81
|
+
NSelected: "{numberItems} items selected",
|
|
82
|
+
selectAll: "Select all",
|
|
83
|
+
},
|
|
84
|
+
// List/ListActions.vue
|
|
85
|
+
listActions: {
|
|
86
|
+
groupActions: "Group actions",
|
|
87
|
+
permanentDelete: "Permanent delete",
|
|
88
|
+
selectionRequired: "You need to select at least one item.",
|
|
89
|
+
},
|
|
90
|
+
// List/ListFilters.vue
|
|
91
|
+
listFilters: { filter: "Filter" },
|
|
92
|
+
// List/ListHead.vue
|
|
93
|
+
listHead: { addNew: "Add new" },
|
|
94
|
+
// List/ListQuickEdit.vue
|
|
95
|
+
listQuickEdit: { badInput: "Bad input, correct wrong fields." },
|
|
96
|
+
// List/ListTable.vue
|
|
97
|
+
listTable: {
|
|
98
|
+
quickAdd: "Quick Add",
|
|
99
|
+
toggleOrder: "Toggle reordering",
|
|
100
|
+
errorOrder: "Reorder failed",
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
// MediaManager/MediaEditor.vue
|
|
104
|
+
mediaEditor: {
|
|
105
|
+
changeFile: "Change File",
|
|
106
|
+
maintainOldUrl: "Maintain old URL",
|
|
107
|
+
confirmDelete: "Are you sure you want to delete this media?",
|
|
108
|
+
},
|
|
109
|
+
// MediaManager/MediaFolders.vue
|
|
110
|
+
mediaFolders: {
|
|
111
|
+
noFolders: "No folders here... Create a new one!",
|
|
112
|
+
newFolder: "Add new folder",
|
|
113
|
+
editFolder: "Edit folder",
|
|
114
|
+
folderName: "Folder name",
|
|
115
|
+
confirmDelete:
|
|
116
|
+
"Are you sure to delele this folder and all its content?",
|
|
117
|
+
},
|
|
118
|
+
// MediaManager/MediaGallery.vue
|
|
119
|
+
mediaGallery: { noMediaFound: "No media found..." },
|
|
120
|
+
// MediaManager/MediaManager.vue
|
|
121
|
+
mediaManager: {
|
|
122
|
+
gallery: "Gallery",
|
|
123
|
+
uploader: "Uploader",
|
|
124
|
+
fileInfo: "File info succesfully updated",
|
|
125
|
+
},
|
|
126
|
+
// MediaManager/MediaUploader.vue
|
|
127
|
+
mediaUploader: { success: "{numberFiles} files succesfully uploaded" },
|
|
128
|
+
},
|
|
129
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
mapo: {
|
|
3
|
+
// Generics
|
|
4
|
+
cancel: "Annulla",
|
|
5
|
+
save: "Salva",
|
|
6
|
+
apply: "Applica",
|
|
7
|
+
confirm: "Conferma",
|
|
8
|
+
ok: "OK",
|
|
9
|
+
close: "Chiudi",
|
|
10
|
+
edit: "Modifica",
|
|
11
|
+
delete: "Elimina",
|
|
12
|
+
add: "Aggiungi",
|
|
13
|
+
remove: "Rimuovi",
|
|
14
|
+
clear: "Rimuovi",
|
|
15
|
+
expand: "Espandi",
|
|
16
|
+
collapse: "Comprimi",
|
|
17
|
+
search: "Cerca...",
|
|
18
|
+
create: "Crea",
|
|
19
|
+
createContinue: "Crea e continua",
|
|
20
|
+
saveContinue: "Salva e continua",
|
|
21
|
+
back: "Indietro",
|
|
22
|
+
genericError: "Qualcosa è andato storto, riprova più tardi...",
|
|
23
|
+
confirmDelete: "Vuoi veramente eliminare questo elemento?",
|
|
24
|
+
fetchingData: "Caricamento in corso...",
|
|
25
|
+
login: "Login",
|
|
26
|
+
loginError:
|
|
27
|
+
"Impossibile effettuare il login in questo momento. Riprova più tardi.",
|
|
28
|
+
logout: "Esci",
|
|
29
|
+
// Elements
|
|
30
|
+
name: "Nome",
|
|
31
|
+
description: "Descrizione",
|
|
32
|
+
mime: "Tipo MIME",
|
|
33
|
+
fileName: "Nome File",
|
|
34
|
+
folder: "Cartella",
|
|
35
|
+
created: "Creato il",
|
|
36
|
+
size: "Dimensioni",
|
|
37
|
+
altTag: "Alt Tag",
|
|
38
|
+
titleTag: "Title Tag",
|
|
39
|
+
linkedModels: "Modelli collegati",
|
|
40
|
+
|
|
41
|
+
// pages/index.vue
|
|
42
|
+
index: {
|
|
43
|
+
welcomeMessage:
|
|
44
|
+
"Congratulazioni!! 🥳 Mapo è stato installato correttamente!",
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// ConfirmDialog.vue
|
|
48
|
+
confirmDialog: {
|
|
49
|
+
areYouSure: "Sei sicuro di ciò che vuoi fare?",
|
|
50
|
+
},
|
|
51
|
+
// DropArea.vue
|
|
52
|
+
dropArea: {
|
|
53
|
+
dropOrClick:
|
|
54
|
+
"Trascina qui i tuoi file, o clicca per selezionarne uno",
|
|
55
|
+
onlyOneFile: "È possibile caricare un solo file alla volta...",
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// Form/fields/MediaField.vue
|
|
59
|
+
mediaField: { confirmRemove: "Vuoi veramente rimuovere questo media?" },
|
|
60
|
+
// Form/fields/MediaM2mField.vue
|
|
61
|
+
mediaM2MField: {
|
|
62
|
+
mediaCarousel: "Galleria Media",
|
|
63
|
+
newSelection: "Nuova selezione",
|
|
64
|
+
},
|
|
65
|
+
// Form/fields/Repeater.vue
|
|
66
|
+
repeater: {
|
|
67
|
+
addHere: "Aggiungi qui",
|
|
68
|
+
selectTemplate: "Seleziona template",
|
|
69
|
+
item: "Elemento n.{numberItem}",
|
|
70
|
+
},
|
|
71
|
+
// Form/fields/SeoPreview.vue
|
|
72
|
+
seoPreview: {
|
|
73
|
+
title: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
|
|
74
|
+
description:
|
|
75
|
+
"Questa è una descrizione di esempio che verrà sostituita non appena inizierai a compilare i campi. Assicurati che le descrizioni siano mobile-friendly e keyword-rich!",
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// List/List.vue
|
|
79
|
+
list: {
|
|
80
|
+
allSelected: "Tutti gli elementi selezionati",
|
|
81
|
+
NSelected: "{numberItems} elementi selezionati",
|
|
82
|
+
selectAll: "Seleziona tutti",
|
|
83
|
+
},
|
|
84
|
+
// List/ListActions.vue
|
|
85
|
+
listActions: {
|
|
86
|
+
groupActions: "Azioni di gruppo",
|
|
87
|
+
permanentDelete: "Eliminazione permanente",
|
|
88
|
+
selectionRequired: "Devi selezionare almeno un elemento",
|
|
89
|
+
},
|
|
90
|
+
// List/ListFilters.vue
|
|
91
|
+
listFilters: { filter: "Filtra" },
|
|
92
|
+
// List/ListHead.vue
|
|
93
|
+
listHead: { addNew: "Aggiungi nuovo" },
|
|
94
|
+
// List/ListQuickEdit.vue
|
|
95
|
+
listQuickEdit: {
|
|
96
|
+
badInput: "Alcuni campi sono compilati in modo errato.",
|
|
97
|
+
},
|
|
98
|
+
// List/ListTable.vue
|
|
99
|
+
listTable: {
|
|
100
|
+
quickAdd: "Aggiunta veloce",
|
|
101
|
+
toggleOrder: "Attiva/Disattiva riordinamento elementi",
|
|
102
|
+
errorOrder: "Riordinamento fallito",
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// MediaManager/MediaEditor.vue
|
|
106
|
+
mediaEditor: {
|
|
107
|
+
changeFile: "Cambia File",
|
|
108
|
+
maintainOldUrl: "Mantieni URL precedente",
|
|
109
|
+
confirmDelete: "Vuoi veramente eliminare questo media?",
|
|
110
|
+
},
|
|
111
|
+
// MediaManager/MediaFolders.vue
|
|
112
|
+
mediaFolders: {
|
|
113
|
+
noFolders: "Non sono presenti cartelle... Creane una!",
|
|
114
|
+
newFolder: "Crea nuova cartella",
|
|
115
|
+
editFolder: "Modifica cartella",
|
|
116
|
+
folderName: "Nome cartella",
|
|
117
|
+
confirmDelete:
|
|
118
|
+
"Vuoi veramente eliminare questa cartella e tutti i suoi contenuti?",
|
|
119
|
+
},
|
|
120
|
+
// MediaManager/MediaGallery.vue
|
|
121
|
+
mediaGallery: { noMediaFound: "Nessun media individuato..." },
|
|
122
|
+
// MediaManager/MediaManager.vue
|
|
123
|
+
mediaManager: {
|
|
124
|
+
gallery: "Galleria",
|
|
125
|
+
uploader: "Caricamento Media",
|
|
126
|
+
fileInfo: "File info succesfully updated",
|
|
127
|
+
},
|
|
128
|
+
// MediaManager/MediaUploader.vue
|
|
129
|
+
mediaUploader: { success: "{numberFiles} file caricati" },
|
|
130
|
+
},
|
|
131
|
+
};
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="container pa-0">
|
|
3
|
-
<span class="repeater-label">{{ label }}:</span>
|
|
4
|
-
<v-divider />
|
|
5
|
-
<draggable
|
|
6
|
-
v-model="items"
|
|
7
|
-
handle=".repeater-handle-sort"
|
|
8
|
-
animation="150"
|
|
9
|
-
@change="sortCallback({ ...$event, items, eventType: 'move' })"
|
|
10
|
-
>
|
|
11
|
-
<div
|
|
12
|
-
class="repeater-wrapper"
|
|
13
|
-
v-for="(model, index) in items"
|
|
14
|
-
:key="index"
|
|
15
|
-
>
|
|
16
|
-
<div class="d-flex">
|
|
17
|
-
<v-divider vertical />
|
|
18
|
-
<div class="row ma-0">
|
|
19
|
-
<div
|
|
20
|
-
v-for="(field, i) in parseFields(model)"
|
|
21
|
-
:key="i"
|
|
22
|
-
:class="field.class || 'col-12'"
|
|
23
|
-
>
|
|
24
|
-
<DetailField
|
|
25
|
-
v-model="items[index]"
|
|
26
|
-
:conf="field"
|
|
27
|
-
:errors="getErrors(index)"
|
|
28
|
-
/>
|
|
29
|
-
</div>
|
|
30
|
-
</div>
|
|
31
|
-
<div class="repeater-side-bar grey lighten-2">
|
|
32
|
-
<span
|
|
33
|
-
class="repeater-counter grey--text text--darken-2 text-truncate"
|
|
34
|
-
>{{ index + 1 }}</span
|
|
35
|
-
>
|
|
36
|
-
<v-tooltip right>
|
|
37
|
-
<template v-slot:activator="{ on, attrs }">
|
|
38
|
-
<v-icon
|
|
39
|
-
v-if="!readonly && sortable"
|
|
40
|
-
v-bind="attrs"
|
|
41
|
-
v-on="on"
|
|
42
|
-
color="grey darken-3"
|
|
43
|
-
class="grey lighten-2 repeater-action repeater-add-line-index"
|
|
44
|
-
@click="addItem(index)"
|
|
45
|
-
>mdi-plus-circle-outline</v-icon
|
|
46
|
-
>
|
|
47
|
-
</template>
|
|
48
|
-
<span>Add here</span>
|
|
49
|
-
</v-tooltip>
|
|
50
|
-
<v-tooltip right>
|
|
51
|
-
<template v-slot:activator="{ on, attrs }">
|
|
52
|
-
<v-hover v-slot="{ hover }">
|
|
53
|
-
<v-icon
|
|
54
|
-
v-if="!readonly"
|
|
55
|
-
v-bind="attrs"
|
|
56
|
-
v-on="on"
|
|
57
|
-
:color="hover ? 'error' : 'grey darken-3'"
|
|
58
|
-
class="repeater-action repeater-remove-line"
|
|
59
|
-
@click="removeItem(index)"
|
|
60
|
-
>mdi-minus-circle-outline</v-icon
|
|
61
|
-
>
|
|
62
|
-
</v-hover>
|
|
63
|
-
</template>
|
|
64
|
-
<span>Remove</span>
|
|
65
|
-
</v-tooltip>
|
|
66
|
-
<v-icon
|
|
67
|
-
v-if="!readonly && sortable"
|
|
68
|
-
color="grey darken-3"
|
|
69
|
-
class="repeater-action repeater-handle-sort"
|
|
70
|
-
>mdi-drag</v-icon
|
|
71
|
-
>
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
<v-divider />
|
|
75
|
-
</div>
|
|
76
|
-
</draggable>
|
|
77
|
-
<div class="d-flex justify-end">
|
|
78
|
-
<v-btn
|
|
79
|
-
class="repeater-add-line"
|
|
80
|
-
@click="addItem"
|
|
81
|
-
:disabled="readonly"
|
|
82
|
-
outlined
|
|
83
|
-
tile
|
|
84
|
-
text
|
|
85
|
-
>
|
|
86
|
-
<v-icon>mdi-plus</v-icon> Add</v-btn
|
|
87
|
-
>
|
|
88
|
-
</div>
|
|
89
|
-
<v-dialog v-if="hasTemplates" v-model="tModalOpen" width="600" scrollable>
|
|
90
|
-
<v-card>
|
|
91
|
-
<v-card-title class="text-h5"> Select template </v-card-title>
|
|
92
|
-
<v-card-text>
|
|
93
|
-
<div class="row mt-4">
|
|
94
|
-
<div
|
|
95
|
-
v-for="(template, i) in templates"
|
|
96
|
-
:key="i"
|
|
97
|
-
class="col-12 col-md-6 pa-0"
|
|
98
|
-
>
|
|
99
|
-
<div @click="tModalCallback(template)" class="template-button">
|
|
100
|
-
<span class="text-h5">{{ template.name }}</span
|
|
101
|
-
><br />
|
|
102
|
-
<span>{{ template.description }}</span>
|
|
103
|
-
<v-img
|
|
104
|
-
v-if="template.preview"
|
|
105
|
-
max-height="150"
|
|
106
|
-
min-width="250px"
|
|
107
|
-
:src="template.preview"
|
|
108
|
-
/>
|
|
109
|
-
<v-skeleton-loader
|
|
110
|
-
v-else
|
|
111
|
-
boilerplate
|
|
112
|
-
min-width="250px"
|
|
113
|
-
type="list-item-avatar-three-line"
|
|
114
|
-
/>
|
|
115
|
-
</div>
|
|
116
|
-
</div>
|
|
117
|
-
</div>
|
|
118
|
-
</v-card-text>
|
|
119
|
-
</v-card>
|
|
120
|
-
</v-dialog>
|
|
121
|
-
</div>
|
|
122
|
-
</template>
|
|
123
|
-
|
|
124
|
-
<style lang="scss" scoped>
|
|
125
|
-
.repeater-action {
|
|
126
|
-
display: none;
|
|
127
|
-
}
|
|
128
|
-
.repeater-side-bar {
|
|
129
|
-
min-width: 24px;
|
|
130
|
-
position: relative;
|
|
131
|
-
display: flex;
|
|
132
|
-
flex-direction: column;
|
|
133
|
-
align-content: center;
|
|
134
|
-
justify-content: center;
|
|
135
|
-
&:hover {
|
|
136
|
-
.repeater-action {
|
|
137
|
-
display: inline-flex;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
.repeater-counter {
|
|
141
|
-
position: absolute;
|
|
142
|
-
align-self: center;
|
|
143
|
-
top: 10px;
|
|
144
|
-
}
|
|
145
|
-
.repeater-add-line-index {
|
|
146
|
-
position: absolute;
|
|
147
|
-
align-self: center;
|
|
148
|
-
top: -11px;
|
|
149
|
-
border-radius: 50%;
|
|
150
|
-
}
|
|
151
|
-
.repeater-handle-sort {
|
|
152
|
-
position: absolute;
|
|
153
|
-
align-self: center;
|
|
154
|
-
bottom: 2px;
|
|
155
|
-
cursor: grab;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
.repeater-add-line {
|
|
159
|
-
border-top: none;
|
|
160
|
-
}
|
|
161
|
-
.template-button {
|
|
162
|
-
padding: 0.5rem;
|
|
163
|
-
margin: 3px;
|
|
164
|
-
border: solid 1px #393939;
|
|
165
|
-
cursor: pointer;
|
|
166
|
-
}
|
|
167
|
-
.theme--light .template-button {
|
|
168
|
-
border-color: #e0e0e0;
|
|
169
|
-
}
|
|
170
|
-
</style>
|
|
171
|
-
|
|
172
|
-
<script>
|
|
173
|
-
import draggable from "vuedraggable";
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* This component is made to manage a list of object that can be added/removed/reordered with a simple form.
|
|
177
|
-
*/
|
|
178
|
-
export default {
|
|
179
|
-
name: "Repeater",
|
|
180
|
-
components: {
|
|
181
|
-
// For recursive dynamic components is better to resolve dependencies at runtime to avoid circular deps
|
|
182
|
-
DetailField: () => import("@mapomodule/uikit/components/Detail/DetailField.vue"),
|
|
183
|
-
draggable,
|
|
184
|
-
},
|
|
185
|
-
data() {
|
|
186
|
-
return {
|
|
187
|
-
items: null,
|
|
188
|
-
tModalOpen: false,
|
|
189
|
-
tModalCallback: () => {},
|
|
190
|
-
};
|
|
191
|
-
},
|
|
192
|
-
props: {
|
|
193
|
-
// V-model of the array needed to edit the objects in realtime.
|
|
194
|
-
value: {
|
|
195
|
-
type: Array,
|
|
196
|
-
default: () => [],
|
|
197
|
-
},
|
|
198
|
-
// The main configuration that determines the arrangement of the fields in each line.
|
|
199
|
-
fields: {
|
|
200
|
-
// [`Array<FieldConfiguration>`](/components/Detail/Detail/#fieldconfiguration)
|
|
201
|
-
type: Array | Object,
|
|
202
|
-
default: () => [],
|
|
203
|
-
},
|
|
204
|
-
// Puts the input in an error state and passes through custom error messages.
|
|
205
|
-
errorMessages: {
|
|
206
|
-
type: Array,
|
|
207
|
-
default: () => [],
|
|
208
|
-
},
|
|
209
|
-
// Sets input label.
|
|
210
|
-
label: String,
|
|
211
|
-
// Makes all the repeater items readonly.
|
|
212
|
-
readonly: Boolean,
|
|
213
|
-
// Makes the repeater field sortable.
|
|
214
|
-
sortable: Boolean,
|
|
215
|
-
// 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.
|
|
216
|
-
translatable: Boolean,
|
|
217
|
-
// 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.
|
|
218
|
-
sortCallback: {
|
|
219
|
-
type: Function,
|
|
220
|
-
default: () => {},
|
|
221
|
-
},
|
|
222
|
-
langs: {
|
|
223
|
-
type: Array,
|
|
224
|
-
default: () => [],
|
|
225
|
-
},
|
|
226
|
-
currentLang: String,
|
|
227
|
-
},
|
|
228
|
-
watch: {
|
|
229
|
-
value(val) {
|
|
230
|
-
this.items = val;
|
|
231
|
-
},
|
|
232
|
-
items(val) {
|
|
233
|
-
this.$emit("input", val);
|
|
234
|
-
},
|
|
235
|
-
tModalOpen(val) {
|
|
236
|
-
!val && this.tModalCallback();
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
methods: {
|
|
240
|
-
async addItem(index) {
|
|
241
|
-
const element = {};
|
|
242
|
-
if (this.hasTemplates) {
|
|
243
|
-
const template = await this.chooseTemplate();
|
|
244
|
-
if (!template) return;
|
|
245
|
-
element[template.tCodeField] = template.tCode;
|
|
246
|
-
}
|
|
247
|
-
const newIndex = typeof index == "number" ? index : this.items.length;
|
|
248
|
-
this.items.splice(newIndex, 0, element);
|
|
249
|
-
this.sortable &&
|
|
250
|
-
this.sortCallback({
|
|
251
|
-
moved: { element, newIndex },
|
|
252
|
-
items: this.items,
|
|
253
|
-
eventType: "add",
|
|
254
|
-
});
|
|
255
|
-
},
|
|
256
|
-
removeItem(index) {
|
|
257
|
-
const element = this.items[index];
|
|
258
|
-
this.items.splice(index, 1);
|
|
259
|
-
this.sortable &&
|
|
260
|
-
this.sortCallback({
|
|
261
|
-
moved: { element, oldIndex: index },
|
|
262
|
-
items: this.items,
|
|
263
|
-
eventType: "remove",
|
|
264
|
-
});
|
|
265
|
-
},
|
|
266
|
-
async chooseTemplate() {
|
|
267
|
-
this.tModalOpen = true;
|
|
268
|
-
return new Promise((resolve) => {
|
|
269
|
-
this.tModalCallback = function (template) {
|
|
270
|
-
resolve(template);
|
|
271
|
-
this.tModalCallback = () => {};
|
|
272
|
-
this.tModalOpen = false;
|
|
273
|
-
};
|
|
274
|
-
});
|
|
275
|
-
},
|
|
276
|
-
getErrors(index) {
|
|
277
|
-
return (this.errorMessages || [])[index] || {};
|
|
278
|
-
},
|
|
279
|
-
parseConf(field, i) {
|
|
280
|
-
const conf = typeof field === "string" ? { value: field } : field;
|
|
281
|
-
conf.value = conf.value || "";
|
|
282
|
-
conf.value = this.translatable ? conf.value.replace(new RegExp(`^translations\.(${this.langs.join("|")})\.?`), "") : conf.value;
|
|
283
|
-
conf.slotName = `fields.${conf.value || i}`;
|
|
284
|
-
if (this.translatable && this.currentLang && !field.synci18n) {
|
|
285
|
-
const base = `translations.${this.currentLang}`;
|
|
286
|
-
conf.value = (conf.value && `${base}.${conf.value}`) || base;
|
|
287
|
-
}
|
|
288
|
-
if (this.readonly) {
|
|
289
|
-
conf.attrs = { ...conf.attrs, readonly: true };
|
|
290
|
-
}
|
|
291
|
-
return conf;
|
|
292
|
-
},
|
|
293
|
-
mapConf(fields) {
|
|
294
|
-
fields = this.translatable ? JSON.parse(JSON.stringify(fields)) : fields; // this hack fixes rendering loop on translatable repeater. :/
|
|
295
|
-
const icon = "mdi-cube-outline";
|
|
296
|
-
const parseGroup = (group) => typeof group === "string" ? { name: group, icon } : { ...group, icon: group.icon !== undefined ? group.icon : icon };
|
|
297
|
-
return fields.map((f, i) =>
|
|
298
|
-
f.group
|
|
299
|
-
? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
|
|
300
|
-
: this.parseConf(f, i)
|
|
301
|
-
);
|
|
302
|
-
},
|
|
303
|
-
parseFields(model) {
|
|
304
|
-
if (this.hasTemplates) {
|
|
305
|
-
const template = this.templates.find(t => model[t.tCodeField] == t.tCode)
|
|
306
|
-
return template ? this.mapConf(template.fields) : [];
|
|
307
|
-
}
|
|
308
|
-
return this.mapConf(this.fields);
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
computed: {
|
|
312
|
-
hasTemplates() {
|
|
313
|
-
return typeof this.fields == "object" && !Array.isArray(this.fields);
|
|
314
|
-
},
|
|
315
|
-
templates() {
|
|
316
|
-
const templates = {};
|
|
317
|
-
if (this.hasTemplates) {
|
|
318
|
-
const titleCase = (string) => (string && string[0].toUpperCase() + string.slice(1).toLowerCase()) || "";
|
|
319
|
-
Object.keys(this.fields).forEach((tKey) => {
|
|
320
|
-
const tValue = this.fields[tKey];
|
|
321
|
-
const { preview, description } = tValue;
|
|
322
|
-
templates[tKey] = {
|
|
323
|
-
fields: tValue.fields || tValue,
|
|
324
|
-
name: tValue.name || titleCase(tKey.replace(/_/, " ")),
|
|
325
|
-
tCode: tValue.tCode || tKey,
|
|
326
|
-
tCodeField: tValue.tCodeField || "tCode",
|
|
327
|
-
preview, description,
|
|
328
|
-
};
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
return Object.values(templates);
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
mounted() {
|
|
335
|
-
this.items = this.value;
|
|
336
|
-
},
|
|
337
|
-
};
|
|
338
|
-
</script>
|