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

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 (90) hide show
  1. package/CHANGELOG.md +873 -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 +97 -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/LangSwitcher.vue +44 -0
  28. package/components/List/List.vue +103 -51
  29. package/components/List/ListActions.vue +23 -5
  30. package/components/List/ListFilters.vue +166 -114
  31. package/components/List/ListHead.vue +30 -12
  32. package/components/List/ListQuickEdit.vue +130 -61
  33. package/components/List/ListTable.vue +210 -66
  34. package/components/Login.vue +17 -7
  35. package/components/LogoutButton.vue +43 -28
  36. package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
  37. package/components/MediaManager/MediaEditor.vue +297 -120
  38. package/components/MediaManager/MediaFileChanger.vue +78 -0
  39. package/components/MediaManager/MediaFolders.vue +224 -116
  40. package/components/MediaManager/MediaGallery.vue +224 -145
  41. package/components/MediaManager/MediaManager.vue +125 -159
  42. package/components/MediaManager/MediaManagerDialog.vue +36 -31
  43. package/components/MediaManager/MediaPreview.vue +258 -0
  44. package/components/MediaManager/MediaUploader.vue +91 -90
  45. package/components/MenuManager/MenuManager.vue +332 -0
  46. package/components/MenuManager/MenuNodeEditor.vue +255 -0
  47. package/components/MenuManager/MenuTreeview.vue +237 -0
  48. package/components/MenuManager/MenuTreeviewNode.vue +208 -0
  49. package/components/PagePreview.vue +58 -0
  50. package/components/SnackBar.vue +5 -7
  51. package/components/ThemeToggle.vue +13 -0
  52. package/components/layout/Sidebar/Sidebar.vue +61 -30
  53. package/components/layout/Sidebar/SidebarList.vue +19 -15
  54. package/components/layout/Sidebar/SidebarListItem.vue +122 -38
  55. package/components/layout/Sidebar/SidebarProfile.vue +42 -0
  56. package/components/layout/Sidebar/SidebarTitle.vue +45 -0
  57. package/components/layout/Topbar/Topbar.vue +11 -42
  58. package/components/layout/routebuilder.js +3 -3
  59. package/defaults/i18n.js +37 -0
  60. package/defaults/vuetify.js +34 -0
  61. package/layouts/default.vue +33 -18
  62. package/layouts/empty.vue +10 -0
  63. package/module.js +7 -5
  64. package/package.json +6 -4
  65. package/pages/index.vue +19 -18
  66. package/static/mapo/tinymce-skins/mapo-dark/content.inline.min.css +7 -0
  67. package/static/mapo/tinymce-skins/mapo-dark/content.min.css +7 -0
  68. package/static/mapo/tinymce-skins/mapo-dark/content.mobile.min.css +7 -0
  69. package/static/mapo/tinymce-skins/mapo-dark/skin.min.css +7 -0
  70. package/static/mapo/tinymce-skins/mapo-dark/skin.mobile.min.css +7 -0
  71. package/static/mapo/tinymce-skins/mapo-light/content.inline.min.css +7 -0
  72. package/static/mapo/tinymce-skins/mapo-light/content.min.css +7 -0
  73. package/static/mapo/tinymce-skins/mapo-light/content.mobile.min.css +7 -0
  74. package/static/mapo/tinymce-skins/mapo-light/skin.min.css +7 -0
  75. package/static/mapo/tinymce-skins/mapo-light/skin.mobile.min.css +7 -0
  76. package/translations/en-US.js +177 -0
  77. package/translations/it-IT.js +180 -0
  78. package/components/Detail/DetailField.vue +0 -129
  79. package/components/Detail/defaults.js +0 -50
  80. package/components/fields/M2mField.vue +0 -95
  81. package/components/fields/MediaField.vue +0 -195
  82. package/components/fields/MediaM2mField.vue +0 -238
  83. package/components/fields/TinyMce/TinyMce.vue +0 -177
  84. package/components/fields/TinyMce/defaults.js +0 -55
  85. package/components/layout/Sidebar/SidebarFooter.vue +0 -75
  86. package/defaults.js +0 -29
  87. package/layouts/error.vue +0 -45
  88. /package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
  89. /package/components/{fields/TinyMce/utils/script.injector.js → Form/fields/wygEditor/utils/tinymce.injector.js} +0 -0
  90. /package/static/{favicon.ico → mapo/favicon.ico} +0 -0
@@ -1,163 +1,340 @@
1
1
  <template>
