@mapomodule/uikit 1.0.0-alpha.6 → 1.0.0-alpha.60

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.
Files changed (231) hide show
  1. package/CHANGELOG.md +953 -0
  2. package/components/ConfirmDialog.vue +58 -37
  3. package/components/Detail/Detail.vue +421 -271
  4. package/components/Detail/DetailLangSwitch.vue +9 -2
  5. package/components/DropArea.vue +63 -56
  6. package/components/Form/Form.vue +218 -0
  7. package/components/Form/FormField.vue +216 -0
  8. package/components/Form/FormGroup.vue +146 -0
  9. package/components/Form/FormTabs.vue +188 -0
  10. package/components/Form/defaults.js +98 -0
  11. package/components/Form/fields/ColorField.vue +79 -0
  12. package/components/{fields → Form/fields}/DateField.vue +20 -11
  13. package/components/Form/fields/DateTimeField.vue +271 -0
  14. package/components/Form/fields/EnhancedMediaField.vue +224 -0
  15. package/components/Form/fields/FileField.vue +125 -0
  16. package/components/Form/fields/FksField.vue +115 -0
  17. package/components/Form/fields/MediaField.vue +159 -0
  18. package/components/Form/fields/MediaM2mField.vue +149 -0
  19. package/components/Form/fields/Repeater.vue +618 -0
  20. package/components/{fields → Form/fields}/SeoPreview.vue +10 -10
  21. package/components/Form/fields/TimeField.vue +154 -0
  22. package/components/Form/fields/mapField/leaflet.injector.js +39 -0
  23. package/components/Form/fields/mapField/mapField.vue +350 -0
  24. package/components/Form/fields/wygEditor/defaults.js +25 -0
  25. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
  26. package/components/Form/fields/wygEditor/wygEditor.vue +285 -0
  27. package/components/Form/fields/wygEditorCKE/defaults.js +103 -0
  28. package/components/Form/fields/wygEditorCKE/utils/ckeditor.injector.js +29 -0
  29. package/components/Form/fields/wygEditorCKE/wygEditorCKE.vue +270 -0
  30. package/components/LangSwitcher.vue +44 -0
  31. package/components/List/List.vue +34 -17
  32. package/components/List/ListActions.vue +22 -4
  33. package/components/List/ListFilters.vue +48 -10
  34. package/components/List/ListHead.vue +11 -3
  35. package/components/List/ListQuickEdit.vue +124 -64
  36. package/components/List/ListTable.vue +118 -18
  37. package/components/Login.vue +17 -7
  38. package/components/LogoutButton.vue +43 -28
  39. package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
  40. package/components/MediaManager/MediaEditor.vue +297 -120
  41. package/components/MediaManager/MediaFileChanger.vue +78 -0
  42. package/components/MediaManager/MediaFolders.vue +224 -116
  43. package/components/MediaManager/MediaGallery.vue +224 -145
  44. package/components/MediaManager/MediaManager.vue +125 -159
  45. package/components/MediaManager/MediaManagerDialog.vue +36 -31
  46. package/components/MediaManager/MediaPreview.vue +258 -0
  47. package/components/MediaManager/MediaUploader.vue +91 -90
  48. package/components/MenuManager/MenuManager.vue +332 -0
  49. package/components/MenuManager/MenuNodeEditor.vue +270 -0
  50. package/components/MenuManager/MenuTreeview.vue +237 -0
  51. package/components/MenuManager/MenuTreeviewNode.vue +208 -0
  52. package/components/PagePreview.vue +58 -0
  53. package/components/SnackBar.vue +5 -7
  54. package/components/ThemeToggle.vue +13 -0
  55. package/components/layout/Sidebar/Sidebar.vue +48 -39
  56. package/components/layout/Sidebar/SidebarList.vue +11 -4
  57. package/components/layout/Sidebar/SidebarListItem.vue +113 -13
  58. package/components/layout/Sidebar/SidebarProfile.vue +42 -0
  59. package/components/layout/Sidebar/SidebarTitle.vue +45 -0
  60. package/components/layout/Topbar/Topbar.vue +11 -9
  61. package/components/layout/routebuilder.js +2 -2
  62. package/defaults/i18n.js +37 -0
  63. package/defaults/vuetify.js +34 -0
  64. package/layouts/default.vue +35 -11
  65. package/layouts/empty.vue +10 -0
  66. package/module.js +7 -5
  67. package/package.json +6 -4
  68. package/pages/index.vue +19 -17
  69. package/static/mapo/ckeditor/plugins/image2/dev/assets/image1.jpg +0 -0
  70. package/static/mapo/ckeditor/plugins/image2/dev/assets/image2.jpg +0 -0
  71. package/static/mapo/ckeditor/plugins/image2/dev/contents.css +35 -0
  72. package/static/mapo/ckeditor/plugins/image2/dev/image2.html +338 -0
  73. package/static/mapo/ckeditor/plugins/image2/dialogs/image2.js +557 -0
  74. package/static/mapo/ckeditor/plugins/image2/icons/hidpi/image.png +0 -0
  75. package/static/mapo/ckeditor/plugins/image2/icons/image.png +0 -0
  76. package/static/mapo/ckeditor/plugins/image2/lang/af.js +21 -0
  77. package/static/mapo/ckeditor/plugins/image2/lang/ar.js +21 -0
  78. package/static/mapo/ckeditor/plugins/image2/lang/az.js +21 -0
  79. package/static/mapo/ckeditor/plugins/image2/lang/bg.js +21 -0
  80. package/static/mapo/ckeditor/plugins/image2/lang/bn.js +21 -0
  81. package/static/mapo/ckeditor/plugins/image2/lang/bs.js +21 -0
  82. package/static/mapo/ckeditor/plugins/image2/lang/ca.js +21 -0
  83. package/static/mapo/ckeditor/plugins/image2/lang/cs.js +21 -0
  84. package/static/mapo/ckeditor/plugins/image2/lang/cy.js +21 -0
  85. package/static/mapo/ckeditor/plugins/image2/lang/da.js +21 -0
  86. package/static/mapo/ckeditor/plugins/image2/lang/de-ch.js +21 -0
  87. package/static/mapo/ckeditor/plugins/image2/lang/de.js +21 -0
  88. package/static/mapo/ckeditor/plugins/image2/lang/el.js +21 -0
  89. package/static/mapo/ckeditor/plugins/image2/lang/en-au.js +21 -0
  90. package/static/mapo/ckeditor/plugins/image2/lang/en-ca.js +21 -0
  91. package/static/mapo/ckeditor/plugins/image2/lang/en-gb.js +21 -0
  92. package/static/mapo/ckeditor/plugins/image2/lang/en.js +21 -0
  93. package/static/mapo/ckeditor/plugins/image2/lang/eo.js +21 -0
  94. package/static/mapo/ckeditor/plugins/image2/lang/es-mx.js +21 -0
  95. package/static/mapo/ckeditor/plugins/image2/lang/es.js +21 -0
  96. package/static/mapo/ckeditor/plugins/image2/lang/et.js +21 -0
  97. package/static/mapo/ckeditor/plugins/image2/lang/eu.js +21 -0
  98. package/static/mapo/ckeditor/plugins/image2/lang/fa.js +21 -0
  99. package/static/mapo/ckeditor/plugins/image2/lang/fi.js +21 -0
  100. package/static/mapo/ckeditor/plugins/image2/lang/fo.js +21 -0
  101. package/static/mapo/ckeditor/plugins/image2/lang/fr-ca.js +21 -0
  102. package/static/mapo/ckeditor/plugins/image2/lang/fr.js +21 -0
  103. package/static/mapo/ckeditor/plugins/image2/lang/gl.js +21 -0
  104. package/static/mapo/ckeditor/plugins/image2/lang/gu.js +21 -0
  105. package/static/mapo/ckeditor/plugins/image2/lang/he.js +21 -0
  106. package/static/mapo/ckeditor/plugins/image2/lang/hi.js +21 -0
  107. package/static/mapo/ckeditor/plugins/image2/lang/hr.js +21 -0
  108. package/static/mapo/ckeditor/plugins/image2/lang/hu.js +21 -0
  109. package/static/mapo/ckeditor/plugins/image2/lang/id.js +21 -0
  110. package/static/mapo/ckeditor/plugins/image2/lang/is.js +21 -0
  111. package/static/mapo/ckeditor/plugins/image2/lang/it.js +21 -0
  112. package/static/mapo/ckeditor/plugins/image2/lang/ja.js +21 -0
  113. package/static/mapo/ckeditor/plugins/image2/lang/ka.js +21 -0
  114. package/static/mapo/ckeditor/plugins/image2/lang/km.js +21 -0
  115. package/static/mapo/ckeditor/plugins/image2/lang/ko.js +21 -0
  116. package/static/mapo/ckeditor/plugins/image2/lang/ku.js +21 -0
  117. package/static/mapo/ckeditor/plugins/image2/lang/lt.js +21 -0
  118. package/static/mapo/ckeditor/plugins/image2/lang/lv.js +21 -0
  119. package/static/mapo/ckeditor/plugins/image2/lang/mk.js +21 -0
  120. package/static/mapo/ckeditor/plugins/image2/lang/mn.js +21 -0
  121. package/static/mapo/ckeditor/plugins/image2/lang/ms.js +21 -0
  122. package/static/mapo/ckeditor/plugins/image2/lang/nb.js +21 -0
  123. package/static/mapo/ckeditor/plugins/image2/lang/nl.js +21 -0
  124. package/static/mapo/ckeditor/plugins/image2/lang/no.js +21 -0
  125. package/static/mapo/ckeditor/plugins/image2/lang/oc.js +21 -0
  126. package/static/mapo/ckeditor/plugins/image2/lang/pl.js +21 -0
  127. package/static/mapo/ckeditor/plugins/image2/lang/pt-br.js +21 -0
  128. package/static/mapo/ckeditor/plugins/image2/lang/pt.js +21 -0
  129. package/static/mapo/ckeditor/plugins/image2/lang/ro.js +21 -0
  130. package/static/mapo/ckeditor/plugins/image2/lang/ru.js +21 -0
  131. package/static/mapo/ckeditor/plugins/image2/lang/si.js +21 -0
  132. package/static/mapo/ckeditor/plugins/image2/lang/sk.js +21 -0
  133. package/static/mapo/ckeditor/plugins/image2/lang/sl.js +21 -0
  134. package/static/mapo/ckeditor/plugins/image2/lang/sq.js +21 -0
  135. package/static/mapo/ckeditor/plugins/image2/lang/sr-latn.js +21 -0
  136. package/static/mapo/ckeditor/plugins/image2/lang/sr.js +21 -0
  137. package/static/mapo/ckeditor/plugins/image2/lang/sv.js +21 -0
  138. package/static/mapo/ckeditor/plugins/image2/lang/th.js +21 -0
  139. package/static/mapo/ckeditor/plugins/image2/lang/tr.js +21 -0
  140. package/static/mapo/ckeditor/plugins/image2/lang/tt.js +21 -0
  141. package/static/mapo/ckeditor/plugins/image2/lang/ug.js +21 -0
  142. package/static/mapo/ckeditor/plugins/image2/lang/uk.js +21 -0
  143. package/static/mapo/ckeditor/plugins/image2/lang/vi.js +21 -0
  144. package/static/mapo/ckeditor/plugins/image2/lang/zh-cn.js +21 -0
  145. package/static/mapo/ckeditor/plugins/image2/lang/zh.js +21 -0
  146. package/static/mapo/ckeditor/plugins/image2/plugin.js +1798 -0
  147. package/static/mapo/ckeditor/plugins/image2/samples/assets/image1.jpg +0 -0
  148. package/static/mapo/ckeditor/plugins/image2/samples/assets/image2.jpg +0 -0
  149. package/static/mapo/ckeditor/plugins/image2/samples/image2.html +68 -0
  150. package/static/mapo/ckeditor/skins/moono/dev/icons16.png +0 -0
  151. package/static/mapo/ckeditor/skins/moono/dev/icons16.svg +2374 -0
  152. package/static/mapo/ckeditor/skins/moono/dev/icons32.png +0 -0
  153. package/static/mapo/ckeditor/skins/moono/dev/icons32.svg +2722 -0
  154. package/static/mapo/ckeditor/skins/moono/dev/locations.json +144 -0
  155. package/static/mapo/ckeditor/skins/moono/dialog.css +5 -0
  156. package/static/mapo/ckeditor/skins/moono/dialog_ie.css +5 -0
  157. package/static/mapo/ckeditor/skins/moono/dialog_ie7.css +5 -0
  158. package/static/mapo/ckeditor/skins/moono/dialog_ie8.css +5 -0
  159. package/static/mapo/ckeditor/skins/moono/dialog_iequirks.css +5 -0
  160. package/static/mapo/ckeditor/skins/moono/editor.css +5 -0
  161. package/static/mapo/ckeditor/skins/moono/editor_gecko.css +5 -0
  162. package/static/mapo/ckeditor/skins/moono/editor_ie.css +5 -0
  163. package/static/mapo/ckeditor/skins/moono/editor_ie7.css +5 -0
  164. package/static/mapo/ckeditor/skins/moono/editor_ie8.css +5 -0
  165. package/static/mapo/ckeditor/skins/moono/editor_iequirks.css +5 -0
  166. package/static/mapo/ckeditor/skins/moono/icons.png +0 -0
  167. package/static/mapo/ckeditor/skins/moono/icons_hidpi.png +0 -0
  168. package/static/mapo/ckeditor/skins/moono/images/anchor.png +0 -0
  169. package/static/mapo/ckeditor/skins/moono/images/arrow.png +0 -0
  170. package/static/mapo/ckeditor/skins/moono/images/close.png +0 -0
  171. package/static/mapo/ckeditor/skins/moono/images/hidpi/anchor.png +0 -0
  172. package/static/mapo/ckeditor/skins/moono/images/hidpi/close.png +0 -0
  173. package/static/mapo/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
  174. package/static/mapo/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
  175. package/static/mapo/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
  176. package/static/mapo/ckeditor/skins/moono/images/lock-open.png +0 -0
  177. package/static/mapo/ckeditor/skins/moono/images/lock.png +0 -0
  178. package/static/mapo/ckeditor/skins/moono/images/refresh.png +0 -0
  179. package/static/mapo/ckeditor/skins/moono/images/spinner.gif +0 -0
  180. package/static/mapo/ckeditor/skins/moono/readme.md +49 -0
  181. package/static/mapo/ckeditor/skins/moono/skin.js +10 -0
  182. package/static/mapo/ckeditor/skins/moono-dark/dialog.css +5 -0
  183. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie.css +5 -0
  184. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie7.css +5 -0
  185. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie8.css +5 -0
  186. package/static/mapo/ckeditor/skins/moono-dark/dialog_iequirks.css +5 -0
  187. package/static/mapo/ckeditor/skins/moono-dark/editor.css +5 -0
  188. package/static/mapo/ckeditor/skins/moono-dark/editor_gecko.css +5 -0
  189. package/static/mapo/ckeditor/skins/moono-dark/editor_ie.css +5 -0
  190. package/static/mapo/ckeditor/skins/moono-dark/editor_ie7.css +5 -0
  191. package/static/mapo/ckeditor/skins/moono-dark/editor_ie8.css +5 -0
  192. package/static/mapo/ckeditor/skins/moono-dark/editor_iequirks.css +5 -0
  193. package/static/mapo/ckeditor/skins/moono-dark/icons.png +0 -0
  194. package/static/mapo/ckeditor/skins/moono-dark/icons_hidpi.png +0 -0
  195. package/static/mapo/ckeditor/skins/moono-dark/images/arrow.png +0 -0
  196. package/static/mapo/ckeditor/skins/moono-dark/images/close.png +0 -0
  197. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/close.png +0 -0
  198. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock-open.png +0 -0
  199. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock.png +0 -0
  200. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/refresh.png +0 -0
  201. package/static/mapo/ckeditor/skins/moono-dark/images/lock-open.png +0 -0
  202. package/static/mapo/ckeditor/skins/moono-dark/images/lock.png +0 -0
  203. package/static/mapo/ckeditor/skins/moono-dark/images/refresh.png +0 -0
  204. package/static/mapo/ckeditor/skins/moono-dark/readme.md +51 -0
  205. package/static/mapo/ckeditor/skins/moono-dark/skin.js +5 -0
  206. package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
  207. package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
  208. package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
  209. package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
  210. package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
  211. package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
  212. package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
  213. package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
  214. package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
  215. package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
  216. package/translations/en-US.js +177 -0
  217. package/translations/it-IT.js +180 -0
  218. package/LICENSE.md +0 -20
  219. package/components/Detail/DetailField.vue +0 -132
  220. package/components/Detail/defaults.js +0 -55
  221. package/components/fields/M2mField.vue +0 -95
  222. package/components/fields/MediaField.vue +0 -195
  223. package/components/fields/MediaM2mField.vue +0 -238
  224. package/components/fields/TinyMce/TinyMce.vue +0 -180
  225. package/components/fields/TinyMce/defaults.js +0 -55
  226. package/components/layout/Sidebar/SidebarFooter.vue +0 -70
  227. package/defaults.js +0 -29
  228. package/layouts/error.vue +0 -45
  229. /package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
  230. /package/components/{fields/TinyMce/utils/script.injector.js → Form/fields/wygEditor/utils/tinymce.injector.js} +0 -0
  231. /package/static/{favicon.ico → mapo/favicon.ico} +0 -0
