From 7e6b4af48ba89386cf693ba73765c13290bb56ef Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Tue, 16 Jun 2020 16:06:55 +0000 Subject: [PATCH] feat: upload button prompt --- frontend/src/components/buttons/Upload.vue | 6 +++- frontend/src/components/files/Listing.vue | 20 +++++++++-- frontend/src/components/prompts/Prompts.vue | 7 ++-- frontend/src/components/prompts/Upload.vue | 37 +++++++++++++++++++++ frontend/src/css/dashboard.css | 31 +++++++++++++++++ frontend/src/i18n/en.json | 4 ++- 6 files changed, 98 insertions(+), 7 deletions(-) create mode 100644 frontend/src/components/prompts/Upload.vue diff --git a/frontend/src/components/buttons/Upload.vue b/frontend/src/components/buttons/Upload.vue index ff1396d0..9e7f07bd 100644 --- a/frontend/src/components/buttons/Upload.vue +++ b/frontend/src/components/buttons/Upload.vue @@ -10,7 +10,11 @@ export default { name: 'upload-button', methods: { upload: function () { - document.getElementById('upload-input').click() + if (typeof(DataTransferItem.prototype.webkitGetAsEntry) !== 'undefined') { + this.$store.commit('showHover', 'upload') + } else { + document.getElementById('upload-input').click(); + } } } } diff --git a/frontend/src/components/files/Listing.vue b/frontend/src/components/files/Listing.vue index d3b159af..14638b98 100644 --- a/frontend/src/components/files/Listing.vue +++ b/frontend/src/components/files/Listing.vue @@ -5,6 +5,7 @@ {{ $t('files.lonely') }} +
+

{{ $t('files.multipleSelectionEnabled') }}

@@ -331,7 +333,7 @@ export default { let conflict = false for (let i = 0; i < files.length; i++) { - let file = files[i]; + let file = files[i] let name = file.name if (folder_upload) { @@ -366,7 +368,19 @@ export default { }) }, uploadInput (event) { - this.checkConflict(event.currentTarget.files, this.req.items, '') + this.$store.commit('closeHovers') + + let files = event.currentTarget.files + let folder_upload = files[0].webkitRelativePath !== undefined && files[0].webkitRelativePath !== '' + + if (folder_upload) { + for (let i = 0; i < files.length; i++) { + let file = files[i] + files[i].fullPath = file.webkitRelativePath + } + } + + this.checkConflict(files, this.req.items, '') }, resetOpacity () { let items = document.getElementsByClassName('item') @@ -388,7 +402,7 @@ export default { } } } else { - resolve(dt.files); + resolve(dt.files) } function readEntry(entry, directory = "") { diff --git a/frontend/src/components/prompts/Prompts.vue b/frontend/src/components/prompts/Prompts.vue index 8e530a27..29d4112b 100644 --- a/frontend/src/components/prompts/Prompts.vue +++ b/frontend/src/components/prompts/Prompts.vue @@ -17,6 +17,7 @@ import NewFile from './NewFile' import NewDir from './NewDir' import Replace from './Replace' import Share from './Share' +import Upload from './Upload' import { mapState } from 'vuex' import buttons from '@/utils/buttons' @@ -33,7 +34,8 @@ export default { NewFile, NewDir, Help, - Replace + Replace, + Upload }, data: function () { return { @@ -58,7 +60,8 @@ export default { 'newDir', 'download', 'replace', - 'share' + 'share', + 'upload' ].indexOf(this.show) >= 0; return matched && this.show || null; diff --git a/frontend/src/components/prompts/Upload.vue b/frontend/src/components/prompts/Upload.vue new file mode 100644 index 00000000..3202ef2c --- /dev/null +++ b/frontend/src/components/prompts/Upload.vue @@ -0,0 +1,37 @@ + + + diff --git a/frontend/src/css/dashboard.css b/frontend/src/css/dashboard.css index d186a727..b29e907f 100644 --- a/frontend/src/css/dashboard.css +++ b/frontend/src/css/dashboard.css @@ -96,6 +96,7 @@ table tr>*:last-child { background-color: #fff; border-radius: 2px; box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2); + overflow: auto; } .card.floating { @@ -366,3 +367,33 @@ table tr>*:last-child { .card .collapsible .collapse { padding: 0 1em; } + +.card .card-action.full { + padding-top: 0; + display: flex; + flex-wrap: wrap; +} + +.card .card-action.full .action { + flex: 1; + padding: 2em; + border-radius: 0.2em; + border: 1px solid rgba(0, 0, 0, 0.1); + text-align: center; +} + +.card .card-action.full .action { + margin: 0 0.25em 0.50em; +} + +.card .card-action.full .action i { + display: block; + padding: 0; + margin-bottom: 0.25em; + font-size: 4em; +} + +.card .card-action.full .action .title { + font-size: 1.5em; + font-weight: 500; +} \ No newline at end of file diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index f42be526..7617caaf 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -116,7 +116,9 @@ "size": "Size", "schedule": "Schedule", "scheduleMessage": "Pick a date and time to schedule the publication of this post.", - "newArchetype": "Create a new post based on an archetype. Your file will be created on content folder." + "newArchetype": "Create a new post based on an archetype. Your file will be created on content folder.", + "upload": "Upload", + "uploadMessage": "Select an option to upload." }, "settings": { "themes": {