2
- <div v-if="media">
3
- <div class="d-flex align-center justify-space-between">
4
- <v-btn class="ma-2" @click="close" icon>
2
+ <div v-if="media" class="media-editor--wrapper">
3
+ <div class="img_overlay">
4
+ <v-btn
5
+ class="img_overlay__button img_overlay__button--back"
6
+ small
7
+ icon
8
+ @click="closeEditor"
9
+ >
5
10
  <v-icon>mdi-arrow-left</v-icon>
6
11
  </v-btn>
7
- <span class="subtitle-2">{{ fileName }}</span>
8
- <div></div>
9
- </div>
10
- <v-container class="px-6">
11
- <v-img
12
- :src="media.file"
13
- :lazy-src="media.thumbnail"
14
- max-height="300"
15
- contain
16
- aspect-ratio="1"
17
- class="grey lighten-2 mb-4 elevation-2"
12
+ <v-btn
13
+ class="img_overlay__button img_overlay__button--href"
14
+ small
15
+ icon
16
+ :href="media.file"
17
+ target="_blank"
18
18
  >
19
- <template v-slot:placeholder>
20
- <v-row class="fill-height ma-0" align="center" justify="center">
21
- <v-progress-circular
22
- indeterminate
23
- color="grey lighten-5"
24
- ></v-progress-circular>
25
- </v-row>
26
- </template>
27
- </v-img>
28
- <v-row class="flex-md-row-reverse">
29
- <v-col md="6" cols="12" class="info-media">
30
- <table class="text-caption fill-height pb-md-10">
31
- <tr>
32
- <td class="pr-3"><b>Filename:</b></td>
33
- <td>{{ fileName }}</td>
34
- </tr>
35
- <tr>
36
- <td class="pr-3"><b>Extension:</b></td>
37
- <td>{{ extension }}</td>
38
- </tr>
39
- <tr>
40
- <td class="pr-3"><b>Created:</b></td>
41
- <td>{{ dateCreated }}</td>
42
- </tr>
43
- <tr>
44
- <td class="pr-3"><b>Size:</b></td>
45
- <td>{{ fileSize }}</td>
46
- </tr>
47
- <tr>
48
- <td class="pr-3"><b>Url:</b></td>
49
- <td>
50
- <a :href="media.file" target="_blank">{{ media.file }}</a>
51
- </td>
52
- </tr>
53
- <tr>
54
- <td class="pr-3"><b>Linked models:</b></td>
55
- <td>{{ media.liks }}</td>
56
- </tr>
57
- </table>
58
- </v-col>
59
- <v-col md="6" cols="12">
60
- <v-row>
61
- <v-col sm="6" md="12" cols="12">
62
- <v-text-field
63
- dense
64
- v-model="media.name"
65
- label="Name"
66
- ></v-text-field>
67
- </v-col>
68
- <v-col sm="6" md="12" cols="12">
69
- <v-text-field
70
- dense
71
- v-model="media.title"
72
- label="Title"
73
- ></v-text-field>
74
- </v-col>
75
- <v-col sm="6" md="12" cols="12">
76
- <v-text-field
77
- dense
78
- v-model="media.description"
79
- label="Description"
80
- ></v-text-field>
81
- </v-col>
82
- <v-col sm="6" md="12" cols="12">
83
- <v-text-field
84
- dense
85
- v-model="media.alt_text"
86
- label="Alt name"
87
- ></v-text-field>
88
- </v-col>
89
- </v-row>
90
- <div class="d-flex justify-end">
91
- <v-btn text color="primary" @click="saveMedia">
92
- <v-icon left> mdi-upload </v-icon>
93
- save
94
- </v-btn>
95
- <v-btn text color="error" @click="deleteMedia">
96
- <v-icon left> mdi-delete </v-icon>
97
- delete
98
- </v-btn>
99
- </div>
100
- </v-col>
101
- </v-row>
102
- </v-container>
19
+ <v-icon>mdi-open-in-new</v-icon>
20
+ </v-btn>
21
+ </div>
22
+ <MediaPreview
23
+ :media="media"
24
+ contain
25
+ filename
26
+ media-controls
27
+ class="media-editor--preview elevation-2"
28
+ />
29
+ <v-overlay absolute v-model="editing" @click="editing = false"></v-overlay>
30
+ <div class="dialog">
31
+ <div class="dialog__container">
32
+ <v-card
33
+ flat
34
+ tile
35
+ class="dialog__content overflow-y-auto"
36
+ :class="{ 'py-0': !editing }"
37
+ :max-height="editing ? height : '0px'"
38
+ >
39
+ <v-card-text class="flex-grow-0">
40
+ <v-row class="flex-md-row-reverse">
41
+ <v-col md="6" cols="12" class="info-media">
42
+ <table class="text-caption fill-height pb-md-10">
43
+ <tr>
44
+ <td class="pr-3">
45
+ <b>{{ $t("mapo.fileName") }}:</b>
46
+ </td>
47
+ <td>{{ fileName }}</td>
48
+ </tr>
49
+ <tr>
50
+ <td class="pr-3">
51
+ <b>{{ $t("mapo.mime") }}:</b>
52
+ </td>
53
+ <td>{{ media.mime_type }}</td>
54
+ </tr>
55
+ <tr>
56
+ <td class="pr-3">
57
+ <b>{{ $t("mapo.created") }}:</b>
58
+ </td>
59
+ <td>{{ dateCreated }}</td>
60
+ </tr>
61
+ <tr>
62
+ <td class="pr-3">
63
+ <b>{{ $t("mapo.size") }}:</b>
64
+ </td>
65
+ <td>{{ fileSize }}</td>
66
+ </tr>
67
+ <tr>
68
+ <td class="pr-3"><b>URL:</b></td>
69
+ <td>
70
+ <a :href="media.file" target="_blank">{{ media.file }}</a>
71
+ </td>
72
+ </tr>
73
+ <tr>
74
+ <td class="pr-3">
75
+ <b>{{ $t("mapo.linkedModels") }}:</b>
76
+ </td>
77
+ <td>
78
+ <ul>
79
+ <li v-for="link in media.links" :key="link.id">
80
+ <b>{{ link.model }} (id:{{ link.id }})</b> - {{ link.name }}
81
+ </li>
82
+ </ul>
83
+ </td>
84
+ </tr>
85
+ </table>
86
+ </v-col>
87
+ <v-col md="6" cols="12">
88
+ <v-row>
89
+ <v-col cols="12">
90
+ <DetailLangSwitch
91
+ :langs="languages"
92
+ v-model="currentLang"
93
+ no-route-change
94
+ />
95
+ </v-col>
96
+ </v-row>
97
+ <Form
98
+ v-model="media"
99
+ class="menu-node-editor--form"
100
+ :currentLang="currentLang"
101
+ :languages="languages"
102
+ :fields="fields"
103
+ :moreSlotBindings="slotBindings"
104
+ :readonly="!canEdit"
105
+ />
106
+ <MediaFileChanger class="mt-6" :file.sync="newFile" :maintain-url.sync="sameUrl" :accept="accept" />
107
+ </v-col>
108
+ </v-row>
109
+ </v-card-text>
110
+ </v-card>
111
+ <v-btn
112
+ tile
113
+ depressed
114
+ width="100%"
115
+ :class="{ 'pr-0': editing }"
116
+ @click="editing = !editing"
117
+ >
118
+ <span>{{ canEdit ? $t("mapo.edit") : $t("mapo.mediaEditor.details") }}</span>
119
+ <v-icon :style="rotate">mdi-chevron-up</v-icon>
120
+ <div class="edit_spacer" :class="{ 'flex-grow-1': editing }"></div>
121
+ <v-btn v-if="editing && canEdit" text tile color="primary" @click="saveMedia">
122
+ {{ $t("mapo.save") }}
123
+ </v-btn>
124
+ <v-btn
125
+ v-if="editing && canDelete"
126
+ text
127
+ tile
128
+ color="error"
129
+ @click.stop="confirmDelete"
130
+ >
131
+ {{ $t("mapo.delete") }}
132
+ </v-btn>
133
+ </v-btn>
134
+ </div>
135
+ </div>
103
136
  </div>