@@ -0,0 +1,618 @@
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
61
+ class="repeater-counter grey--text text--darken-2 text-truncate"
62
+ >{{ index + 1 }}</span
63
+ >
64
+ <v-tooltip right>
65
+ <template v-slot:activator="{ on, attrs }">
66
+ <v-icon
67
+ v-if="!readonly && sortable"
68
+ v-bind="attrs"
69
+ v-on="on"
70
+ color="grey darken-3"
71
+ class="grey lighten-2 repeater-action repeater-add-line-index"
72
+ @click="addItem(index)"
73
+ >mdi-plus-circle-outline</v-icon
74
+ >
75
+ </template>
76
+ <span>{{ $t("mapo.repeater.addHere") }}</span>
77
+ </v-tooltip>
78
+ <v-tooltip right>
79
+ <template v-slot:activator="{ on, attrs }">
80
+ <v-hover v-slot="{ hover }">
81
+ <v-icon
82
+ v-if="!readonly"
83
+ v-bind="attrs"
84
+ v-on="on"
85
+ :color="hover ? 'error' : 'grey darken-3'"
86
+ class="repeater-action repeater-remove-line"
87
+ @click="removeItem(index)"
88
+ >mdi-minus-circle-outline</v-icon
89
+ >
90
+ </v-hover>
91
+ </template>
92
+ <span>{{ $t("mapo.remove") }}</span>
93
+ </v-tooltip>
94
+ <v-icon
95
+ v-if="!readonly && sortable"
96
+ color="grey darken-3"
97
+ class="repeater-action repeater-handle-sort"
98
+ >mdi-drag-horizontal</v-icon
99
+ >
100
+ </div>
101
+ </div>
102
+ </div>
103
+ </draggable>
104
+ <v-divider />
105
+ <div class="d-flex justify-end">
106
+ <v-btn
107
+ class="repeater-add-line"
108
+ @click="addItem"
109
+ :disabled="readonly"
110
+ outlined
111
+ tile
112
+ text
113
+ >
114
+ <v-icon>mdi-plus</v-icon> {{ $t("mapo.add") }}</v-btn
115
+ >
116
+ </div>
117
+ <v-dialog v-if="hasTemplates" v-model="tModalOpen" width="600" scrollable>
118
+ <v-card>
119
+ <v-card-title class="text-h5">{{
120
+ $t("mapo.repeater.selectTemplate")
121
+ }}</v-card-title>
122
+ <v-card-text>
123
+ <div class="row mt-4">
124
+ <div
125
+ v-for="(template, i) in templates"
126
+ :key="i"
127
+ class="col-12 col-md-6 pa-0"
128
+ >
129
+ <div @click="tModalCallback(template)" class="template-button">
130
+ <span class="text-h5">{{ template.name }}</span
131
+ ><br />
132
+ <span>{{ template.description }}</span>
133
+ <v-img
134
+ v-if="template.preview"
135
+ max-height="150"
136
+ min-width="250px"
137
+ :src="template.preview"
138
+ />
139
+ <v-skeleton-loader
140
+ v-else
141
+ boilerplate
142
+ min-width="250px"
143
+ type="list-item-avatar-three-line"
144
+ />
145
+ </div>
146
+ </div>
147
+ </div>
148
+ </v-card-text>
149
+ </v-card>
150
+ </v-dialog>
151
+ </div>
152
+ </template>
153
+
154
+ <style lang="scss" scoped>
155
+ .repeater-action {
156
+ display: none;
157
+ }
158
+ .repeater-fields {
159
+ display: none;
160
+ overflow: hidden;
161
+ width: 100%;
162
+ }
163
+ .expand-icon {
164
+ cursor: pointer;
165
+ transform: rotate(0deg);
166
+ transition: transform 225ms cubic-bezier(0.4, 0, 0.2, 1);
167
+ }
168
+ .collapsed-preview {
169
+ flex-basis: 100%;
170
+ display: flex;
171
+ align-items: flex-start;
172
+ }
173
+ .collapsed-label {
174
+ cursor: pointer;
175
+ flex-basis: 100%;
176
+ margin: 15px;
177
+ text-align: center;
178
+ display: -webkit-box;
179
+ -webkit-line-clamp: 2;
180
+ -webkit-box-orient: vertical;
181
+ overflow: hidden;
182
+ text-overflow: ellipsis;
183
+ }
184
+ .theme--light .repeater-line-wrapper {
185
+ border-color: rgba(0, 0, 0, 0.12);
186
+ }
187
+ .repeater-line-wrapper {
188
+ border: 1px solid;
189
+ border-bottom: none;
190
+ border-color: rgba(255, 255, 255, 0.12);
191
+ &:hover {
192
+ .repeater-action {
193
+ display: inline-flex;
194
+ }
195
+ .repeater-counter {
196
+ display: none;
197
+ }
198
+ }
199
+ &.expanded {
200
+ > div > div > .expand-icon {
201
+ transform: rotate(180deg);
202
+ }
203
+ > div > div > .collapsed-label {
204
+ display: none;
205
+ }
206
+ > div > .repeater-fields {
207
+ display: flex;
208
+ }
209
+ > div > .collapsed-preview {
210
+ flex-basis: 0;
211
+ }
212
+ }
213
+ }
214
+ .repeater-side-bar {
215
+ min-width: 24px;
216
+ position: relative;
217
+ display: flex;
218
+ flex-direction: column;
219
+ align-content: center;
220
+ justify-content: center;
221
+ .repeater-counter {
222
+ position: absolute;
223
+ align-self: center;
224
+ top: 10px;
225
+ }
226
+ .repeater-add-line-index {
227
+ position: absolute;
228
+ align-self: center;
229
+ top: -11px;
230
+ border-radius: 50%;
231
+ }
232
+ .repeater-handle-sort {
233
+ position: absolute;
234
+ align-self: center;
235
+ bottom: 0px;
236
+ height: 15px;
237
+ overflow: hidden;
238
+ cursor: grab;
239
+ }
240
+ }
241
+ .repeater-add-line {
242
+ border-top: none;
243
+ }
244
+ .template-button {
245
+ padding: 0.5rem;
246
+ margin: 3px;
247
+ border: solid 1px #393939;
248
+ cursor: pointer;
249
+ }
250
+ .theme--light .template-button {
251
+ border-color: #e0e0e0;
252
+ }
253
+ </style>
254
+
255
+ <script>
256
+ import draggable from "vuedraggable";
257
+ import { getPointed, deepClone } from "@mapomodule/utils/helpers/objHelpers";
258
+ import { titleCase } from "@mapomodule/utils/helpers/formatters";
259
+ import { nameSpacedSlots } from "@mapomodule/utils/helpers/slots";
260
+
261
+ /**
262
+ * This component is made to manage a list of object that can be added/removed/reordered with a simple form.
263
+ */
264
+ export default {
265
+ name: "Repeater",
266
+ components: {
267
+ // For recursive dynamic components is better to resolve dependencies at runtime to avoid circular deps
268
+ Form: () => import("@mapomodule/uikit/components/Form/Form.vue"),
269
+ draggable,
270
+ },
271
+ data() {
272
+ return {
273
+ items: this.value ? deepClone(this.value) : [],
274
+ tModalOpen: false,
275
+ tModalCallback: () => {},
276
+ collapsedStack: (this.value || []).map(() => !!this.collapsable),
277
+ };
278
+ },
279
+ props: {
280
+ // V-model of the array needed to edit the objects in realtime.
281
+ value: {
282
+ type: Array,
283
+ default: () => [],
284
+ },
285
+ // 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)
286
+ fields: {
287
+ // [`Array<FieldConfiguration>`](/components/Detail/Detail/#fieldconfiguration)
288
+ type: Array | Object,
289
+ default: () => [],
290
+ },
291
+ // Puts the input in an error state and passes through custom error messages.
292
+ errorMessages: {
293
+ type: Array,
294
+ default: () => [],
295
+ },
296
+ // Sets input label.
297
+ label: String,
298
+ // Makes all the repeater items readonly.
299
+ readonly: Boolean,
300
+ // Makes the repeater field sortable.
301
+ sortable: Boolean,
302
+ // Makes the repeater field collapsable.
303
+ collapsable: Boolean,
304
+ // 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.
305
+ translatable: Boolean,
306
+ // 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.
307
+ sortCallback: {
308
+ type: Function,
309
+ default: () => {},
310
+ },
311
+ // 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.
312
+ collapsedLabel: {
313
+ type: String | Function,
314
+ default: null,
315
+ },
316
+ // This is mainly an internal property. It is used by DetailField to pass the list of languages inherited from the Detail component.
317
+ langs: {
318
+ // `Array<String>`
319
+ type: Array,
320
+ default() {
321
+ return this.$mapo.$options?.content?.languages || [];
322
+ },
323
+ },
324
+ // This is mainly an internal property. It is used by DetailField to pass the active language inherited from the Detail component.
325
+ currentLang: String,
326
+ maxHeight: String | Number,
327
+ },
328
+ watch: {
329
+ value(val) {
330
+ const isEmpty = (v) => !v || Object.keys(v).length == 0;
331
+ if (
332
+ (isEmpty(val) && isEmpty(this.items)) ||
333
+ JSON.stringify(val) === JSON.stringify(this.items)
334
+ )
335
+ return;
336
+ this.items = (val && deepClone(val)) || [];
337
+ if (val.length != this.collapsedStack.length)
338
+ this.collapsedStack = (val || []).map(() => !!this.collapsable);
339
+ },
340
+ items: {
341
+ handler(val) {
342
+ this.$emit("input", deepClone(val));
343
+ },
344
+ deep: true,
345
+ },
346
+ tModalOpen(val) {
347
+ !val && this.tModalCallback();
348
+ },
349
+ },
350
+ methods: {
351
+ isExpanded(index) {
352
+ return !this.collapsedStack[index];
353
+ },
354
+ async addItem(index) {
355
+ const element = {};
356
+ if (this.hasTemplates) {
357
+ const template = await this.chooseTemplate();
358
+ if (!template) return;
359
+ element[template.tCodeField] = template.tCode;
360
+ }
361
+ const newIndex = typeof index == "number" ? index : this.items.length;
362
+ this.items.splice(newIndex, 0, element);
363
+ this.collapsedStack.splice(newIndex, 0, false);
364
+ this.sortable &&
365
+ this.sortCallback({
366
+ moved: { element, newIndex },
367
+ items: this.items,
368
+ eventType: "add",
369
+ });
370
+ },
371
+ removeItem(index) {
372
+ const element = this.items[index];
373
+ this.items.splice(index, 1);
374
+ this.collapsedStack.splice(index, 1);
375
+ this.sortable &&
376
+ this.sortCallback({
377
+ moved: { element, oldIndex: index },
378
+ items: this.items,
379
+ eventType: "remove",
380
+ });
381
+ },
382
+ async chooseTemplate() {
383
+ this.tModalOpen = true;
384
+ return new Promise((resolve) => {
385
+ this.tModalCallback = function (template) {
386
+ resolve(template);
387
+ this.tModalCallback = () => {};
388
+ this.tModalOpen = false;
389
+ };
390
+ });
391
+ },
392
+ getErrors(index) {
393
+ return (this.errorMessages || [])[index] || {};
394
+ },
395
+ getFields(model) {
396
+ if (this.hasTemplates) {
397
+ const template = this.templates.find(
398
+ (t) => model[t.tCodeField] == t.tCode
399
+ );
400
+ return template ? template.fields : [];
401
+ }
402
+ return this.fields;
403
+ },
404
+ templateSlots(model, slots) {
405
+ if (this.hasTemplates) {
406
+ const template = this.templates.find(
407
+ (t) => model[t.tCodeField] == t.tCode
408
+ );
409
+ return nameSpacedSlots(slots, `template.${template.tCode}.`).reduce(
410
+ (acc, v) => ({ [`template.${template.tCode}.${v}`]: v, ...acc }),
411
+ {}
412
+ );
413
+ }
414
+ return Object.keys(slots).reduce((acc, v) => ({ [v]: v, ...acc }), {});
415
+ },
416
+ getCollapsedLabel(model, index) {
417
+ const fallback = this.$t("mapo.repeater.item", { numberItem: index + 1 });
418
+ switch (typeof this.collapsedLabel) {
419
+ case "string":
420
+ return getPointed(model, this.collapsedLabel, fallback);
421
+ case "function":
422
+ return this.collapsedLabel(model);
423
+ default:
424
+ const field = this.getFields(model).find(
425
+ (f) => !f.type || f.type.toLowerCase() == "text"
426
+ );
427
+ return getPointed(model, field.value, fallback);
428
+ }
429
+ },
430
+ draggableReorder(event) {
431
+ const { newIndex, oldIndex } = event.moved;
432
+ const stackItem = this.collapsedStack[oldIndex];
433
+ this.collapsedStack.splice(oldIndex, 1);
434
+ this.collapsedStack.splice(newIndex, 0, stackItem);
435
+ this.sortCallback({ ...event, items: this.items, eventType: "move" });
436
+ },
437
+ toggleExpand(index, forceValue) {
438
+ this.collapsedStack[index] =
439
+ forceValue == undefined ? !this.collapsedStack[index] : !forceValue;
440
+ this.collapsedStack = [...this.collapsedStack];
441
+ },
442
+ collapseAll() {
443
+ this.collapsedStack = this.collapsedStack.map(() => true);
444
+ },
445
+ },
446
+ computed: {
447
+ hasTemplates() {
448
+ return typeof this.fields == "object" && !Array.isArray(this.fields);
449
+ },
450
+ templates() {
451
+ const templates = {};
452
+ if (this.hasTemplates) {
453
+ Object.keys(this.fields).forEach((tKey) => {
454
+ const tValue = this.fields[tKey];
455
+ const { preview, description } = tValue;
456
+ templates[tKey] = {
457
+ fields: tValue.fields || tValue,
458
+ name: tValue.name || titleCase(tKey.replace(/_/, " ")),
459
+ tCode: tValue.tCode || tKey,
460
+ tCodeField: tValue.tCodeField || "tCode",
461
+ preview,
462
+ description,
463
+ };
464
+ });
465
+ }
466
+ return Object.values(templates);
467
+ },
468
+ maxHeightStyle() {
469
+ if (this.maxHeight !== undefined) {
470
+ const maxHeight = isNaN(this.maxHeight)
471
+ ? this.maxHeight
472
+ : `${this.maxHeight}px`;
473
+ return {
474
+ maxHeight,
475
+ paddingTop: "15px",
476
+ overflowX: "hidden",
477
+ overflowY: "auto",
478
+ };
479
+ }
480
+ },
481
+ },
482
+ };
483
+ </script>
484
+
485
+ <docs>
486
+
487
+
488
+ ## How to configure the repeater
489
+
490
+ In the Repeater the most important attr is the `fields` attr.
491
+ Through the `fields` attr you can configure your repeater. It accepts an array of [`FieldConfiguration`](/components/Detail/Detail/#fieldconfiguration) or an object.
492
+ 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.
493
+ In case we use an object instead of the array we are configuring the Repeater to manage different templates.
494
+ A **Template Repeater** is a repeater that allows the user to choose a different template for each line.
495
+ Each key of the object represents a different template. Each value of these keys is an array of [`FieldConfiguration`](/components/Detail/Detail/#fieldconfiguration).
496
+ 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.
497
+ The keys of the "template" configuration can also be objects.
498
+ Using objects we can better specify some additional properties of the template.
499
+
500
+ #### The template configuration
501
+
502
+ |Name|Description|Type|Required|Default|
503
+ |---|---|---|---|---|
504
+ |name|The name of the template.|`String`|`false`|The key name of the template|
505
+ |description|The description of the template.|`String`|`false`|`null`|
506
+ |preview|The preview image of the template. It must be an image url.|`String`|`false`|A skeleton boilerplate placeholder|
507
+ |tCode|The identifier of the template.|`String`|`false`|The key name of the template|
508
+ |tCodeField|The key where the repeater saves the template identifier in the row|`String`|`false`|`tCode`|
509
+ |fields|The actual fields of the template.|[`Array<FieldConfiguration>`](/components/Detail/Detail/#fieldconfiguration)|`true`|-|
510
+
511
+
512
+ <br><br>
513
+
514
+ #### Example of a Simple Repeater configuration:
515
+ This is an example of the fields attr.
516
+ ```js
517
+ [ // here we have only the list of fields
518
+ { value: "sku", class: "col-md-6" },
519
+ { value: "name", class: "col-md-6" },
520
+ ]
521
+ ```
522
+ #### Example of a Template Repeater configuration:
523
+ This is an example of the fields attr.
524
+ ```js
525
+ { // here we have the object that contains the templates
526
+ template_1: [ // This template prvides only the list of fields. Other configurations will falback to defaults.
527
+ { value: "title", class: "col-md-6" },
528
+ { value: "subtitle", class: "col-md-6" },
529
+ ],
530
+ template_2: {
531
+ name: "Custom template", // the name of the template. (by default it takes the key name `temlpate_2`)
532
+ description: "custom description", // additional description.
533
+ preview: "https://blog.openreplay.com/c4052718994cbc8eb6dac8c89c23ba06/img3.gif", // Custom preview image of the template.
534
+ tCode: "titledatecontent", // this is the identifier of the template (by defaults it takes the key name `template_2`)
535
+ tCodeField: "typology", // this is the key where the repeater saves the template type in the row. (by default `tCode`)
536
+ fields: [ // the actual fields of the template.
537
+ { value: "title", class: "col-md-6" },
538
+ { value: "date", type: "date", class: "col-md-6" },
539
+ { value: "content", type: "editor" },
540
+ ],
541
+ },
542
+ }
543
+ ```
544
+
545
+ ## Live Demo
546
+
547
+ <br>
548
+
549
+ ::: warning LIVE DEMO 🎉🎉🎉
550
+ This is an interactive example. You can play with it but remember that all http features are disabled since there is no backend server.
551
+ :::
552
+
553
+
554
+ ::: demo
555
+ <template>
556
+ <v-app>
557
+ <div class="d-flex justify-end"><ThemeToggle/></div>
558
+ <div>
559
+ <h3>Simple Repeater:</h3>
560
+ <Repeater v-model="data1" :fields="fields1" label="Contents" sortable />
561
+ <h4>Contents:</h4>
562
+ <pre style="background-color: unset">{{ data1 }}</pre>
563
+ </div>
564
+ <div>
565
+ <h3>Repeater with templates:</h3>
566
+ <Repeater v-model="data2" :fields="fields2" label="Contents" sortable />
567
+ <h4>Contents:</h4>
568
+ <pre style="background-color: unset">{{ data2 }}</pre>
569
+ </div>
570
+ <div>
571
+ <h3>Translatable Repeater:</h3>
572
+ <DetailLangSwitch class="mb-4" v-model="currentLanguage" :langs="languages"/>
573
+ <Repeater v-model="data3" :fields="fields1" :langs="languages" :currentLang="currentLanguage" label="Contents" sortable translatable />
574
+ <h4>Contents:</h4>
575
+ <pre style="background-color: unset">{{ data3 }}</pre>
576
+ </div>
577
+ </v-app>
578
+ </template>
579
+
580
+ <script>
581
+ export default {
582
+ data() {
583
+ return {
584
+ data1: [],
585
+ data2: [],
586
+ data3: [],
587
+ fields1: [
588
+ { value: "sku", class: "col-md-6" },
589
+ { value: "name", class: "col-md-6" },
590
+ ],
591
+ fields2: {
592
+ template_1: [
593
+ { value: "title", class: "col-md-6" },
594
+ { value: "subtitle", class: "col-md-6" },
595
+ ],
596
+ template_2: {
597
+ name: "Custom template",
598
+ description: "custom description",
599
+ preview:
600
+ "https://blog.openreplay.com/c4052718994cbc8eb6dac8c89c23ba06/img3.gif",
601
+ fields: [
602
+ { value: "title", class: "col-md-6" },
603
+ { value: "date", type: "date", class: "col-md-6" },
604
+ { value: "content", type: "editor" },
605
+ ],
606
+ },
607
+ },
608
+ languages: ['it', 'en'],
609
+ currentLanguage: 'it'
610
+ };
611
+ },
612
+ };
613
+ </script>
614
+ :::
615
+
616
+
617
+
618
+ </docs>
@@ -3,7 +3,7 @@
3
3
  <div class="preview">
4
4
  <span class="preview__title">{{ getTitle }}</span>
5
5
  <br />
6
- <span class="preview__url">{{ getPermalink }}</span>
6
+ <span class="preview__url">{{domain}}{{ getPermalink }}</span>
7
7
  <br />
8
8
  <span class="preview__desc">{{ getDescription }}</span>
9
9
  </div>
@@ -51,27 +51,27 @@ export default {
51
51
  },
52
52
  // Seo title
53
53
  title: {
54
- type: String,
55
- default:
56
- "It was the best of times, it was the blurst of times, it was the ..."
54
+ type: String
57
55
  },
58
56
  // Seo permalink
59
57
  permalink: {
60
58
  type: String,
61
- default: "example.com/how_to_dive"
59
+ default: "how-to-dive"
62
60
  },
63
61
  // Seo description
64
62
  description: {
63
+ type: String
64
+ },
65
+ domain: {
65
66
  type: String,
66
- default:
67
- "This is an example description that will get replaced when you start typing. Make sure to keep descriptions mobile-friendly and keyword-rich!"
67
+ default: process.browser ? `${window.location.origin}/` : ""
68
68
  }
69
69
  },
70
70
  computed: {
71
71
  getTitle(){
72
72
  if (this.value && this.value.title)
73
73
  return this.value.title
74
- return this.title
74
+ return this.title || this.$t("mapo.seoPreview.title")
75
75
  },
76
76
  getPermalink(){
77
77
  if (this.value && this.value.permalink)
@@ -81,9 +81,9 @@ export default {
81
81
  getDescription(){
82
82
  if (this.value && this.value.description)
83
83
  return this.value.description
84
- return this.description
84
+ return this.description || this.$t("mapo.seoPreview.description")
85
85
  }
86
86
  },
87
87
 
88
88
  };
89
- </script>
89
+ </script>