@mapomodule/uikit 1.0.0-alpha.0 → 1.0.0-alpha.12

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 (44) hide show
  1. package/CHANGELOG.md +228 -0
  2. package/LICENSE.md +20 -0
  3. package/components/Detail/Detail.vue +209 -120
  4. package/components/Detail/DetailField.vue +57 -30
  5. package/components/Detail/DetailLangSwitch.vue +1 -1
  6. package/components/Detail/defaults.js +32 -25
  7. package/components/DropArea.vue +3 -3
  8. package/components/List/List.vue +100 -40
  9. package/components/List/ListActions.vue +56 -17
  10. package/components/List/ListFilters.vue +127 -113
  11. package/components/List/ListHead.vue +30 -12
  12. package/components/List/ListQuickEdit.vue +198 -55
  13. package/components/List/ListTable.vue +227 -78
  14. package/components/Login.vue +14 -5
  15. package/components/MediaManager/MediaEditor.vue +253 -107
  16. package/components/MediaManager/MediaFolders.vue +125 -41
  17. package/components/MediaManager/MediaGallery.vue +56 -52
  18. package/components/MediaManager/MediaManager.vue +114 -74
  19. package/components/MediaManager/MediaManagerDialog.vue +19 -22
  20. package/components/MediaManager/MediaPreview.vue +180 -0
  21. package/components/MediaManager/MediaUploader.vue +35 -32
  22. package/components/SnackBar.vue +3 -4
  23. package/components/fields/DateField.vue +9 -3
  24. package/components/fields/FileField.vue +108 -0
  25. package/components/fields/FksField.vue +60 -0
  26. package/components/fields/MediaField.vue +24 -6
  27. package/components/fields/MediaM2mField.vue +8 -3
  28. package/components/fields/SeoPreview.vue +89 -0
  29. package/components/fields/{TinyMce → wygEditor}/defaults.js +6 -4
  30. package/components/fields/{TinyMce → wygEditor}/utils/events.js +0 -0
  31. package/components/fields/{TinyMce → wygEditor}/utils/mapomedia.plugin.js +7 -6
  32. package/components/fields/{TinyMce → wygEditor}/utils/script.injector.js +0 -0
  33. package/components/fields/{TinyMce/TinyMce.vue → wygEditor/wygEditor.vue} +43 -21
  34. package/components/layout/Sidebar/Sidebar.vue +46 -24
  35. package/components/layout/Sidebar/SidebarFooter.vue +42 -46
  36. package/components/layout/Sidebar/SidebarList.vue +13 -14
  37. package/components/layout/Sidebar/SidebarListItem.vue +81 -38
  38. package/components/layout/Topbar/Topbar.vue +3 -36
  39. package/components/layout/routebuilder.js +1 -1
  40. package/defaults.js +2 -2
  41. package/layouts/default.vue +3 -14
  42. package/package.json +3 -3
  43. package/pages/index.vue +15 -78
  44. package/components/fields/M2mField.vue +0 -95
@@ -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,38 @@
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-reverse 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-spacer></v-spacer>
11
+ <v-text-field
12
+ v-show="tab == 0"
13
+ v-model="searchValue"
14
+ @input="
15
+ loadingSearch = true;
16
+ search();
17
+ "
18
+ prepend-inner-icon="mdi-magnify"
19
+ label="Search"
20
+ single-line
21
+ hide-details
22
+ outlined
23
+ dense
24
+ clearable
25
+ :loading="loadingSearch"
26
+ class="mx-2 shrink"
27
+ ></v-text-field>
28
+ <v-btn class="ma-2" @click="getRoot" icon>
29
+ <v-icon>mdi-update</v-icon>
30
+ </v-btn>
31
+ </v-card-title>
32
+ <v-card-text class="pa-0">
30
33
  <MediaFolders
31
34
  v-if="!noFolders"
32
- v-bind="{ folders, parentFolder }"
35
+ v-bind="{ folders, parentFolders, loading }"
33
36
  @updateFolder="updateOrCreateFolder($event)"
34
37
  @deleteFolder="deleteFolder($event)"
35
38
  @goToFolder="
@@ -37,53 +40,63 @@
37
40
  getRoot();
38
41
  "
39
42
  />
40
- <v-divider v-if="!noFolders" class="mb-4"></v-divider>
41
-
42
43
  <v-tabs-items v-model="tab" class="transparent">
43
44
  <v-tab-item>
44
45
  <MediaGallery
46
+ v-show="!editMedia"
45
47
  v-bind="{ select, page, pages, medias }"
48
+ :selection="$attrs.selection"
49
+ @update:selection="$emit('update:selection', $event)"
46
50
  @selectionChange="selectionChange($event)"
47
51
  @pageChange="getRoot({ page: $event })"
48
52
  @editMedia="openEditor($event)"
49
53
  />
54
+ <MediaEditor
55
+ v-model="editMedia"
56
+ @deleteMedia="deleteMedia($event)"
57
+ @updateMedia="updateMedia($event)"
58
+ />
50
59
  </v-tab-item>
51
60
  <v-tab-item>
52
61
  <MediaUploader
53
62
  v-bind="{ folders, parentFolder }"
54
- @Upload="getRoot({ page: 1 })"
63
+ @Upload="
64
+ tab = 0;
65
+ getRoot({ page: 1 });
66
+ "
55
67
  />
56
68
  </v-tab-item>
57
69
  </v-tabs-items>
