@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
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div class="pa-4">
3
- <v-row v-if="selection.length" class="selection mb-4 mx-1">
3
+ <v-row v-if="internalSelection.length && select == 'multi'" class="selection mb-4 grey darken-2">
4
4
  <v-col
5
- v-for="media in selection"
5
+ v-for="media in internalSelection"
6
6
  :key="media.file"
7
7
  class="d-flex"
8
8
  cols="2"
@@ -10,21 +10,11 @@
10
10
  md="1"
11
11
  @click.stop="selectMedia(media)"
12
12
  >
13
- <v-img
14
- :src="media.file"
15
- :lazy-src="media.thumbnail"
16
- aspect-ratio="1"
17
- class="grey lighten-2 elevation-4 selection__item"
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>
13
+ <MediaPreview
14
+ :media="media"
15
+ icon-size="20px"
16
+ class="elevation-4 cursor-pointer selection__item"
17
+ />
28
18
  </v-col>
29
19
  </v-row>
30
20
  <v-row
@@ -53,27 +43,18 @@
53
43
  :ripple="false"
54
44
  color="white"
55
45
  class="img-container__btn"
46
+ :class="{'d-none': select == 'none'}"
56
47
  >
57
48
  <v-icon>mdi-circle-edit-outline</v-icon>
58
49
  </v-btn>
59
-
60
- <v-img
61
- v-bind:class="{ selected: isSelected(media) }"
62
- :src="media.file"
63
- :lazy-src="media.thumbnail"
64
- aspect-ratio="1"
65
- class="grey lighten-2 elevation-4"
66
- @click.stop="selectMedia(media)"
67
- >
68
- <template v-slot:placeholder>
69
- <v-row class="fill-height ma-0" align="center" justify="center">
70
- <v-progress-circular
71
- indeterminate
72
- color="grey lighten-5"
73
- ></v-progress-circular>
74
- </v-row>
75
- </template>
76
- </v-img>
50
+ <MediaPreview
51
+ class="elevation-4 cursor-pointer"
52
+ :media="media"
53
+ :selected="isSelected(media)"
54
+ @click.native="selectMedia(media)"
55
+ filename
56
+ video-preview
57
+ />
77
58
  </v-col>
78
59
  </v-row>
79
60
  <v-row>
@@ -89,6 +70,9 @@
89
70
  </template>
90
71
 
91
72
  <style lang="scss" scoped>
73
+ .cursor-pointer{
74
+ cursor: pointer;
75
+ }
92
76
  .img-container {
93
77
  display: flex;
94
78
  position: relative;
@@ -102,9 +86,7 @@
102
86
  }
103
87
  }
104
88
  .selection {
105
- border-radius: 5px;
106
- background: #79797908;
107
- box-shadow: inset 5px 5px 18px #151515, inset -5px -5px 18px #151515;
89
+ margin: -16px;
108
90
  &__confirm {
109
91
  margin: auto 0 auto auto;
110
92
  display: flex;
@@ -122,6 +104,7 @@
122
104
  height: 100%;
123
105
  background: #00000082;
124
106
  border: solid #ffffff6e 2px;
107
+ color: white;
125
108
  }
126
109
  }
127
110
  .selected {
@@ -133,9 +116,6 @@
133
116
  height: 100%;
134
117
  }
135
118
  }
136
- .theme--light .selection {
137
- box-shadow: inset 5px 5px 10px #e3e3e3, inset -5px -5px 10px #e3e3e3;
138
- }
139
119
  </style>
140
120
 
141
121
  <script>
@@ -143,7 +123,7 @@ export default {
143
123
  name: "MediaGallery",
144
124
  data() {
145
125
  return {
146
- selection: [],
126
+ internalSelection: [],
147
127
  };
148
128
  },
149
129
  props: {
@@ -167,6 +147,15 @@ export default {
167
147
  return ["none", "single", "multi"].indexOf(value) !== -1;
168
148
  },
169
149
  },
150
+ selection: {
151
+ type: Array,
152
+ required: false
153
+ },
154
+ },
155
+ watch: {
156
+ selection(value) {
157
+ if (value !== undefined) this.internalSelection = value;
158
+ },
170
159
  },
171
160
  computed: {
172
161
  currentPage: {
@@ -180,23 +169,38 @@ export default {
180
169
  },
181
170
  methods: {
182
171
  isSelected(media) {
183
- return this.selection.findIndex((m) => m.id === media.id) !== -1;
172
+ return this.internalSelection.findIndex((m) => m.id === media.id) !== -1;
184
173
  },
185
174
  selectMedia(media) {
186
- if (this.select == "single") {
187
- this.$emit("selectionChange", media);
188
- } else if (this.select == "multi") {
189
- const index = this.selection.findIndex((m) => m.id === media.id);
190
- index == -1
191
- ? this.selection.push(media)
192
- : this.selection.splice(index, 1);
193
- this.selection = this.selection.slice();
194
- this.$emit("selectionChange", this.selection);
175
+ switch (this.select) {
176
+ case "single":
177
+ this.$emit("selectionChange", media);
178
+ this.internalSelection = [media];
179
+ this.$emit("update:selection", this.internalSelection);
180
+ break;
181
+ case "multi":
182
+ const index = this.internalSelection.findIndex(m => m.id === media.id);
183
+ index == -1
184
+ ? this.internalSelection.push(media)
185
+ : this.internalSelection.splice(index, 1);
186
+ this.internalSelection = this.internalSelection.slice();
187
+ this.$emit("selectionChange", this.internalSelection);
188
+ this.$emit("update:selection", this.internalSelection);
189
+ break;
190
+ default:
191
+ this.editMedia(media);
192
+ break;
195
193
  }
196
194
  },
197
195
  editMedia(media) {
198
196
  this.$emit("editMedia", media);
199
197
  },
198
+ fileName(media) {
199
+ return media && media.file && media.file.split("/").pop();
200
+ },
201
+ },
202
+ mounted() {
203
+ if (this.selection !== undefined) this.internalSelection = this.selection;
200
204
  },
201
205
  };
202
206
  </script>
@@ -1,35 +1,41 @@
1
1
  <template>
2
- <v-card v-bind="{ light, dark, elevation }">
3
- <div v-if="!editMedia" class="d-flex">
4
- <div class="d-flex">
5
- <v-btn class="ma-2" @click="getRoot" icon>
6
- <v-icon>mdi-update</v-icon>
7
- </v-btn>
8
- <v-btn
9
- v-if="parentFolder"
10
- class="ma-2"
11
- @click="getRoot({ folder: { id: parentFolder.updir } })"
12
- icon
13
- >
14
- <v-icon>mdi-arrow-left</v-icon>
15
- </v-btn>
16
- <span class="ma-2 d-flex align-center">{{
17
- parentFolder ? parentFolder.path : "/"
18
- }}</span>
19
- </div>
20
- <v-spacer></v-spacer>
2
+ <v-card elevation="0">
3
+ <v-card-title class="d-flex flex-wrap pa-0">
21
4
  <div>
22
5
  <v-tabs v-model="tab" right background-color="transparent">
23
6
  <v-tab>Gallery</v-tab>
24
7
  <v-tab>Uploader</v-tab>
25
8
  </v-tabs>
26
9
  </div>
27
- </div>
28
-
29
- <div v-if="!editMedia">
10
+ <v-btn v-show="$vuetify.breakpoint.xs" class="ma-2 ml-auto" @click="getRoot" icon>
11
+ <v-icon>mdi-update</v-icon>
12
+ </v-btn>
13
+ <div class="d-flex ma-auto mr-0" :style="$vuetify.breakpoint.xs ? 'width: 100%' : ''">
14
+ <v-text-field
15
+ v-show="!editMedia && tab == 0"
16
+ v-model="searchValue"
17
+ @input="
18
+ loadingSearch = true;
19
+ search();
20
+ "
21
+ prepend-inner-icon="mdi-magnify"
22
+ label="Search"
23
+ single-line
24
+ hide-details
25
+ outlined
26
+ dense
27
+ clearable
28
+ :loading="loadingSearch"
29
+ class="mx-2 mt-2"
30
+ ></v-text-field>
31
+ <v-btn v-show="!$vuetify.breakpoint.xs" class="ma-2" @click="getRoot" icon>
32
+ <v-icon>mdi-update</v-icon>
33
+ </v-btn>
34
+ </div>
30
35
  <MediaFolders
36
+ v-show="!editMedia"
31
37
  v-if="!noFolders"
32
- v-bind="{ folders, parentFolder }"
38
+ v-bind="{ folders, parentFolders, loading }"
33
39
  @updateFolder="updateOrCreateFolder($event)"
34
40
  @deleteFolder="deleteFolder($event)"
35
41
  @goToFolder="
@@ -37,54 +43,64 @@
37
43
  getRoot();
38
44
  "
39
45
  />
40
- <v-divider v-if="!noFolders" class="mb-4"></v-divider>
41
-
46
+ </v-card-title>
47
+ <v-card-text class="pa-0">
42
48
  <v-tabs-items v-model="tab" class="transparent">
43
49
  <v-tab-item>
44
50
  <MediaGallery
51
+ v-show="!editMedia"
45
52
  v-bind="{ select, page, pages, medias }"
53
+ :selection="$attrs.selection"
54
+ @update:selection="$emit('update:selection', $event)"
46
55
  @selectionChange="selectionChange($event)"
47
56
  @pageChange="getRoot({ page: $event })"
48
57
  @editMedia="openEditor($event)"
49
58
  />
59
+ <MediaEditor
60
+ v-model="editMedia"
61
+ @deleteMedia="deleteMedia($event)"
62
+ @updateMedia="updateMedia($event)"
63
+ />
50
64
  </v-tab-item>
51
65
  <v-tab-item>
52
66
  <MediaUploader
53
67
  v-bind="{ folders, parentFolder }"
54
- @Upload="getRoot({ page: 1 })"
68
+ @Upload="
69
+ tab = 0;
70
+ getRoot({ page: 1 });
71
+ "
55
72
  />
56
73
  </v-tab-item>
57
74
  </v-tabs-items>
58
- </div>
59
- <MediaEditor
60
- v-model="editMedia"
61
- @deleteMedia="deleteMedia($event)"
62
- @updateMedia="updateMedia($event)"
63
- />
75
+ </v-card-text>
76
+ <v-card-actions>
77
+ <!-- Slot to provide custom button actions inside the media manager -->
78
+ <slot name="actions"></slot>
79
+ </v-card-actions>
64
80
  </v-card>
65
81
  </template>
66
82
 
67
- <style lang="scss" scoped>
68
- </style>
69
-
70
83
  <script>
71
- import MediaFolders from './MediaFolders.vue';
84
+ import { debounce } from "@mapomodule/utils/helpers/debounce";
85
+
86
+ const initialData = () => ({
87
+ _mediaFolderCrud: null,
88
+ _mediaFileCrud: null,
89
+ medias: [],
90
+ folders: [],
91
+ parentFolders: [],
92
+ page: 1,
93
+ pages: 1,
94
+ tab: 0,
95
+ editMedia: null,
96
+ loading: false,
97
+ searchValue: "",
98
+ loadingSearch: false,
99
+ });
100
+
72
101
  export default {
73
102
  name: "MediaManager",
74
- components: { MediaFolders },
75
- data() {
76
- return {
77
- _mediaFolderCrud: null,
78
- _mediaFileCrud: null,
79
- medias: [],
80
- folders: [],
81
- parentFolder: null,
82
- page: 1,
83
- pages: 1,
84
- tab: null,
85
- editMedia: null,
86
- };
87
- },
103
+ data: initialData,
88
104
  props: {
89
105
  select: {
90
106
  type: String,
@@ -97,53 +113,71 @@ export default {
97
113
  type: Boolean,
98
114
  default: false,
99
115
  },
100
- light: {
101
- type: Boolean,
102
- default: false,
103
- },
104
- dark: {
105
- type: Boolean,
106
- default: false,
107
- },
108
- elevation: {
109
- type: Number | String,
110
- default: undefined,
116
+ mime: {
117
+ type: String,
118
+ required: false,
111
119
  },
112
120
  },
113
121
  computed: {
114
122
  mediaFolderCrud() {
115
123
  this._mediaFolderCrud =
116
- this._mediaFolderCrud ||
117
- this.$mapo.$api.crud("api/camomilla/media-folders");
124
+ this._mediaFolderCrud || this.$mapo.$api.crud("api/media-folders");
118
125
  return this._mediaFolderCrud;
119
126
  },
120
127
  mediaFileCrud() {
121
128
  this._mediaFileCrud =
122
- this._mediaFileCrud || this.$mapo.$api.crud("api/camomilla/media");
129
+ this._mediaFileCrud || this.$mapo.$api.crud("api/media");
123
130
  return this._mediaFileCrud;
124
131
  },
132
+ parentFolder: {
133
+ get() {
134
+ return (
135
+ (this.parentFolders.length &&
136
+ this.parentFolders[this.parentFolders.length - 1]) ||
137
+ null
138
+ );
139
+ },
140
+ set(val) {
141
+ if (!val || !val.path) {
142
+ this.parentFolders = [];
143
+ } else {
144
+ const index = this.parentFolders.findIndex((f) => f.path == val.path);
145
+ if (index == -1) {
146
+ this.parentFolders.push(val);
147
+ } else {
148
+ this.parentFolders.splice(index + 1, this.parentFolders.length - (index + 1));
149
+ }
150
+ }
151
+ },
152
+ },
125
153
  },
126
154
  methods: {
127
- getRoot: async function (context) {
155
+ async getRoot(context) {
156
+ this.loading = true;
128
157
  const { page, folder } = context || {};
129
158
  const { id } = folder || this.parentFolder || {};
130
159
  let response;
131
160
  this.page = page || this.page;
132
- const params = { page: this.page };
133
- if (id) {
134
- response = await this.mediaFolderCrud.detail(id, {
135
- params,
136
- });
137
- } else {
138
- response = await this.mediaFolderCrud.list({ params });
161
+ const params = {
162
+ page: this.page,
163
+ search: this.searchValue || undefined,
164
+ fltr: this.mime ? `mime_type=${this.mime}` : undefined,
165
+ };
166
+ try {
167
+ response = id
168
+ ? await this.mediaFolderCrud.detail(id, { params })
169
+ : await this.mediaFolderCrud.list({ params });
170
+ } catch (error) {
171
+ console.error({ code: error.response.status, response: error.response.data})
139
172
  }
173
+
140
174
  this.processResponse(response);
175
+ this.loading = false;
176
+ this.editMedia = null;
141
177
  },
142
178
 
143
179
  updateOrCreateFolder(folder) {
144
- return this.mediaFolderCrud
145
- .updateOrCreate(folder)
146
- .then(() => this.getRoot());
180
+ return this.mediaFolderCrud.updateOrCreate(folder).then(() => this.getRoot());
147
181
  },
148
182
 
149
183
  deleteFolder(folder) {
@@ -160,17 +194,20 @@ export default {
160
194
  return this.mediaFileCrud.detail(media_id);
161
195
  },
162
196
 
163
- updateMedia(media) {
197
+ async updateMedia(media) {
164
198
  const files = ["file", "objectURL", "thumbnail"];
165
199
  const payload = this.$mapo.$api.multipart(media, files);
166
200
  const conf = { headers: { "Content-Type": "multipart/form-data" } };
167
- return this.mediaFileCrud
168
- .partialUpdate(media.id, payload, conf)
169
- .then(() =>
170
- this.$mapo.$snack.open({
171
- message: "file info succesfully updated.",
172
- })
173
- );
201
+ const res = await this.mediaFileCrud.partialUpdate(media.id, payload, conf)
202
+ if (media.file){
203
+ this.medias = []
204
+ await this.getRoot()
205
+ }
206
+ this.editMedia = res
207
+ this.$mapo.$snack.open({
208
+ message: "File info succesfully updated."
209
+ })
210
+ return res
174
211
  },
175
212
  processResponse(resp) {
176
213
  this.medias = resp?.media?.items || [];
@@ -185,6 +222,13 @@ export default {
185
222
  async openEditor(event) {
186
223
  this.editMedia = await this.detailMedia(event.id);
187
224
  },
225
+ search: debounce(function () {
226
+ this.getRoot().then(() => (this.loadingSearch = false));
227
+ }, 500),
228
+ reset() {
229
+ Object.assign(this.$data, initialData());
230
+ this.getRoot();
231
+ },
188
232
  },
189
233
  async fetch() {
190
234
  await this.getRoot();
@@ -1,18 +1,20 @@
1
1
  <template>
2
2
  <div>
3
3
  <slot v-bind="{ on, attrs }" name="activator"></slot>
4
- <v-dialog v-model="dialog" width="800">
5
- <v-card v-bind="{ light, dark, elevation }">
6
- <MediaManager
7
- @selectionChange="selectionChange($event)"
8
- v-bind="{ select, noFolders, light, dark }"
9
- elevation="0"
10
- />
11
- <v-card-actions v-if="select == 'multi'">
4
+ <v-dialog v-model="dialog" max-width="100%" width="800" scrollable>
5
+ <media-manager
6
+ @selectionChange="selectionChange($event)"
7
+ :selection="$attrs.selection"
8
+ @update:selection="$emit('update:selection', $event)"
9
+ v-bind="{ select, noFolders, mime }"
10
+ elevation="0"
11
+ ref="mediaManager"
12
+ >
13
+ <template v-slot:actions>
12
14
  <v-spacer></v-spacer>
13
- <v-btn color="primary" text @click="done">done</v-btn>
14
- </v-card-actions>
15
- </v-card>
15
+ <v-btn v-if="select == 'multi'" color="primary" text @click="done">done</v-btn>
16
+ </template>
17
+ </media-manager>
16
18
  </v-dialog>
17
19
  </div>
18
20
  </template>
@@ -24,6 +26,7 @@ export default {
24
26
  selection: [],
25
27
  dialog: false,
26
28
  attrs: { ...this.$attrs },
29
+ reset: false,
27
30
  on: {
28
31
  click: (event) => {
29
32
  event.preventDefault();
@@ -48,17 +51,9 @@ export default {
48
51
  return ["none", "single", "multi"].indexOf(val) !== -1;
49
52
  },
50
53
  },
51
- light: {
52
- type: Boolean,
53
- default: false,
54
- },
55
- dark: {
56
- type: Boolean,
57
- default: false,
58
- },
59
- elevation: {
60
- type: Number | String,
61
- default: undefined,
54
+ mime: {
55
+ type: String,
56
+ required: false
62
57
  },
63
58
  },
64
59
  watch: {
@@ -71,6 +66,8 @@ export default {
71
66
  if (!val && this.reject) {
72
67
  this.reject();
73
68
  }
69
+ if (val && this.reset) this.$refs.mediaManager.reset();
70
+ this.reset = !val;
74
71
  },
75
72
  },
76
73
  methods: {