@mapomodule/uikit 1.0.0-alpha.2 → 1.0.0-alpha.7

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 (31) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/components/Detail/Detail.vue +156 -95
  3. package/components/Detail/DetailField.vue +14 -11
  4. package/components/Detail/defaults.js +6 -1
  5. package/components/DropArea.vue +1 -1
  6. package/components/List/List.vue +100 -40
  7. package/components/List/ListActions.vue +38 -17
  8. package/components/List/ListFilters.vue +127 -113
  9. package/components/List/ListHead.vue +23 -13
  10. package/components/List/ListQuickEdit.vue +14 -5
  11. package/components/List/ListTable.vue +218 -76
  12. package/components/MediaManager/MediaEditor.vue +247 -107
  13. package/components/MediaManager/MediaFolders.vue +122 -38
  14. package/components/MediaManager/MediaGallery.vue +56 -52
  15. package/components/MediaManager/MediaManager.vue +114 -74
  16. package/components/MediaManager/MediaManagerDialog.vue +19 -22
  17. package/components/MediaManager/MediaPreview.vue +180 -0
  18. package/components/MediaManager/MediaUploader.vue +35 -32
  19. package/components/fields/MediaField.vue +12 -2
  20. package/components/fields/SeoPreview.vue +89 -0
  21. package/components/fields/TinyMce/TinyMce.vue +29 -10
  22. package/components/fields/TinyMce/defaults.js +1 -1
  23. package/components/layout/Sidebar/Sidebar.vue +46 -24
  24. package/components/layout/Sidebar/SidebarFooter.vue +41 -46
  25. package/components/layout/Sidebar/SidebarList.vue +12 -14
  26. package/components/layout/Sidebar/SidebarListItem.vue +65 -38
  27. package/components/layout/Topbar/Topbar.vue +3 -36
  28. package/components/layout/routebuilder.js +1 -1
  29. package/layouts/default.vue +3 -14
  30. package/package.json +2 -2
  31. package/pages/index.vue +1 -2
