Merge pull request #18894 from nextcloud/fix/note/debounce

Save sharing note on close or submit
This commit is contained in:
Roeland Jago Douma 2020-01-16 00:31:23 +01:00 committed by GitHub
commit 312f7c9c07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 61 additions and 30 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,10 @@
<div v-tooltip.auto="tooltip" class="sharing-entry__desc">
<h5>{{ title }}</h5>
</div>
<Actions menu-align="right" class="sharing-entry__actions">
<Actions
menu-align="right"
class="sharing-entry__actions"
@close="onMenuClose">
<template v-if="share.canEdit">
<!-- edit permission -->
<ActionCheckbox
@ -114,9 +117,10 @@
}"
:class="{ error: errors.note}"
:disabled="saving"
:value.sync="share.note"
:value="share.newNote || share.note"
icon="icon-edit"
@update:value="debounceQueueUpdate('note')" />
@update:value="onNoteChange"
@submit="onNoteSubmit" />
</template>
</template>
@ -303,6 +307,13 @@ export default {
this.share.permissions = permissions
this.queueUpdate('permissions')
},
/**
* Save potential changed data on menu close
*/
onMenuClose() {
this.onNoteSubmit()
},
},
}
</script>

View File

@ -121,7 +121,7 @@
class="sharing-entry__actions"
menu-align="right"
:open.sync="open"
@close="onPasswordSubmit">
@close="onMenuClose">
<template v-if="share">
<template v-if="share.canEdit">
<!-- folder -->
@ -252,9 +252,10 @@
:class="{ error: errors.note}"
:disabled="saving"
:placeholder="t('files_sharing', 'Enter a note for the share recipient')"
:value="share.note"
:value="share.newNote || share.note"
icon="icon-edit"
@update:value="onNoteChange" />
@update:value="onNoteChange"
@submit="onNoteSubmit" />
</template>
<!-- external sharing via url (social...) -->
@ -777,6 +778,14 @@ export default {
}
},
/**
* Save potential changed data on menu close
*/
onMenuClose() {
this.onPasswordSubmit()
this.onNoteSubmit()
},
/**
* Cancel the share creation
* Used in the pending popover

View File

@ -182,15 +182,26 @@ export default {
this.queueUpdate('expireDate')
},
/**
* Note changed, let's save it to a different key
* @param {String} note the share note
*/
onNoteChange(note) {
this.$set(this.share, 'newNote', note.trim())
},
/**
* When the note change, we trim, save and dispatch
*
* @param {string} note the note
*/
onNoteChange: debounce(function(note) {
this.share.note = note.trim()
this.queueUpdate('note')
}, 500),
onNoteSubmit() {
if (this.share.newNote) {
this.share.note = this.share.newNote
this.$delete(this.share, 'newNote')
this.queueUpdate('note')
}
},
/**
* Delete share button handler