Skip to content

Commit c8f18cb

Browse files
committed
Added UploadImage component
1 parent 43f61fd commit c8f18cb

File tree

4 files changed

+154
-1
lines changed

4 files changed

+154
-1
lines changed

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"dependencies": {
1313
"@quasar/extras": "^1.0.0",
1414
"@vue/compiler-sfc": "^3.1.0",
15+
"@vueform/toggle": "^2.0.1",
1516
"core-js": "^3.6.5",
1617
"localforage": "^1.10.0",
1718
"lodash.clonedeep": "^4.5.0",

src/components/home_sidebar_items/ComponentTab/EditDeleteComponents.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Description:
145145
<script>
146146
import { mapState, mapActions } from "vuex";
147147
import Multiselect from "vue-multiselect";
148-
import { ToggleButton } from "vue-js-toggle-button";
148+
// import { ToggleButton } from "vue-js-toggle-button";
149149
import HTMLQueue from "../../dashboard_items/HTMLQueue.vue";
150150
import Icons from "../Icons.vue";
151151
import AddProps from "./AddProps.vue";
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!--
2+
Description:
3+
Displays Mockup Image upload dropdown as well as minified mockup image once selected
4+
Functionality includes: importing and clearing mockup image
5+
-->
6+
7+
<template>
8+
<div class="home-sidebar drawer-menu">
9+
<q-list>
10+
<q-expansion-item expand-separator label="Upload Mockup Image">
11+
<div class="upload">
12+
<q-btn class="upload-btn" color="secondary" label="Upload Mockup" @click="importMockup" />
13+
<q-btn
14+
v-if="source !== ''"
15+
class="upload-btn"
16+
color="secondary"
17+
label="Clear Image"
18+
@click="removeImage"
19+
/>
20+
<q-btn v-else disable class="upload-btn" color="secondary" label="Clear Image" />
21+
</div>
22+
<div class="file-path">
23+
<q-card>
24+
<img class='img' v-if='this.imagePath[this.activeRoute] !== ""' :src="'file:///' + this.imagePath[this.activeRoute]"/>
25+
</q-card>
26+
</div>
27+
</q-expansion-item>
28+
</q-list>
29+
</div>
30+
</template>
31+
32+
<script>
33+
import { mapState, mapActions } from 'vuex'
34+
import uploadImage from '../../utils/uploadImage.util'
35+
import clearImageDialog from '../../utils/clearImage.util'
36+
37+
export default {
38+
name: 'upload-image',
39+
data () {
40+
return {
41+
files: [],
42+
source: ''
43+
}
44+
},
45+
computed: {
46+
...mapState(['imagePath', 'activeRoute'])
47+
},
48+
methods: {
49+
...mapActions(['importImage', 'clearImage']),
50+
// imports mockup image
51+
importMockup () {
52+
const img = uploadImage()
53+
if (img !== '') {
54+
this.importImage({ img, route: this.activeRoute })
55+
if (this.imagePath[this.activeRoute]) {
56+
this.source = 'file:///' + this.imagePath[this.activeRoute]
57+
}
58+
}
59+
},
60+
// removes mockup image
61+
removeImage () {
62+
const res = clearImageDialog()
63+
// console.log('REMOVEIMAGE: remove is ', res )
64+
if (res === 0) {
65+
this.clearImage({ route: this.activeRoute })
66+
this.source = this.imagePath[this.activeRoute]
67+
}
68+
},
69+
// imports image on browser
70+
// currently images aren't able to be stored on browser
71+
async importMockupBrowser () {
72+
// console.log(`importMockupBrowser: ${this.$refs.myFiles.files}`)
73+
this.files = this.$refs.myFiles.files[0]
74+
await this.importImage(this.files.name)
75+
// await console.log(this.files.name)
76+
},
77+
// removes image on browser
78+
removeImageBrowser () {
79+
this.clearImage()
80+
}
81+
},
82+
// watches for changes in state to activeRoute
83+
watch: {
84+
// once you change your active route, the mockup image should change as well
85+
activeRoute: function () {
86+
// console.log('Route has changed')
87+
if (this.imagePath[this.activeRoute]) {
88+
// if there is a uploaded image
89+
this.source = 'file:///' + this.imagePath[this.activeRoute]
90+
} else {
91+
this.source = ''
92+
}
93+
}
94+
}
95+
}
96+
</script>
97+
98+
<style lang="scss">
99+
.home-sidebar {
100+
margin: 1rem;
101+
justify-content: center;
102+
border-radius: 5px;
103+
padding: 0px;
104+
background: $subsecondary;
105+
}
106+
107+
.upload-btn {
108+
text-transform: capitalize;
109+
font-size: 12px;
110+
}
111+
112+
.upload {
113+
margin: 0.5rem;
114+
display: flex;
115+
justify-content: space-evenly;
116+
}
117+
118+
.file-path {
119+
padding-bottom: 1em;
120+
height: 100%;
121+
margin: 1rem;
122+
font-size: 11px;
123+
}
124+
125+
.file-header {
126+
padding-left: 0.4em;
127+
}
128+
129+
.file-content {
130+
padding: 0em 1em 1em 1em;
131+
}
132+
133+
.browser-btn {
134+
width: 90px;
135+
background: $secondary;
136+
}
137+
138+
.img {
139+
max-height: 200px;
140+
}
141+
</style>

0 commit comments

Comments
 (0)