package/CHANGELOG.md ADDED
@@ -0,0 +1,115 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # [1.0.0-alpha.7](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2022-01-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **detail:** fix v-card content margin on detail component ([f07d5c1](https://github.com/lotrekagency/mapo/commit/f07d5c1581e71407e79fce95c8dc10109196ed0b))
12
+ * **detail:** remove lang swtch if only one lang is selected ([35cf58a](https://github.com/lotrekagency/mapo/commit/35cf58aa17ce4350f983643a8182fdf795dd4abb))
13
+ * **detail:** remove v-container from detail component to fix sizing ([2947652](https://github.com/lotrekagency/mapo/commit/29476528a6c13325c4da49a3e2aa842302e6bd04))
14
+ * **list:** fix search box for very small displays ([edf7287](https://github.com/lotrekagency/mapo/commit/edf7287c6974b8bb1412d9e0fb8bc4b1f1b48480))
15
+ * **media:** fix reset on media dialog ([3727502](https://github.com/lotrekagency/mapo/commit/3727502b59c9fa809b4dbc139b0cd01198008a18))
16
+ * **media:** reset media dialog after close ([5aded79](https://github.com/lotrekagency/mapo/commit/5aded794dbfb5482119db45bfb975e7241f86f15))
17
+ * **mediamanager:** better display of folder path in media manager ([bdc5692](https://github.com/lotrekagency/mapo/commit/bdc569264164e61af1c210aeb1c5da9d5b21220a))
18
+ * **mediamanager:** better ui for selection ([2307d38](https://github.com/lotrekagency/mapo/commit/2307d38a5a4e0fe838b5f9173692e132fe69e3be))
19
+ * **mediamanager:** fix backbutton background in media editor ([315d9df](https://github.com/lotrekagency/mapo/commit/315d9df2a9021ee1ea1328b4d959f0fd5f652f47))
20
+ * **mediamanager:** fix corb errors loading image preview in mediamanager ([7f34e34](https://github.com/lotrekagency/mapo/commit/7f34e34dfdfe4380d1704c0c8dda0a507676aeae))
21
+ * **mediamanager:** fix DOMException: The play() request was interrupted ([89a2a3e](https://github.com/lotrekagency/mapo/commit/89a2a3e1bb47178245ca7d131bdfedbcbcc41c17))
22
+ * **mediamanager:** fix editor opening ([3888652](https://github.com/lotrekagency/mapo/commit/3888652b0441cd17f0468db57fd895afd97a3625))
23
+ * **mediamanager:** make editing animation smooth ([81bd34b](https://github.com/lotrekagency/mapo/commit/81bd34b04d0d561317a1928dcdc796adc539350b))
24
+ * **mediamanager:** minor fixes to mediamanager ui ([a7b6089](https://github.com/lotrekagency/mapo/commit/a7b6089c38af9a6079bd8bebfeddd2dcff0b2c75))
25
+ * **mediamanager:** prevent media type check fail if no media type present ([2ee88fe](https://github.com/lotrekagency/mapo/commit/2ee88fed81d527434cf854e68ff8210247b2cf39))
26
+ * **mediamanagerdialog:** better positioning on small device of media manager dialog content ([9da147c](https://github.com/lotrekagency/mapo/commit/9da147c7e2d356da7f74e2edcbf05c5dafcbd94d))
27
+ * **sidebar:** fix nested SidebarListItems not triggering active class when the list-item is not a link ([9e92971](https://github.com/lotrekagency/mapo/commit/9e929710e74946c1470c29c007d780a1e712170b))
28
+ * **tinymce:** added missing al text to image tag ([55a3926](https://github.com/lotrekagency/mapo/commit/55a39261b3e449381d974eaa1b328a46dffb6f51))
29
+ * **uikit:** fix some content disposition in main layout ([1e9c79b](https://github.com/lotrekagency/mapo/commit/1e9c79b6b80d781c5aded10800c9df255b6ef8e8))
30
+
31
+
32
+ ### Features
33
+
34
+ * **media:** added mime type filtering ([da01658](https://github.com/lotrekagency/mapo/commit/da016585d450143f6419d98a7f53ee5ec8cf7358))
35
+ * **media:** added search input ([a1ac6ae](https://github.com/lotrekagency/mapo/commit/a1ac6aef8d28a248431cd80955c5a1446f41f608))
36
+ * **media:** selection prop 2-way binded ([e87f21c](https://github.com/lotrekagency/mapo/commit/e87f21c085e0cf0a61a99025d9f5e7970285ab72))
37
+ * **mediafield:** update media field to handle files ([5158108](https://github.com/lotrekagency/mapo/commit/51581086d96e09af31471721f0ea32df3fe58e09))
38
+ * **mediamanager:** added audio playback for audio files ([6aec9f7](https://github.com/lotrekagency/mapo/commit/6aec9f7b749c5002832fd194d565742b99a4b700))
39
+ * **mediamanager:** added icon for media that are not images ([d77f17b](https://github.com/lotrekagency/mapo/commit/d77f17b2d77db7bf4dc387be0b6d3892a4772b02))
40
+ * **mediamanager:** added link to img shortcut button in editor ([1dd446f](https://github.com/lotrekagency/mapo/commit/1dd446f76df1d3a7e71fdefb81ad60de1fdb4e93))
41
+ * **mediamanager:** added the possibility to change the media file using same url of the old file ([f21f383](https://github.com/lotrekagency/mapo/commit/f21f383b6f3f0176f806688a50ebff93a53d3203))
42
+ * **mediamanager:** added video preview for video mime types ([55fc423](https://github.com/lotrekagency/mapo/commit/55fc423c03265fb2c17bc42f1be0ba511928267c))
43
+ * **mediamanager:** many ui enhancements for mediamanager ([30ab3ff](https://github.com/lotrekagency/mapo/commit/30ab3ff89dc0ff3b9a210cfd32e2a874dfc073a6))
44
+ * **mediamanager:** media folders manager graphic enhancements ([0e8e7ec](https://github.com/lotrekagency/mapo/commit/0e8e7ec35482d043c42c88c38c9d32c8fa8e54e9))
45
+ * **sidebar:** added spidermenu for nested routes ([084029d](https://github.com/lotrekagency/mapo/commit/084029de717f29412b045fe703c4cfbd19353400))
46
+ * **tinymce:** added callback to manage video and documents insertions with mapomedia plugin ([b4e6f63](https://github.com/lotrekagency/mapo/commit/b4e6f6362e025010614e7ca8351a9d1e3af08650))
47
+
48
+
49
+
50
+
51
+
52
+ # [1.0.0-alpha.6](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2021-12-26)
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * **uikit:** fix sidebar footer items not collapsing on mini variant ([04c510e](https://github.com/lotrekagency/mapo/commit/04c510ee87bd7b74161725c366e2eac2bd3efe9f))
58
+ * **uikit:** fix sidebar items not collapsing on mini variant ([67a9524](https://github.com/lotrekagency/mapo/commit/67a9524b17b6cbdf455b8e6f56f7cc0674b1dbed))
59
+ * various css fixes ([658c363](https://github.com/lotrekagency/mapo/commit/658c3636e869f0a2bd53efe41295cf87d6af3962))
60
+ * **list:** fix v-menu position on large screens ([41bd08d](https://github.com/lotrekagency/mapo/commit/41bd08d36d85e685a755c7e0de97bbb05a24c03d))
61
+ * **list:** fixed v-menu filter positioning ([e99848e](https://github.com/lotrekagency/mapo/commit/e99848e0beb2df124db1ba9968696bbe8ee7b683))
62
+ * **list:** fixed v-menu position for filters ([cb95260](https://github.com/lotrekagency/mapo/commit/cb9526085d536ff7b468316b1d2571c7ae9509d8))
63
+ * **list:** load page from query params ([88dea98](https://github.com/lotrekagency/mapo/commit/88dea98063cdab79c9c518fe0e3bf8d3c90f0161))
64
+ * **list:** refactoring for injected elements and FE pagination ([f9c968e](https://github.com/lotrekagency/mapo/commit/f9c968e0edf87654df60781d7d2d465d15e40ab9))
65
+ * **list:** removed lock to BE pagination if items in list are less than itemsPerPage ([3fe34e0](https://github.com/lotrekagency/mapo/commit/3fe34e0d1438a0980e8819070f9b158ad3b6e0b8))
66
+ * **uikit:** better handle detail component lang switches ([5297e49](https://github.com/lotrekagency/mapo/commit/5297e4956536b382600c250f5c797c8db5e58f84))
67
+ * **uikit:** fix detailfield not reading conf value changes ([5628268](https://github.com/lotrekagency/mapo/commit/5628268e4e78201523eba60adaf17286dfb38c8b))
68
+ * **uikit:** fix lang changhe in detail component ([32494f7](https://github.com/lotrekagency/mapo/commit/32494f7d094f7e9cebc14f7524ad716eb89fd6d7))
69
+ * **uikit:** fix positioning of element in list component and subcomponents ([887c3b6](https://github.com/lotrekagency/mapo/commit/887c3b6aae52d1a3494ebcc01f0f155f21373f9c))
70
+ * **uikit:** set endpoint to default null in detail field ([5c9296c](https://github.com/lotrekagency/mapo/commit/5c9296c81f8667319699e933f528c4c05a1f541d))
71
+ * fixed v-model with datepicker filter ([ef4634e](https://github.com/lotrekagency/mapo/commit/ef4634e8ad0719ec2991a8c40a87191c0e32d7ec))
72
+ * load saved date range into datepicker ([eb94dd5](https://github.com/lotrekagency/mapo/commit/eb94dd5686b9fed16e0f39bf122c767d8bd1017b))
73
+
74
+
75
+ ### Features
76
+
77
+ * **list:** added support to offline items ([495fd1f](https://github.com/lotrekagency/mapo/commit/495fd1f30cd0adc228b48ca4384b9df572e69216))
78
+ * **list:** handle multisort ([41feb88](https://github.com/lotrekagency/mapo/commit/41feb88ec15be5cc9afbcdf3d2dea23142301153))
79
+ * **uikit:** add possibility to remove icon from sidebar ([106d85f](https://github.com/lotrekagency/mapo/commit/106d85f576cdc9e6438b48fa8e695315cac2262b))
80
+ * **uikit:** added langChange event to detail component ([70d3430](https://github.com/lotrekagency/mapo/commit/70d3430694e67dfcd65539a3d474847123e05db5))
81
+ * **uikit:** added possibility to change detail component current lang fromprop ([1993aa7](https://github.com/lotrekagency/mapo/commit/1993aa74a66768eea319f41a41878916544adcbb))
82
+ * **uikit:** added possibility to override field container class in detail component with key class in field configuration ([afe1e52](https://github.com/lotrekagency/mapo/commit/afe1e522683d08c5e63650e55dbe2f9a9404e681))
83
+ * **uikit:** added seopreview field ([03e52fe](https://github.com/lotrekagency/mapo/commit/03e52fed08e60c8b43226856a8d05d4c724ad9b2))
84
+ * **uikit:** added v-model to Detail Component, now you can bind the payload externally from detail field. ([a50b082](https://github.com/lotrekagency/mapo/commit/a50b08261d6b8eba3e5b6f1ea2f1f4bb0d591b8e))
85
+ * **uikit:** display errors on tinymce component also with red label shake animation ([2c9e158](https://github.com/lotrekagency/mapo/commit/2c9e158090ee1f770518ad755437171a1b16afbd))
86
+ * **uikit:** newsidebar built with vuetify components to better support theming ([9cc237f](https://github.com/lotrekagency/mapo/commit/9cc237fa7dcfe193edc0fd9cb90e3bbbb103931d))
87
+
88
+
89
+
90
+
91
+
92
+ # [1.0.0-alpha.5](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2021-12-20)
93
+
94
+
95
+ ### Bug Fixes
96
+
97
+ * **uikit:** fix list component http call with no pagination at all ([ebe4b61](https://github.com/lotrekagency/mapo/commit/ebe4b617f3be5ccb70c10c041c81868e9ee6b828))
98
+
99
+
100
+ ### Features
101
+
102
+ * added search field on list component ([0c845e2](https://github.com/lotrekagency/mapo/commit/0c845e26e30afed66b351cc7a0f940f9a20e0943))
103
+ * select all option on list component ([588d2c5](https://github.com/lotrekagency/mapo/commit/588d2c57ca5fd36477cf1ee3c33e2289eb979acf))
104
+ * slot for selected items' counter ([0551b5e](https://github.com/lotrekagency/mapo/commit/0551b5e916f25fc740a0cae58c5548ab0c6e35ff))
105
+
106
+
107
+
108
+
109
+
110
+ # [1.0.0-alpha.4](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2021-10-25)
111
+
112
+
113
+ ### Bug Fixes
114
+
115
+ * Display corret version of mapo in index page ([22ae4cf](https://github.com/lotrekagency/mapo/commit/22ae4cf55f1f3c6fcda64b085fe3c13c416bafb8))
@@ -1,10 +1,10 @@
1
1
  <template>
2
- <v-container>
2
+ <div>
3
3
  <!-- Use this to override the title of the detail component. -->
4
4
  <slot name="title" v-bind="slotBindings">
5
5
  <!-- `<h1> "Create | Edit" + modelName </h1>` -->
6
- <v-row class="mb-14">
7
- <h1>{{ isNew ? "Create" : "Edit" }} {{ modelName }}</h1>
6
+ <v-row class="mb-5">
7
+ <v-col col="12"><h1 class="display-1">{{ isNew ? "Create" : "Edit" }} {{ modelName }}</h1></v-col>
8
8
  </v-row>
9
9
  </slot>
10
10
  <v-form ref="form">
@@ -16,7 +16,7 @@
16
16
  <slot name="body.lang" v-bind="slotBindings">
17
17
  <!-- [`DetailLangSwitch`](/components/detail/DetailLangSwitch/) -->
18
18
  <DetailLangSwitch
19
- v-if="langs && langs.length"
19
+ v-if="langs && langs.length > 1"
20
20
  class="mb-4"
21
21
  v-model="currentLang"
22
22
  :langs="langs"
@@ -26,47 +26,57 @@
26
26
  <slot name="body.top.underlang" v-bind="slotBindings"></slot>
27
27
  <!-- Use this to override the content of the main body. -->
28
28
  <slot name="body" v-bind="slotBindings">
29
- <!-- The result of the [`DetailConfiguration`](#detailconfiguration) contained in the main body. -->
30
- <div v-for="(field, index) in mainFields" :key="index">
31
- <v-card v-if="field.group" class="my-2">
32
- <v-card-title>
33
- <v-icon left> {{ field.group.icon }} </v-icon>
34
- <span>{{ field.group.name }}</span>
35
- </v-card-title>
36
- <v-card-text>
37
- <div
38
- v-for="(fields, fieldsI) in field.fields"
39
- :key="fieldsI"
40
- class="mb-4"
41
- >
42
- <!-- This is a dynamic slot. You can use it to override a field component. For example use `fields.title` to override the component of the field with value `title`. -->
43
- <slot
44
- :name="fields.slotName"
45
- v-bind="{
46
- conf: fields,
47
- ...slotBindings,
48
- }"
49
- >
50
- <!-- A [`DetailField`](/components/detail/DetailField/) configured by a [`FieldConfiguration`](#fieldconfiguration). -->
51
- <DetailField
52
- v-model="model"
53
- :conf="fields"
54
- :errors="errors"
55
- />
56
- </slot>
57
- </div>
58
- </v-card-text>
59
- </v-card>
60
- <slot
61
- v-else
62
- :name="field.slotName"
63
- v-bind="{
64
- conf: field,
65
- ...slotBindings,
66
- }"
29
+ <div class="row">
30
+ <!-- The result of the [`DetailConfiguration`](#detailconfiguration) contained in the main body. -->
31
+ <div
32
+ class="col-12"
33
+ :class="field.class"
34
+ v-for="(field, index) in mainFields"
35
+ :key="index"
67
36
  >
68
- <DetailField v-model="model" :conf="field" :errors="errors" />
69
- </slot>
37
+ <v-card v-if="field.group" class="my-2">
38
+ <v-card-title>
39
+ <v-icon left> {{ field.group.icon }} </v-icon>
40
+ <span>{{ field.group.name }}</span>
41
+ </v-card-title>
42
+ <div class="container">
43
+ <div class="row">
44
+ <div
45
+ v-for="(fields, fieldsI) in field.fields"
46
+ :key="fieldsI"
47
+ class="col-12"
48
+ :class="fields.class"
49
+ >
50
+ <!-- This is a dynamic slot. You can use it to override a field component. For example use `fields.title` to override the component of the field with value `title`. -->
51
+ <slot
52
+ :name="fields.slotName"
53
+ v-bind="{
54
+ conf: fields,
55
+ ...slotBindings,
56
+ }"
57
+ >
58
+ <!-- A [`DetailField`](/components/detail/DetailField/) configured by a [`FieldConfiguration`](#fieldconfiguration). -->
59
+ <DetailField
60
+ v-model="model"
61
+ :conf="fields"
62
+ :errors="errors"
63
+ />
64
+ </slot>
65
+ </div>
66
+ </div>
67
+ </div>
68
+ </v-card>
69
+ <slot
70
+ v-else
71
+ :name="field.slotName"
72
+ v-bind="{
73
+ conf: field,
74
+ ...slotBindings,
75
+ }"
76
+ >
77
+ <DetailField v-model="model" :conf="field" :errors="errors" />
78
+ </slot>
79
+ </div>
70
80
  </div>
71
81
  </slot>
72
82
  <!-- Use this to add content under the main body. -->
@@ -118,45 +128,55 @@
118
128
  </slot>
119
129
  <!-- Use this to add content on the top of the sidebar fields (or under sidebar buttons). -->
120
130
  <slot name="side.top" v-bind="slotBindings"></slot>
121
- <div v-for="(field, index) in sideFields" :key="index">
122
- <v-card v-if="field.group" class="mb-4">
123
- <v-card-title>
124
- <v-icon left> {{ field.group.icon }} </v-icon>
125
- <span>{{ field.group.name }}</span>
126
- </v-card-title>
127
- <v-card-text>
128
- <div
129
- v-for="(fields, fieldsI) in field.fields"
130
- :key="fieldsI"
131
- class="mb-4"
132
- >
133
- <!-- @vuese-ignore -->
134
- <slot
135
- :name="fields.slotName"
136
- v-bind="{
137
- conf: fields,
138
- ...slotBindings,
139
- }"
140
- >
141
- <DetailField
142
- v-model="model"
143
- :conf="fields"
144
- :errors="errors"
145
- />
146
- </slot>
147
- </div>
148
- </v-card-text>
149
- </v-card>
150
- <slot
151
- v-else
152
- :name="field.slotName"
153
- v-bind="{
154
- conf: field,
155
- ...slotBindings,
156
- }"
131
+ <div class="row">
132
+ <div
133
+ class="col-12"
134
+ :class="field.class"
135
+ v-for="(field, index) in sideFields"
136
+ :key="index"
157
137
  >
158
- <DetailField v-model="model" :conf="field" :errors="errors" />
159
- </slot>
138
+ <v-card v-if="field.group" class="mb-4">
139
+ <v-card-title>
140
+ <v-icon left> {{ field.group.icon }} </v-icon>
141
+ <span>{{ field.group.name }}</span>
142
+ </v-card-title>
143
+ <div class="container">
144
+ <div class="row">
145
+ <div
146
+ v-for="(fields, fieldsI) in field.fields"
147
+ :key="fieldsI"
148
+ class="col-12"
149
+ :class="field.class"
150
+ >
151
+ <!-- @vuese-ignore -->
152
+ <slot
153
+ :name="fields.slotName"
154
+ v-bind="{
155
+ conf: fields,
156
+ ...slotBindings,
157
+ }"
158
+ >
159
+ <DetailField
160
+ v-model="model"
161
+ :conf="fields"
162
+ :errors="errors"
163
+ />
164
+ </slot>
165
+ </div>
166
+ </div>
167
+ </div>
168
+ </v-card>
169
+ <slot
170
+ v-else
171
+ :name="field.slotName"
172
+ v-bind="{
173
+ conf: field,
174
+ ...slotBindings,
175
+ }"
176
+ >
177
+ <DetailField v-model="model" :conf="field" :errors="errors" />
178
+ </slot>
179
+ </div>
160
180
  </div>
161
181
  <!-- Use this to add content under the sidebar fields. -->
162
182
  <slot name="side.bottom" v-bind="slotBindings"></slot>
@@ -164,7 +184,7 @@
164
184
  </v-col>
165
185
  </v-row>
166
186
  </v-form>
167
- </v-container>
187
+ </div>
168
188
  </template>
169
189
 
170
190
 
@@ -183,6 +203,16 @@ export default {
183
203
  };
184
204
  },
185
205
  props: {
206
+ // V-model of the object we are editing.
207
+ value: {
208
+ type: Object,
209
+ required: false
210
+ },
211
+ // Set the current lang to value.
212
+ lang: {
213
+ type: String,
214
+ required: false
215
+ },
186
216
  // The main configuration that determines the arrangement of the fields in the detail layout.
187
217
  fields: {
188
218
  // [`DetailConfiguration`](#detailconfiguration)
@@ -195,7 +225,10 @@ export default {
195
225
  default: () => []
196
226
  },
197
227
  // 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.
198
- endpoint: String,
228
+ endpoint: {
229
+ type: String,
230
+ default: null
231
+ },
199
232
  // The identifier of the object you need to retrieve and edit. It can be "new" if you need to create a new payload.
200
233
  identifier: {
201
234
  // `String|Number`.
@@ -247,12 +280,22 @@ export default {
247
280
  }
248
281
  });
249
282
  },
250
- parseConf(field) {
283
+ initLang(lang = this.currentLang) {
284
+ if (lang && !this.model.translations) {
285
+ this.model.translations = {};
286
+ }
287
+ if (lang && !this.model.translations[lang]) {
288
+ this.model.translations[lang] = {};
289
+ }
290
+ },
291
+ parseConf(field, i) {
251
292
  const conf = typeof field === "string" ? { value: field } : field;
252
- conf.value = conf.value.replace(/^translations\..*\./, "");
253
- conf.slotName = `fields.${conf.value}`;
293
+ conf.value = conf.value || "";
294
+ conf.value = conf.value.replace(new RegExp(`^translations\.(${this.languages.join("|")})\.?`), "");
295
+ conf.slotName = `fields.${conf.value || i}`;
254
296
  if (this.currentLang && !field.synci18n) {
255
- conf.value = `translations.${this.currentLang}.${conf.value}`;
297
+ const base = `translations.${this.currentLang}`;
298
+ conf.value = (conf.value && `${base}.${conf.value}`) || base;
256
299
  }
257
300
  return conf;
258
301
  },
@@ -262,20 +305,34 @@ export default {
262
305
  typeof group === "string"
263
306
  ? { name: group, icon }
264
307
  : { ...group, icon: group.icon || icon };
265
- return fields.map(f =>
308
+ return fields.map((f, i) =>
266
309
  f.group
267
310
  ? { group: parseGroup(f.group), fields: this.mapConf(f.fields) }
268
- : this.parseConf(f)
311
+ : this.parseConf(f, i)
269
312
  );
270
313
  }
271
314
  },
272
315
  watch: {
273
316
  currentLang(val) {
274
- if (val && !this.model.translations) {
275
- this.model.translations = {};
317
+ this.initLang();
318
+ // Fired when the current language changes.
319
+ // @arg Emits the language name as a string.
320
+ this.$emit("update:lang", val);
321
+ },
322
+ model(val) {
323
+ // Fired when the v-model changes.
324
+ // @arg Emits the entire payload modified.
325
+ this.$emit("input", val);
326
+ },
327
+ lang(val) {
328
+ if (val && this.langs.includes(val)) {
329
+ this.currentLang = val;
276
330
  }
277
- if (val && !this.model.translations[val]) {
278
- this.model.translations[val] = {};
331
+ },
332
+ value(val) {
333
+ if (val) {
334
+ this.model = val;
335
+ this.initLang();
279
336
  }
280
337
  }
281
338
  },
@@ -331,7 +388,10 @@ export default {
331
388
  },
332
389
  mounted() {
333
390
  if (this.identifier && this.identifier !== "new") {
334
- this.crud.detail(this.identifier).then(res => (this.model = res));
391
+ this.crud.detail(this.identifier).then(res => {
392
+ this.model = res;
393
+ this.initLang();
394
+ });
335
395
  }
336
396
  }
337
397
  };
@@ -446,6 +506,7 @@ export default {
446
506
  "title",
447
507
  { value: "description", type: "textarea" },
448
508
  "permalink",
509
+ { type: "seoPreview" }
449
510
  ]
450
511
  }
451
512
  ],
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <component :is="is" v-model="model" v-bind="fieldProp"></component>
2
+ <component :is="is" v-model="model" v-bind="fieldAttrs"></component>
3
3
  </template>
4
4
 
5
5
  <script>
@@ -8,6 +8,8 @@ import DateField from "@mapomodule/uikit/components/fields/DateField.vue";
8
8
  import M2mField from "@mapomodule/uikit/components/fields/M2mField.vue";
9
9
  import MediaM2mField from "@mapomodule/uikit/components/fields/MediaM2mField.vue";
10
10
  import MediaField from "@mapomodule/uikit/components/fields/MediaField.vue";
11
+ import SeoPreview from "@mapomodule/uikit/components/fields/SeoPreview.vue";
12
+
11
13
 
12
14
  import { getPointed, setPointed } from "@mapomodule/utils/helpers/objHelpers";
13
15
  import defaults from "./defaults";
@@ -22,15 +24,16 @@ export default {
22
24
  DateField,
23
25
  M2mField,
24
26
  MediaM2mField,
25
- MediaField
27
+ MediaField,
28
+ SeoPreview
26
29
  },
27
30
 
28
31
  data() {
29
32
  return {
30
33
  model: null,
31
- fieldsMap: defaults.mapping,
32
- fieldsProps: defaults.props,
33
- fieldsAccess: defaults.accessor
34
+ defaultMap: defaults.mapping,
35
+ defaultAttrs: defaults.props,
36
+ defaultAccess: defaults.accessor
34
37
  };
35
38
  },
36
39
  props: {
@@ -55,8 +58,8 @@ export default {
55
58
  this.setModel(val);
56
59
  }
57
60
  },
58
- conf(newConf, oldConf) {
59
- if (newConf.value !== oldConf.value) {
61
+ "conf.value"(newValue, oldValue) {
62
+ if (newValue !== oldValue) {
60
63
  this.setModel();
61
64
  }
62
65
  },
@@ -90,15 +93,15 @@ export default {
90
93
  return {
91
94
  get: func,
92
95
  set: func,
93
- ...(this.fieldsAccess[this.is] || {}),
96
+ ...(this.defaultAccess[this.is] || {}),
94
97
  ...this.conf.accessor
95
98
  };
96
99
  },
97
- fieldProp() {
100
+ fieldAttrs() {
98
101
  return {
99
102
  label: this.label,
100
103
  errorMessages: getPointed(this.errors || {}, this.conf.value, []),
101
- ...(this.fieldsProps[this.is] || {}),
104
+ ...(this.defaultAttrs[this.is] || {}),
102
105
  ...this.conf.attrs
103
106
  };
104
107
  },
@@ -120,7 +123,7 @@ export default {
120
123
  is() {
121
124
  return (
122
125
  this.conf.is ||
123
- (this.conf.type && this.fieldsMap[this.conf.type]) ||
126
+ (this.conf.type && this.defaultMap[this.conf.type]) ||
124
127
  "v-text-field"
125
128
  );
126
129
  }
@@ -9,7 +9,8 @@ const mapping = {
9
9
  editor: "tiny-mce",
10
10
  media: "media-field",
11
11
  m2m: "m2m-field",
12
- mediaList: "media-m2m-field"
12
+ mediaList: "media-m2m-field",
13
+ seoPreview: "seo-preview"
13
14
  }
14
15
 
15
16
  const props = {
@@ -43,6 +44,10 @@ const accessor = {
43
44
  },
44
45
  "date-field": {
45
46
  get: dateFunc, set: dateFunc
47
+ },
48
+ "seo-preview": {
49
+ get: ({ val }) => ({ title: "", permalink: "", description: "", ...val }),
50
+ set: ({ val }) => ({ title: "", permalink: "", description: "", ...val })
46
51
  }
47
52
  }
48
53
  export default {
@@ -69,7 +69,7 @@
69
69
  <!-- Slot to provide custom button actions inside the drop area -->
70
70
  <slot v-bind:clearList="clearList" name="actions">
71
71
  <!-- `<v-btn @click="clearList" icon><v-icon>mdi-close</v-icon></v-btn>` -->
72
- <v-btn @click="clearList" icon>
72
+ <v-btn v-if="uploadedFiles && uploadedFiles.length" @click="clearList" icon>
73
73
  <v-icon>mdi-close</v-icon>
74
74
  </v-btn>
75
75
  </slot>