@mapomodule/uikit 1.0.0 → 2.0.0-beta.1

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 (266) hide show
  1. package/README.md +167 -0
  2. package/dist/index.d.cts +2 -0
  3. package/dist/index.d.mts +2 -0
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.mjs +18 -0
  6. package/dist/module.d.cts +2 -0
  7. package/dist/module.d.mts +2 -0
  8. package/dist/module.d.ts +2 -0
  9. package/dist/module.json +9 -0
  10. package/dist/module.mjs +18 -0
  11. package/dist/types.d.mts +13 -0
  12. package/package.json +63 -12
  13. package/src/index.ts +10 -0
  14. package/src/module.ts +181 -0
  15. package/src/runtime/assets/main.css +59 -0
  16. package/src/runtime/components/MapoConfirmDialog.vue +34 -0
  17. package/src/runtime/components/MapoDetail.vue +861 -0
  18. package/src/runtime/components/MapoDetailLangSwitch.vue +166 -0
  19. package/src/runtime/components/MapoList.vue +339 -0
  20. package/src/runtime/components/MapoListActions.vue +152 -0
  21. package/src/runtime/components/MapoListFilters.vue +289 -0
  22. package/src/runtime/components/MapoListHead.vue +12 -0
  23. package/src/runtime/components/MapoListQuickEdit.vue +163 -0
  24. package/src/runtime/components/MapoListTable.vue +926 -0
  25. package/src/runtime/components/MapoListTabs.vue +48 -0
  26. package/src/runtime/components/MapoLogin.vue +209 -0
  27. package/src/runtime/components/MapoLogoutButton.vue +46 -0
  28. package/src/runtime/components/MapoRootComponents.vue +9 -0
  29. package/src/runtime/components/MapoSidebar.vue +112 -0
  30. package/src/runtime/components/MapoSidebarList.vue +35 -0
  31. package/src/runtime/components/MapoSidebarListItem.vue +79 -0
  32. package/src/runtime/components/MapoSidebarProfile.vue +57 -0
  33. package/src/runtime/components/MapoSnackBar.vue +42 -0
  34. package/src/runtime/components/MapoThemeToggle.vue +23 -0
  35. package/src/runtime/components/MapoTopbar.vue +36 -0
  36. package/src/runtime/layouts/default.vue +53 -0
  37. package/src/runtime/layouts/empty.vue +9 -0
  38. package/src/runtime/page-meta.nuxt.d.ts +45 -0
  39. package/src/runtime/pages/index.vue +14 -0
  40. package/src/runtime/pages/login.vue +7 -0
  41. package/src/runtime/types/list.ts +64 -0
  42. package/CHANGELOG.md +0 -1030
  43. package/assets/mixins.scss +0 -22
  44. package/assets/variables.scss +0 -18
  45. package/components/ConfirmDialog.vue +0 -173
  46. package/components/Detail/Detail.vue +0 -696
  47. package/components/Detail/DetailLangSwitch.vue +0 -79
  48. package/components/DropArea.vue +0 -257
  49. package/components/Form/Form.vue +0 -218
  50. package/components/Form/FormField.vue +0 -216
  51. package/components/Form/FormGroup.vue +0 -146
  52. package/components/Form/FormTabs.vue +0 -188
  53. package/components/Form/defaults.js +0 -98
  54. package/components/Form/fields/ColorField.vue +0 -79
  55. package/components/Form/fields/DateField.vue +0 -77
  56. package/components/Form/fields/DateTimeField.vue +0 -271
  57. package/components/Form/fields/EnhancedMediaField.vue +0 -224
  58. package/components/Form/fields/FileField.vue +0 -125
  59. package/components/Form/fields/FksField.vue +0 -115
  60. package/components/Form/fields/MediaField.vue +0 -159
  61. package/components/Form/fields/MediaM2mField.vue +0 -149
  62. package/components/Form/fields/Repeater.vue +0 -618
  63. package/components/Form/fields/SeoPreview.vue +0 -89
  64. package/components/Form/fields/TimeField.vue +0 -154
  65. package/components/Form/fields/mapField/leaflet.injector.js +0 -39
  66. package/components/Form/fields/mapField/mapField.vue +0 -350
  67. package/components/Form/fields/wygEditor/defaults.js +0 -25
  68. package/components/Form/fields/wygEditor/utils/events.js +0 -64
  69. package/components/Form/fields/wygEditor/utils/mapomedia.plugin.js +0 -32
  70. package/components/Form/fields/wygEditor/utils/tinymce.injector.js +0 -29
  71. package/components/Form/fields/wygEditor/wygEditor.vue +0 -285
  72. package/components/Form/fields/wygEditorCKE/defaults.js +0 -103
  73. package/components/Form/fields/wygEditorCKE/utils/ckeditor.injector.js +0 -29
  74. package/components/Form/fields/wygEditorCKE/wygEditorCKE.vue +0 -270
  75. package/components/LangSwitcher.vue +0 -44
  76. package/components/List/List.vue +0 -271
  77. package/components/List/ListActions.vue +0 -164
  78. package/components/List/ListFilters.vue +0 -372
  79. package/components/List/ListHead.vue +0 -67
  80. package/components/List/ListQuickEdit.vue +0 -228
  81. package/components/List/ListTable.vue +0 -484
  82. package/components/List/ListTabs.vue +0 -65
  83. package/components/Login.vue +0 -125
  84. package/components/Logo.vue +0 -79
  85. package/components/LogoutButton.vue +0 -54
  86. package/components/MediaManager/MediaBreadcrumbs.vue +0 -45
  87. package/components/MediaManager/MediaEditor.vue +0 -340
  88. package/components/MediaManager/MediaFileChanger.vue +0 -78
  89. package/components/MediaManager/MediaFolders.vue +0 -287
  90. package/components/MediaManager/MediaGallery.vue +0 -281
  91. package/components/MediaManager/MediaManager.vue +0 -159
  92. package/components/MediaManager/MediaManagerDialog.vue +0 -104
  93. package/components/MediaManager/MediaPreview.vue +0 -258
  94. package/components/MediaManager/MediaUploader.vue +0 -163
  95. package/components/MenuManager/MenuManager.vue +0 -332
  96. package/components/MenuManager/MenuNodeEditor.vue +0 -270
  97. package/components/MenuManager/MenuTreeview.vue +0 -237
  98. package/components/MenuManager/MenuTreeviewNode.vue +0 -208
  99. package/components/PagePreview.vue +0 -58
  100. package/components/RootComponents.vue +0 -25
  101. package/components/SnackBar.vue +0 -69
  102. package/components/ThemeToggle.vue +0 -13
  103. package/components/layout/Sidebar/Sidebar.vue +0 -89
  104. package/components/layout/Sidebar/SidebarList.vue +0 -49
  105. package/components/layout/Sidebar/SidebarListItem.vue +0 -185
  106. package/components/layout/Sidebar/SidebarProfile.vue +0 -42
  107. package/components/layout/Sidebar/SidebarTitle.vue +0 -45
  108. package/components/layout/Topbar/Topbar.vue +0 -29
  109. package/components/layout/routebuilder.js +0 -48
  110. package/defaults/i18n.js +0 -37
  111. package/defaults/vuetify.js +0 -34
  112. package/layouts/default.vue +0 -47
  113. package/layouts/empty.vue +0 -16
  114. package/module.js +0 -80
  115. package/pages/index.vue +0 -37
  116. package/pages/login.vue +0 -10
  117. package/static/mapo/ckeditor/plugins/image2/dev/assets/image1.jpg +0 -0
  118. package/static/mapo/ckeditor/plugins/image2/dev/assets/image2.jpg +0 -0
  119. package/static/mapo/ckeditor/plugins/image2/dev/contents.css +0 -35
  120. package/static/mapo/ckeditor/plugins/image2/dev/image2.html +0 -338
  121. package/static/mapo/ckeditor/plugins/image2/dialogs/image2.js +0 -557
  122. package/static/mapo/ckeditor/plugins/image2/icons/hidpi/image.png +0 -0
  123. package/static/mapo/ckeditor/plugins/image2/icons/image.png +0 -0
  124. package/static/mapo/ckeditor/plugins/image2/lang/af.js +0 -21
  125. package/static/mapo/ckeditor/plugins/image2/lang/ar.js +0 -21
  126. package/static/mapo/ckeditor/plugins/image2/lang/az.js +0 -21
  127. package/static/mapo/ckeditor/plugins/image2/lang/bg.js +0 -21
  128. package/static/mapo/ckeditor/plugins/image2/lang/bn.js +0 -21
  129. package/static/mapo/ckeditor/plugins/image2/lang/bs.js +0 -21
  130. package/static/mapo/ckeditor/plugins/image2/lang/ca.js +0 -21
  131. package/static/mapo/ckeditor/plugins/image2/lang/cs.js +0 -21
  132. package/static/mapo/ckeditor/plugins/image2/lang/cy.js +0 -21
  133. package/static/mapo/ckeditor/plugins/image2/lang/da.js +0 -21
  134. package/static/mapo/ckeditor/plugins/image2/lang/de-ch.js +0 -21
  135. package/static/mapo/ckeditor/plugins/image2/lang/de.js +0 -21
  136. package/static/mapo/ckeditor/plugins/image2/lang/el.js +0 -21
  137. package/static/mapo/ckeditor/plugins/image2/lang/en-au.js +0 -21
  138. package/static/mapo/ckeditor/plugins/image2/lang/en-ca.js +0 -21
  139. package/static/mapo/ckeditor/plugins/image2/lang/en-gb.js +0 -21
  140. package/static/mapo/ckeditor/plugins/image2/lang/en.js +0 -21
  141. package/static/mapo/ckeditor/plugins/image2/lang/eo.js +0 -21
  142. package/static/mapo/ckeditor/plugins/image2/lang/es-mx.js +0 -21
  143. package/static/mapo/ckeditor/plugins/image2/lang/es.js +0 -21
  144. package/static/mapo/ckeditor/plugins/image2/lang/et.js +0 -21
  145. package/static/mapo/ckeditor/plugins/image2/lang/eu.js +0 -21
  146. package/static/mapo/ckeditor/plugins/image2/lang/fa.js +0 -21
  147. package/static/mapo/ckeditor/plugins/image2/lang/fi.js +0 -21
  148. package/static/mapo/ckeditor/plugins/image2/lang/fo.js +0 -21
  149. package/static/mapo/ckeditor/plugins/image2/lang/fr-ca.js +0 -21
  150. package/static/mapo/ckeditor/plugins/image2/lang/fr.js +0 -21
  151. package/static/mapo/ckeditor/plugins/image2/lang/gl.js +0 -21
  152. package/static/mapo/ckeditor/plugins/image2/lang/gu.js +0 -21
  153. package/static/mapo/ckeditor/plugins/image2/lang/he.js +0 -21
  154. package/static/mapo/ckeditor/plugins/image2/lang/hi.js +0 -21
  155. package/static/mapo/ckeditor/plugins/image2/lang/hr.js +0 -21
  156. package/static/mapo/ckeditor/plugins/image2/lang/hu.js +0 -21
  157. package/static/mapo/ckeditor/plugins/image2/lang/id.js +0 -21
  158. package/static/mapo/ckeditor/plugins/image2/lang/is.js +0 -21
  159. package/static/mapo/ckeditor/plugins/image2/lang/it.js +0 -21
  160. package/static/mapo/ckeditor/plugins/image2/lang/ja.js +0 -21
  161. package/static/mapo/ckeditor/plugins/image2/lang/ka.js +0 -21
  162. package/static/mapo/ckeditor/plugins/image2/lang/km.js +0 -21
  163. package/static/mapo/ckeditor/plugins/image2/lang/ko.js +0 -21
  164. package/static/mapo/ckeditor/plugins/image2/lang/ku.js +0 -21
  165. package/static/mapo/ckeditor/plugins/image2/lang/lt.js +0 -21
  166. package/static/mapo/ckeditor/plugins/image2/lang/lv.js +0 -21
  167. package/static/mapo/ckeditor/plugins/image2/lang/mk.js +0 -21
  168. package/static/mapo/ckeditor/plugins/image2/lang/mn.js +0 -21
  169. package/static/mapo/ckeditor/plugins/image2/lang/ms.js +0 -21
  170. package/static/mapo/ckeditor/plugins/image2/lang/nb.js +0 -21
  171. package/static/mapo/ckeditor/plugins/image2/lang/nl.js +0 -21
  172. package/static/mapo/ckeditor/plugins/image2/lang/no.js +0 -21
  173. package/static/mapo/ckeditor/plugins/image2/lang/oc.js +0 -21
  174. package/static/mapo/ckeditor/plugins/image2/lang/pl.js +0 -21
  175. package/static/mapo/ckeditor/plugins/image2/lang/pt-br.js +0 -21
  176. package/static/mapo/ckeditor/plugins/image2/lang/pt.js +0 -21
  177. package/static/mapo/ckeditor/plugins/image2/lang/ro.js +0 -21
  178. package/static/mapo/ckeditor/plugins/image2/lang/ru.js +0 -21
  179. package/static/mapo/ckeditor/plugins/image2/lang/si.js +0 -21
  180. package/static/mapo/ckeditor/plugins/image2/lang/sk.js +0 -21
  181. package/static/mapo/ckeditor/plugins/image2/lang/sl.js +0 -21
  182. package/static/mapo/ckeditor/plugins/image2/lang/sq.js +0 -21
  183. package/static/mapo/ckeditor/plugins/image2/lang/sr-latn.js +0 -21
  184. package/static/mapo/ckeditor/plugins/image2/lang/sr.js +0 -21
  185. package/static/mapo/ckeditor/plugins/image2/lang/sv.js +0 -21
  186. package/static/mapo/ckeditor/plugins/image2/lang/th.js +0 -21
  187. package/static/mapo/ckeditor/plugins/image2/lang/tr.js +0 -21
  188. package/static/mapo/ckeditor/plugins/image2/lang/tt.js +0 -21
  189. package/static/mapo/ckeditor/plugins/image2/lang/ug.js +0 -21
  190. package/static/mapo/ckeditor/plugins/image2/lang/uk.js +0 -21
  191. package/static/mapo/ckeditor/plugins/image2/lang/vi.js +0 -21
  192. package/static/mapo/ckeditor/plugins/image2/lang/zh-cn.js +0 -21
  193. package/static/mapo/ckeditor/plugins/image2/lang/zh.js +0 -21
  194. package/static/mapo/ckeditor/plugins/image2/plugin.js +0 -1798
  195. package/static/mapo/ckeditor/plugins/image2/samples/assets/image1.jpg +0 -0
  196. package/static/mapo/ckeditor/plugins/image2/samples/assets/image2.jpg +0 -0
  197. package/static/mapo/ckeditor/plugins/image2/samples/image2.html +0 -68
  198. package/static/mapo/ckeditor/skins/moono/dev/icons16.png +0 -0
  199. package/static/mapo/ckeditor/skins/moono/dev/icons16.svg +0 -2374
  200. package/static/mapo/ckeditor/skins/moono/dev/icons32.png +0 -0
  201. package/static/mapo/ckeditor/skins/moono/dev/icons32.svg +0 -2722
  202. package/static/mapo/ckeditor/skins/moono/dev/locations.json +0 -144
  203. package/static/mapo/ckeditor/skins/moono/dialog.css +0 -5
  204. package/static/mapo/ckeditor/skins/moono/dialog_ie.css +0 -5
  205. package/static/mapo/ckeditor/skins/moono/dialog_ie7.css +0 -5
  206. package/static/mapo/ckeditor/skins/moono/dialog_ie8.css +0 -5
  207. package/static/mapo/ckeditor/skins/moono/dialog_iequirks.css +0 -5
  208. package/static/mapo/ckeditor/skins/moono/editor.css +0 -5
  209. package/static/mapo/ckeditor/skins/moono/editor_gecko.css +0 -5
  210. package/static/mapo/ckeditor/skins/moono/editor_ie.css +0 -5
  211. package/static/mapo/ckeditor/skins/moono/editor_ie7.css +0 -5
  212. package/static/mapo/ckeditor/skins/moono/editor_ie8.css +0 -5
  213. package/static/mapo/ckeditor/skins/moono/editor_iequirks.css +0 -5
  214. package/static/mapo/ckeditor/skins/moono/icons.png +0 -0
  215. package/static/mapo/ckeditor/skins/moono/icons_hidpi.png +0 -0
  216. package/static/mapo/ckeditor/skins/moono/images/anchor.png +0 -0
  217. package/static/mapo/ckeditor/skins/moono/images/arrow.png +0 -0
  218. package/static/mapo/ckeditor/skins/moono/images/close.png +0 -0
  219. package/static/mapo/ckeditor/skins/moono/images/hidpi/anchor.png +0 -0
  220. package/static/mapo/ckeditor/skins/moono/images/hidpi/close.png +0 -0
  221. package/static/mapo/ckeditor/skins/moono/images/hidpi/lock-open.png +0 -0
  222. package/static/mapo/ckeditor/skins/moono/images/hidpi/lock.png +0 -0
  223. package/static/mapo/ckeditor/skins/moono/images/hidpi/refresh.png +0 -0
  224. package/static/mapo/ckeditor/skins/moono/images/lock-open.png +0 -0
  225. package/static/mapo/ckeditor/skins/moono/images/lock.png +0 -0
  226. package/static/mapo/ckeditor/skins/moono/images/refresh.png +0 -0
  227. package/static/mapo/ckeditor/skins/moono/images/spinner.gif +0 -0
  228. package/static/mapo/ckeditor/skins/moono/readme.md +0 -49
  229. package/static/mapo/ckeditor/skins/moono/skin.js +0 -10
  230. package/static/mapo/ckeditor/skins/moono-dark/dialog.css +0 -5
  231. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie.css +0 -5
  232. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie7.css +0 -5
  233. package/static/mapo/ckeditor/skins/moono-dark/dialog_ie8.css +0 -5
  234. package/static/mapo/ckeditor/skins/moono-dark/dialog_iequirks.css +0 -5
  235. package/static/mapo/ckeditor/skins/moono-dark/editor.css +0 -5
  236. package/static/mapo/ckeditor/skins/moono-dark/editor_gecko.css +0 -5
  237. package/static/mapo/ckeditor/skins/moono-dark/editor_ie.css +0 -5
  238. package/static/mapo/ckeditor/skins/moono-dark/editor_ie7.css +0 -5
  239. package/static/mapo/ckeditor/skins/moono-dark/editor_ie8.css +0 -5
  240. package/static/mapo/ckeditor/skins/moono-dark/editor_iequirks.css +0 -5
  241. package/static/mapo/ckeditor/skins/moono-dark/icons.png +0 -0
  242. package/static/mapo/ckeditor/skins/moono-dark/icons_hidpi.png +0 -0
  243. package/static/mapo/ckeditor/skins/moono-dark/images/arrow.png +0 -0
  244. package/static/mapo/ckeditor/skins/moono-dark/images/close.png +0 -0
  245. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/close.png +0 -0
  246. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock-open.png +0 -0
  247. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/lock.png +0 -0
  248. package/static/mapo/ckeditor/skins/moono-dark/images/hidpi/refresh.png +0 -0
  249. package/static/mapo/ckeditor/skins/moono-dark/images/lock-open.png +0 -0
  250. package/static/mapo/ckeditor/skins/moono-dark/images/lock.png +0 -0
  251. package/static/mapo/ckeditor/skins/moono-dark/images/refresh.png +0 -0
  252. package/static/mapo/ckeditor/skins/moono-dark/readme.md +0 -51
  253. package/static/mapo/ckeditor/skins/moono-dark/skin.js +0 -5
  254. package/static/mapo/favicon.ico +0 -0
  255. package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +0 -7
  256. package/static/mapo/tinymce-skins/mapo-dark/content.min.css +0 -7
  257. package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +0 -7
  258. package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +0 -7
  259. package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +0 -7
  260. package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +0 -7
  261. package/static/mapo/tinymce-skins/mapo-light/content.min.css +0 -7
  262. package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +0 -7
  263. package/static/mapo/tinymce-skins/mapo-light/skin.min.css +0 -7
  264. package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +0 -7
  265. package/translations/en-US.js +0 -177
  266. package/translations/it-IT.js +0 -180