58
- </div>
59
- <MediaEditor
60
- v-model="editMedia"
61
- @deleteMedia="deleteMedia($event)"
62
- @updateMedia="updateMedia($event)"
63
- />
70
+ </v-card-text>
71
+ <v-card-actions>
72
+ <!-- Slot to provide custom button actions inside the media manager -->
73
+ <slot name="actions"></slot>
74
+ </v-card-actions>
64
75
  </v-card>
65
76
  </template>
66
77
 
67
- <style lang="scss" scoped>
68
- </style>
69
-
70
78
  <script>
71
- import MediaFolders from './MediaFolders.vue';
79
+ import { debounce } from "@mapomodule/utils/helpers/debounce";
80
+
81
+ const initialData = () => ({
82
+ _mediaFolderCrud: null,
83
+ _mediaFileCrud: null,
84
+ medias: [],
85
+ folders: [],
86
+ parentFolders: [],
87
+ page: 1,
88
+ pages: 1,
89
+ tab: 0,
90
+ editMedia: null,
91
+ loading: false,
92
+ searchValue: "",
93
+ loadingSearch: false,
94
+ });
95
+
72
96
  export default {
73
97
  name: "MediaManager",
74
- components: { MediaFolders },
75
98
  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
- };
99
+ return initialData();
87
100
  },
88
101
  props: {
89
102
  select: {
@@ -97,24 +110,15 @@ export default {
97
110
  type: Boolean,
98
111
  default: false,
99
112
  },
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,
113
+ mime: {
114
+ type: String,
115
+ required: false,
111
116
  },
112
117
  },
113
118
  computed: {
114
119
  mediaFolderCrud() {
115
120
  this._mediaFolderCrud =
116
- this._mediaFolderCrud ||
117
- this.$mapo.$api.crud("api/camomilla/media-folders");
121
+ this._mediaFolderCrud || this.$mapo.$api.crud("api/camomilla/media-folders");
118
122
  return this._mediaFolderCrud;
119
123
  },
120
124
  mediaFileCrud() {
@@ -122,14 +126,40 @@ export default {
122
126
  this._mediaFileCrud || this.$mapo.$api.crud("api/camomilla/media");
123
127
  return this._mediaFileCrud;
124
128
  },
129
+ parentFolder: {
130
+ get() {
131
+ return (
132
+ (this.parentFolders.length &&
133
+ this.parentFolders[this.parentFolders.length - 1]) ||
134
+ null
135
+ );
136
+ },
137
+ set(val) {
138
+ if (!val || !val.path) {
139
+ this.parentFolders = [];
140
+ } else {
141
+ const index = this.parentFolders.findIndex((f) => f.path == val.path);
142
+ if (index == -1) {
143
+ this.parentFolders.push(val);
144
+ } else {
145
+ this.parentFolders.splice(index + 1, this.parentFolders.length - (index + 1));
146
+ }
147
+ }
148
+ },
149
+ },
125
150
  },
126
151
  methods: {
127
- getRoot: async function (context) {
152
+ async getRoot(context) {
153
+ this.loading = true;
128
154
  const { page, folder } = context || {};
129
155
  const { id } = folder || this.parentFolder || {};
130
156
  let response;
131
157
  this.page = page || this.page;
132
- const params = { page: this.page };
158
+ const params = {
159
+ page: this.page,
160
+ search: this.searchValue || undefined,
161
+ fltr: this.mime ? `mime_type=${this.mime}` : undefined,
162
+ };
133
163
  if (id) {
134
164
  response = await this.mediaFolderCrud.detail(id, {
135
165
  params,
@@ -138,12 +168,12 @@ export default {
138
168
  response = await this.mediaFolderCrud.list({ params });
139
169
  }
140
170
  this.processResponse(response);
171
+ this.loading = false;
172
+ this.editMedia = null;
141
173
  },
142
174
 
143
175
  updateOrCreateFolder(folder) {
144
- return this.mediaFolderCrud
145
- .updateOrCreate(folder)
146
- .then(() => this.getRoot());
176
+ return this.mediaFolderCrud.updateOrCreate(folder).then(() => this.getRoot());
147
177
  },
148
178
 
149
179
  deleteFolder(folder) {
@@ -160,17 +190,20 @@ export default {
160
190
  return this.mediaFileCrud.detail(media_id);
161
191
  },
162
192
 
163
- updateMedia(media) {
193
+ async updateMedia(media) {
164
194
  const files = ["file", "objectURL", "thumbnail"];
165
195
  const payload = this.$mapo.$api.multipart(media, files);
166
196
  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
- );
197
+ const res = await this.mediaFileCrud.partialUpdate(media.id, payload, conf)
198
+ if (media.file){
199
+ this.medias = []
200
+ await this.getRoot()
201
+ }
202
+ this.editMedia = res
203
+ this.$mapo.$snack.open({
204
+ message: "File info succesfully updated."
205
+ })
206
+ return res
174
207
  },
175
208
  processResponse(resp) {
176
209
  this.medias = resp?.media?.items || [];
@@ -185,6 +218,13 @@ export default {
185
218
  async openEditor(event) {
186
219
  this.editMedia = await this.detailMedia(event.id);
187
220
  },
221
+ search: debounce(function () {
222
+ this.getRoot().then(() => (this.loadingSearch = false));
223
+ }, 500),
224
+ reset() {
225
+ Object.assign(this.$data, initialData());
226
+ this.getRoot();
227
+ },
188
228
  },
189
229
  async fetch() {
190
230
  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" 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: {