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

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 (55) hide show
  1. package/CHANGELOG.md +406 -0
  2. package/components/Detail/Detail.vue +288 -260
  3. package/components/Detail/DetailLangSwitch.vue +1 -1
  4. package/components/DropArea.vue +3 -3
  5. package/components/Form/Form.vue +224 -0
  6. package/components/Form/FormField.vue +185 -0
  7. package/components/Form/FormGroup.vue +88 -0
  8. package/components/Form/FormTabs.vue +134 -0
  9. package/components/Form/defaults.js +58 -0
  10. package/components/{fields → Form/fields}/DateField.vue +9 -3
  11. package/components/Form/fields/FileField.vue +125 -0
  12. package/components/Form/fields/FksField.vue +88 -0
  13. package/components/{fields → Form/fields}/MediaField.vue +36 -6
  14. package/components/{fields → Form/fields}/MediaM2mField.vue +8 -3
  15. package/components/Form/fields/Repeater.vue +562 -0
  16. package/components/Form/fields/SeoPreview.vue +89 -0
  17. package/components/{fields/TinyMce → Form/fields/wygEditor}/defaults.js +7 -5
  18. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/events.js +0 -0
  19. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/mapomedia.plugin.js +7 -6
  20. package/components/{fields/TinyMce → Form/fields/wygEditor}/utils/script.injector.js +0 -0
  21. package/components/Form/fields/wygEditor/wygEditor.vue +256 -0
  22. package/components/List/List.vue +120 -42
  23. package/components/List/ListActions.vue +56 -17
  24. package/components/List/ListFilters.vue +158 -113
  25. package/components/List/ListHead.vue +30 -12
  26. package/components/List/ListQuickEdit.vue +128 -59
  27. package/components/List/ListTable.vue +293 -80
  28. package/components/Login.vue +14 -5
  29. package/components/MediaManager/MediaEditor.vue +253 -107
  30. package/components/MediaManager/MediaFolders.vue +134 -43
  31. package/components/MediaManager/MediaGallery.vue +56 -52
  32. package/components/MediaManager/MediaManager.vue +127 -83
  33. package/components/MediaManager/MediaManagerDialog.vue +19 -22
  34. package/components/MediaManager/MediaPreview.vue +180 -0
  35. package/components/MediaManager/MediaUploader.vue +35 -32
  36. package/components/SnackBar.vue +3 -4
  37. package/components/ThemeToggle.vue +13 -0
  38. package/components/layout/Sidebar/Sidebar.vue +35 -32
  39. package/components/layout/Sidebar/SidebarFooter.vue +42 -46
  40. package/components/layout/Sidebar/SidebarList.vue +13 -14
  41. package/components/layout/Sidebar/SidebarListItem.vue +99 -38
  42. package/components/layout/Sidebar/SidebarProfile.vue +42 -0
  43. package/components/layout/Topbar/Topbar.vue +3 -35
  44. package/components/layout/routebuilder.js +3 -3
  45. package/defaults.js +2 -2
  46. package/layouts/default.vue +20 -18
  47. package/layouts/empty.vue +10 -0
  48. package/module.js +1 -1
  49. package/package.json +5 -4
  50. package/pages/index.vue +1 -2
  51. package/components/Detail/DetailField.vue +0 -129
  52. package/components/Detail/defaults.js +0 -50
  53. package/components/fields/M2mField.vue +0 -95
  54. package/components/fields/TinyMce/TinyMce.vue +0 -177
  55. package/layouts/error.vue +0 -45