@@ -1,696 +0,0 @@
1
- <template>
2
- <div class="mapo-detail--wrapper">
3
- <div class="mapo-detail--loader" v-if="loading">
4
- <v-progress-linear color="primary" indeterminate absolute></v-progress-linear>
5
- <span class="detail-component-loading">
6
- <v-icon size="30">mdi-timer-sand</v-icon>
7
- {{ $t("mapo.fetchingData") }}
8
- </span>
9
- </div>
10
- <div class="mapo-detail--loaded" v-else>
11
- <!-- Use this to override the title of the detail component. -->
12
- <slot name="title" v-bind="slotBindings">
13
- <!-- `<h1> "Create | Edit" + modelName </h1>` -->
14
- <h1 class="mapo-detail--title">
15
- {{ isNew ? $t("mapo.create") : $t("mapo.edit") }} {{ modelName }}
16
- </h1>
17
- </slot>
18
- <v-form class="mapo-detail--form" ref="form">
19
- <v-row>
20
- <v-col class="mapo-detail--main" cols="12" :md="12 - sidenavCol">
21
- <!-- Use this to add content at the top of the central layout. -->
22
- <slot name="body.top" v-bind="slotBindings"></slot>
23
- <!-- Use this to override the Language Switch panel. -->
24
- <slot name="body.lang" v-bind="slotBindings">
25
- <!-- [`DetailLangSwitch`](/components/detail/DetailLangSwitch/) -->
26
- <DetailLangSwitch
27
- v-if="langs && langs.length"
28
- v-show="langs.length > 1"
29
- class="mapo-detail--language-tabs"
30
- v-model="currentLang"
31
- :langs="langs"
32
- :errors="errors"
33
- /></slot>
34
- <!-- Use this to add content under the Language Switch panel. -->
35
- <slot name="body.top.underlang" v-bind="slotBindings"></slot>
36
- <!-- Use this to override the content of the main body. -->
37
- <slot name="body" v-bind="slotBindings">
38
- <Form
39
- v-model="model"
40
- :currentLang="currentLang"
41
- :languages="langs"
42
- :errors="errors"
43
- :fields="mainFields"
44
- :moreSlotBindings="slotBindings"
45
- :readonly="isReadonly"
46
- >
47
- <template v-for="(_, slot) in $slots" :slot="slot">
48
- <!-- @vuese-ignore -->
49
- <slot :name="slot"></slot>
50
- </template>
51
- <template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
52
- <!-- @vuese-ignore -->
53
- <slot :name="slot" v-bind="props" />
54
- </template>
55
- </Form>
56
- </slot>
57
- <!-- Use this to add content under the main body. -->
58
- <slot name="body.bottom" v-bind="slotBindings"></slot>
59
- </v-col>
60
- <v-col class="mapo-detail--sidenav" cols="12" :md="sidenavCol">
61
- <div class="mapo-detail--sidenav-col" :style="stickySide">
62
- <!-- Use this to add content on the top of the sidebar button panel. -->
63
- <slot name="side.buttons.top" v-bind="slotBindings"></slot>
64
- <!-- Use this to override the the sidebar button panel. -->
65
- <slot name="side.buttons" v-bind="slotBindings">
66
- <!-- Save, Save and continue, Back, and Delete buttons. -->
67
- <div class="mapo-detail--buttons">
68
- <!-- Use this to override the Save button. -->
69
- <slot name="button.save" v-bind="slotBindings">
70
- <!-- The Save button. -->
71
- <v-btn
72
- v-show="canGoBack"
73
- :loading="buttonClicked == 'saveAndBackBtn'"
74
- :disabled="isReadonly"
75
- tile
76
- block
77
- @click="saveItem(true)"
78
- >{{ isNew ? $t("mapo.create") : $t("mapo.save") }}</v-btn
79
- >
80
- </slot>
81
- <!-- Use this to override the Save and continue button. -->
82
- <slot name="button.savecontinue" v-bind="slotBindings">
83
- <!-- The Save and continue button. -->
84
- <v-btn
85
- :loading="buttonClicked == 'saveBtn'"
86
- :disabled="isReadonly"
87
- tile
88
- block
89
- @click="saveItem(false)"
90
- >{{
91
- isNew ? $t("mapo.createContinue") : $t("mapo.saveContinue")
92
- }}</v-btn
93
- >
94
- </slot>
95
- <!-- Use this to override the Back button. -->
96
- <slot name="button.back" v-bind="slotBindings">
97
- <!-- The Back button. -->
98
- <v-btn v-show="canGoBack" tile block @click="back">{{
99
- $t("mapo.back")
100
- }}</v-btn>
101
- </slot>
102
- <!-- Use this to override the Delete button. -->
103
- <slot
104
- name="button.delete"
105
- :loading="buttonClicked == 'deleteBtn'"
106
- v-bind="slotBindings"
107
- >
108
- <!-- The Delete button. -->
109
- <v-btn
110
- v-if="!isNew"
111
- color="error"
112
- tile
113
- block
114
- :disabled="!canDelete"
115
- @click="deleteItem"
116
- >{{ $t("mapo.delete") }}</v-btn
117
- >
118
- </slot>
119
- <!-- Use this to override the Preview Page button. -->
120
- <slot name="button.preview" v-bind="slotBindings">
121
- <!-- The Preview Page button. Needs a preview field from model. Declare it in the props. -->
122
- <PagePreview
123
- v-if="previewUrl"
124
- :pageUrl="previewUrl"
125
- />
126
- </slot>
127
- </div>
128
- </slot>
129
- <!-- Use this to add content on the top of the sidebar fields (or under sidebar buttons). -->
130
- <slot name="side.top" v-bind="slotBindings"></slot>
131
- <Form
132
- v-model="model"
133
- :currentLang="currentLang"
134
- :languages="langs"
135
- :errors="errors"
136
- :fields="sideFields"
137
- :moreSlotBindings="slotBindings"
138
- :readonly="isReadonly"
139
- >
140
- <template v-for="(_, slot) in $slots" :slot="slot">
141
- <!-- @vuese-ignore -->
142
- <slot :name="slot"></slot>
143
- </template>
144
- <template v-for="(_, slot) in $scopedSlots" v-slot:[slot]="props">
145
- <!-- @vuese-ignore -->
146
- <slot :name="slot" v-bind="props" />
147
- </template>
148
- </Form>
149
- <!-- Use this to add content under the sidebar fields. -->
150
- <slot name="side.bottom" v-bind="slotBindings"></slot>
151
- </div>
152
- </v-col>
153
- </v-row>
154
- </v-form>
155
- </div>
156
- </div>
157
- </template>
158
-
159
- <style lang="scss" scoped>
160
- .mapo-detail--loader {
161
- .v-progress-linear {
162
- top: 0;
163
- }
164
- span {
165
- position: absolute;
166
- top: 50%;
167
- transform: translateY(-50%);
168
- width: 100%;
169
- display: flex;
170
- flex-direction: column;
171
- justify-content: center;
172
- align-items: center;
173
- }
174
- }
175
- .mapo-detail--title {
176
- margin-bottom: 20px;
177
- font-weight: normal;
178
- }
179
- .mapo-detail--language-tabs {
180
- margin-bottom: 20px;
181
- }
182
- .mapo-detail--sidenav-col {
183
- display: flex;
184
- flex-direction: column;
185
- }
186
- .mapo-detail--buttons {
187
- margin-top: 16px;
188
- margin-bottom: 0px;
189
- order: 1;
190
- @media (min-width: 960px) {
191
- margin-bottom: 16px;
192
- margin-top: 0px;
193
- order: 0;
194
- }
195
- .v-btn {
196
- margin-bottom: 8px;
197
- }
198
- }
199
- </style>
200
-
201
- <script>
202
- import { diffObjs, deepClone } from "@mapomodule/utils/helpers/objHelpers";
203
-
204
- /**
205
- * The purpose of this component is to provide you with a very quick way to create an edit page for a payload to send to the server.
206
- * A use case example could be "build a page that allows you to change the specifications of a product for an ecommerce".<br> <h4>Index:</h4> [[toc]]
207
- */
208
- export default {
209
- name: "Detail",
210
- data() {
211
- return {
212
- model: {},
213
- modelLanguages: [],
214
- currentLang: this.lang,
215
- errors: null,
216
- buttonClicked: null,
217
- };
218
- },
219
- props: {
220
- // V-model of the object we are editing.
221
- value: {
222
- type: Object,
223
- required: false,
224
- },
225
- // Set the current lang to value.
226
- lang: {
227
- type: String,
228
- required: false,
229
- },
230
- // The main configuration that determines the arrangement of the fields in the detail layout.
231
- fields: {
232
- // [`DetailConfiguration`](#detailconfiguration)
233
- type: Object | Array,
234
- required: true,
235
- },
236
- usePatch: {
237
- type: Boolean,
238
- default() {
239
- return this.$mapo.$options?.content?.usePatch || false;
240
- },
241
- },
242
- // A list of languages into which the payload needs to be translated.
243
- languages: {
244
- type: Array,
245
- default() {
246
- return this.$mapo.$options?.content?.languages || [];
247
- },
248
- },
249
- // Forces use of languages passed as prop, instead of those loaded with model
250
- forceLanguages: {
251
- type: Boolean,
252
- default() {
253
- return this.$mapo.$options?.content?.forceLanguages || false;
254
- },
255
- },
256
- // The url of the endpoint to which the payload is to be sent. From this url a complete crud (See [this.$mapo.$api.crud](/core/#$api.crud)) will be created.
257
- endpoint: {
258
- type: String,
259
- default: null,
260
- },
261
- // This determines the width of the sidebar in desktop view in a 12 col grid.
262
- sidenavCol: {
263
- type: Number | String,
264
- default: "4",
265
- validator: function (value) {
266
- // The value must be a number between 0 and 12
267
- return [...Array(12).keys()].indexOf(+value) !== -1;
268
- },
269
- },
270
- // The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
271
- identifier: {
272
- // `String|Number`.
273
- type: String | Number,
274
- default: "new",
275
- },
276
- // The title of the detail page.
277
- modelName: String,
278
- // This determines the style of the sidebar. If set to true the sidebar will remain sticky during the scroll.
279
- sticky: {
280
- type: Boolean,
281
- default: true,
282
- },
283
- // Set the multipart politic. Accepts `'auto'|'force|'disable'`. If auto is set the request is transformed in multipart if any file is in the payload. If set to force the request is transformed in multipart no matter if files are found. If set to `'disable'` the request is never transformed in multipart.
284
- multipart: {
285
- type: String,
286
- default: "auto",
287
- validator: function (value) {
288
- // The value must match one of these strings
289
- return ["auto", "force", "disable"].indexOf(value) !== -1;
290
- },
291
- },
292
- // The name of the field that contains the url of the page preview. [optional]
293
- previewField: {
294
- type: String,
295
- required: false,
296
- },
297
- // This forces the detail page to be readonly.
298
- readonly: Boolean
299
- },
300
- methods: {
301
- back() {
302
- this.$nuxt.context?.from?.name == "login"
303
- ? this.$router.go(-3)
304
- : this.$router.back();
305
- },
306
- saveItem(back = false) {
307
- this.buttonClicked = back ? "saveAndBackBtn" : "saveBtn";
308
- this.errors = null;
309
- this.$refs.form?.resetValidation();
310
- this.apiSendPayload()
311
- .then((resp) => {
312
- Object.assign(this.model, resp);
313
- this.modelBkp = deepClone(this.model);
314
- this.$mapo.$snack.open({
315
- message: this.isNew
316
- ? this.$t("mapo.createSuccess")
317
- : this.$t("mapo.saveSuccess"),
318
- color: "success",
319
- });
320
- this.isNew && this.$router.replace({ params: { detail: resp.id } });
321
- back && this.back();
322
- })
323
- .catch((error) => {
324
- this.errors = (error.response.status == 400 && error.response.data) || null;
325
- this.$mapo.$snack.open({
326
- message: error.response?.data?.detail || this.$t("mapo.genericError"),
327
- color: "error",
328
- });
329
- })
330
- .finally(() => {
331
- this.buttonClicked = null;
332
- });
333
- },
334
- deleteItem() {
335
- this.$mapo.$confirm
336
- .open({
337
- title: this.$t("mapo.delete"),
338
- question: this.$t("mapo.confirmDelete"),
339
- approveButton: {
340
- text: this.$t("mapo.delete"),
341
- attrs: { color: "red", text: true },
342
- },
343
- })
344
- .then((res) => {
345
- if (res) {
346
- this.buttonClicked = "deleteBtn";
347
- this.crud
348
- .delete(this.identifier)
349
- .then(() => {
350
- this.unsetRouterGuard();
351
- this.back();
352
- })
353
- .catch((error) =>
354
- this.$mapo.$snack.open({
355
- message: error.response?.data?.detail || this.$t("mapo.genericError"),
356
- color: "error",
357
- })
358
- )
359
- .finally(() => {
360
- this.buttonClicked = null;
361
- });
362
- }
363
- });
364
- },
365
- async checkUnsavedHook(to, from, next) {
366
- if (to.name !== from.name && this.hasDiff) {
367
- this.$mapo.$confirm
368
- .open({
369
- title: this.$t("mapo.unsavedData"),
370
- question: this.$t("mapo.confirmLeaveChanges"),
371
- approveButton: { text: this.$t("mapo.confirm"), attrs: { text: true } },
372
- })
373
- .then(next);
374
- } else {
375
- next();
376
- }
377
- },
378
- setRouterGuard() {
379
- this.$router.beforeHooks.push(this.checkUnsavedHook);
380
- window?.addEventListener("beforeunload", this.preventWindowClose);
381
- },
382
- preventWindowClose(event) {
383
- const text = this.$t("mapo.confirmLeaveChanges");
384
- if (this.hasDiff) {
385
- event.returnValue = text;
386
- return text;
387
- }
388
- },
389
- unsetRouterGuard() {
390
- window?.removeEventListener("beforeunload", this.preventWindowClose);
391
- this.$router.beforeHooks = this.$router.beforeHooks.filter(
392
- (f) => f != this.checkUnsavedHook
393
- );
394
- },
395
- },
396
- watch: {
397
- currentLang(val) {
398
- // Fired when the current language changes.
399
- // @arg Emits the language name as a string.
400
- this.$emit("update:lang", val);
401
- },
402
- model(val) {
403
- // Fired when the v-model changes.
404
- // @arg Emits the entire payload modified.
405
- this.$emit("input", val);
406
- },
407
- lang(val) {
408
- if (val && this.langs.includes(val)) {
409
- this.currentLang = val;
410
- }
411
- },
412
- value(val) {
413
- if (val) {
414
- this.model = val;
415
- }
416
- },
417
- },
418
- computed: {
419
- canGoBack() {
420
- if (typeof window !== "undefined") {
421
- return (
422
- (this.$nuxt?.context?.from?.name !== "login" && window.history.length > 1) ||
423
- window.history.length > 3
424
- );
425
- }
426
- return true;
427
- },
428
- crud() {
429
- return this.$mapo.$api.crud(this.endpoint);
430
- },
431
- apiSendPayload() {
432
- let method, args;
433
- if (!this.model.id) {
434
- method = this.crud.create;
435
- args = [this.model, {}, { multipart: this.multipart }];
436
- } else if (this.usePatch) {
437
- method = this.crud.partialUpdate;
438
- args = [this.model.id, this.modelDiff, {}, { multipart: this.multipart }];
439
- } else {
440
- method = this.crud.update;
441
- args = [this.model.id, this.model, {}, { multipart: this.multipart }];
442
- }
443
- return async () => method(...args);
444
- },
445
- isReadonly() {
446
- if (this.readonly) return this.readonly;
447
- if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
448
- return !this.$mapo.$auth.user.permissions.includes(this.isNew ? "add" : "change");
449
- }
450
- return !!this.buttonClicked;
451
- },
452
- canDelete() {
453
- if (this.readonly) return false;
454
- if (this.$mapo.$auth.routeMiddlewares.includes("permissions")) {
455
- return this.$mapo.$auth.user.permissions.includes("delete");
456
- }
457
- return true;
458
- },
459
- mainFields() {
460
- return this.fields instanceof Array ? this.fields : this.fields.main || [];
461
- },
462
- sideFields() {
463
- return (this.fields instanceof Object && this.fields.sidenav) || [];
464
- },
465
- isNew() {
466
- return this.identifier && this.identifier == "new";
467
- },
468
- loading() {
469
- if (this.identifier === "new") {
470
- return false;
471
- }
472
- return !Object.keys(this.model).length;
473
- },
474
- langs() {
475
- return !this.forceLanguages && (this.modelLanguages || []).length
476
- ? this.modelLanguages
477
- : this.languages;
478
- },
479
- slotBindings() {
480
- return {
481
- model: this.model,
482
- errors: this.errors,
483
- currentLang: this.currentLang,
484
- crud: this.crud,
485
- isNew: this.isNew,
486
- langs: this.langs,
487
- loading: this.loading,
488
- form: this.$refs.form,
489
- saveItem: this.saveItem,
490
- deleteItem: this.deleteItem,
491
- };
492
- },
493
- stickySide() {
494
- return this.sticky
495
- ? {
496
- position: "sticky",
497
- top: "60px",
498
- }
499
- : {};
500
- },
501
- modelDiff() {
502
- return diffObjs(this.modelBkp, this.model) || {};
503
- },
504
- hasDiff() {
505
- return !!(this.modelDiff && Object.keys(this.modelDiff).length > 0);
506
- },
507
- previewUrl() {
508
- return this.previewField ? this.model[this.previewField] : null;
509
- },
510
- },
511
- async mounted() {
512
- if (this.identifier && this.identifier !== "new") {
513
- try {
514
- this.model = await this.crud.detail(this.identifier);
515
- this.modelLanguages = this.model?.lang_info?.site_languages.map((l) => l.id);
516
- } catch (error) {
517
- this.$nuxt.error({
518
- statusCode: error.response.status,
519
- message: error.response.data?.detail || this.$t("mapo.genericError"),
520
- });
521
- }
522
- } else if (this.value) {
523
- this.model = this.value;
524
- this.modelLanguages = this.model?.lang_info?.site_languages.map((l) => l.id);
525
- }
526
- this.modelBkp = deepClone(this.model);
527
- this.setRouterGuard();
528
- },
529
- destroyed() {
530
- this.unsetRouterGuard();
531
- },
532
- };
533
- </script>
534
-
535
- <docs>
536
-
537
- ## DetailConfiguration
538
-
539
- The DetailConfiguration determines the behavior of the main form and is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
540
- Each field configuration represents a field of the form.
541
- The configuration can also consist of an object with two keys `{ main sidenav }`.
542
- Each key is an `Array` of [`FieldConfiguration`](#fieldconfiguration) and will modify a different part of the component:
543
- - The main body
544
- - The sidebar
545
-
546
-
547
- ### FieldConfiguration
548
-
549
- The `FieldConfiguration` is a `String` containing the dottedPath of a value inside the payload we want to modify.
550
- So, for example, if we have the payload: `{ image: { name: "...", url: "..." } }` we can modify the image name using the dottedPath `"image.name"`.
551
-
552
- The default component used to render a field of a form is a [`v-text-field`](https://vuetifyjs.com/en/components/text-fields/).
553
- If you want more control over the generated component you can use an `Object` with this attributes:
554
-
555
- |Name|Description|Type|Required|Default|
556
- |---|---|---|---|---|
557
- |value|The dottedPath of the value we want to modify.|`String`|`true`|-|
558
- |synci18n|Determines if the field is translatable or not. If set to true the value will remain the same in all translations (untranslatable).|`Boolean`|`false`|`false`|
559
- |type|Type of the field. This determines which component will be rendered. The list of possible choices can be found [here](#field-types) |`String`|`false`|`text`|
560
- |accessor|[`Accessor`](#accessor) object to specify the setter and the getter of the field.|`Object`|`false`|`{set: x=>x, get: x=>x}`|
561
- |attrs|The attributes that will be passed to the component.|`Object`|`false`|-|
562
- |is|The component to be rendered in the form. This has a higher priority than the "type" attribute. Here you can pass in any regitered Vue component instance or name. [Learn more](https://vuejs.org/v2/guide/components.html#Dynamic-Components).|`String | VueComponent`|`false`|-|
563
-
564
- #### Accessor
565
-
566
- The accessor object contains two funcition `get` and `set`. Each function will be called with a ctx as argument. The ctx contains the val (value) and the model (the payload).
567
- If you want to change the value as it is being processed by the component, you can set one or both of the accessors.
568
- Each function must return the processed value.
569
-
570
- #### Field types
571
-
572
- Here the list of the FieldConfiguration type association.
573
-
574
- - `text` ==> [v-text-field](https://vuetifyjs.com/en/components/text-fields/),
575
- - `select` ==> [v-select](https://vuetifyjs.com/en/components/selects/),
576
- - `date` ==> [date-field](/components/Form/fields/DateField/),
577
- - `textarea` ==> [v-textarea](https://vuetifyjs.com/en/components/textareas/),
578
- - `switch` ==> [v-switch](https://vuetifyjs.com/en/components/switches/),
579
- - `slider` ==> [v-slider](https://vuetifyjs.com/en/components/sliders/),
580
- - `file` ==> [file-field](/components/Form/fields/FileField/),
581
- - `editor` ==> [wyg-editor](/components/Form/fields/wygEditor/wygEditor/),
582
- - `media` ==> [media-field](/components/Form/fields/MediaField/),
583
- - `enhancedMedia` ==> [enhanced-media-field](/components/Form/fields/EnhancedMediaField/),
584
- - `mediaList` ==> [media-m2m-field](/components/Form/fields/MediaM2mField/)
585
- - `m2m` or `fks` ==> [fks-field](/components/Form/fields/FksField/),
586
- - `repeater` ==> [repeater](/components/Form/fields/Repeater/),
587
-
588
-
589
- #### Example of a [`FieldConfiguration`](#fieldconfiguration):
590
-
591
- ```js
592
- {
593
- value: "pubblicationDate",
594
- accessor: {
595
- set: ({ val }) => val && new Date(val).toISOString()
596
- },
597
- type: "date",
598
- synci18n: true,
599
- attrs: { color: "purple" }
600
- }
601
- ```
602
-
603
- ### FieldGroup
604
-
605
- You can use this mixed with `FieldConfiguration` to group multiple fields in one card with a title and an icon.
606
- The `FieldGroup` has the key group that is a string repreenting the name of the group and the key fields that is an `Array` of [`FieldConfiguration`](#fieldconfiguration).
607
- The group key can also be an `Object`. In that case it contains the name and the icon for the group `{name: "...", icon: "..."}`. For a list of all available icons, visit the official [Material Design Icons](https://materialdesignicons.com/) page.
608
-
609
- <br><br>
610
-
611
- ## Live Demo
612
-
613
- <br>
614
-
615
- ::: warning LIVE DEMO 🎉🎉🎉
616
- This is an interactive example. You can play with it but remember that all http features are disabled since there is no backend server.
617
- :::
618
-
619
-
620
- ::: demo
621
- <template>
622
- <v-app>
623
- <div class="d-flex justify-end"><ThemeToggle/></div>
624
- <Detail
625
- endpoint="api/articles"
626
- identifier="new"
627
- :fields="fields"
628
- :languages="['it', 'en', 'de']"
629
- modelName="article"
630
- />
631
- </v-app>
632
- </template>
633
-
634
- <script>
635
- export default {
636
- data: () => ({
637
- fields: {
638
- main: [
639
- { value: "identifier", synci18n: true },
640
- { value: "content", type: "editor" },
641
- { value: "sections", type: "repeater", attrs: {
642
- sortable: true,
643
- fields: [
644
- { value: "title", class: "col-md-6" },
645
- { value: "subtitle", class: "col-md-6" },
646
- { value: "content", type: "textarea" },
647
- ]}
648
- },
649
- {
650
- group: "Seo",
651
- fields: [
652
- "title",
653
- { value: "description", type: "textarea" },
654
- "permalink",
655
- { type: "seoPreview" }
656
- ]
657
- }
658
- ],
659
- sidenav: [
660
- {
661
- group: "Status",
662
- fields: [
663
- { value: "trash", type: "switch", synci18n: true },
664
- {
665
- value: "status",
666
- type: "select",
667
- attrs: {
668
- items: [
669
- { text: "Draft", value: "DRF" },
670
- { text: "Published", value: "PUB" },
671
- { text: "Trash", value: "TRS" }
672
- ]
673
- },
674
- synci18n: true
675
- },
676
- {
677
- value: "pubblication_date",
678
- accessor: {
679
- set: ({ val }) => val && new Date(val).toISOString()
680
- },
681
- type: "date",
682
- synci18n: true
683
- }
684
- ]
685
- },
686
- { value: "highlight_image", type: "media", synci18n: true }
687
- ]
688
- }
689
- })
690
- };
691
- </script>
692
- :::
693
-
694
-
695
-
696
- </docs>