Merge pull request #394 from nextcloud/fix/multiple_input_followup

Fix some small MultipleInput issues
This commit is contained in:
Jan C. Borchardt 2020-06-10 00:39:07 +02:00 committed by GitHub
commit 0472f3036c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -76,7 +76,8 @@
:maxlength="maxStringLengths.optionText"
minlength="1"
type="text"
@click="addNewEntry">
@click="addNewEntry"
@focus="addNewEntry">
</li>
</ul>
</Question>
@ -221,6 +222,9 @@ export default {
* Add a new empty answer locally
*/
addNewEntry() {
// If entering from non-edit-mode (possible by click), activate edit-mode
this.edit = true
// Add local entry
const options = this.options.slice()
options.push({
@ -258,22 +262,28 @@ export default {
* @param {number} id the options id
*/
deleteOption(id) {
// Remove entry
const options = this.options.slice()
const optionIndex = options.findIndex(option => option.id === id)
const option = Object.assign({}, this.options[optionIndex])
// delete locally
options.splice(optionIndex, 1)
if (options.length === 1) {
// Clear Text, but don't remove. Will be removed, when leaving edit-mode
options[0].text = ''
} else {
// Remove entry
const option = Object.assign({}, this.options[optionIndex])
// delete from Db
this.deleteOptionFromDatabase(option)
// delete locally
options.splice(optionIndex, 1)
// delete from Db
this.deleteOptionFromDatabase(option)
}
// Update question
this.updateOptions(options)
this.$nextTick(() => {
this.focusIndex(optionIndex)
this.focusIndex(optionIndex - 1)
})
},