refs #874 Hold polls data in NewTootModal component
This commit is contained in:
parent
e558945fca
commit
d95ec64513
|
@ -14,7 +14,7 @@
|
||||||
</div>
|
</div>
|
||||||
<Status v-model="status" :opened="newTootModal" :fixCursorPos="hashtagInserting" @paste="onPaste" @toot="toot" />
|
<Status v-model="status" :opened="newTootModal" :fixCursorPos="hashtagInserting" @paste="onPaste" @toot="toot" />
|
||||||
</el-form>
|
</el-form>
|
||||||
<Poll v-if="openPoll"></Poll>
|
<Poll v-if="openPoll" v-model="polls" @addPoll="addPoll" @removePoll="removePoll"></Poll>
|
||||||
<div class="preview">
|
<div class="preview">
|
||||||
<div class="image-wrapper" v-for="media in attachedMedias" v-bind:key="media.id">
|
<div class="image-wrapper" v-for="media in attachedMedias" v-bind:key="media.id">
|
||||||
<img :src="media.preview_url" class="preview-image" />
|
<img :src="media.preview_url" class="preview-image" />
|
||||||
|
@ -141,7 +141,8 @@ export default {
|
||||||
spoiler: '',
|
spoiler: '',
|
||||||
showContentWarning: false,
|
showContentWarning: false,
|
||||||
visibilityList: Visibility,
|
visibilityList: Visibility,
|
||||||
openPoll: false
|
openPoll: false,
|
||||||
|
polls: ['', '']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -335,6 +336,12 @@ export default {
|
||||||
},
|
},
|
||||||
togglePollForm() {
|
togglePollForm() {
|
||||||
this.openPoll = !this.openPoll
|
this.openPoll = !this.openPoll
|
||||||
|
},
|
||||||
|
addPoll() {
|
||||||
|
this.polls.push('')
|
||||||
|
},
|
||||||
|
removePoll(id) {
|
||||||
|
this.polls.splice(id, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="poll">
|
<div class="poll">
|
||||||
<ul class="poll-list">
|
<ul class="poll-list">
|
||||||
<li class="poll-option" v-for="(option, id) in polls" v-bind:key="id">
|
<li class="poll-option" v-for="(option, id) in value" v-bind:key="id">
|
||||||
<el-radio :disabled="true" :label="id">
|
<el-radio :disabled="true" :label="id">
|
||||||
<el-input :placeholder="`choice ${id}`" v-model="polls[id]" size="small"></el-input>
|
<el-input :placeholder="`choice ${id}`" :value="value[id]" @input="value => updateOption(value, id)" size="small"></el-input>
|
||||||
<el-button class="remove-poll" type="text" @click="removePoll(id)" size="small"><icon name="times"></icon></el-button>
|
<el-button class="remove-poll" type="text" @click="removePoll(id)" size="small"><icon name="times"></icon></el-button>
|
||||||
</el-radio>
|
</el-radio>
|
||||||
</li>
|
</li>
|
||||||
|
@ -15,17 +15,17 @@
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'poll',
|
name: 'poll',
|
||||||
data() {
|
props: ['value'],
|
||||||
return {
|
|
||||||
polls: ['', '']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
addPoll() {
|
addPoll() {
|
||||||
this.polls.push('')
|
this.$emit('addPoll')
|
||||||
},
|
},
|
||||||
removePoll(id) {
|
removePoll(id) {
|
||||||
this.polls.splice(id, 1)
|
this.$emit('removePoll', id)
|
||||||
|
},
|
||||||
|
updateOption(item, index) {
|
||||||
|
const newValue = [...this.value.slice(0, index), item, ...this.value.slice(index + 1)]
|
||||||
|
this.$emit('input', newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue