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

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 (49) hide show
  1. package/CHANGELOG.md +370 -0
  2. package/components/Detail/Detail.vue +281 -126
  3. package/components/Detail/DetailField.vue +68 -29
  4. package/components/Detail/DetailLangSwitch.vue +1 -1
  5. package/components/Detail/defaults.js +33 -25
  6. package/components/DropArea.vue +3 -3
  7. package/components/List/List.vue +120 -42
  8. package/components/List/ListActions.vue +56 -17
  9. package/components/List/ListFilters.vue +158 -113
  10. package/components/List/ListHead.vue +30 -12
  11. package/components/List/ListQuickEdit.vue +207 -55
  12. package/components/List/ListTable.vue +292 -77
  13. package/components/Login.vue +14 -5
  14. package/components/MediaManager/MediaEditor.vue +253 -107
  15. package/components/MediaManager/MediaFolders.vue +134 -43
  16. package/components/MediaManager/MediaGallery.vue +56 -52
  17. package/components/MediaManager/MediaManager.vue +127 -83
  18. package/components/MediaManager/MediaManagerDialog.vue +19 -22
  19. package/components/MediaManager/MediaPreview.vue +180 -0
  20. package/components/MediaManager/MediaUploader.vue +35 -32
  21. package/components/SnackBar.vue +3 -4
  22. package/components/ThemeToggle.vue +13 -0
  23. package/components/fields/DateField.vue +9 -3
  24. package/components/fields/FileField.vue +125 -0
  25. package/components/fields/FksField.vue +88 -0
  26. package/components/fields/MediaField.vue +36 -6
  27. package/components/fields/MediaM2mField.vue +8 -3
  28. package/components/fields/Repeater.vue +338 -0
  29. package/components/fields/SeoPreview.vue +89 -0
  30. package/components/fields/{TinyMce → wygEditor}/defaults.js +7 -5
  31. package/components/fields/{TinyMce → wygEditor}/utils/events.js +0 -0
  32. package/components/fields/{TinyMce → wygEditor}/utils/mapomedia.plugin.js +7 -6
  33. package/components/fields/{TinyMce → wygEditor}/utils/script.injector.js +0 -0
  34. package/components/fields/wygEditor/wygEditor.vue +256 -0
  35. package/components/layout/Sidebar/Sidebar.vue +35 -32
  36. package/components/layout/Sidebar/SidebarFooter.vue +42 -46
  37. package/components/layout/Sidebar/SidebarList.vue +13 -14
  38. package/components/layout/Sidebar/SidebarListItem.vue +99 -38
  39. package/components/layout/Sidebar/SidebarProfile.vue +42 -0
  40. package/components/layout/Topbar/Topbar.vue +3 -35
  41. package/components/layout/routebuilder.js +3 -3
  42. package/defaults.js +2 -2
  43. package/layouts/default.vue +20 -18
  44. package/layouts/empty.vue +10 -0
  45. package/package.json +5 -4
  46. package/pages/index.vue +1 -2
  47. package/components/fields/M2mField.vue +0 -95
  48. package/components/fields/TinyMce/TinyMce.vue +0 -177
  49. package/layouts/error.vue +0 -45
