summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2020-10-18 15:52:34 +0900
committersyuilo <syuilotan@yahoo.co.jp>2020-10-18 15:52:34 +0900
commit87edeb41da2d1d1a4111864f92c1097e0b496dbf (patch)
tree89fbe8939115c0efe00cd6e5758f32827fd972a1 /src/client
parentClean up (diff)
downloadsharkey-87edeb41da2d1d1a4111864f92c1097e0b496dbf.tar.gz
sharkey-87edeb41da2d1d1a4111864f92c1097e0b496dbf.tar.bz2
sharkey-87edeb41da2d1d1a4111864f92c1097e0b496dbf.zip
Fix poll editor bug
Diffstat (limited to 'src/client')
-rw-r--r--src/client/components/poll-editor.vue43
1 files changed, 20 insertions, 23 deletions
diff --git a/src/client/components/poll-editor.vue b/src/client/components/poll-editor.vue
index 5b615677dc..8d7e163878 100644
--- a/src/client/components/poll-editor.vue
+++ b/src/client/components/poll-editor.vue
@@ -57,7 +57,6 @@ import MkInput from './ui/input.vue';
import MkSelect from './ui/select.vue';
import MkSwitch from './ui/switch.vue';
import MkButton from './ui/button.vue';
-import * as os from '@/os';
export default defineComponent({
components: {
@@ -78,8 +77,8 @@ export default defineComponent({
data() {
return {
- choices: ['', ''],
- multiple: false,
+ choices: this.poll.choices,
+ multiple: this.poll.multiple,
expiration: 'infinite',
atDate: formatDateTimeString(addTime(new Date(), 1, 'day'), 'yyyy-MM-dd'),
atTime: '00:00',
@@ -90,26 +89,6 @@ export default defineComponent({
},
watch: {
- poll: {
- handler(poll) {
- if (poll == null) return;
- if (poll.choices.length == 0) return;
- this.choices = poll.choices;
- if (poll.choices.length == 1) this.choices = this.choices.concat('');
- this.multiple = poll.multiple;
- if (poll.expiresAt) {
- this.expiration = 'at';
- this.atDate = this.atTime = poll.expiresAt;
- } else if (typeof poll.expiredAfter === 'number') {
- this.expiration = 'after';
- this.after = poll.expiredAfter;
- } else {
- this.expiration = 'infinite';
- }
- },
- deep: true,
- immediate: true
- },
choices: {
handler() {
this.$emit('updated', this.get());
@@ -136,6 +115,24 @@ export default defineComponent({
this.$emit('updated', this.get());
},
},
+ unit: {
+ handler() {
+ this.$emit('updated', this.get());
+ },
+ },
+ },
+
+ created() {
+ const poll = this.poll;
+ if (poll.expiresAt) {
+ this.expiration = 'at';
+ this.atDate = this.atTime = poll.expiresAt;
+ } else if (typeof poll.expiredAfter === 'number') {
+ this.expiration = 'after';
+ this.after = poll.expiredAfter / 1000;
+ } else {
+ this.expiration = 'infinite';
+ }
},
methods: {