@@ -0,0 +1,58 @@
1
+ const mapping = {
2
+ text: "vTextField",
3
+ select: "vSelect",
4
+ date: "DateField",
5
+ textarea: "vTextarea",
6
+ switch: "vSwitch",
7
+ slider: "vSlider",
8
+ file: "FileField",
9
+ editor: "wygEditor",
10
+ media: "MediaField",
11
+ fks: "FksField",
12
+ m2m: "FksField",
13
+ mediaList: "MediaM2mField",
14
+ seoPreview: "SeoPreview",
15
+ repeater: "Repeater",
16
+ }
17
+
18
+ const props = {
19
+ vSelect: {
20
+ itemText: "text",
21
+ itemValue: "value"
22
+ },
23
+ MediaField: {
24
+ outlined: false
25
+ },
26
+ vSwitch: {
27
+ inset: true,
28
+ ripple: false
29
+ },
30
+ FksField:{
31
+ itemValue: "id",
32
+ returnObject: true,
33
+ },
34
+ All : {
35
+ outlined: true,
36
+ class: "rounded-0",
37
+ }
38
+ }
39
+
40
+ const dateFunc = function ({ val }) {
41
+ return val && new Date(val).toISOString().split("T")[0];
42
+ };
43
+
44
+ const accessor = {
45
+ vDatePicker: {
46
+ get: dateFunc, set: dateFunc
47
+ },
48
+ DateField: {
49
+ get: dateFunc, set: dateFunc
50
+ },
51
+ SeoPreview: {
52
+ get: ({ val }) => ({ title: "", permalink: "", description: "", ...val }),
53
+ set: ({ val }) => ({ title: "", permalink: "", description: "", ...val })
54
+ }
55
+ }
56
+ export default {
57
+ mapping, props, accessor
58
+ }
@@ -15,8 +15,9 @@
15
15
  prepend-inner-icon="mdi-calendar"
16
16
  readonly
17
17
  v-bind="{ ...$attrs, ...attrs }"
18
- v-on="on"
19
- clearable
18
+ v-on="readonly ? undefined : on"
19
+ :clearable="!readonly"
20
+ class="rounded-0"
20
21
  ></v-text-field>
21
22
  </template>
22
23
  <v-date-picker v-model="model" :range="range" no-title>
@@ -49,7 +50,12 @@ export default {
49
50
  range: {
50
51
  type: Boolean,
51
52
  default: false
52
- }
53
+ },
54
+ // This set the component status to readonly, stopping the user interaction.
55
+ readonly: {
56
+ type: Boolean,
57
+ default: false,
58
+ },
53
59
  },