@@ -0,0 +1,180 @@
1
+ <template>
2
+ <v-img
3
+ :src="(media.is_image && media.file) || null"
4
+ :lazy-src="(media.is_image && media.thumbnail) || null"
5
+ aspect-ratio="1"
6
+ class="grey lighten-2"
7
+ :class="{
8
+ selected,
9
+ 'media-controls': mediaControls,
10
+ 'video-preview': videoPreview,
11
+ }"
12
+ v-bind="$attrs"
13
+ v-on="videoListeners"
14
+ >
15
+ <template v-slot:placeholder>
16
+ <v-row class="fill-height ma-0" align="center" justify="center">
17
+ <v-progress-circular
18
+ v-if="media.is_image"
19
+ indeterminate
20
+ color="grey lighten-5"
21
+ ></v-progress-circular>
22
+ <div
23
+ class="d-flex justify-center align-center"
24
+ :class="{ playing }"
25
+ style="width: 100%; height: 100%"
26
+ v-else-if="isVideo"
27
+ >
28
+ <video
29
+ :width="$attrs.contain && '100%'"
30
+ height="100%"
31
+ ref="video"
32
+ :controls="mediaControls"
33
+ >
34
+ <source :src="media.file" :type="media.mime_type" />
35
+ </video>
36
+ <v-icon
37
+ v-if="!mediaControls"
38
+ :size="size"
39
+ color="grey darken-4"
40
+ class="grey lighten-2 rounded-circle video-preview-icon"
41
+ >mdi-play</v-icon
42
+ >
43
+ </div>
44
+ <div
45
+ class="
46
+ d-flex
47
+ flex-column
48
+ align-center
49
+ justify-space-between
50
+ fill-height
51
+ "
52
+ style="width: 100%"
53
+ v-else
54
+ >
55
+ <div></div>
56
+ <v-icon :size="size" color="grey darken-2">
57
+ {{ isAudio ? "mdi-headphones" : "mdi-file" }}
58
+ </v-icon>
59
+ <audio v-if="isAudio && mediaControls" controls>
60
+ <source :src="media.file" :type="media.mime_type" />
61
+ </audio>
62
+ <span
63
+ class="grey--text text--darken-3 text-truncate pl-1 pr-8"
64
+ style="width: 100%"
65
+ >{{ (filename && name) || undefined }}</span
66
+ >
67
+ </div>
68
+ </v-row>
69
+ </template>
70
+ </v-img>
71
+ </template>
72
+
73
+ <style lang="scss">
74
+ .v-image.media-controls {
75
+ .v-image__placeholder {
76
+ z-index: 0;
77
+ }
78
+ }
79
+ .v-image.video-preview {
80
+ .v-image__placeholder {
81
+ height: calc(100% + 1px);
82
+ }
83
+ }
84
+ .video-preview-icon.v-icon.v-icon {
85
+ position: absolute;
86
+ opacity: 0.5;
87
+ transition: transform 0.3s ease-out, opacity 0.3s ease-out;
88
+ }
89
+ .playing .video-preview-icon.v-icon.v-icon {
90
+ opacity: 0;
91
+ transform: scale(1.2);
92
+ }
93
+ </style>
94
+
95
+ <script>
96
+ export default {
97
+ data() {
98
+ return {
99
+ playing: false,
100
+ playPromise: null,
101
+ };
102
+ },
103
+ props: {
104
+ media: {
105
+ type: Object,
106
+ default: () => ({}),
107
+ },
108
+ selected: {
109
+ type: Boolean,
110
+ default: false,
111
+ },
112
+ filename: {
113
+ type: Boolean,
114
+ default: false,
115
+ },
116
+ iconSize: {
117
+ type: String || Number,
118
+ default: "70px",
119
+ },
120
+ videoPreview: {
121
+ type: Boolean,
122
+ default: false,
123
+ },
124
+ mediaControls: {
125
+ type: Boolean,
126
+ default: false,
127
+ },
128
+ },
129
+ computed: {
130
+ name() {
131
+ return this.media && this.media.file && this.media.file.split("/").pop();
132
+ },
133
+ size() {
134
+ return (
135
+ (this.iconSize &&
136
+ (typeof this.iconSize == "string"
137
+ ? this.iconSize
138
+ : this.iconSize + "px")) ||
139
+ "70px"
140
+ );
141
+ },
142
+ isVideo() {
143
+ return this.media.mime_type && this.media.mime_type.startsWith("video/");
144
+ },
145
+ isAudio() {
146
+ return this.media.mime_type && this.media.mime_type.startsWith("audio/");
147
+ },
148
+ videoListeners() {
149
+ if (this.isVideo && this.videoPreview) {
150
+ return {
151
+ mouseenter: this.startVideoPreview,
152
+ mouseleave: this.stopVideoPreview,
153
+ };
154
+ }
155
+ },
156
+ },
157
+ methods: {
158
+ startVideoPreview() {
159
+ const video = this.$refs.video;
160
+ if (video && !this.playing) {
161
+ video.loop = true;
162
+ video.muted = true;
163
+ video.currentTime = 1;
164
+ this.playPromise = video.play().then(() => (this.playing = true));
165
+ }
166
+ },
167
+ async stopVideoPreview() {
168
+ if (this.playPromise) {
169
+ await this.playPromise;
170
+ }
171
+ const video = this.$refs.video;
172
+ if (video && this.playing) {
173
+ video.currentTime = 0;
174
+ video.pause();
175
+ this.playing = false;
176
+ }
177
+ },
178
+ },
179
+ };
180
+ </script>
@@ -2,12 +2,14 @@
2
2
  <v-container>
