@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
@@ -1,129 +0,0 @@
1
- <template>
2
- <component :is="is" v-model="model" v-bind="fieldProp"></component>
3
- </template>
4
-
5
- <script>
6
- import TinyMce from "@mapomodule/uikit/components/fields/TinyMce/TinyMce.vue";
7
- import DateField from "@mapomodule/uikit/components/fields/DateField.vue";
8
- import M2mField from "@mapomodule/uikit/components/fields/M2mField.vue";
9
- import MediaM2mField from "@mapomodule/uikit/components/fields/MediaM2mField.vue";
10
- import MediaField from "@mapomodule/uikit/components/fields/MediaField.vue";
11
-
12
- import { getPointed, setPointed } from "@mapomodule/utils/helpers/objHelpers";
13
- import defaults from "./defaults";
14
-
15
- /**
16
- * This is mainly an internal component. It is used by the [`DetailComponent`](/components/detail/Detail/) in order to render dinamic fields inside the main form.
17
- */
18
- export default {
19
- name: "DetailField",
20
- components: {
21
- TinyMce,
22
- DateField,
23
- M2mField,
24
- MediaM2mField,
25
- MediaField
26
- },
27
-
28
- data() {
29
- return {
30
- model: null,
31
- fieldsMap: defaults.mapping,
32
- fieldsProps: defaults.props,
33
- fieldsAccess: defaults.accessor
34
- };
35
- },
36
- props: {
37
- // V-model of the payload needed to edit the field value in realtime.
38
- value: {
39
- type: Object,
40
- required: true
41
- },
42
- // An object representing all the errors of all fields. This means that this component will find the error of its field following the dottedPath of the value in the error dict.
43
- errors: Object,
44
- // The main configuration that determines the rendering of the field. See [FieldConfiguration](/components/detail/Detail/#fieldconfiguration).
45
- conf: {
46
- // [`FieldConfiguration`](/components/detail/Detail/#fieldconfiguration)
47
- type: Object,
48
- required: true
49
- }
50
- },
51
- watch: {
52
- value: {
53
- deep: true,
54
- handler(val) {
55
- this.setModel(val);
56
- }
57
- },
58
- conf(newConf, oldConf) {
59
- if (newConf.value !== oldConf.value) {
60
- this.setModel();
61
- }
62
- },
63
- model(val) {
64
- const dump = { ...this.value };
65
- setPointed(
66
- dump,
67
- this.conf.value,
68
- this.accessor.set({ model: { ...this.value }, val })
69
- );
70
- // Fired when the v-model changes.
71
- // @arg Emits the entire payload modified.
72
- this.$emit("input", dump);
73
- }
74
- },
75
- methods: {
76
- setModel(val = this.value) {
77
- var model = this.accessor.get({
78
- model: { ...val },
79
- val: getPointed({ ...val }, this.conf.value)
80
- });
81
- if (val && JSON.stringify(this.model) !== JSON.stringify(model))
82
- this.model = model;
83
- }
84
- },
85
- computed: {
86
- accessor() {
87
- let func = function({ val }) {
88
- return val;
89
- };
90
- return {
91
- get: func,
92
- set: func,
93
- ...(this.fieldsAccess[this.is] || {}),
94
- ...this.conf.accessor
95
- };
96
- },
97
- fieldProp() {
98
- return {
99
- label: this.label,
100
- errorMessages: getPointed(this.errors || {}, this.conf.value, []),
101
- ...(this.fieldsProps[this.is] || {}),
102
- ...this.conf.attrs
103
- };
104
- },
105
- label() {
106
- if (this.conf.label !== undefined) {
107
- return this.conf.label;
108
- }
109
- const titleCase = string =>
110
- (string && string[0].toUpperCase() + string.slice(1).toLowerCase()) ||
111
- "";
112
- return titleCase(
113
- (this.conf.value || "")
114
- .replace(/^translations\.\w\w\./, "")
115
- .split(".")
116
- .join(" ")
117
- .replace(/_/, " ")
118
- );
119
- },
120
- is() {
121
- return (
122
- this.conf.is ||
123
- (this.conf.type && this.fieldsMap[this.conf.type]) ||
124
- "v-text-field"
125
- );
126
- }
127
- }
128
- };
129
- </script>
@@ -1,50 +0,0 @@
1
- const mapping = {
2
- text: "v-text-field",
3
- select: "v-select",
4
- date: "date-field",
5
- textarea: "v-textarea",
6
- switch: "v-switch",
7
- slider: "v-slider",
8
- file: "v-file-input",
9
- editor: "tiny-mce",
10
- media: "media-field",
11
- m2m: "m2m-field",
12
- mediaList: "media-m2m-field"
13
- }
14
-
15
- const props = {
16
- "v-text-field": {
17
- outlined: true
18
- },
19
- "v-textarea": {
20
- outlined: true
21
- },
22
- "date-field": {
23
- outlined: true
24
- },
25
- "v-select": {
26
- outlined: true,
27
- itemText: "text",
28
- itemValue: "value"
29
- },
30
- "v-switch": {
31
- inset: true,
32
- ripple: false
33
- }
34
- }
35
-
36
- const dateFunc = function ({ val }) {
37
- return val && new Date(val).toISOString().split("T")[0];
38
- };
39
-
40
- const accessor = {
41
- "v-date-picker": {
42
- get: dateFunc, set: dateFunc
43
- },
44
- "date-field": {
45
- get: dateFunc, set: dateFunc
46
- }
47
- }
48
- export default {
49
- mapping, props, accessor
50
- }
@@ -1,95 +0,0 @@
1
- <template>
2
- <div>
3
- <v-checkbox
4
- v-for="(option, index) in options"
5
- :key="index"
6
- :label="option[itemText]"
7
- :input-value="isSelected(option)"
8
- @change="changed($event, option)"
9
- >
10
- </v-checkbox>
11
- </div>
12
- </template>
13
-
14
- <script>
15
- /**
16
- * This component is made to simplify Many To Many associations. With this component you can modify an array selecting items from a list of checkboxes.
17
- */
18
-
19
- export default {
20
- name: "M2mField",
21
- data() {
22
- return {
23
- proxyItems: []
24
- };
25
- },
26
- props: {
27
- // V-model property. It is the array to be modified.
28
- value: {
29
- type: Array,
30
- required: true
31
- },
32
- // This is the array of options from which you can choose.
33
- items: {
34
- type: Array,
35
- default: () => []
36
- },
37
- itemText: {
38
- type: String,
39
- default: "text"
40
- },
41
- itemValue: {
42
- type: String,
43
- default: "*"
44
- },
45
- lookup: {
46
- type: String,
47
- default: "id"
48
- },
49
- endPoint: String,
50
- mapping: {
51
- type: Function,
52
- default: items => items
53
- }
54
- },
55
- computed: {
56
- hasKey() {
57
- return this.itemValue !== "*";
58
- },
59
- options() {
60
- return this.mapping(this.proxyItems);
61
- }
62
- },
63
- methods: {
64
- isSelected(option) {
65
- return !!(this.value || []).find(
66
- e => e[this.lookup] == option[this.lookup]
67
- );
68
- },
69
- changed(value, option) {
70
- let val = this.hasKey ? option[this.itemValue] : option;
71
- let newArr = [...(this.value || [])];
72
- if (value) {
73
- newArr.push(val);
74
- } else {
75
- let i = newArr.findIndex(e => e[this.lookup] == option[this.lookup]);
76
- i !== -1 && newArr.splice(i, 1);
77
- }
78
- this.$emit("input", newArr);
79
- }
80
- },
81
- watch: {
82
- items(val) {
83
- this.proxyItems = val;
84
- }
85
- },
86
- mounted() {
87
- if (this.endPoint && (!this.items || !this.items.length)) {
88
- this.$mapo.$api
89
- .crud(this.endPoint)
90
- .list()
91
- .then(res => (this.proxyItems = res));
92
- }
93
- }
94
- };
95
- </script>
@@ -1,195 +0,0 @@
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
- <v-hover v-model="isHovered">
12
- <div style="position: relative">
13
- <v-img
14
- v-if="mediaExists"
15
- :src="internalValue.file"
16
- :lazy-src="internalValue.thumbnail"
17
- v-bind="{
18
- aspectRatio,
19
- contain,
20
- height,
21
- width,
22
- maxWidth,
23
- maxHeight,
24
- minWidth,
25
- minHeight,
26
- }"
27
- >
28
- <template v-slot:placeholder>
29
- <v-row
30
- v-if="internalValue"
31
- class="fill-height ma-0"
32
- align="center"
33
- justify="center"
34
- >
35
- <v-progress-circular
36
- indeterminate
37
- color="grey"
38
- ></v-progress-circular>
39
- </v-row>
40
- </template>
41
- </v-img>
42
-
43
- <!-- If the media is not avaible, it shows a btn to add new media -->
44
- <v-card
45
- v-else-if="!rmAddBtn"
46
- v-bind="{
47
- height,
48
- width,
49
- maxWidth,
50
- maxHeight,
51
- minWidth,
52
- minHeight,
53
- ...$attrs,
54
- }"
55
- >
56
- <v-card-title>{{ label }}</v-card-title>
57
-
58
- <v-card-actions>
59
- <v-btn @click="editing = true" block :min-height="minHeight">
60
- <v-icon size="80"> mdi-plus-circle-outline </v-icon>
61
- </v-btn>
62
- </v-card-actions>
63
- </v-card>
64
-
65
- <!-- Shows darkening overlay on image with buttons on top while hovered -->
66
- <v-overlay opacity="0.3" absolute :value="overlay">
67
- <v-row>
68
- <v-col cols="12">
69
- <h3>{{ label }}</h3>
70
- </v-col>
71
- </v-row>
72
- <v-row>
73
- <v-col cols="6">
74
- <v-btn @click="editing = true" fab v-bind="$attrs">
75
- <v-icon>mdi-pencil</v-icon>
76
- </v-btn>
77
- </v-col>
78
-
79
- <v-col cols="6">
80
- <v-btn @click="confirmDelete" fab v-bind="$attrs">
81
- <v-icon>mdi-delete</v-icon>
82
- </v-btn>
83
- </v-col>
84
- </v-row>
85
- </v-overlay>
86
-
87
- <!-- Select media dialog -->
88
- <media-manager-dialog
89
- v-model="editing"
90
- select="single"
91
- v-on:selectionChange="update"
92
- v-bind="$attrs"
93
- >
94
- </media-manager-dialog>
95
-
96
- </div>
97
- </v-hover>
98
- </div>
99
- </template>
100
-
101
- <style scoped>
102
- </style>
103
-
104
- <script>
105
- export default {
106
- name: "MediaField",
107
- data() {
108
- return {
109
- internalValue: null,
110
- editing: false,
111
- isHovered: false,
112
- };
113
- },
114
-
115
- props: {
116
- value: Object,
117
- label: String,
118
- title: {
119
- type: String,
120
- default: () => "",
121
- },
122
- rmAddBtn: {
123
- type: Boolean,
124
- default: false,
125
- },
126
- //image reflections
127
- aspectRatio: {
128
- type: String | Number,
129
- default: undefined,
130
- },
131
- contain: {
132
- type: Boolean,
133
- default: false,
134
- },
135
- height: {
136
- type: String | Number,
137
- default: "100%",
138
- },
139
- width: {
140
- type: String | Number,
141
- default: "100%",
142
- },
143
- maxWidth: {
144
- type: String | Number,
145
- default: undefined,
146
- },
147
- maxHeight: {
148
- type: String | Number,
149
- default: undefined,
150
- },
151
- minWidth: {
152
- type: String | Number,
153
- default: undefined,
154
- },
155
- minHeight: {
156
- type: String | Number,
157
- default: 300,
158
- },
159
- },
160
-
161
- computed: {
162
- mediaExists() {
163
- return !!this.internalValue?.file;
164
- },
165
- overlay() {
166
- return this.isHovered && this.mediaExists;
167
- },
168
- },
169
-
170
- methods: {
171
- update(val) {
172
- this.internalValue = val;
173
- },
174
- confirmDelete() {
175
- this.$mapo.$confirm
176
- .open({
177
- title: "Remove",
178
- question: "Are you sure to want to remove this media?"
179
- })
180
- .then((res) => (res ? (this.internalValue = null) : null));
181
- },
182
- },
183
-
184
- watch: {
185
- value(val) {
186
- if (val !== this.internalValue) {
187
- this.internalValue = val;
188
- }
189
- },
190
- internalValue(val) {
191
- this.$emit("input", val);
192
- },
193
- },
194
- };
195
- </script>
@@ -1,238 +0,0 @@
1
- <template>
2
- <div>
3
- <v-card
4
- v-bind="{
5
- minWidth,
6
- minHeight,
7
- height,
8
- width,
9
- maxHeight,
10
- maxWidth,
11
- elevation,
12
- dark,
13
- light: !dark,
14
- }"
15
- >
16
- <v-card-title v-if="!pages">Media Carousel</v-card-title>
17
- <v-card-actions>
18
- <v-row justify="center" class="ma-1" no-gutters>
19
- <v-col>
20
- <v-btn
21
- @click="mmdialog = true"
22
- block
23
- outlined
24
- :min-height="pages ? undefined : minHeight"
25
- >
26
- <div v-if="pages">New Selection</div>
27
- <v-icon v-else size="80"> mdi-plus-circle-outline </v-icon>
28
- </v-btn>
29
- </v-col>
30
- </v-row>
31
- </v-card-actions>
32
-
33
- <v-window v-model="page">
34
- <v-window-item
35
- class="page"
36
- v-for="(pageMedias, i) in paginatedMedias"
37
- :key="i"
38
- >
39
- <v-container class="pa-0">
40
- <v-row
41
- v-for="row in rows"
42
- :key="row"
43
- align="center"
44
- align-content="center"
45
- justify="center"
46
- >
47
- <v-col v-for="col in cols" :key="col">
48
- <MediaElement
49
- v-if="pageMedias[getIndexFromGrid(row, col)]"
50
- v-model="pageMedias[getIndexFromGrid(row, col)]"
51
- :aspect-ratio="1"
52
- :dark="dark"
53
- rm-add-btn
54
- @changed-media="checkMediaEdit($event, i, row, col)"
55
- />
56
- <div v-else class="placeholder"></div>
57
- </v-col>
58
- </v-row>
59
- </v-container>
60
- </v-window-item>
61
- </v-window>
62
-
63
- <v-card-actions class="paginator mt-auto" v-if="pages">
64
- <v-row justify="center" class="py-2">
65
- <v-btn text @click="prev">
66
- <v-icon>mdi-chevron-left</v-icon>
67
- </v-btn>
68
- <v-item-group v-model="page" class="text-center mx-1" mandatory>
69
- <v-item
70
- v-for="n in pages"
71
- :key="`btn-${n}`"
72
- v-slot="{ active, toggle }"
73
- >
74
- <v-btn :input-value="active" icon @click="toggle">
75
- <v-icon>mdi-record</v-icon>
76
- </v-btn>
77
- </v-item>
78
- </v-item-group>
79
- <v-btn text @click="next">
80
- <v-icon>mdi-chevron-right</v-icon>
81
- </v-btn>
82
- </v-row>
83
- </v-card-actions>
84
- </v-card>
85
-
86
- <media-manager-dialog
87
- v-model="mmdialog"
88
- select="multi"
89
- v-on:selectionChange="update"
90
- :light="!dark"
91
- :dark="dark"
92
- >
93
- </media-manager-dialog>
94
- </div>
95
- </template>
96
-
97
- <style scoped>
98
- .v-card {
99
- display: flex;
100
- flex-direction: column;
101
- }
102
-
103
- .v-window {
104
- overflow: hidden;
105
- position: relative;
106
- width: 100%;
107
- }
108
-
109
- .placeholder {
110
- padding-bottom: 100%;
111
- }
112
- </style>
113
-
114
- <script>
115
- export default {
116
- name: "MediaM2mField",
117
- transition: "tasks-transition",
118
- data() {
119
- return {
120
- child_medias: [],
121
-
122
- page: 0,
123
- mmdialog: false,
124
- };
125
- },
126
-
127
- props: {
128
- medias: {
129
- type: Array,
130
- default: () => [],
131
- },
132
- cols: {
133
- type: Number,
134
- default: 2,
135
- },
136
- rows: {
137
- type: Number,
138
- default: 2,
139
- },
140
-
141
- //reflections
142
- minWidth: {
143
- type: Number | String,
144
- default: 300,
145
- },
146
- minHeight: {
147
- type: Number | String,
148
- default: 300,
149
- },
150
- height: {
151
- type: Number | String,
152
- },
153
- width: {
154
- type: Number | String,
155
- },
156
- maxHeight: {
157
- type: Number | String,
158
- },
159
- maxWidth: {
160
- type: Number | String,
161
- },
162
-
163
- elevation: {
164
- type: Number | String,
165
- default: undefined,
166
- },
167
- flat: {
168
- type: Boolean,
169
- default: false,
170
- },
171
-
172
- dark: {
173
- type: Boolean,
174
- default: false,
175
- },
176
- },
177
-
178
- model: {
179
- prop: "medias",
180
- event: "changed-selection",
181
- },
182
-
183
- mounted() {
184
- if (this.medias) this.child_medias = this.medias;
185
- },
186
-
187
- computed: {
188
- mediasPerPage() {
189
- return this.cols * this.rows;
190
- },
191
- pages() {
192
- return Math.ceil(this.child_medias.length / this.mediasPerPage);
193
- },
194
- paginatedMedias() {
195
- var array = new Array(this.pages);
196
- for (let i = 0; i < array.length; i++) {
197
- array[i] = this.child_medias.slice(
198
- i * this.mediasPerPage,
199
- (i + 1) * this.mediasPerPage
200
- );
201
- }
202
- return array;
203
- },
204
- },
205
-
206
- methods: {
207
- getIndexFromGrid(row, col) {
208
- return (row - 1) * this.cols + col - 1;
209
- },
210
- update(selection) {
211
- this.child_medias = [...selection];
212
- this.$emit("changed-selection", [...selection]);
213
- },
214
- checkMediaEdit(event, page, row, col) {
215
- //if event is not empty, then exit
216
- let index = this.mediasPerPage * page + this.getIndexFromGrid(row, col);
217
- if (event) {
218
- this.child_medias[index] = event;
219
- } else {
220
- this.child_medias.splice(index, 1);
221
- }
222
- this.update(this.child_medias);
223
- },
224
- next() {
225
- this.page = this.page + 1 === this.length ? 0 : this.page + 1;
226
- },
227
- prev() {
228
- this.page = this.page - 1 < 0 ? this.length - 1 : this.page - 1;
229
- },
230
- },
231
-
232
- watch: {
233
- medias(val) {
234
- this.child_medias = val;
235
- },
236
- },
237
- };
238
- </script>