54
60
  watch: {
55
61
  value(val) {
@@ -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: null,
19
+ options: [],
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 ? "Fetching data.." : 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>
@@ -12,8 +12,10 @@
12
12
  <div style="position: relative">
13
13
  <v-img
14
14
  v-if="mediaExists"
15
- :src="internalValue.file"
16
- :lazy-src="internalValue.thumbnail"
15
+ :src="internalValue.is_image && internalValue.file || null"
16
+ :lazy-src="internalValue.is_image && internalValue.thumbnail || null"
17
+
18
+ :class="{'grey lighten-2': !internalValue.is_image}"
17
19
  v-bind="{
18
20
  aspectRatio,
19
21
  contain,
@@ -33,9 +35,15 @@
33
35
  justify="center"
34
36
  >
35
37
  <v-progress-circular
38
+ v-if="internalValue.is_image"
36
39
  indeterminate
37
40
  color="grey"
38
41
  ></v-progress-circular>
42
+ <div class="d-flex flex-column align-center justify-space-between fill-height" style="width: 100%" v-else>
43
+ <div></div>
44
+ <v-icon size="70px" color="grey">mdi-file</v-icon>
45
+ <span class="grey--text text--darken-3 text-truncate pl-1 pr-8" style="width: 100%">{{fileName}}</span>
46
+ </div>
39
47
  </v-row>
40
48
  </template>
41
49
  </v-img>
@@ -43,6 +51,7 @@
43
51
  <!-- If the media is not avaible, it shows a btn to add new media -->
44
52
  <v-card
45
53
  v-else-if="!rmAddBtn"
54
+ class="rounded-0"
46
55
  v-bind="{
47
56
  height,
48
57
  width,
@@ -56,7 +65,7 @@
56
65
  <v-card-title>{{ label }}</v-card-title>
57
66
 
58
67
  <v-card-actions>
59
- <v-btn @click="editing = true" block :min-height="minHeight">
68
+ <v-btn tile :disabled="readonly" @click="editing = true" block :min-height="minHeight">
60
69
  <v-icon size="80"> mdi-plus-circle-outline </v-icon>
61
70
  </v-btn>
62
71
  </v-card-actions>
@@ -71,13 +80,13 @@
71
80
  </v-row>
72
81
  <v-row>
73
82
  <v-col cols="6">
74
- <v-btn @click="editing = true" fab v-bind="$attrs">
83
+ <v-btn :disabled="readonly" @click="editing = true" fab v-bind="$attrs">
75
84
  <v-icon>mdi-pencil</v-icon>
76
85
  </v-btn>
77
86
  </v-col>
78
87
 
79
88
  <v-col cols="6">
80
- <v-btn @click="confirmDelete" fab v-bind="$attrs">
89
+ <v-btn :disabled="readonly" @click="confirmDelete" fab v-bind="$attrs">
81
90
  <v-icon>mdi-delete</v-icon>
82
91
  </v-btn>
83
92
  </v-col>
@@ -95,6 +104,11 @@
95
104
 
96
105
  </div>
97
106
  </v-hover>
107
+ <v-messages
108
+ v-model="errorMessages"
109
+ color="error"
110
+ class="mt-2"
111
+ />
98
112
  </div>
99
113
  </template>
100
114
 
@@ -119,6 +133,10 @@ export default {
119
133
  type: String,
120
134
  default: () => "",
121
135
  },
136
+ errorMessages: {
137
+ type: String | Array,
138
+ default: () => []
139
+ },
122
140
  rmAddBtn: {
123
141
  type: Boolean,
124
142
  default: false,
@@ -156,6 +174,11 @@ export default {
156
174
  type: String | Number,
157
175
  default: 300,
158
176
  },
177
+ // This set the component status to readonly, stopping the user interaction.
178
+ readonly: {
179
+ type: Boolean,
180
+ default: false,
181
+ },
159
182
  },
160
183
 
161
184
  computed: {
@@ -165,6 +188,9 @@ export default {
165
188
  overlay() {
166
189
  return this.isHovered && this.mediaExists;
167
190
  },
191
+ fileName() {
192
+ return this.internalValue && this.internalValue.file && this.internalValue.file.split("/").pop();
193
+ },
168
194
  },
169
195
 
170
196
  methods: {
@@ -175,7 +201,8 @@ export default {
175
201
  this.$mapo.$confirm
176
202
  .open({
177
203
  title: "Remove",
178
- question: "Are you sure to want to remove this media?"
204
+ question: "Are you sure to want to remove this media?",
205
+ approveButton: { text: "Remove", attrs: { color: "red", text: true } }
179
206
  })
180
207
  .then((res) => (res ? (this.internalValue = null) : null));
181
208
  },
@@ -191,5 +218,8 @@ export default {
191
218
  this.$emit("input", val);
192
219
  },
193
220
  },
221
+ mounted(){
222
+ this.internalValue = this.val
223
+ }
194
224
  };
195
225
  </script>
@@ -62,7 +62,7 @@
62
62
 
63
63
  <v-card-actions class="paginator mt-auto" v-if="pages">
64
64
  <v-row justify="center" class="py-2">
65
- <v-btn text @click="prev">
65
+ <v-btn :disabled="readonly" text @click="prev">
66
66
  <v-icon>mdi-chevron-left</v-icon>
67
67
  </v-btn>
68
68
  <v-item-group v-model="page" class="text-center mx-1" mandatory>
@@ -71,12 +71,12 @@
71
71
  :key="`btn-${n}`"
72
72
  v-slot="{ active, toggle }"
73
73
  >
74
- <v-btn :input-value="active" icon @click="toggle">
74
+ <v-btn :disabled="readonly" :input-value="active" icon @click="toggle">
75
75
  <v-icon>mdi-record</v-icon>
76
76
  </v-btn>
77
77
  </v-item>
78
78
  </v-item-group>
79
- <v-btn text @click="next">
79
+ <v-btn :disabled="readonly" text @click="next">
80
80
  <v-icon>mdi-chevron-right</v-icon>
81
81
  </v-btn>
82
82
  </v-row>
@@ -173,6 +173,11 @@ export default {
173
173
  type: Boolean,
174
174
  default: false,
175
175
  },
176
+ // This set the component status to readonly, stopping the user interaction.
177
+ readonly: {
178
+ type: Boolean,
179
+ default: false,
180
+ },
176
181
  },
177
182
 
178
183
  model: {