Update UI to handle both click modes

This commit is contained in:
Julien Loir 2020-11-08 17:34:29 +01:00
parent b3a36cd648
commit 077448b4e5
4 changed files with 31 additions and 5 deletions

View File

@ -6,8 +6,8 @@
@dragstart="dragStart" @dragstart="dragStart"
@dragover="dragOver" @dragover="dragOver"
@drop="drop" @drop="drop"
@click="click" @click="itemClick"
@dblclick="open" @dblclick="dblclick"
@touchstart="touchstart" @touchstart="touchstart"
:data-dir="isDir" :data-dir="isDir"
:aria-label="name" :aria-label="name"
@ -26,6 +26,9 @@
<p class="modified"> <p class="modified">
<time :datetime="modified">{{ humanTime() }}</time> <time :datetime="modified">{{ humanTime() }}</time>
</p> </p>
<input v-if="user.singleClick" v-bind:checked="isSelected"
class="selection" type="checkbox" @click.stop="click">
</div> </div>
</div> </div>
</template> </template>
@ -47,7 +50,7 @@ export default {
}, },
props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'], props: ['name', 'isDir', 'url', 'type', 'size', 'modified', 'index'],
computed: { computed: {
...mapState(['selected', 'req', 'user', 'jwt']), ...mapState(['user', 'selected', 'req', 'user', 'jwt']),
...mapGetters(['selectedCount']), ...mapGetters(['selectedCount']),
isSelected () { isSelected () {
return (this.selected.indexOf(this.index) !== -1) return (this.selected.indexOf(this.index) !== -1)
@ -170,8 +173,12 @@ export default {
action(overwrite, rename) action(overwrite, rename)
}, },
itemClick: function(event) {
if (this.user.singleClick) this.open()
else this.click(event)
},
click: function (event) { click: function (event) {
if (this.selectedCount !== 0) event.preventDefault() if (!this.user.singleClick && this.selectedCount !== 0) event.preventDefault()
if (this.$store.state.selected.indexOf(this.index) !== -1) { if (this.$store.state.selected.indexOf(this.index) !== -1) {
this.removeSelected(this.index) this.removeSelected(this.index)
return return
@ -198,9 +205,12 @@ export default {
return return
} }
if (!event.ctrlKey && !this.$store.state.multiple) this.resetSelected() if (!this.user.singleClick && !event.ctrlKey && !this.$store.state.multiple) this.resetSelected()
this.addSelected(this.index) this.addSelected(this.index)
}, },
dblclick: function () {
if (!this.user.singleClick) this.open()
},
touchstart () { touchstart () {
setTimeout(() => { setTimeout(() => {
this.touches = 0 this.touches = 0

View File

@ -24,6 +24,10 @@
<input type="checkbox" :disabled="user.perm.admin" v-model="user.lockPassword"> {{ $t('settings.lockPassword') }} <input type="checkbox" :disabled="user.perm.admin" v-model="user.lockPassword"> {{ $t('settings.lockPassword') }}
</p> </p>
<p>
<input type="checkbox" v-model="user.singleClick"> {{ $t('settings.singleClick') }}
</p>
<permissions :perm.sync="user.perm" /> <permissions :perm.sync="user.perm" />
<commands v-if="isExecEnabled" :commands.sync="user.commands" /> <commands v-if="isExecEnabled" :commands.sync="user.commands" />

View File

@ -104,6 +104,12 @@
width: calc(100% - 5vw); width: calc(100% - 5vw);
} }
#listing.mosaic .item .selection {
position: absolute;
top: 16px;
right: 16px;
}
#listing.list { #listing.list {
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
@ -217,6 +223,11 @@
font-weight: bold; font-weight: bold;
} }
#listing.list .item .selection {
position: absolute;
right: 24px;
}
#listing #multiple-selection { #listing #multiple-selection {
position: fixed; position: fixed;
bottom: -4em; bottom: -4em;

View File

@ -173,6 +173,7 @@
"globalRules": "This is a global set of allow and disallow rules. They apply to every user. You can define specific rules on each user's settings to override this ones.", "globalRules": "This is a global set of allow and disallow rules. They apply to every user. You can define specific rules on each user's settings to override this ones.",
"allowSignup": "Allow users to signup", "allowSignup": "Allow users to signup",
"createUserDir": "Auto create user home dir while adding new user", "createUserDir": "Auto create user home dir while adding new user",
"singleClick": "Use only single click gestures on the interface",
"insertRegex": "Insert regex expression", "insertRegex": "Insert regex expression",
"insertPath": "Insert the path", "insertPath": "Insert the path",
"userUpdated": "User updated!", "userUpdated": "User updated!",