refs #874 Set expire in poll form
This commit is contained in:
parent
7e1ca935de
commit
f71e902463
|
@ -223,7 +223,16 @@
|
||||||
"pined_hashtag": "Pin the hashtag"
|
"pined_hashtag": "Pin the hashtag"
|
||||||
},
|
},
|
||||||
"poll": {
|
"poll": {
|
||||||
"add_choice": "Add a choice"
|
"add_choice": "Add a choice",
|
||||||
|
"expires": {
|
||||||
|
"5_minutes": "5 minutes",
|
||||||
|
"30_minutes": "30 minutes",
|
||||||
|
"1_hour": "1 hour",
|
||||||
|
"6_hours": "6 hours",
|
||||||
|
"1_day": "1 day",
|
||||||
|
"3_days": "3 days",
|
||||||
|
"7_days": "7 days"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"jump": {
|
"jump": {
|
||||||
|
|
|
@ -14,7 +14,14 @@
|
||||||
</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" v-model="polls" @addPoll="addPoll" @removePoll="removePoll"></Poll>
|
<Poll
|
||||||
|
v-if="openPoll"
|
||||||
|
v-model="polls"
|
||||||
|
@addPoll="addPoll"
|
||||||
|
@removePoll="removePoll"
|
||||||
|
:defaultExpire="pollExpire"
|
||||||
|
@changeExpire="changeExpire"
|
||||||
|
></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" />
|
||||||
|
@ -142,7 +149,11 @@ export default {
|
||||||
showContentWarning: false,
|
showContentWarning: false,
|
||||||
visibilityList: Visibility,
|
visibilityList: Visibility,
|
||||||
openPoll: false,
|
openPoll: false,
|
||||||
polls: ['', '']
|
polls: ['', ''],
|
||||||
|
pollExpire: {
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.1_day'),
|
||||||
|
value: 3600 * 24
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -219,6 +230,10 @@ export default {
|
||||||
close() {
|
close() {
|
||||||
this.filteredAccount = []
|
this.filteredAccount = []
|
||||||
this.polls = ['', '']
|
this.polls = ['', '']
|
||||||
|
this.pollExpire = {
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.1_day'),
|
||||||
|
value: 3600 * 24
|
||||||
|
}
|
||||||
this.$store.dispatch('TimelineSpace/Modals/NewToot/resetMediaCount')
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/resetMediaCount')
|
||||||
this.$store.dispatch('TimelineSpace/Modals/NewToot/closeModal')
|
this.$store.dispatch('TimelineSpace/Modals/NewToot/closeModal')
|
||||||
},
|
},
|
||||||
|
@ -226,7 +241,8 @@ export default {
|
||||||
const form = {
|
const form = {
|
||||||
status: this.status,
|
status: this.status,
|
||||||
spoiler: this.spoiler,
|
spoiler: this.spoiler,
|
||||||
polls: this.polls
|
polls: this.polls,
|
||||||
|
pollExpireSeconds: this.pollExpire.value
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -344,6 +360,9 @@ export default {
|
||||||
},
|
},
|
||||||
removePoll(id) {
|
removePoll(id) {
|
||||||
this.polls.splice(id, 1)
|
this.polls.splice(id, 1)
|
||||||
|
},
|
||||||
|
changeExpire(obj) {
|
||||||
|
this.pollExpire = obj
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,54 @@
|
||||||
</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 v-model="expiresIn" size="small" value-key="value" @change="changeExpire">
|
||||||
|
<el-option v-for="exp in expires" :key="exp.value" :label="exp.label" :value="exp"> </el-option>
|
||||||
|
</el-select>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'poll',
|
name: 'poll',
|
||||||
props: ['value'],
|
props: ['value', 'defaultExpire'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
expires: [
|
||||||
|
{
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.5_minutes'),
|
||||||
|
value: 60 * 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.30_minutes'),
|
||||||
|
value: 60 * 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.1_hour'),
|
||||||
|
value: 3600
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.6_hours'),
|
||||||
|
value: 3600 * 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.1_day'),
|
||||||
|
value: 3600 * 24
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.3_days'),
|
||||||
|
value: 3600 * 24 * 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: this.$t('modals.new_toot.poll.expires.7_days'),
|
||||||
|
value: 3600 * 24 * 7
|
||||||
|
}
|
||||||
|
],
|
||||||
|
expiresIn: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.expiresIn = this.defaultExpire
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addPoll() {
|
addPoll() {
|
||||||
this.$emit('addPoll')
|
this.$emit('addPoll')
|
||||||
|
@ -26,6 +67,9 @@ export default {
|
||||||
updateOption(item, index) {
|
updateOption(item, index) {
|
||||||
const newValue = [...this.value.slice(0, index), item, ...this.value.slice(index + 1)]
|
const newValue = [...this.value.slice(0, index), item, ...this.value.slice(index + 1)]
|
||||||
this.$emit('input', newValue)
|
this.$emit('input', newValue)
|
||||||
|
},
|
||||||
|
changeExpire(exp) {
|
||||||
|
this.$emit('changeExpire', exp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ type TootForm = {
|
||||||
status: string
|
status: string
|
||||||
spoiler: string
|
spoiler: string
|
||||||
polls: Array<string>
|
polls: Array<string>
|
||||||
|
pollExpireSeconds: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NewTootState = {
|
export type NewTootState = {
|
||||||
|
@ -206,7 +207,7 @@ const actions: ActionTree<NewTootState, RootState> = {
|
||||||
sensitive: state.sensitive,
|
sensitive: state.sensitive,
|
||||||
spoiler_text: params.spoiler,
|
spoiler_text: params.spoiler,
|
||||||
poll: {
|
poll: {
|
||||||
expires_in: 86400,
|
expires_in: params.pollExpireSeconds,
|
||||||
multiple: false,
|
multiple: false,
|
||||||
options: params.polls
|
options: params.polls
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue