@mapomodule/uikit 1.0.0-alpha.5 → 1.0.0-alpha.51

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 (230) hide show
  1. package/CHANGELOG.md +892 -0
  2. package/components/ConfirmDialog.vue +58 -37
  3. package/components/Detail/Detail.vue +450 -243
  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 +214 -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 +88 -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 +596 -0
  20. package/components/Form/fields/SeoPreview.vue +89 -0
  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 +348 -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 +100 -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 +103 -51
  32. package/components/List/ListActions.vue +23 -5
  33. package/components/List/ListFilters.vue +166 -114
  34. package/components/List/ListHead.vue +30 -12
  35. package/components/List/ListQuickEdit.vue +130 -61
  36. package/components/List/ListTable.vue +210 -66
  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 +255 -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 +61 -30
  56. package/components/layout/Sidebar/SidebarList.vue +19 -15
  57. package/components/layout/Sidebar/SidebarListItem.vue +122 -38
  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 -42
  61. package/components/layout/routebuilder.js +3 -3
  62. package/defaults/i18n.js +37 -0
  63. package/defaults/vuetify.js +34 -0
  64. package/layouts/default.vue +33 -18
  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 -18
  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/components/Detail/DetailField.vue +0 -129
  219. package/components/Detail/defaults.js +0 -50
  220. package/components/fields/M2mField.vue +0 -95
  221. package/components/fields/MediaField.vue +0 -195
  222. package/components/fields/MediaM2mField.vue +0 -238
  223. package/components/fields/TinyMce/TinyMce.vue +0 -177
  224. package/components/fields/TinyMce/defaults.js +0 -55
  225. package/components/layout/Sidebar/SidebarFooter.vue +0 -75
  226. package/defaults.js +0 -29
  227. package/layouts/error.vue +0 -45
  228. /package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
  229. /package/components/{fields/TinyMce/utils/script.injector.js → Form/fields/wygEditor/utils/tinymce.injector.js} +0 -0
  230. /package/static/{favicon.ico → mapo/favicon.ico} +0 -0
