@mapomodule/uikit 1.0.0-alpha.4 → 1.0.0-alpha.41

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