Close poll form after status submit

This commit is contained in:
Maxim Filippov 2019-04-10 02:07:13 +02:00
parent 20766b8522
commit f1a9a04451
4 changed files with 26 additions and 8 deletions

View File

@ -42,17 +42,16 @@ export default {
methods: {
onAddOption () {
if (this.optionsLength < maxOptions) {
this.$store.commit('addPollOption', '')
this.$store.dispatch('addPollOption', { option: '' })
}
},
onDeleteOption (index) {
console.log(index)
if (this.optionsLength > 1) {
this.$store.commit('deletePollOption', index)
this.$store.dispatch('deletePollOption', { index })
}
},
onUpdateOption (e, index) {
this.$store.commit('updatePollOption', { index, option: e.target.value })
this.$store.dispatch('updatePollOption', { index, option: e.target.value })
}
}
}

View File

@ -275,6 +275,8 @@ const PostStatusForm = {
visibility: newStatus.visibility,
contentType: newStatus.contentType
}
this.$store.dispatch('swapPollOptions', { options: ['', ''] })
this.pollFormVisible = false
this.$refs.mediaUpload.clearFile()
this.$emit('posted')
let el = this.$el.querySelector('textarea')

View File

@ -74,7 +74,7 @@
</div>
</div>
</div>
<poll-form :visible="pollFormVisible" />
<poll-form :visible="pollFormVisible" :options="newStatus.pollOptions" />
<div class='form-bottom'>
<media-upload ref="mediaUpload" @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="uploadFailed" :drop-files="dropFiles"></media-upload>
<div class="poll-icon">

View File

@ -3,14 +3,31 @@ const poll = {
pollOptions: ['', '']
},
mutations: {
addPollOption (state, option) {
ADD_OPTION (state, { option }) {
state.pollOptions.push(option)
},
updatePollOption (state, { index, option }) {
UPDATE_OPTION (state, { index, option }) {
state.pollOptions[index] = option
},
deletePollOption (state, index) {
DELETE_OPTION (state, { index }) {
state.pollOptions.splice(index, 1)
},
SWAP_OPTIONS (state, { options }) {
state.pollOptions = options
}
},
actions: {
addPollOption (store, { option }) {
store.commit('ADD_OPTION', { option })
},
updatePollOption (store, { index, option }) {
store.commit('UPDATE_OPTION', { index, option })
},
deletePollOption (store, { index }) {
store.commit('DELETE_OPTION', { index })
},
swapPollOptions (store, { options }) {
store.commit('SWAP_OPTIONS', { options })
}
}
}