3
3
  <drop-area @change="updateMediaList($event)" multiple>
4
4
  <template v-slot:actions="{ clearList }">
5
- <v-btn @click="clearList" icon>
6
- <v-icon ref="closeButton">mdi-close</v-icon>
7
- </v-btn>
8
- <v-btn @click="updateAll" icon>
9
- <v-icon>mdi-upload</v-icon>
10
- </v-btn>
5
+ <div v-if="mediaList && mediaList.length">
6
+ <v-btn @click="clearList" icon>
7
+ <v-icon ref="closeButton">mdi-close</v-icon>
8
+ </v-btn>
9
+ <v-btn @click="updateAll" icon>
10
+ <v-icon>mdi-upload</v-icon>
11
+ </v-btn>
12
+ </div>
11
13
  </template>
12
14
  <template v-slot:editContent="{ editedItem }">
13
15
  <v-container>
@@ -62,23 +64,23 @@ export default {
62
64
  count: 0,
63
65
  progress: 0,
64
66
  mediaList: [],
65
- _mediaFileCrud: null,
67
+ _mediaFileCrud: null
66
68
  };
67
69
  },
68
70
  props: {
69
71
  parentFolder: {
70
- type: Object,
72
+ type: Object
71
73
  },
72
74
  folders: {
73
75
  type: Array,
74
- default: () => [],
75
- },
76
+ default: () => []
77
+ }
76
78
  },
77
79
  computed: {
78
80
  mediaFileCrud() {
79
81
  this._mediaFileCrud =
80
82
  this._mediaFileCrud ||
81
- this.$mapo.$api.crud("api/camomilla/media/upload");
83
+ this.$mapo.$api.crud("api/media");
82
84
  return this._mediaFileCrud;
83
85
  },
84
86
  completed() {
@@ -88,19 +90,19 @@ export default {
88
90
  return [
89
91
  {
90
92
  text: (this.parentFolder && this.parentFolder.path) || "/",
91
- value: (this.parentFolder && this.parentFolder.id) || null,
93
+ value: (this.parentFolder && this.parentFolder.id) || null
92
94
  },
93
- ...this.folders.map((folder) => ({
95
+ ...this.folders.map(folder => ({
94
96
  text: folder.path,
95
- value: folder.id,
96
- })),
97
+ value: folder.id
98
+ }))
97
99
  ];
98
- },
100
+ }
99
101
  },
