@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,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>
@@ -1,58 +1,61 @@
1
1
  <template>
2
2
  <v-navigation-drawer
3
- v-model="drawerSetter"
4
- :mini-variant="miniVariant"
3
+ v-model="drawer"
4
+ :mini-variant.sync="miniVariant"
5
+ width="300"
5
6
  :clipped="this.$store.getters['mapo/app/clipped']"
6
7
  fixed
7
8
  app
8
9
  >
9
- <div class="sidebar__core">
10
- <SidebarList />
11
- <SidebarFooter />
10
+ <div class="menu_container">
11
+ <div>
12
+ <SidebarProfile />
13
+ <v-divider></v-divider>
14
+ </div>
15
+ <div class="menu_container">
16
+ <SidebarList :force-collapse="miniVariant" />
17
+ <SidebarFooter :force-collapse="miniVariant" />
18
+ </div>
12
19
  </div>
13
20
  </v-navigation-drawer>
14
21
  </template>
15
22
 
16
23
  <style lang="scss" scoped>
17
- @import '@mapomodule/uikit/assets/variables.scss';
18
-
19
- .sidebar {
20
- &__core {
21
- display: flex;
22
- flex-direction: column;
23
- height: 100%;
24
- // background: $b-1;
25
- // color: $white;
26
- }
24
+ @import "@mapomodule/uikit/assets/variables.scss";
25
+ .menu_container {
26
+ display: flex;
27
+ flex-direction: column;
28
+ height: 100%;
29
+ justify-content: space-between;
30
+ flex: 1;
27
31
  }
28
32
  </style>
29
33
 
30
34
  <script>
31
- import { mapMutations } from 'vuex'
32
35
  // @vuese
33
36
  export default {
34
37
  name: "Sidebar",
35
- data () {
36
- return {
37
- miniVariant: false,
38
- }
39
- },
40
38
  computed: {
41
- drawerSetter: {
39
+ drawer: {
42
40
  get() {
43
- return this.$store.getters['mapo/app/drawer'];
41
+ return this.$store.getters["mapo/app/drawer"];
44
42
  },
45
43
  set(value) {
46
- if (this.$store.getters['mapo/app/drawer'] !== value)
44
+ if (this.$store.getters["mapo/app/drawer"] !== value)
47
45
  this.$store.dispatch("mapo/app/toggleSidebarDrawer");
48
46
  return value;
49
- }
50
- }
51
- },
52
- methods: {
53
- drawerReverse () {
54
- return this.drawer = !this.drawer
47
+ },
55
48
  },
56
- }
57
- }
49
+ miniVariant: {
50
+ get() {
51
+ return this.$store.getters["mapo/app/minivariant"];
52
+ },
53
+ set(value) {
54
+ if (this.$store.getters["mapo/app/minivariant"] !== value)
55
+ this.$store.dispatch("mapo/app/toggleSidebarMinivariant");
56
+ return value;
57
+ },
58
+ },
59
+ },
60
+ };
58
61
  </script>
@@ -1,68 +1,61 @@
1
1
  <template>
2
- <div class="sidebar__ender">
3
- <sidebar-list-item
4
- class="sidebar__ender__item"
5
- v-for="(item, i) in routes"
6
- :key="i"
7
- :link="item.link"
8
- :label="item.label"
9
- :childrens="item.childrens"
10
- :icon="item.icon"
11
- />
12
- <logout-button class="sidebar__ender__item sidebar__ender__item--logout" />
2
+ <div>
3
+ <v-divider></v-divider>
4
+ <v-list dense class="py-0">
5
+ <SidebarListItem
6
+ v-for="(item, i) in routes"
7
+ :key="i"
8
+ :link="item.link"
9
+ :label="item.label"
10
+ :meta="item.meta"
11
+ :childrens="item.childrens"
12
+ :icon="item.icon"
13
+ :force-collapse="forceCollapse"
14
+ />
15
+ </v-list>
16
+ <v-divider></v-divider>
17
+ <v-list-item v-if="$mapo.$auth.user.isLoggedIn" dense class="logout__button" link @click.native="logout">
18
+ <v-list-item-icon>
19
+ <v-icon>mdi-logout</v-icon>
20
+ </v-list-item-icon>
21
+ <v-list-item-title> Logout </v-list-item-title>
22
+ </v-list-item>
13
23
  </div>