@@ -0,0 +1,271 @@
1
+ <template>
2
+ <div>
3
+ <v-menu ref="menu" v-model="menu" :close-on-content-click="false" max-width="580">
4
+ <template v-slot:activator="{ on, attrs }">
5
+ <v-text-field
6
+ :value="textFieldString"
7
+ prepend-inner-icon="mdi-calendar"
8
+ readonly
9
+ v-bind="{ ...$attrs, ...attrs }"
10
+ v-on="readonly ? undefined : on"
11
+ :clearable="!readonly"
12
+ class="rounded-inherit"
13
+ ></v-text-field>
14
+ </template>
15
+ <v-card>
16
+ <div class="d-flex flex-nowrap">
17
+ <v-date-picker
18
+ v-model="dateModel"
19
+ :range="range"
20
+ no-title
21
+ v-bind="datePickerAttrs"
22
+ class="rounded-0"
23
+ ref="datePicker"
24
+ >
25
+ </v-date-picker
26
+ ><v-time-picker
27
+ v-model="timeModel"
28
+ no-title
29
+ v-bind="timePickerAttrs"
30
+ ref="timePicker"
31
+ class="rounded-0"
32
+ >
33
+ </v-time-picker>
34
+ </div>
35
+ <v-card-actions class="justify-center">
36
+ <input
37
+ v-model="startRawDateTime"
38
+ type="datetime-local"
39
+ class="primary--text text-h6 raw-input"
40
+ ref="startRawInput"
41
+ autofocus
42
+ @click="disableCalendar"
43
+ @keydown="disableCalendar"
44
+ />
45
+ <v-divider class="mx-4" v-if="range"></v-divider>
46
+ <input
47
+ v-if="range"
48
+ :disabled="!startDateTime"
49
+ v-model="endRawDateTime"
50
+ type="datetime-local"
51
+ class="primary--text text-h6 raw-input"
52
+ ref="endRawInput"
53
+ autofocus
54
+ @click="disableCalendar"
55
+ @keydown="disableCalendar"
56
+ />
57
+ <v-btn text @click="menu = false">{{ $t('mapo.ok') }}</v-btn>
58
+ </v-card-actions>
59
+ </v-card>
60
+ </v-menu>
61
+ </div>
62
+ </template>
63
+
64
+ <style scoped>
65
+ .rounded-inherit {
66
+ border-radius: inherit;
67
+ }
68
+ .raw-input {
69
+ outline: none;
70
+ }
71
+ </style>
72
+
73
+ <script>
74
+ import {
75
+ formatLocalTime,
76
+ formatLocalDate,
77
+ formatLocalDateTime,
78
+ mergeDate,
79
+ mergeTime,
80
+ cleanDateStr,
81
+ } from "@mapomodule/utils/helpers/datetime";
82
+
83
+ /**
84
+ * This component is used to edit a datetime in iso format. It is a combination of "v-text-field", "v-date-picker" and "v-time-picker".
85
+ * All dates are emitted using UTC timezone.
86
+ */
87
+ export default {
88
+ name: "DateTimeField",
89
+ data() {
90
+ return {
91
+ startDateTime: null,
92
+ endDateTime: null,
93
+ menu: null,
94
+ isStartFocused: true,
95
+ focusinFunc: () => {
96
+ this.isStartFocused = document.activeElement !== this.$refs.endRawInput;
97
+ },
98
+ };
99
+ },
100
+ props: {
101
+ // V-model property. Is the date to be modified. It can be also array in case of date range.
102
+ value: {
103
+ // `String|Array`
104
+ type: String | Array,
105
+ },
106
+ // Determines if we need to work with date ranges.
107
+ range: {
108
+ type: Boolean,
109
+ default: false,
110
+ },
111
+ // This set the component status to readonly, stopping the user interaction.
112
+ readonly: {
113
+ type: Boolean,
114
+ default: false,
115
+ },
116
+ datePickerAttrs: {
117
+ type: Object,
118
+ default: () => {},
119
+ },
120
+ timePickerAttrs: {
121
+ type: Object,
122
+ default: () => {},
123
+ },
124
+ },
125
+ watch: {
126
+ value(val) {
127
+ this.setupValue();
128
+ },
129
+ menu(val) {
130
+ if (val)
131
+ setTimeout(() => {
132
+ this.$refs.startRawInput?.focus();
133
+ this.$refs.timePicker.selecting = 1;
134
+ });
135
+ },
136
+ isStartFocused(val, old) {
137
+ if (val != old) this.$refs.timePicker.selecting = 1;
138
+ },
139
+ },
140
+ methods: {
141
+ disableCalendar(evt) {
142
+ if (!evt.keyCode || evt.keyCode == 13) {
143
+ evt.preventDefault();
144
+ return false;
145
+ }
146
+ },
147
+ selectTimePickerMethod(oldDateTime, newDateTime) {
148
+ const currentValue = oldDateTime?.split("T").splice(-1)[0]?.split(":") || [];
149
+ const nextValue = newDateTime?.split("T").splice(-1)[0].split(":") || [];
150
+ for (
151
+ let index = 0;
152
+ index < Math.min(currentValue.length, nextValue.length);
153
+ index++
154
+ ) {
155
+ if (currentValue[index] != nextValue[index]) {
156
+ this.$refs.timePicker.selecting = index + 1;
157
+ break;
158
+ }
159
+ }
160
+ },
161
+ emit() {
162
+ if (this.range) {
163
+ const start = this.startDateTime && new Date(this.startDateTime);
164
+ const end = this.endDateTime && new Date(this.endDateTime);
165
+ if (start && end && start > end)
166
+ [this.startDateTime, this.endDateTime] = [this.endDateTime, this.startDateTime];
167
+ }
168
+ this.$emit(
169
+ "input",
170
+ this.range
171
+ ? [this.startDateTime, this.endDateTime].filter((d) => d)
172
+ : this.startDateTime
173
+ );
174
+ },
175
+ setupValue() {
176
+ const dates =
177
+ (typeof this.value == "string" && this.value
178
+ ? this.value.split(",").filter((v) => v)
179
+ : this.value) || [];
180
+ this.startDateTime = dates.length > 0 ? cleanDateStr(dates[0]) : null;
181
+ this.endDateTime = dates.length > 1 ? cleanDateStr(dates[1]) : null;
182
+ },
183
+ },
184
+ computed: {
185
+ timeModel: {
186
+ get() {
187
+ const time = this.isStartFocused ? this.startDateTime : this.endDateTime;
188
+ if (!time) return null;
189
+ return formatLocalTime(time);
190
+ },
191
+ set(value) {
192
+ if (this.isStartFocused)
193
+ this.startDateTime = mergeTime(this.startDateTime, value).toISOString();
194
+ else this.endDateTime = mergeTime(this.endDateTime, value).toISOString();
195
+ this.emit();
196
+ },
197
+ },
198
+ dateModel: {
199
+ get() {
200
+ const d = [this.startDateTime, this.endDateTime]
201
+ .filter((d) => d)
202
+ .map((d) => formatLocalDate(d));
203
+ if (this.range) return d;
204
+ else if (d.length > 0) return d[0];
205
+ return null;
206
+ },
207
+ set(value) {
208
+ if (this.range && value.length == 2) {
209
+ this.endDateTime = mergeDate(this.endDateTime || null, value[1]).toISOString();
210
+ this.startDateTime = mergeDate(
211
+ this.startDateTime || null,
212
+ value[0]
213
+ ).toISOString();
214
+ setTimeout(() => this.$refs.endRawInput?.focus());
215
+ } else {
216
+ this.endDateTime = null;
217
+ this.startDateTime = mergeDate(
218
+ this.startDateTime || null,
219
+ Array.isArray(value) ? value[0] : value
220
+ ).toISOString();
221
+ }
222
+ this.emit();
223
+ },
224
+ },
225
+ startRawDateTime: {
226
+ get() {
227
+ if (!this.startDateTime) return null;
228
+ return formatLocalDateTime(this.startDateTime);
229
+ },
230
+ set(value) {
231
+ const oldDateTime = this.startDateTime;
232
+ if (value) this.startDateTime = new Date(value).toISOString();
233
+ this.selectTimePickerMethod(oldDateTime, this.startDateTime);
234
+ this.emit();
235
+ },
236
+ },
237
+ endRawDateTime: {
238
+ get() {
239
+ if (!this.endDateTime) return null;
240
+ return formatLocalDateTime(this.endDateTime);
241
+ },
242
+ set(value) {
243
+ const oldDateTime = this.endDateTime;
244
+ if (value) this.endDateTime = new Date(value).toISOString();
245
+ this.selectTimePickerMethod(oldDateTime, this.endDateTime);
246
+ setTimeout(() => this.$refs.endRawInput?.focus());
247
+ this.emit();
248
+ },
249
+ },
250
+ textFieldString() {
251
+ return this.range
252
+ ? [this.startDateTime, this.endDateTime]
253
+ .filter((d) => d)
254
+ .map((d) => new Date(d).toLocaleString())
255
+ .join(", ")
256
+ : this.startDateTime && new Date(this.startDateTime).toLocaleString();
257
+ },
258
+ },
259
+ mounted() {
260
+ if (process.client) {
261
+ document.addEventListener("focusin", this.focusinFunc);
262
+ }
263
+ this.setupValue();
264
+ },
265
+ destroyed() {
266
+ if (process.client) {
267
+ document.removeEventListener("focusin", this.focusinFunc);
268
+ }
269
+ },
270
+ };
271
+ </script>
@@ -0,0 +1,224 @@
1
+ <template>
2
+ <div>
3
+ <v-text-field
4
+ v-if="title"
5
+ v-model="title"
6
+ class="mb-n8 pb-0"
7
+ solo
8
+ readonly
9
+ v-bind="$attrs"
10
+ ></v-text-field>
11
+
12
+ <!-- If the media is not avaible, it shows a btn to add new media -->
13
+ <v-card
14
+ class="rounded-0"
15
+ v-bind="{
16
+ height,
17
+ width,
18
+ maxWidth,
19
+ maxHeight,
20
+ minWidth,
21
+ minHeight,
22
+ ...$attrs,
23
+ }"
24
+ >
25
+ <MediaPreview
26
+ class="media-preview"
27
+ :key="childKey"
28
+ v-if="mediaExists"
29
+ :media="internalValue"
30
+ :video-preview="internalValue.is_image ? false : true"
31
+ />
32
+
33
+ <v-card-title>{{ label }}</v-card-title>
34
+ <v-card-text v-show="internalValue">
35
+ <h4>{{ $t("mapo.fileName") }}:</h4>
36
+ {{ fileName }}
37
+ <h4>{{ $t("mapo.created") }}:</h4>
38
+ {{ fileInfo.created }}
39
+ </v-card-text>
40
+ <v-card-actions>
41
+ <template v-if="!internalValue && !rmAddBtn">
42
+ <v-btn
43
+ tile
44
+ :disabled="readonly"
45
+ @click="editing = true"
46
+ block
47
+ :min-height="minHeight"
48
+ >
49
+ <v-icon size="80"> mdi-plus-circle-outline </v-icon>
50
+ </v-btn>
51
+ </template>
52
+ <template v-else>
53
+ <v-row >
54
+ <v-col align="center">
55
+ <v-btn
56
+ :disabled="readonly"
57
+ @click="editing = true"
58
+ block
59
+ >
60
+ <v-icon>mdi-pencil</v-icon>
61
+ </v-btn>
62
+ </v-col>
63
+ <v-col align="center">
64
+ <v-btn
65
+ :disabled="readonly"
66
+ @click="confirmDelete"
67
+ color="error"
68
+ block
69
+ >
70
+ <v-icon>mdi-delete</v-icon>
71
+ </v-btn>
72
+ </v-col>
73
+ </v-row>
74
+ </template>
75
+ </v-card-actions>
76
+ </v-card>
77
+ <!-- Select media dialog -->
78
+ <media-manager-dialog
79
+ v-model="editing"
80
+ select="single"
81
+ v-on:selectionChange="update"
82
+ v-bind="$attrs"
83
+ >
84
+ </media-manager-dialog>
85
+
86
+ <v-messages v-model="errorMessages" color="error" class="mt-2" />
87
+ </div>
88
+ </template>
89
+
90
+ <style scoped>
91
+ .media-preview {
92
+ cursor: pointer;
93
+ }
94
+ </style>
95
+
96
+ <script>
97
+ export default {
98
+ name: "EnhancedMediaField",
99
+ data() {
100
+ return {
101
+ internalValue: null,
102
+ editing: false,
103
+ childKey: 0,
104
+ };
105
+ },
106
+
107
+ props: {
108
+ value: Object,
109
+ label: String,
110
+ title: {
111
+ type: String,
112
+ default: () => "",
113
+ },
114
+ errorMessages: {
115
+ type: String | Array,
116
+ default: () => [],
117
+ },
118
+ rmAddBtn: {
119
+ type: Boolean,
120
+ default: false,
121
+ },
122
+ //image reflections
123
+ aspectRatio: {
124
+ type: String | Number,
125
+ default: undefined,
126
+ },
127
+ contain: {
128
+ type: Boolean,
129
+ default: false,
130
+ },
131
+ height: {
132
+ type: String | Number,
133
+ default: "100%",
134
+ },
135
+ width: {
136
+ type: String | Number,
137
+ default: "100%",
138
+ },
139
+ maxWidth: {
140
+ type: String | Number,
141
+ default: undefined,
142
+ },
143
+ maxHeight: {
144
+ type: String | Number,
145
+ default: undefined,
146
+ },
147
+ minWidth: {
148
+ type: String | Number,
149
+ default: undefined,
150
+ },
151
+ minHeight: {
152
+ type: String | Number,
153
+ default: 300,
154
+ },
155
+ // This set the component status to readonly, stopping the user interaction.
156
+ readonly: {
157
+ type: Boolean,
158
+ default: false,
159
+ },
160
+ },
161
+
162
+ computed: {
163
+ mediaExists() {
164
+ return !!this.internalValue?.file;
165
+ },
166
+ fileInfo() {
167
+ return {
168
+ title: this.internalValue?.title,
169
+ created: new Date(this.internalValue?.created).toLocaleDateString(
170
+ this.internalValue?.language_code
171
+ ),
172
+ };
173
+ },
174
+ fileName() {
175
+ return (
176
+ this.internalValue &&
177
+ this.internalValue.file &&
178
+ this.internalValue.file.split("/").pop()
179
+ );
180
+ },
181
+ },
182
+
183
+ methods: {
184
+ update(val) {
185
+ this.updateChild();
186
+ this.internalValue = val;
187
+ },
188
+ confirmDelete() {
189
+ this.$mapo.$confirm
190
+ .open({
191
+ title: this.$t("mapo.remove"),
192
+ question: this.$t("mapo.mediaField.confirmRemove"),
193
+ approveButton: {
194
+ text: this.$t("mapo.remove"),
195
+ attrs: { color: "red", text: true },
196
+ },
197
+ })
198
+ .then((res) => (res ? (this.internalValue = null) : null));
199
+ },
200
+ updateChild() {
201
+ this.childKey += 1;
202
+ },
203
+ isImage(val) {
204
+ if (!val?.is_image && val?.mime_type.includes("image")) {
205
+ Object.assign(val, { is_image: true });
206
+ }
207
+ },
208
+ },
209
+ watch: {
210
+ value(val) {
211
+ if (val !== this.internalValue) {
212
+ this.internalValue = val;
213
+ }
214
+ },
215
+ internalValue(val) {
216
+ this.isImage(val);
217
+ this.$emit("input", val);
218
+ },
219
+ },
220
+ mounted() {
221
+ this.internalValue = this.value;
222
+ },
223
+ };
224
+ </script>
@@ -0,0 +1,125 @@
1
+ <template>
2
+ <div class="filefield-wrapper">
3
+ <v-file-input
4
+ v-bind="$attrs"
5
+ :messages="messages"
6
+ :value="model"
7
+ @change="modelSet"
8
+ >
9
+ <template v-slot:message="{ message }">
10
+ <span
11
+ v-if="message == fileUrl"
12
+ v-show="message"
13
+ class="filefield-current"
14
+ ><b class="mr-1">Current:</b>
15
+ <a @click="openFile(message)">{{ message }}</a>
16
+ <v-spacer></v-spacer>
17
+ <v-icon @click="clear" class="mb-1" small>mdi-close</v-icon>
18
+ </span>
19
+ <span v-else>
20
+ {{ message }}
21
+ </span>
22
+ </template>
23
+ </v-file-input>
24
+ </div>
25
+ </template>
26
+
27
+ <style lang="scss" scoped>
28
+ .filefield-current {
29
+ max-width: 100%;
30
+ white-space: nowrap;
31
+ display: flex;
32
+ a {
33
+ overflow: hidden;
34
+ text-overflow: ellipsis;
35
+ }
36
+ }
37
+ </style>
38
+
39
+
40
+ <script>
41
+ /**
42
+ * This component is made to enhance [v-file-input](https://vuetifyjs.com/en/components/file-inputs/). The main upgrade from the vuetify component is the ability to maintain and show the url of the current saved file.
43
+ */
44
+
45
+ export default {
46
+ name: "FileField",
47
+ data() {
48
+ return {
49
+ file: null,
50
+ fileUrl: null,
51
+ };
52
+ },
53
+ props: {
54
+ // V-model property. It is the file.
55
+ value: {
56
+ type: Object | Array | null,
57
+ required: true,
58
+ },
59
+ },
60
+ computed: {
61
+ model: {
62
+ get() {
63
+ return this.file;
64
+ },
65
+ set(val) {
66
+ if (!val || typeof val == "string") this.fileUrl = val;
67
+ if (!val || val instanceof File) this.file = val;
68
+ },
69
+ },
70
+ messages() {
71
+ const messages =
72
+ typeof this.$attrs.messages == "string"
73
+ ? [this.$attrs.messages]
74
+ : this.$attrs.messages || [];
75
+ this.fileUrl &&
76
+ !messages.includes(this.fileUrl) &&
77
+ messages.push(this.fileUrl);
78
+ return messages;
79
+ },
80
+ },
81
+ watch: {
82
+ value(val) {
83
+ this.model = val;
84
+ },
85
+ model(val) {
86
+ this.$emit("input", val);
87
+ },
88
+ },
89
+ methods: {
90
+ clear() {
91
+ this.fileUrl = null;
92
+ this.file = null;
93
+ this.model = null;
94
+ this.$emit("input", null);
95
+ },
96
+ modelSet(val) {
97
+ if (!val) {
98
+ this.$emit("input", this.fileUrl);
99
+ } else {
100
+ this.model = val;
101
+ }
102
+ },
103
+ openFile(url) {
104
+ const w = 700;
105
+ const h = 700;
106
+ const left = screen.width / 2 - w / 2;
107
+ const top = screen.height / 2 - h / 2;
108
+ window.open(
109
+ url,
110
+ url,
111
+ `width=${w},
112
+ height=${h},
113
+ top=${top},
114
+ left=${left}
115
+ `
116
+ );
117
+
118
+ return false;
119
+ },
120
+ },
121
+ created() {
122
+ this.model = this.value;
123
+ },
124
+ };
125
+ </script>
@@ -0,0 +1,88 @@
1
+ <template>
2
+ <v-autocomplete
3
+ v-bind="fieldAttrs"
4
+ v-model="model"
5
+ :items="options"
6
+ ></v-autocomplete>
7
+ </template>
8
+
9
+ <script>
10
+ /**
11
+ * This component is made to simplify ManyToMany and ForeignKeys associations. With this component you can modify an array selecting items from a list of checkboxes or a signle item selecting from a checkbox.
12
+ */
13
+
14
+ export default {
15
+ name: "FksField",
16
+ data() {
17
+ return {
18
+ model: this.value,
19
+ options: this.items || [],
20
+ loading: false,
21
+ };
22
+ },
23
+ props: {
24
+ // V-model property. It is the attribute to be modified.
25
+ value: {
26
+ type: Object | Array | null,
27
+ required: true,
28
+ },
29
+ // This is the array of options from which you can choose.
30
+ items: {
31
+ type: Array,
32
+ default: () => [],
33
+ },
34
+ // This is the endpoint where the component can fetch options.
35
+ endpoint: String | Object,
36
+ },
37
+ computed: {
38
+ fieldAttrs() {
39
+ return {
40
+ chips: this.$attrs.multiple === false ? false : true,
41
+ multiple: true,
42
+ loading: this.loading,
43
+ noDataText: this.loading ? this.$t("mapo.fetchingData") : undefined,
44
+ ...this.$attrs,
45
+ };
46
+ },
47
+ crudConfig() {
48
+ switch (typeof this.endpoint) {
49
+ case "string":
50
+ return {
51
+ url: this.endpoint,
52
+ conf: null,
53
+ };
54
+ case "object":
55
+ return {
56
+ url: this.endpoint.url,
57
+ conf: this.endpoint.conf,
58
+ };
59
+ default:
60
+ return { url: "", conf: null };
61
+ }
62
+ },
63
+ },
64
+ watch: {
65
+ items(val) {
66
+ this.options = val || [];
67
+ },
68
+ value(val) {
69
+ this.model = val;
70
+ },
71
+ model(val) {
72
+ this.$emit("input", val);
73
+ },
74
+ },
75
+ mounted() {
76
+ if (this.crudConfig.url) {
77
+ this.loading = true;
78
+ this.$mapo.$api
79
+ .crud(this.crudConfig.url)
80
+ .list(this.crudConfig.conf)
81
+ .then((res) => {
82
+ this.options = res;
83
+ this.loading = false;
84
+ });
85
+ }
86
+ },
87
+ };
88
+ </script>