@mapomodule/uikit 1.0.0-alpha.6 → 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.
@@ -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: {
@@ -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
  },
@@ -8,6 +8,7 @@
8
8
  :childrens="item.childrens"
9
9
  :icon="item.icon"
10
10
  :force-collapse="forceCollapse"
11
+ spider-menu
11
12
  />
12
13
  </v-list>
13
14
  </template>
@@ -26,7 +27,7 @@ export default {
26
27
  },
27
28
  data() {
28
29
  return {
29
- defaultIcon: ({label}) => `mdi-alpha-${label[0]}-circle`.toLowerCase(),
30
+ defaultIcon: ({label}) => `mdi-alpha-${label[0]}-box-outline`.toLowerCase(),
30
31
  routes: this.routes,
31
32
  };
32
33
  },
@@ -1,8 +1,9 @@
1
1
  <template>
2
- <div>
2
+ <div :class="{ child, expanded, 'spider-menu': spiderMenu }">
3
3
  <v-list-item
4
4
  :style="indent"
5
5
  :exact-path="expanded"
6
+ :input-value="!expanded && !link && activeChild"
6
7
  @click.native="!link && (expanded = !expanded)"
7
8
  link
8
9
  :to="link"
@@ -24,15 +25,16 @@
24
25
 
25
26
  <div :style="indent" v-if="childrens.length && expanded && !forceCollapse">
26
27
  <SidebarListItem
27
- class="sidebar__list__item"
28
28
  v-for="(item, i) in childrens"
29
29
  :key="i"
30
- :force-collapse="forceCollapse"
31
30
  :link="item.link"
32
31
  :label="item.label"
33
32
  :childrens="item.childrens"
34
33
  :depth="(depth || 0) + 1"
35
34
  :icon="item.icon"
35
+ :force-collapse="forceCollapse"
36
+ :spider-menu="spiderMenu"
37
+ child
36
38
  />
37
39
  </div>
38
40
  </div>
@@ -49,6 +51,41 @@
49
51
  border-radius: 50%;
50
52
  }
51
53
  }
54
+ .spider-menu.child {
55
+ .v-list-item__icon {
56
+ &::after {
57
+ content: "";
58
+ position: absolute;
59
+ width: 5px;
60
+ height: 30px;
61
+ top: -9px;
62
+ margin-left: -4px;
63
+ border-bottom: solid 3px #acacac;
64
+ border-left: solid 3px #acacac;
65
+ z-index: -1;
66
+ }
67
+ &::before {
68
+ content: "";
69
+ position: absolute;
70
+ width: 5px;
71
+ height: 10px;
72
+ top: 21px;
73
+ margin-left: -4px;
74
+ border-left: solid 3px #acacac;
75
+ z-index: -1;
76
+ }
77
+ }
78
+ }
79
+ .spider-menu.child:last-child {
80
+ .v-list-item__icon {
81
+ &::before {
82
+ height: 0px;
83
+ }
84
+ &::after {
85
+ border-bottom-left-radius: 3px;
86
+ }
87
+ }
88
+ }
52
89
  </style>
53
90
 
54
91
  <script>
@@ -56,22 +93,26 @@ export default {
56
93
  name: "SidebarListItem",
57
94
  data() {
58
95
  return {
59
- expanded: false
96
+ expanded: false,
97
+ nestDepth: 14,
60
98
  };
61
99
  },
62
100
  computed: {
63
101
  indent() {
64
102
  return {
65
- paddingLeft: `calc(1rem + ${+this.depth * 14}px)`,
66
- marginLeft: this.depth > 1 && `calc(-1rem - ${(this.depth - 1) * 14}px)`
103
+ paddingLeft: `calc(1rem + ${+this.depth * this.nestDepth}px)`,
104
+ marginLeft: this.depth > 1 && `calc(-1rem - ${(this.depth - 1) * this.nestDepth}px)`,
67
105
  };
68
106
  },
69
107
  rotate() {
70
108
  return {
71
109
  transform: this.expanded ? "rotate(180deg)" : "rotate(0deg)",
72
- transition: "transform 225ms cubic-bezier(0.4, 0, 0.2, 1)"
110
+ transition: "transform 225ms cubic-bezier(0.4, 0, 0.2, 1)",
73
111
  };
74
- }
112
+ },
113
+ activeChild() {
114
+ return (this.childrens || []).some((child) => this.$nuxt.$route.path.startsWith(child.link));
115
+ },
75
116
  },
76
117
  props: {
77
118
  link: String,
@@ -79,7 +120,9 @@ export default {
79
120
  icon: String,
80
121
  childrens: Array,
81
122
  depth: Number,
82
- forceCollapse: Boolean
83
- }
123
+ forceCollapse: Boolean,
124
+ child: Boolean,
125
+ spiderMenu: Boolean,
126
+ },
84
127
  };
85
128
  </script>
@@ -3,10 +3,8 @@
3
3
  <Sidebar />
4
4
  <Topbar :title="title" :drawer="this.$store.getters['mapo/app/drawer']" />
5
5
  <v-main>
6
- <v-container fluid>
7
- <nuxt />
8
- <root-components />
9
- </v-container>
6
+ <nuxt />
7
+ <root-components />
10
8
  </v-main>
11
9
  </v-app>
12
10
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/uikit",
3
- "version": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.7",
4
4
  "license": "MIT",
5
5
  "description": "This is part of Mapo nuxt module. Injects Mapo ui components in the nuxt component discovery system.",
6
6
  "author": "bnznamco <gabriele.baldi.01@gmail.com>",
@@ -13,5 +13,5 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "gitHead": "c30717d018606a1393f3a1f680276b1817d1d7a8"
16
+ "gitHead": "bdfb81790a70aa1c8ddfde78c8f9ba7345f7ba64"
17
17
  }