14
24
  </template>
15
25
 
16
26
  <style lang="scss" scoped>
17
- @import "@mapomodule/uikit/assets/variables.scss";
18
-
19
- .sidebar {
20
- &__ender {
21
- margin-top: auto;
22
- display: flex;
23
- flex-direction: column;
24
- &__icon {
25
- font-size: 1rem;
26
- margin-right: 0.5rem;
27
- }
28
- &__item {
29
- display: block;
30
- width: 100%;
31
- text-decoration: none;
32
- color: white;
33
- background: $b-2;
34
- transition: all linear 0.25s;
35
- border-radius: 0;
36
- &:hover {
37
- background: rgba($b-2, 0.25);
38
- }
39
- &--logout {
40
- background: $black !important;
41
- &:hover {
42
- background: rgba($black, 0.25) !important;
43
- }
44
- }
45
- }
27
+ .logout__button{
28
+ &.theme--light{
29
+ background: #ffffffd6;
30
+ filter: invert(1);
31
+ }
32
+ &.theme--dark{
33
+ background: #121212;
46
34
  }
47
35
  }
48
36
  </style>
49
-
50
37
  <script>
51
38
  import { buildRoutes } from "../routebuilder";
52
39
 
53
40
  // @vuese
54
41
  export default {
55
42
  name: "SidebarFooter",
43
+ props: {
44
+ forceCollapse: {
45
+ type: Boolean,
46
+ default: false
47
+ }
48
+ },
56
49
  data() {
57
50
  return {
58
- defaultIcon: ({label}) => `mdi-alpha-${label[0]}-box`.toLowerCase(),
59
- routes: this.routes,
51
+ defaultIcon: ({ label }) => `mdi-alpha-${label[0]}-box`.toLowerCase(),
52
+ routes: this.routes
60
53
  };
61
54
  },
62
- mounted: function () {
55
+ mounted() {
63
56
  this.routes = this.buildRoutes(
64
57
  this.$router.options.routes.filter(
65
- (route) => route.meta && route.meta.sidebarFooter === true
58
+ route => route.meta && route.meta.sidebarFooter === true
66
59
  )
67
60
  );
68
61
  },
@@ -70,6 +63,9 @@ export default {
70
63
  buildRoutes(routes) {
71
64
  return buildRoutes(routes, this.defaultIcon);
72
65
  },
73
- },
66
+ logout() {
67
+ this.$store.dispatch("mapo/user/logout");
68
+ }
69
+ }
74
70
  };
75
71
  </script>
@@ -1,39 +1,38 @@
1
1
  <template>
2
- <div class="sidebar__list">
2
+ <v-list dense class="py-0 overflow-y-auto">
3
3
  <SidebarListItem
4
- class="sidebar__list__item"
5
4
  v-for="(item, i) in routes"
6
5
  :key="i"
7
6
  :link="item.link"
8
7
  :label="item.label"
8
+ :meta="item.meta"
9
9
  :childrens="item.childrens"
10
10
  :icon="item.icon"
11
+ :force-collapse="forceCollapse"
12
+ spider-menu
11
13
  />
12
- </div>
14
+ </v-list>
13
15
  </template>
14
16
 
15
- <style lang="scss" scoped>
16
- .sidebar {
17
- &__list {
18
- display: flex;
19
- flex-direction: column;
20
- }
21
- }
22
- </style>
23
-
24
17
  <script>
25
18
  import { buildRoutes } from "../routebuilder";
26
19
 
27
20
  // @vuese
28
21
  export default {
29
22
  name: "SidebarList",
23
+ props: {
24
+ forceCollapse: {
25
+ type: Boolean,
26
+ default: false
27
+ }
28
+ },
30
29
  data() {
31
30
  return {
32
- defaultIcon: ({label}) => `mdi-alpha-${label[0]}-circle`.toLowerCase(),
31
+ defaultIcon: ({label}) => `mdi-alpha-${label[0]}-box-outline`.toLowerCase(),
33
32
  routes: this.routes,
34
33
  };
35
34
  },
36
- mounted: function () {
35
+ mounted() {
37
36
  this.routes = this.buildRoutes(this.$router.options.routes.filter(route => !route.meta || !route.meta.sidebarFooter));
38
37
  },
39
38
  methods: {