|
3 | 3 | <q-list> |
4 | 4 | <q-expansion-item dense dense-toggle expand-separator label="Upload Mockup Image"> |
5 | 5 | <div class="upload"> |
6 | | - <q-btn class="upload-btn" color="secondary" label="Upload Mockup" @click="importMockup" /> |
| 6 | + <!-- for electron, below is for browser usage |
| 7 | + <q-btn class="upload-btn" color="secondary" label="Upload Mockup" @click="importMockup" />--> |
| 8 | + <form enctype="multipart/form-data" action="/upload/image" method="post"> |
| 9 | + <input |
| 10 | + type="file" |
| 11 | + class="browser-btn" |
| 12 | + ref="myFiles" |
| 13 | + accept="image/*" |
| 14 | + @change="importMockupBrowser" |
| 15 | + /> |
| 16 | + </form> |
7 | 17 | <q-btn |
8 | 18 | v-if="imageExists" |
9 | 19 | class="upload-btn" |
10 | 20 | color="secondary" |
11 | 21 | label="Clear Image" |
12 | | - @click="removeImage" |
| 22 | + @click="removeImageBrowser" |
13 | 23 | /> |
| 24 | + <!-- for electron |
| 25 | + <q-btn |
| 26 | + v-if="imageExists" |
| 27 | + class="upload-btn" |
| 28 | + color="secondary" |
| 29 | + label="Clear Image" |
| 30 | + @click="removeImage" |
| 31 | + />--> |
14 | 32 | <q-btn v-else disable class="upload-btn" color="secondary" label="Clear Image" /> |
15 | 33 | </div> |
16 | 34 | <div class="file-path"> |
|
29 | 47 | </template> |
30 | 48 |
|
31 | 49 | <script> |
32 | | -import { mapState, mapActions } from 'vuex' |
33 | | -import uploadImage from '../utils/uploadImage.util' |
34 | | -import clearImageDialog from '../utils/clearImage.util' |
| 50 | +import { mapState, mapActions } from "vuex"; |
| 51 | +/** |
| 52 | + * Electron functionality |
| 53 | + */ |
| 54 | +// import uploadImage from '../utils/uploadImage.util' |
| 55 | +// import clearImageDialog from '../utils/clearImage.util' |
35 | 56 |
|
36 | 57 | export default { |
37 | | - name: 'upload-image', |
| 58 | + name: "upload-image", |
| 59 | + data() { |
| 60 | + return { |
| 61 | + files: [] |
| 62 | + }; |
| 63 | + }, |
38 | 64 | computed: { |
39 | | - ...mapState(['imagePath']), |
40 | | - imageExists () { |
41 | | - return this.imagePath.length |
| 65 | + ...mapState(["imagePath"]), |
| 66 | + imageExists() { |
| 67 | + return this.imagePath.length; |
42 | 68 | } |
43 | 69 | }, |
44 | 70 | methods: { |
45 | | - ...mapActions(['importImage', 'clearImage']), |
46 | | - importMockup () { |
47 | | - const img = uploadImage() |
48 | | - this.importImage(img) |
| 71 | + ...mapActions(["importImage", "clearImage"]), |
| 72 | + /** |
| 73 | + * @description: for use with electron |
| 74 | + */ |
| 75 | + importMockup() { |
| 76 | + // const img = uploadImage() |
| 77 | + // this.importImage(img) |
| 78 | + }, |
| 79 | + removeImage() { |
| 80 | + // const res = clearImageDialog() |
| 81 | + // if (res === 0) this.clearImage() |
| 82 | + }, |
| 83 | + /** |
| 84 | + * @description: for use with the browser |
| 85 | + * currently needs an approach for storing the file on the browser.. |
| 86 | + * also, needs async functionality to update state in store (yet we cant even save the file so its useless, gonna check out local storage) |
| 87 | + */ |
| 88 | + async importMockupBrowser() { |
| 89 | + console.log(`importMockupBrowser: ${this.$refs.myFiles.files}`); |
| 90 | + this.files = this.$refs.myFiles.files[0]; |
| 91 | + await this.importImage(this.files.name); |
| 92 | + await console.log(this.files.name); |
49 | 93 | }, |
50 | | - removeImage () { |
51 | | - const res = clearImageDialog() |
52 | | - if (res === 0) this.clearImage() |
| 94 | + removeImageBrowser() { |
| 95 | + this.clearImage(); |
53 | 96 | } |
54 | 97 | } |
55 | | -} |
| 98 | +}; |
56 | 99 | </script> |
57 | 100 |
|
58 | | -<style> |
| 101 | +<style lang="stylus"> |
59 | 102 | .home-sidebar { |
60 | 103 | margin: 1rem; |
61 | 104 | justify-content: center; |
62 | 105 | border-radius: 5px; |
63 | 106 | } |
| 107 | +
|
64 | 108 | .upload-btn { |
65 | 109 | text-transform: capitalize; |
66 | 110 | font-size: 12px; |
67 | 111 | } |
| 112 | +
|
68 | 113 | .upload { |
69 | 114 | margin: 0.5rem; |
70 | 115 | display: flex; |
71 | 116 | justify-content: space-evenly; |
72 | 117 | } |
| 118 | +
|
73 | 119 | .file-path { |
74 | 120 | padding-bottom: 1rem; |
75 | 121 | margin: 1rem; |
76 | 122 | font-size: 11px; |
77 | 123 | } |
| 124 | +
|
78 | 125 | .file-header { |
79 | 126 | padding-left: 0.4em; |
80 | 127 | } |
| 128 | +
|
81 | 129 | .file-content { |
82 | 130 | padding: 0em 1em 1em 1em; |
83 | 131 | } |
| 132 | +
|
| 133 | +.browser-btn { |
| 134 | + width: 90px; |
| 135 | + background: $secondary; |
| 136 | +} |
84 | 137 | </style> |
0 commit comments