100
102
  methods: {
101
103
  updateMediaList(mediaList) {
102
104
  this.mediaList = mediaList;
103
- this.mediaList.forEach((media) => {
105
+ this.mediaList.forEach(media => {
104
106
  media.info.title = media.info.title || media.info.name;
105
107
  media.info.alt_text = media.info.alt_text || media.info.name;
106
108
  media.info.description = media.info.description || media.info.name;
@@ -114,7 +116,7 @@ export default {
114
116
  },
115
117
  updateAll() {
116
118
  return Promise.all(
117
- this.mediaList.map((media) =>
119
+ this.mediaList.map(media =>
118
120
  this.uploadMedia(
119
121
  Object.assign(
120
122
  { file: media.blob },
@@ -122,27 +124,28 @@ export default {
122
124
  title: media.info.title,
123
125
  alt_text: media.info.alt_text,
124
126
  description: media.info.description,
125
- folder: media.info.folder,
127
+ folder: media.info.folder
126
128
  }
127
129
  )
128
130
  )
129
131
  )
130
- ).then((response) => {
131
- this.$mapo.$snack.open({
132
- message: `${
133
- response.length || this.mediaList.length
134
- } files succesfully uploaded`,
135
- });
136
- this.$emit("Upload", (response.length && response) || this.mediaList);
137
- this.$refs.closeButton.$el.click();
132
+ ).then(response => {
133
+ if (this.mediaList && this.mediaList.length) {
134
+ this.$mapo.$snack.open({
135
+ message: `${response.length ||
136
+ this.mediaList.length} files succesfully uploaded`
137
+ });
138
+ this.$emit("Upload", (response.length && response) || this.mediaList);
139
+ this.$refs.closeButton.$el.click();
140
+ }
138
141
  });
139
142
  },
140
143
  uploadMedia(media) {
141
- const index = this.mediaList.findIndex((el) => el.blob === media.file);
144
+ const index = this.mediaList.findIndex(el => el.blob === media.file);
142
145
  const payload = this.$mapo.$api.multipart(media, ["file"]);
143
146
  const conf = {
144
147
  headers: { "Content-Type": "multipart/form-data" },
145
- onUploadProgress: function (event) {
148
+ onUploadProgress: function(event) {
146
149
  this.mediaList[index].progress = Math.ceil(
147
150
  (event.loaded / event.total) * 100
148
151
  );
@@ -153,10 +156,10 @@ export default {
153
156
  (acc, media) => acc + (media.progress === 100),
154
157
  0
155
158
  );
156
- }.bind(this),
159
+ }.bind(this)
157
160
  };
158
161
  return this.mediaFileCrud.create(payload, conf);
159
- },
160
- },
162
+ }
163
+ }
161
164
  };
162
165
  </script>
@@ -2,7 +2,7 @@
2
2
  <v-snackbar v-model="snackbar">
3
3
  {{ message }}
4
4
  <template v-slot:action="{ attrs }">
5
- <v-btn color="green" text v-bind="attrs" @click="closeSnack">
5
+ <v-btn :color="color" text v-bind="attrs" @click="closeSnack">
6
6
  Close
7
7
  </v-btn>
8
8
  </template>
@@ -23,7 +23,7 @@ export default {
23
23
  data: () => ({
24
24
  snackbar: false,
25
25
  message: null,
26
- color: "green",
26
+ color: "primary",
27
27
  }),
28
28
  computed: {
29
29
  ...mapGetters({
@@ -34,7 +34,6 @@ export default {
34
34
  closeSnack() {
35
35
  this.snackbar = false;
36
36
  this.message = null;
37
- this.color = "green";
38
37
  },
39
38
  },
40
39
 
@@ -48,7 +47,7 @@ export default {
48
47
  if (val) {
49
48
  this.snackbar = true;
50
49
  this.message = val.message;
51
- this.color = val.color || this.color;
50
+ this.color = val.color || "primary";
52
51
  } else {
53
52
  this.closeSnack();
54
53
  }
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <v-icon @click="toggleTheme">mdi-theme-light-dark</v-icon>
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ methods: {
8
+ toggleTheme() {
9
+ this.$vuetify.theme.dark = !this.$vuetify.theme.dark;
10
+ },
11
+ },
12
+ };
13
+ </script>
@@ -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>