104
137
  </template>
138
+
105
139
  <style lang="scss" scoped>
140
+ .media-editor--wrapper {
141
+ height: 100%;
142
+ display: flex;
143
+ flex-direction: column;
144
+ justify-content: space-between;
145
+ }
146
+
106
147
  table tr td:nth-child(2) {
107
148
  overflow-wrap: anywhere;
108
149
  }
150
+ .dialog {
151
+ position: relative;
152
+ height: 56px;
153
+ z-index: 5;
154
+ &__container {
155
+ position: absolute;
156
+ bottom: 0;
157
+ width: 100%;
158
+ }
159
+ &__content {
160
+ transition-property: max-height, padding;
161
+ transition-duration: 0.3s;
162
+ transition-timing-function: ease-out;
163
+ }
164
+ }
165
+ .media-editor--preview {
166
+ max-height: calc(100vh - 180px);
167
+ flex-grow: 1;
168
+ @media (max-width: 600px) {
169
+ max-height: calc(100vh - 260px);
170
+ min-height: calc(100vh - 260px);
171
+ }
172
+ }
173
+ .v-dialog .media-editor--preview {
174
+ max-height: calc(100vh - 510px);
175
+ @media (max-width: 600px) {
176
+ max-height: calc(100vh - 375px);
177
+ min-height: unset;
178
+ }
179
+ }
180
+ .edit_spacer {
181
+ flex-grow: 0;
182
+ transition: flex-grow 0.3s ease-out;
183
+ }
184
+ .img_overlay {
185
+ position: relative;
186
+ &__button {
187
+ position: absolute;
188
+ z-index: 1;
189
+ color: #333333 !important;
190
+ background: #e0e0e096;
191
+ top: 30px;
192
+ &--back {
193
+ left: 10px;
194
+ }
195
+ &--href {
196
+ right: 10px;
197
+ }
198
+ }
199
+ }
109
200
  </style>
