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

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 (31) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/components/Detail/Detail.vue +156 -95
  3. package/components/Detail/DetailField.vue +14 -11
  4. package/components/Detail/defaults.js +6 -1
  5. package/components/DropArea.vue +1 -1
  6. package/components/List/List.vue +100 -40
  7. package/components/List/ListActions.vue +38 -17
  8. package/components/List/ListFilters.vue +127 -113
  9. package/components/List/ListHead.vue +23 -13
  10. package/components/List/ListQuickEdit.vue +14 -5
  11. package/components/List/ListTable.vue +218 -76
  12. package/components/MediaManager/MediaEditor.vue +247 -107
  13. package/components/MediaManager/MediaFolders.vue +122 -38
  14. package/components/MediaManager/MediaGallery.vue +56 -52
  15. package/components/MediaManager/MediaManager.vue +114 -74
  16. package/components/MediaManager/MediaManagerDialog.vue +19 -22
  17. package/components/MediaManager/MediaPreview.vue +180 -0
  18. package/components/MediaManager/MediaUploader.vue +35 -32
  19. package/components/fields/MediaField.vue +12 -2
  20. package/components/fields/SeoPreview.vue +89 -0
  21. package/components/fields/TinyMce/TinyMce.vue +29 -10
  22. package/components/fields/TinyMce/defaults.js +1 -1
  23. package/components/layout/Sidebar/Sidebar.vue +46 -24
  24. package/components/layout/Sidebar/SidebarFooter.vue +41 -46
  25. package/components/layout/Sidebar/SidebarList.vue +12 -14
  26. package/components/layout/Sidebar/SidebarListItem.vue +65 -38
  27. package/components/layout/Topbar/Topbar.vue +3 -36
  28. package/components/layout/routebuilder.js +1 -1
  29. package/layouts/default.vue +3 -14
  30. package/package.json +2 -2
  31. package/pages/index.vue +1 -2
@@ -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/camomilla/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>
@@ -12,8 +12,9 @@
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
+ :class="{'grey lighten-2 rounded': !internalValue.is_image}"
17
18
  v-bind="{
18
19
  aspectRatio,
19
20
  contain,
@@ -33,9 +34,15 @@
33
34
  justify="center"
34
35
  >
35
36
  <v-progress-circular
37
+ v-if="internalValue.is_image"
36
38
  indeterminate
37
39
  color="grey"
38
40
  ></v-progress-circular>
41
+ <div class="d-flex flex-column align-center justify-space-between fill-height" style="width: 100%" v-else>
42
+ <div></div>
43
+ <v-icon size="70px" color="grey">mdi-file</v-icon>
44
+ <span class="grey--text text--darken-3 text-truncate pl-1 pr-8" style="width: 100%">{{fileName}}</span>
45
+ </div>
39
46
  </v-row>
40
47
  </template>
41
48
  </v-img>
@@ -165,6 +172,9 @@ export default {
165
172
  overlay() {
166
173
  return this.isHovered && this.mediaExists;
167
174
  },
175
+ fileName() {
176
+ return this.internalValue && this.internalValue.file && this.internalValue.file.split("/").pop();
177
+ },
168
178
  },
169
179
 
