refs #3730 Fix to set poll expire

This commit is contained in:
AkiraFukushima 2022-11-04 21:39:52 +09:00
parent 14b9b81ffe
commit 07cb9dcb73
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
2 changed files with 16 additions and 4 deletions

View File

@ -31,7 +31,8 @@
<Poll <Poll
v-if="openPoll" v-if="openPoll"
v-model:polls="polls" v-model:polls="polls"
v-model:expire="pollExpire" :expire="pollExpire"
@update:expire="updatePollExpire"
@addPoll="addPoll" @addPoll="addPoll"
@removePoll="removePoll" @removePoll="removePoll"
ref="pollRef" ref="pollRef"
@ -425,6 +426,11 @@ export default defineComponent({
enableResizing.value = true enableResizing.value = true
}) })
} }
const updatePollExpire = newExpire => {
pollExpire.label = newExpire.label
pollExpire.value = newExpire.value
}
const toggleContentWarning = () => { const toggleContentWarning = () => {
const previousHeight = spoilerRef.value ? spoilerRef.value.offsetHeight : 0 const previousHeight = spoilerRef.value ? spoilerRef.value.offsetHeight : 0
enableResizing.value = false enableResizing.value = false
@ -468,6 +474,7 @@ export default defineComponent({
openPoll, openPoll,
polls, polls,
pollExpire, pollExpire,
updatePollExpire,
statusHeight, statusHeight,
// DOM refs // DOM refs
previewRef, previewRef,

View File

@ -9,7 +9,7 @@
</li> </li>
</ul> </ul>
<el-button class="add-poll" type="info" size="small" @click="addPoll" plain>{{ $t('modals.new_toot.poll.add_choice') }}</el-button> <el-button class="add-poll" type="info" size="small" @click="addPoll" plain>{{ $t('modals.new_toot.poll.add_choice') }}</el-button>
<el-select :modelValue="expire" @change="$emit('update:expire', $event)" size="small" value-key="value"> <el-select :model-value="expire" size="small" value-key="value" @change="updateExpire">
<el-option v-for="exp in expiresList" :key="exp.value" :label="exp.label" :value="exp"> </el-option> <el-option v-for="exp in expiresList" :key="exp.value" :label="exp.label" :value="exp"> </el-option>
</el-select> </el-select>
</div> </div>
@ -36,6 +36,7 @@ export default defineComponent({
required: true required: true
} }
}, },
emits: ['addPoll', 'removePoll', 'update:expire', 'update:polls'],
setup(props, ctx) { setup(props, ctx) {
const i18n = useI18next() const i18n = useI18next()
const { expire, polls } = toRefs(props) const { expire, polls } = toRefs(props)
@ -76,9 +77,12 @@ export default defineComponent({
const removePoll = (id: number) => { const removePoll = (id: number) => {
ctx.emit('removePoll', id) ctx.emit('removePoll', id)
} }
const updateExpire = newExpire => {
ctx.emit('update:expire', newExpire)
}
watch(expire, (newExpire, _old) => { watch(expire, (newExpire, _old) => {
ctx.emit('update:expire', newExpire) updateExpire(newExpire)
}) })
watch( watch(
polls, polls,
@ -93,7 +97,8 @@ export default defineComponent({
expire, expire,
expiresList, expiresList,
addPoll, addPoll,
removePoll removePoll,
updateExpire
} }
} }
}) })