110
201
  <script>
202
+ import { deepClone } from "@mapomodule/utils/helpers/objHelpers";
111
203
  import { humanFileSize } from "@mapomodule/utils/helpers/formatters";
204
+ import { mapGetters, mapActions } from "vuex";
112
205
 
113
206
  export default {
114
207
  name: "MediaEditor",
115
208
  data() {
116
209
  return {
117
- media: null
210
+ media: null,
211
+ editing: false,
212
+ newFile: null,
213
+ sameUrl: false,
214
+ currentLang: this.$i18n.locale,
118
215
  };
119
216
  },
120
217
  props: {
121
- value: {
122
- type: Object,
123
- default: () => null
124
- }
218
+ languages: {
219
+ type: Array,
220
+ default() {
221
+ return this.$mapo.$options?.content?.languages || [];
222
+ },
223
+ },
125
224
  },
126
225
  computed: {
226
+ ...mapGetters("mapo/media", ["editMedia"]),
127
227
  fileSize() {
128
228
  return this.media && humanFileSize(this.media.size);
129
229
  },
130
230
  dateCreated() {
131
231
  return this.media && new Date(this.media.created).toLocaleString();
132
232
  },
133
- extension() {
134
- return this.media && this.media.file && this.media.file.split(".").pop();
135
- },
136
233
  fileName() {
137
234
  return this.media && this.media.file && this.media.file.split("/").pop();
138
- }
235
+ },
236
+ rotate() {
237
+ return {
238
+ transform: this.editing ? "rotate(180deg)" : "rotate(0deg)",
239
+ transition: "transform .3s cubic-bezier(0.25, 0.8, 0.5, 1)",
240
+ };
241
+ },
242
+ height() {
243
+ switch (this.$vuetify.breakpoint.name) {
244
+ case "xs":
245
+ return "50vh";
246
+ default:
247
+ return 425;
248
+ }
249
+ },
250
+ fields() {
251
+ return [
252
+ { value: "title", label: this.$t('mapo.titleTag'), attrs: { dense: true } },
253
+ { value: "description", label: this.$t('mapo.description'), attrs: { dense: true } },
254
+ { value: "alt_text", label: this.$t('mapo.altTag'), attrs: { dense: true } },
255
+ ]
256
+ },
257
+ slotBindings() {
258
+ return {
259
+ model: this.media,
260
+ currentLang: this.lang,
261
+ langs: this.languages,
262
+ fields: this.fields,
263
+ readonly: !this.canEdit,
264
+ };
265
+ },
266
+ accept() {
267
+ switch (this.media.mime_type && this.media.mime_type.split("/")[0]) {
268
+ case "image":
269
+ return "image/*";
270
+ case "video":
271
+ return "video/*";
272
+ case "audio":
273
+ return "audio/*";
274
+ default:
275
+ return "*";
276
+ }
277
+ },
278
+ permissionsModel() {
279
+ return this.$mapo.$options?.medias?.permissionsModel || "media";
280
+ },
281
+ canEdit() {
282
+ return this.$store.getters["mapo/user/hasModelPermission"](
283
+ this.permissionsModel,
284
+ "change"
285
+ );
286
+ },
287
+ canDelete() {
288
+ return this.$store.getters["mapo/user/hasModelPermission"](
289
+ this.permissionsModel,
290
+ "delete"
291
+ );
292
+ },
139
293
  },