170
180
  methods: {
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <div class="container">
3
+ <div class="preview">
4
+ <span class="preview__title">{{ getTitle }}</span>
5
+ <br />
6
+ <span class="preview__url">{{ getPermalink }}</span>
7
+ <br />
8
+ <span class="preview__desc">{{ getDescription }}</span>
9
+ </div>
10
+ </div>
11
+ </template>
12
+
13
+ <style lang="scss" scoped>
14
+ .container {
15
+ background: #ffffff;
16
+ border-radius: 3px;
17
+ }
18
+ .preview {
19
+ display: block;
20
+ max-width: 32em;
21
+ margin: 30px 8px;
22
+ &__title {
23
+ color: #035ac6;
24
+ font-size: 1.2em;
25
+ cursor: pointer;
26
+ &:hover {
27
+ text-decoration: underline;
28
+ }
29
+ }
30
+ &__url {
31
+ color: green;
32
+ font-size: 0.92em;
33
+ }
34
+ &__desc {
35
+ color: #9b9da1;
36
+ }
37
+ }
38
+ </style>
39
+
40
+ <script>
41
+ /**
42
+ * This component is used to make a preview of seo data.
43
+ */
44
+ export default {
45
+ name: "SeoPreview",
46
+ props: {
47
+ // V-model for DetailField (need to be an object `{title, permalink, description}`)
48
+ value:{
49
+ type: Object,
50
+ default: () => {}
51
+ },
52
+ // Seo title
53
+ title: {
54
+ type: String,
55
+ default:
56
+ "It was the best of times, it was the blurst of times, it was the ..."
57
+ },
58
+ // Seo permalink
59
+ permalink: {
60
+ type: String,
61
+ default: "example.com/how_to_dive"
62
+ },
63
+ // Seo description
64
+ description: {
65
+ type: String,
66
+ default:
67
+ "This is an example description that will get replaced when you start typing. Make sure to keep descriptions mobile-friendly and keyword-rich!"
68
+ }
69
+ },
70
+ computed: {
71
+ getTitle(){
72
+ if (this.value && this.value.title)
73
+ return this.value.title
74
+ return this.title
75
+ },
76
+ getPermalink(){
77
+ if (this.value && this.value.permalink)
78
+ return this.value.permalink
79
+ return this.permalink
80
+ },
81
+ getDescription(){
82
+ if (this.value && this.value.description)
83
+ return this.value.description
84
+ return this.description
85
+ }
86
+ },
87
+
88
+ };
89
+ </script>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div>
3
3
  <media-manager-dialog ref="mediaManager"></media-manager-dialog>
4
- <span v-if="label">{{ label }}:</span>
4
+ <span v-if="label" class="v-label" :class="{'error--text': errorMessages && errorMessages.length}">{{ label }}:</span>
5
5
  <div ref="editorNode">
6
6
  <v-skeleton-loader
7
7
  type="table-heading, list-item-two-line, list-item-avatar-two-line, list-item-three-lineimage, table-tfoot"
@@ -74,7 +74,7 @@ export default {
74
74
 
75
75
  methods: {
76
76
  initEditor() {
77
- initMapoMedia(this.insertImgCallback);
77
+ initMapoMedia(this.insertMediaCallback);
78
78
  window.tinymce.init(
79
79
  Object.assign(defaults, this.conf, {
80
80
  target: this.$refs.editorNode,
@@ -108,15 +108,31 @@ export default {
108
108
  });
109
109
  }
110
110
  },
111
- insertImgCallback: async function () {
111
+ insertMediaCallback: async function () {
112
112
  return new Promise((resolve, reject) => {
113
- this.$refs.mediaManager
114
- .open()
115
- .then((result) =>
116
- result
117
- ? resolve(`<img width="50%" src="${result.file}">`)
118
- : reject("No image selected")
119
- )
113
+ this.$refs.mediaManager.open()
114
+ .then((result) => {
115
+ if (result) {
116
+ let html;
117
+ switch (result.mime_type && result.mime_type.split("/")[0]) {
118
+ case "image":
119
+ html = `<img width="300px" src="${result.file}" alt="${result.alt_text}">`;
120
+ break;
121
+ case "video":
122
+ html = `<video controls><source src="${result.file}" type="${result.mime_type}"></video>`;
123
+ break;
124
+ case "audio":
125
+ html = `<audio controls><source src="${result.file}" type="${result.mime_type}"></audio>`;
126
+ break;
127
+ default:
128
+ html = `<a href="${result.file}" target="_blank">${result.file}</a>`;
129
+ break;
130
+ }
131
+ resolve(html);
132
+ } else {
133
+ reject("No image selected");
134
+ }
135
+ })
120
136
  .catch((error) => reject(error));
121
137
  });
122
138
  },
@@ -145,6 +161,9 @@ export default {
145
161
  .tox-statusbar__branding {
146
162
  display: none;
147
163
  }
164
+ .v-label.error--text{
165
+ animation: v-shake 0.6s cubic-bezier(0.25, 0.8, 0.5, 1);
166
+ }
148
167
  </style>
149
168
 
150
169
  <docs>
@@ -43,7 +43,7 @@ export default {
43
43
  // ],
44
44
  template_cdate_format: '[Date Created (CDATE): %m/%d/%Y : %H:%M:%S]',
45
45
  template_mdate_format: '[Date Modified (MDATE): %m/%d/%Y : %H:%M:%S]',
46
- height: 600,
46
+ height: 400,
47
47
  image_caption: true,
48
48
  quickbars_selection_toolbar: 'bold italic | quicklink h2 h3 blockquote quickimage quicktable',
49
49
  noneditable_noneditable_class: 'mceNonEditable',
@@ -1,58 +1,80 @@
1
1
  <template>
2
2
  <v-navigation-drawer
3
3
  v-model="drawerSetter"
4
- :mini-variant="miniVariant"
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
+ <v-list-item>
13
+ <v-list-item-avatar v-if="avatar">
14
+ <v-img :src="avatar"></v-img>
15
+ </v-list-item-avatar>
16
+ <v-list-item-icon v-else>
17
+ <v-icon>mdi-account</v-icon>
18
+ </v-list-item-icon>
19
+ <v-list-item-title>{{
20
+ this.$mapo.$auth.user.username
21
+ }}</v-list-item-title>
22
+ <v-btn icon @click.stop="miniVariant = !miniVariant">
23
+ <v-icon>mdi-chevron-left</v-icon>
24
+ </v-btn>
25
+ </v-list-item>
26
+ <v-divider></v-divider>
27
+ </div>
28
+ <div class="menu_container">
29
+ <SidebarList :force-collapse="miniVariant" />
30
+ <SidebarFooter :force-collapse="miniVariant" />
31
+ </div>
12
32
  </div>
13
33
  </v-navigation-drawer>
14
34
  </template>
15
35
 
16
36
  <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
- }
37
+ @import "@mapomodule/uikit/assets/variables.scss";
38
+ .menu_container {
39
+ display: flex;
40
+ flex-direction: column;
41
+ height: 100%;
42
+ justify-content: space-between;
43
+ flex: 1;
27
44
  }
28
45
  </style>
29
46
 
30
47
  <script>
31
- import { mapMutations } from 'vuex'
32
48
  // @vuese
33
49
  export default {
34
50
  name: "Sidebar",
35
- data () {
51
+ data() {
36
52
  return {
37
- miniVariant: false,
38
- }
53
+ miniVariant: false
54
+ };
39
55
  },
40
56
  computed: {
41
57
  drawerSetter: {
42
58
  get() {
43
- return this.$store.getters['mapo/app/drawer'];
59
+ return this.$store.getters["mapo/app/drawer"];
44
60
  },
45
61
  set(value) {
46
- if (this.$store.getters['mapo/app/drawer'] !== value)
62
+ if (this.$store.getters["mapo/app/drawer"] !== value)
47
63
  this.$store.dispatch("mapo/app/toggleSidebarDrawer");
48
64
  return value;
49
65
  }
66
+ },
67
+ username() {
68
+ return this.$mapo.$auth.user.username;
69
+ },
70
+ avatar() {
71
+ return this.$mapo.$auth.user.avatar;
50
72
  }
51
73
  },
52
74
  methods: {
53
- drawerReverse () {
54
- return this.drawer = !this.drawer
55
- },
75
+ drawerReverse() {
76
+ return (this.drawer = !this.drawer);
77
+ }
56
78
  }
57
- }
79
+ };
58
80
  </script>