-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
download shared subdirectory #1184
Changes from 15 commits
dddf854
338c546
72ca1f4
4eceee4
7c56617
e700f6e
158c7b8
a8d3328
55c19c2
621093e
ed8aded
341a465
e669f3b
c36860c
57e11a5
5087c6c
b483e8d
5eeb74a
5e1e2e4
0c50a39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
</div> | ||
|
||
<!-- This buttons are shown on a dropdown on mobile phones --> | ||
<div id="dropdown" :class="{ active: showMore }"> | ||
<div class="dropdown" :class="{ active: showMore }"> | ||
<div v-if="!isListing || !isMobile"> | ||
<share-button v-show="showShareButton"></share-button> | ||
<rename-button v-show="showRenameButton"></rename-button> | ||
|
@@ -49,6 +49,17 @@ | |
</button> | ||
</div> | ||
</template> | ||
<template v-if="isSharing"> | ||
<!-- This buttons are shown on a dropdown on mobile phones --> | ||
<div class="dropdown" :class="{ active: showMore }"> | ||
<download-button v-if="sharedSelectedCount > 0"></download-button> | ||
|
||
<button @click="toggleSharedMultipleSelection" :aria-label="$t('buttons.selectMultiple')" :title="$t('buttons.selectMultiple')" class="action" > | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we reuse the existing selection toggle and download buttons? |
||
<i class="material-icons">check_circle</i> | ||
<span>{{ $t('buttons.select') }}</span> | ||
</button> | ||
</div> | ||
</template> | ||
|
||
<div v-show="showOverlay" @click="resetPrompts" class="overlay"></div> | ||
</div> | ||
|
@@ -110,14 +121,17 @@ export default { | |
'isEditor', | ||
'isPreview', | ||
'isListing', | ||
'isLogged' | ||
'isLogged', | ||
'isSharing', | ||
'sharedSelectedCount' | ||
]), | ||
...mapState([ | ||
'req', | ||
'user', | ||
'loading', | ||
'reload', | ||
'multiple' | ||
'multiple', | ||
'shared' | ||
]), | ||
logoURL: () => logoURL, | ||
isExecEnabled: () => enableExec, | ||
|
@@ -156,7 +170,7 @@ export default { | |
: this.user.perm.create) | ||
}, | ||
showMore () { | ||
return this.isFiles && this.$store.state.show === 'more' | ||
return (this.isFiles || this.isSharing) && this.$store.state.show === 'more' | ||
}, | ||
showOverlay () { | ||
return this.showMore | ||
|
@@ -176,6 +190,10 @@ export default { | |
this.$store.commit('multiple', !this.multiple) | ||
this.resetPrompts() | ||
}, | ||
toggleSharedMultipleSelection () { | ||
this.$store.commit('sharedMultiple', !this.shared.multiple) | ||
this.resetPrompts() | ||
}, | ||
resetPrompts () { | ||
this.$store.commit('closeHovers') | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<template> | ||
<div class="item" | ||
role="button" | ||
tabindex="0" | ||
@click="click" | ||
@dblclick="dblclick" | ||
@touchstart="touchstart" | ||
:data-dir="isDir" | ||
:aria-label="name" | ||
:aria-selected="isSelected"> | ||
<div> | ||
<i class="material-icons">{{ icon }}</i> | ||
</div> | ||
|
||
<div> | ||
<p class="name">{{ name }}</p> | ||
|
||
<p v-if="isDir" class="size" data-order="-1">—</p> | ||
<p v-else class="size" :data-order="humanSize()">{{ humanSize() }}</p> | ||
|
||
<p class="modified"> | ||
<time :datetime="modified">{{ humanTime() }}</time> | ||
</p> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapMutations, mapGetters, mapState } from 'vuex' | ||
import filesize from 'filesize' | ||
import moment from 'moment' | ||
|
||
export default { | ||
name: 'sharedItem', | ||
data: function () { | ||
return { | ||
touches: 0 | ||
} | ||
}, | ||
props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'], | ||
computed: { | ||
...mapState(['shared']), | ||
...mapGetters(['sharedSelectedCount']), | ||
isSelected () { | ||
return (this.shared.selected.indexOf(this.index) !== -1) | ||
}, | ||
icon () { | ||
if (this.isDir) return 'folder' | ||
if (this.type === 'image') return 'insert_photo' | ||
if (this.type === 'audio') return 'volume_up' | ||
if (this.type === 'video') return 'movie' | ||
return 'insert_drive_file' | ||
} | ||
}, | ||
methods: { | ||
...mapMutations(['addSharedSelected', 'removeSharedSelected', 'resetSharedSelected']), | ||
humanSize: function () { | ||
return filesize(this.size) | ||
}, | ||
humanTime: function () { | ||
return moment(this.modified).fromNow() | ||
}, | ||
click: function (event) { | ||
if (this.sharedSelectedCount !== 0) event.preventDefault() | ||
if (this.$store.state.shared.selected.indexOf(this.index) !== -1) { | ||
this.removeSharedSelected(this.index) | ||
return | ||
} | ||
|
||
if (event.shiftKey && this.shared.selected.length > 0) { | ||
let fi = 0 | ||
let la = 0 | ||
|
||
if (this.index > this.shared.selected[0]) { | ||
fi = this.shared.selected[0] + 1 | ||
la = this.index | ||
} else { | ||
fi = this.index | ||
la = this.shared.selected[0] - 1 | ||
} | ||
|
||
for (; fi <= la; fi++) { | ||
if (this.$store.state.shared.selected.indexOf(fi) == -1) { | ||
this.addSharedSelected(fi) | ||
} | ||
} | ||
|
||
return | ||
} | ||
|
||
if (!event.ctrlKey && !event.metaKey && !this.$store.state.shared.multiple) this.resetSharedSelected() | ||
this.addSharedSelected(this.index) | ||
}, | ||
dblclick: function () { | ||
this.open() | ||
}, | ||
touchstart () { | ||
setTimeout(() => { | ||
this.touches = 0 | ||
}, 300) | ||
|
||
this.touches++ | ||
if (this.touches > 1) { | ||
this.open() | ||
} | ||
}, | ||
open: function () { | ||
this.$router.push({path: this.url}) | ||
} | ||
} | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,14 @@ const state = { | |
showShell: false, | ||
showMessage: null, | ||
showConfirm: null, | ||
previewMode: false | ||
previewMode: false, | ||
shared: { | ||
req: {}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can reuse the current existing state properties. Also you can make the hash work as a getter using only the req state. |
||
hash: '', | ||
loaded: false, | ||
selected: [], | ||
multiple: false | ||
} | ||
} | ||
|
||
export default new Vuex.Store({ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a whole new dropdown, lets use the
v-show
directive on the wanted elements.