mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-24 07:00:49 +08:00
Compare commits
6 Commits
codex/add-
...
codex/modi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5814fb673a | ||
|
|
4ee4266e3d | ||
|
|
6a27fbe1d7 | ||
|
|
38ff04c358 | ||
|
|
fc27200ac1 | ||
|
|
eefefac236 |
@@ -111,7 +111,7 @@ public class PostMapper {
|
|||||||
.collect(Collectors.groupingBy(PollVote::getOptionIndex,
|
.collect(Collectors.groupingBy(PollVote::getOptionIndex,
|
||||||
Collectors.mapping(v -> userMapper.toAuthorDto(v.getUser()), Collectors.toList())));
|
Collectors.mapping(v -> userMapper.toAuthorDto(v.getUser()), Collectors.toList())));
|
||||||
p.setOptionParticipants(optionParticipants);
|
p.setOptionParticipants(optionParticipants);
|
||||||
p.setMultiple(pp.isMultiple());
|
p.setMultiple(Boolean.TRUE.equals(pp.getMultiple()));
|
||||||
dto.setPoll(p);
|
dto.setPoll(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class PollPost extends Post {
|
|||||||
private Set<User> participants = new HashSet<>();
|
private Set<User> participants = new HashSet<>();
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
private boolean multiple = false;
|
private Boolean multiple = false;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
private LocalDateTime endTime;
|
private LocalDateTime endTime;
|
||||||
|
|||||||
@@ -19,10 +19,8 @@
|
|||||||
</client-only>
|
</client-only>
|
||||||
</div>
|
</div>
|
||||||
<div class="poll-multiple-row">
|
<div class="poll-multiple-row">
|
||||||
<label class="poll-row-title">
|
<span class="poll-row-title">多选</span>
|
||||||
<input type="checkbox" v-model="data.multiple" class="multiple-checkbox" />
|
<BaseSwitch v-model="data.multiple" />
|
||||||
多选
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -31,6 +29,7 @@
|
|||||||
import 'flatpickr/dist/flatpickr.css'
|
import 'flatpickr/dist/flatpickr.css'
|
||||||
import FlatPickr from 'vue-flatpickr-component'
|
import FlatPickr from 'vue-flatpickr-component'
|
||||||
import BaseInput from '~/components/BaseInput.vue'
|
import BaseInput from '~/components/BaseInput.vue'
|
||||||
|
import BaseSwitch from '~/components/BaseSwitch.vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
data: {
|
data: {
|
||||||
@@ -89,9 +88,7 @@ const removeOption = (idx) => {
|
|||||||
.poll-multiple-row {
|
.poll-multiple-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
gap: 10px;
|
||||||
.multiple-checkbox {
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
}
|
||||||
.time-picker {
|
.time-picker {
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
|
|||||||
@@ -59,11 +59,26 @@
|
|||||||
v-for="(opt, idx) in poll.options"
|
v-for="(opt, idx) in poll.options"
|
||||||
:key="idx"
|
:key="idx"
|
||||||
class="poll-option"
|
class="poll-option"
|
||||||
@click="voteOption(idx)"
|
@click="selectOption(idx)"
|
||||||
>
|
>
|
||||||
<input type="radio" :checked="false" name="poll-option" class="poll-option-input" />
|
<input
|
||||||
|
type="radio"
|
||||||
|
:checked="selectedOption === idx"
|
||||||
|
name="poll-option"
|
||||||
|
class="poll-option-input"
|
||||||
|
/>
|
||||||
<span class="poll-option-text">{{ opt }}</span>
|
<span class="poll-option-text">{{ opt }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="single-selection-container">
|
||||||
|
<div class="single-selection-title">
|
||||||
|
<i class="fas fa-info-circle info-icon"></i>
|
||||||
|
该投票为单选
|
||||||
|
</div>
|
||||||
|
<div class="join-poll-button" @click="submitSinglePoll">
|
||||||
|
<i class="fas fa-plus"></i> 加入投票
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -198,6 +213,18 @@ const voteOption = async (idx) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const selectedOption = ref(null)
|
||||||
|
const selectOption = (idx) => {
|
||||||
|
selectedOption.value = idx
|
||||||
|
}
|
||||||
|
const submitSinglePoll = async () => {
|
||||||
|
if (selectedOption.value === null) {
|
||||||
|
toast.error('请选择一个选项')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await voteOption(selectedOption.value)
|
||||||
|
}
|
||||||
|
|
||||||
const selectedOptions = ref([])
|
const selectedOptions = ref([])
|
||||||
const toggleOption = (idx) => {
|
const toggleOption = (idx) => {
|
||||||
const i = selectedOptions.value.indexOf(idx)
|
const i = selectedOptions.value.indexOf(idx)
|
||||||
@@ -368,14 +395,16 @@ const submitMultiPoll = async () => {
|
|||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.multi-selection-container {
|
.multi-selection-container,
|
||||||
|
.single-selection-container {
|
||||||
padding: 20px 15px 20px 5px;
|
padding: 20px 15px 20px 5px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.multi-selection-title {
|
.multi-selection-title,
|
||||||
|
.single-selection-title {
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user