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

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 +730 -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 +42 -28
  34. package/components/MediaManager/MediaBreadcrumbs.vue +45 -0
  35. package/components/MediaManager/MediaEditor.vue +282 -121
  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 +111 -39
  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 +134 -0
  70. package/translations/it-IT.js +136 -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,224 @@
1
+ <template>
2
+ <div>
3
+ <v-text-field
4
+ v-if="title"
5
+ v-model="title"
6
+ class="mb-n8 pb-0"
7
+ solo
8
+ readonly
9
+ v-bind="$attrs"
10
+ ></v-text-field>
11
+
12
+ <!-- If the media is not avaible, it shows a btn to add new media -->
13
+ <v-card
14
+ class="rounded-0"
15
+ v-bind="{
16
+ height,
17
+ width,
18
+ maxWidth,
19
+ maxHeight,
20
+ minWidth,
21
+ minHeight,
22
+ ...$attrs,
23
+ }"
24
+ >
25
+ <MediaPreview
26
+ class="media-preview"
27
+ :key="childKey"
28
+ v-if="mediaExists"
29
+ :media="internalValue"
30
+ :video-preview="internalValue.is_image ? false : true"
31
+ />
32
+
33
+ <v-card-title>{{ label }}</v-card-title>
34
+ <v-card-text v-show="internalValue">
35
+ <h4>{{ $t("mapo.fileName") }}:</h4>
36
+ {{ fileName }}
37
+ <h4>{{ $t("mapo.created") }}:</h4>
38
+ {{ fileInfo.created }}
39
+ </v-card-text>
40
+ <v-card-actions>
41
+ <template v-if="!internalValue && !rmAddBtn">
42
+ <v-btn
43
+ tile
44
+ :disabled="readonly"
45
+ @click="editing = true"
46
+ block
47
+ :min-height="minHeight"
48
+ >
49
+ <v-icon size="80"> mdi-plus-circle-outline </v-icon>
50
+ </v-btn>
51
+ </template>
52
+ <template v-else>
53
+ <v-row >
54
+ <v-col align="center">
55
+ <v-btn
56
+ :disabled="readonly"
57
+ @click="editing = true"
58
+ block
59
+ >
60
+ <v-icon>mdi-pencil</v-icon>
61
+ </v-btn>
62
+ </v-col>
63
+ <v-col align="center">
64
+ <v-btn
65
+ :disabled="readonly"
66
+ @click="confirmDelete"
67
+ color="error"
68
+ block
69
+ >
70
+ <v-icon>mdi-delete</v-icon>
71
+ </v-btn>
72
+ </v-col>
73
+ </v-row>
74
+ </template>
75
+ </v-card-actions>
76
+ </v-card>
77
+ <!-- Select media dialog -->
78
+ <media-manager-dialog
79
+ v-model="editing"
80
+ select="single"
81
+ v-on:selectionChange="update"
82
+ v-bind="$attrs"
83
+ >
84
+ </media-manager-dialog>
85
+
86
+ <v-messages v-model="errorMessages" color="error" class="mt-2" />
87
+ </div>
88
+ </template>
89
+
90
+ <style scoped>
91
+ .media-preview {
92
+ cursor: pointer;
93
+ }
94
+ </style>
95
+
96
+ <script>
97
+ export default {
98
+ name: "EnhancedMediaField",
99
+ data() {
100
+ return {
101
+ internalValue: null,
102
+ editing: false,
103
+ childKey: 0,
104
+ };
105
+ },
106
+
107
+ props: {
108
+ value: Object,
109
+ label: String,
110
+ title: {
111
+ type: String,
112
+ default: () => "",
113
+ },
114
+ errorMessages: {
115
+ type: String | Array,
116
+ default: () => [],
117
+ },
118
+ rmAddBtn: {
119
+ type: Boolean,
120
+ default: false,
121
+ },
122
+ //image reflections
123
+ aspectRatio: {
124
+ type: String | Number,
125
+ default: undefined,
126
+ },
127
+ contain: {
128
+ type: Boolean,
129
+ default: false,
130
+ },
131
+ height: {
132
+ type: String | Number,
133
+ default: "100%",
134
+ },
135
+ width: {
136
+ type: String | Number,
137
+ default: "100%",
138
+ },
139
+ maxWidth: {
140
+ type: String | Number,
141
+ default: undefined,
142
+ },
143
+ maxHeight: {
144
+ type: String | Number,
145
+ default: undefined,
146
+ },
147
+ minWidth: {
148
+ type: String | Number,
149
+ default: undefined,
150
+ },
151
+ minHeight: {
152
+ type: String | Number,
153
+ default: 300,
154
+ },
155
+ // This set the component status to readonly, stopping the user interaction.
156
+ readonly: {
157
+ type: Boolean,
158
+ default: false,
159
+ },
160
+ },
161
+
162
+ computed: {
163
+ mediaExists() {
164
+ return !!this.internalValue?.file;
165
+ },
166
+ fileInfo() {
167
+ return {
168
+ title: this.internalValue?.title,
169
+ created: new Date(this.internalValue?.created).toLocaleDateString(
170
+ this.internalValue?.language_code
171
+ ),
172
+ };
173
+ },
174
+ fileName() {
175
+ return (
176
+ this.internalValue &&
177
+ this.internalValue.file &&
178
+ this.internalValue.file.split("/").pop()
179
+ );
180
+ },
181
+ },
182
+
183
+ methods: {
184
+ update(val) {
185
+ this.updateChild();
186
+ this.internalValue = val;
187
+ },
188
+ confirmDelete() {
189
+ this.$mapo.$confirm
190
+ .open({
191
+ title: this.$t("mapo.remove"),
192
+ question: this.$t("mapo.mediaField.confirmRemove"),
193
+ approveButton: {
194
+ text: this.$t("mapo.remove"),
195
+ attrs: { color: "red", text: true },
196
+ },
197
+ })
198
+ .then((res) => (res ? (this.internalValue = null) : null));
199
+ },
200
+ updateChild() {
201
+ this.childKey += 1;
202
+ },
203
+ isImage(val) {
204
+ if (!val?.is_image && val?.mime_type.includes("image")) {
205
+ Object.assign(val, { is_image: true });
206
+ }
207
+ },
208
+ },
209
+ watch: {
210
+ value(val) {
211
+ if (val !== this.internalValue) {
212
+ this.internalValue = val;
213
+ }
214
+ },
215
+ internalValue(val) {
216
+ this.isImage(val);
217
+ this.$emit("input", val);
218
+ },
219
+ },
220
+ mounted() {
221
+ this.internalValue = this.value;
222
+ },
223
+ };
224
+ </script>
@@ -0,0 +1,125 @@
1
+ <template>
2
+ <div class="filefield-wrapper">
3
+ <v-file-input
4
+ v-bind="$attrs"
5
+ :messages="messages"
6
+ :value="model"
7
+ @change="modelSet"
8
+ >
9
+ <template v-slot:message="{ message }">
10
+ <span
11
+ v-if="message == fileUrl"
12
+ v-show="message"
13
+ class="filefield-current"
14
+ ><b class="mr-1">Current:</b>
15
+ <a @click="openFile(message)">{{ message }}</a>
16
+ <v-spacer></v-spacer>
17
+ <v-icon @click="clear" class="mb-1" small>mdi-close</v-icon>
18
+ </span>
19
+ <span v-else>
20
+ {{ message }}
21
+ </span>
22
+ </template>
23
+ </v-file-input>
24
+ </div>
25
+ </template>
26
+
27
+ <style lang="scss" scoped>
28
+ .filefield-current {
29
+ max-width: 100%;
30
+ white-space: nowrap;
31
+ display: flex;
32
+ a {
33
+ overflow: hidden;
34
+ text-overflow: ellipsis;
35
+ }
36
+ }
37
+ </style>
38
+
39
+
40
+ <script>
41
+ /**
42
+ * This component is made to enhance [v-file-input](https://vuetifyjs.com/en/components/file-inputs/). The main upgrade from the vuetify component is the ability to maintain and show the url of the current saved file.
43
+ */
44
+
45
+ export default {
46
+ name: "FileField",
47
+ data() {
48
+ return {
49
+ file: null,
50
+ fileUrl: null,
51
+ };
52
+ },
53
+ props: {
54
+ // V-model property. It is the file.
55
+ value: {
56
+ type: Object | Array | null,
57
+ required: true,
58
+ },
59
+ },
60
+ computed: {
61
+ model: {
62
+ get() {
63
+ return this.file;
64
+ },
65
+ set(val) {
66
+ if (!val || typeof val == "string") this.fileUrl = val;
67
+ if (!val || val instanceof File) this.file = val;
68
+ },
69
+ },
70
+ messages() {
71
+ const messages =
72
+ typeof this.$attrs.messages == "string"
73
+ ? [this.$attrs.messages]
74
+ : this.$attrs.messages || [];
75
+ this.fileUrl &&
76
+ !messages.includes(this.fileUrl) &&
77
+ messages.push(this.fileUrl);
78
+ return messages;
79
+ },
80
+ },
81
+ watch: {
82
+ value(val) {
83
+ this.model = val;
84
+ },
85
+ model(val) {
86
+ this.$emit("input", val);
87
+ },
88
+ },
89
+ methods: {
90
+ clear() {
91
+ this.fileUrl = null;
92
+ this.file = null;
93
+ this.model = null;
94
+ this.$emit("input", null);
95
+ },
96
+ modelSet(val) {
97
+ if (!val) {
98
+ this.$emit("input", this.fileUrl);
99
+ } else {
100
+ this.model = val;
101
+ }
102
+ },
103
+ openFile(url) {
104
+ const w = 700;
105
+ const h = 700;
106
+ const left = screen.width / 2 - w / 2;
107
+ const top = screen.height / 2 - h / 2;
108
+ window.open(
109
+ url,
110
+ url,
111
+ `width=${w},
112
+ height=${h},
113
+ top=${top},
114
+ left=${left}
115
+ `
116
+ );
117
+
118
+ return false;
119
+ },
120
+ },
121
+ created() {
122
+ this.model = this.value;
123
+ },
124
+ };
125
+ </script>
@@ -0,0 +1,88 @@
1
+ <template>
2
+ <v-autocomplete
3
+ v-bind="fieldAttrs"
4
+ v-model="model"
5
+ :items="options"
6
+ ></v-autocomplete>
7
+ </template>
8
+
9
+ <script>
10
+ /**
11
+ * This component is made to simplify ManyToMany and ForeignKeys associations. With this component you can modify an array selecting items from a list of checkboxes or a signle item selecting from a checkbox.
12
+ */
13
+
14
+ export default {
15
+ name: "FksField",
16
+ data() {
17
+ return {
18
+ model: this.value,
19
+ options: this.items || [],
20
+ loading: false,
21
+ };
22
+ },
23
+ props: {
24
+ // V-model property. It is the attribute to be modified.
25
+ value: {
26
+ type: Object | Array | null,
27
+ required: true,
28
+ },
29
+ // This is the array of options from which you can choose.
30
+ items: {
31
+ type: Array,
32
+ default: () => [],
33
+ },
34
+ // This is the endpoint where the component can fetch options.
35
+ endpoint: String | Object,
36
+ },
37
+ computed: {
38
+ fieldAttrs() {
39
+ return {
40
+ chips: this.$attrs.multiple === false ? false : true,
41
+ multiple: true,
42
+ loading: this.loading,
43
+ noDataText: this.loading ? this.$t("mapo.fetchingData") : undefined,
44
+ ...this.$attrs,
45
+ };
46
+ },
47
+ crudConfig() {
48
+ switch (typeof this.endpoint) {
49
+ case "string":
50
+ return {
51
+ url: this.endpoint,
52
+ conf: null,
53
+ };
54
+ case "object":
55
+ return {
56
+ url: this.endpoint.url,
57
+ conf: this.endpoint.conf,
58
+ };
59
+ default:
60
+ return { url: "", conf: null };
61
+ }
62
+ },
63
+ },
64
+ watch: {
65
+ items(val) {
66
+ this.options = val || [];
67
+ },
68
+ value(val) {
69
+ this.model = val;
70
+ },
71
+ model(val) {
72
+ this.$emit("input", val);
73
+ },
74
+ },
75
+ mounted() {
76
+ if (this.crudConfig.url) {
77
+ this.loading = true;
78
+ this.$mapo.$api
79
+ .crud(this.crudConfig.url)
80
+ .list(this.crudConfig.conf)
81
+ .then((res) => {
82
+ this.options = res;
83
+ this.loading = false;
84
+ });
85
+ }
86
+ },
87
+ };
88
+ </script>
@@ -0,0 +1,159 @@
1
+ <template>
2
+ <media-manager-dialog
3
+ select="single"
4
+ :selected.sync="model"
5
+ v-bind="$attrs"
6
+ >
7
+ <template v-slot:activator="{ on, attrs }">
8
+ <v-text-field
9
+ readonly
10
+ v-bind="{ ...$attrs, ...attrs }"
11
+ v-on="readonly ? undefined : on"
12
+ class="media-field--card"
13
+ :class="{ 'media-field--selected': !!model }"
14
+ :value="model ? ' ' : ''"
15
+ >
16
+ <template v-if="model" v-slot:append>
17
+ <MediaPreview
18
+ v-if="model"
19
+ :media="model"
20
+ :video-preview="!model.is_image"
21
+ class="media-field--preview"
22
+ />
23
+ <div class="media-field--info caption text--secondary">
24
+ <p>
25
+ <b>{{ $t("mapo.fileName") }}:</b> {{ fileName }}
26
+ </p>
27
+ <p>
28
+ <b>{{ $t("mapo.size") }}:</b> {{ fileSize }}
29
+ </p>
30
+ <p>
31
+ <b>{{ $t("mapo.mime") }}:</b> {{ model.mime_type }}
32
+ </p>
33
+ <p>
34
+ <b>{{ $t("mapo.altTag") }}:</b> {{ model.alt_text }}
35
+ </p>
36
+ </div>
37
+ <v-btn
38
+ @click.native="clear"
39
+ class="media-field--info-btn"
40
+ tile
41
+ small
42
+ icon
43
+ ><v-icon>mdi-close</v-icon></v-btn
44
+ >
45
+ </template>
46
+ </v-text-field>
47
+ </template>
48
+ </media-manager-dialog>
49
+ </template>
50
+ <style lang="scss">
51
+ .media-field--card.v-text-field > .v-input__control > .v-input__slot {
52
+ input {
53
+ cursor: pointer;
54
+ }
55
+ }
56
+ .media-field--selected {
57
+ .v-text-field__slot {
58
+ position: absolute !important;
59
+ width: calc(100% - 24px);
60
+ height: 100%;
61
+ }
62
+ .v-input__append-inner {
63
+ margin-left: 0 !important;
64
+ width: 100%;
65
+ }
66
+ &.media-field--card.v-text-field > .v-input__control > .v-input__slot {
67
+ cursor: pointer;
68
+ input {
69
+ position: absolute;
70
+ cursor: pointer;
71
+ width: 100%;
72
+ min-height: 100%;
73
+ }
74
+ }
75
+ }
76
+
77
+ .media-field--preview {
78
+ width: 100px;
79
+ height: 100px;
80
+ border: 1px solid;
81
+ border-color: inherit;
82
+ margin-bottom: 10px;
83
+ margin-right: 12px;
84
+ }
85
+ .media-field--info {
86
+ width: 100%;
87
+ max-width: calc(100% - 112px);
88
+ p {
89
+ margin-bottom: 0;
90
+ overflow: hidden;
91
+ text-overflow: ellipsis;
92
+ white-space: nowrap;
93
+ }
94
+ &-btn {
95
+ position: absolute;
96
+ top: 0;
97
+ right: 0;
98
+ }
99
+ }
100
+ .media-field--add {
101
+ width: 100px;
102
+ margin-bottom: 10px;
103
+ }
104
+ .media-field--card{
105
+ border-radius: inherit;
106
+ }
107
+ </style>
108
+
109
+ <script>
110
+ import { humanFileSize } from "@mapomodule/utils/helpers/formatters";
111
+
112
+ /**
113
+ * This component is made to manage media fields for single selection.
114
+ */
115
+ export default {
116
+ name: "MultimediaField",
117
+ data() {
118
+ return {
119
+ model: this.value,
120
+ };
121
+ },
122
+ props: {
123
+ // V-model property. Color must be hex codified.
124
+ value: {
125
+ type: Object | null,
126
+ },
127
+ // This set the component status to readonly, stopping the user interaction.
128
+ readonly: {
129
+ type: Boolean,
130
+ default: false,
131
+ },
132
+ },
133
+ computed: {
134
+ fileName() {
135
+ return this.model && this.model.file && this.model.file.split("/").pop();
136
+ },
137
+ dateCreated() {
138
+ return this.model && new Date(this.model.created).toLocaleString();
139
+ },
140
+ fileSize() {
141
+ return this.model && humanFileSize(this.model.size);
142
+ },
143
+ },
144
+ methods:{
145
+ clear(event){
146
+ event.stopPropagation();
147
+ this.model = null;
148
+ }
149
+ },
150
+ watch: {
151
+ value(val) {
152
+ this.model = val;
153
+ },
154
+ model(val) {
155
+ this.$emit("input", val);
156
+ },
157
+ },
158
+ };
159
+ </script>