140
294
  watch: {
141
- value(val) {
142
- this.media = val;
143
- }
295
+ editMedia(val) {
296
+ this.media = deepClone(val);
297
+ this.editing = false;
298
+ this.newFile = null;
299
+ this.sameUrl = false;
300
+ },
144
301
  },
145
302
  methods: {
303
+ ...mapActions("mapo/media", ["getRoot", "closeEditor", "deleteMedia", "updateMedia"]),
146
304
  saveMedia() {
147
- this.$emit("updateMedia", this.media);
305
+ this.updateMedia({
306
+ ...this.media,
307
+ file: this.newFile || undefined,
308
+ same_url: (this.newFile && this.sameUrl) || undefined,
309
+ language_code: this.$i18n.locale,
310
+ }).catch(error => {
311
+ this.$mapo.$snack.open({
312
+ message: error.response?.data?.detail || this.$t("mapo.genericError"),
313
+ color: "error",
314
+ })
315
+ }).finally(() => {
316
+ this.newFile = null;
317
+ this.sameUrl = false;
318
+ });
148
319
  },
149
- deleteMedia() {
320
+ confirmDelete() {
150
321
  this.$mapo.$confirm
151
322
  .open({
152
- title: "Delete",
153
- question: "Are you sure you want to delete this media?",
154
- approveButton: { text: "Delete", attrs: { color: "red" } }
323
+ title: this.$t("mapo.delete"),
324
+ question: this.$t("mapo.mediaEditor.confirmDelete"),
325
+ approveButton: {
326
+ text: this.$t("mapo.delete"),
327
+ attrs: { color: "red", text: true },
328
+ },
155
329
  })
156
- .then(res => res && this.$emit("deleteMedia", this.media));
330
+ .then((res) => res && this.deleteMedia(this.media)
331
+ .catch(error =>
332
+ this.$mapo.$snack.open({
333
+ message: error.response?.data?.detail || this.$t("mapo.genericError"),
334
+ color: "error",
335
+ })
336
+ ).finally(() => {this.getRoot(); this.closeEditor()}));
157
337
  },
158
- close() {
159
- this.$emit("input", null);
160
- }
161
- }
338
+ },
162
339
  };
163
340
  </script>
@@ -0,0 +1,78 @@
1
+ <template>
2
+ <div>
3
+ <div class="d-flex flex-column flex-grow-1">
4
+ <v-file-input
5
+ v-model="newFile"
6
+ :accept="accept"
7
+ :label="$t('mapo.mediaEditor.changeFile')"
8
+ show-size
9
+ dense
10
+ prepend-icon
11
+ outlined
12
+ class="rounded-0"
13
+ ></v-file-input>
14
+ <v-checkbox
15
+ v-if="newFile"
16
+ v-model="sameUrl"
17
+ :label="$t('mapo.mediaEditor.maintainOldUrl')"
18
+ class="ma-0"
19
+ hide-details
20
+ dense
21
+ ></v-checkbox>
22
+ </div>
23
+ <v-img
24
+ v-if="newFile && newFilePreview"
25
+ :src="newFilePreview"
26
+ aspect-ratio="1"
27
+ min-width="70px"
28
+ max-width="110px"
29
+ class="grey lighten-2 ml-3"
30
+ >
31
+ <template v-slot:placeholder>
32
+ <v-row class="fill-height ma-0" align="center" justify="center">
33
+ <v-progress-circular
34
+ indeterminate
35
+ color="grey lighten-5"
36
+ ></v-progress-circular>
37
+ </v-row>
38
+ </template>
39
+ </v-img>
40
+ </div>
41
+ </template>
42
+
43
+ <script>
44
+ export default {
45
+ data() {
46
+ return {
47
+ newFile: null,
48
+ sameUrl: false,
49
+ };
50
+ },
51
+ props: {
52
+ accept: String,
53
+ file: {},
54
+ maintainUrl: Boolean,
55
+ },
56
+ watch: {
57
+ newFile(val) {
58
+ this.$emit("update:file", val);
59
+ },
60
+ file(val) {
61
+ this.newFile = val;
62
+ },
63
+ sameUrl(val) {
64
+ this.$emit("update:maintainUrl", val);
65
+ },
66
+ maintainUrl(val) {
67
+ this.sameUrl = val;
68
+ },
69
+ },
70
+ computed: {
71
+ newFilePreview() {
72
+ return this.newFile?.type?.startsWith("image/")
73
+ ? URL.createObjectURL(this.newFile)
74
+ : null;
75
+ },
76
+ },
77
+ };
78
+ </script>