Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2021-01-24 15:16:16 +0300
committerdartcafe <github@dartcafe.de>2021-02-12 15:17:27 +0300
commit216778eebc9015c9a3a730e61907cf1f142189d8 (patch)
tree2de2844cf5f967eb970e7f60923c6ecfa9119ab3 /src/js/components/Options/OptionsDateAdd.vue
parentac22fbe40db9cc4e247c5755eae992d137a0804d (diff)
initit date poll with duration
Diffstat (limited to 'src/js/components/Options/OptionsDateAdd.vue')
-rw-r--r--src/js/components/Options/OptionsDateAdd.vue71
1 files changed, 55 insertions, 16 deletions
diff --git a/src/js/components/Options/OptionsDateAdd.vue b/src/js/components/Options/OptionsDateAdd.vue
index c95e25a3..006ef1ab 100644
--- a/src/js/components/Options/OptionsDateAdd.vue
+++ b/src/js/components/Options/OptionsDateAdd.vue
@@ -27,6 +27,11 @@
confirm
style="width: inherit;"
@change="addOption(lastOption)" />
+ <input id="useDuration"
+ v-model="useDuration"
+ type="checkbox"
+ class="checkbox">
+ <label for="useDuration"> {{ t('polls', 'With end date') }}</label>
</ConfigBox>
</template>
@@ -47,37 +52,71 @@ export default {
data() {
return {
lastOption: '',
+ useDuration: false,
}
},
computed: {
optionDatePicker() {
- return {
- editable: false,
- minuteStep: 5,
- type: 'datetime',
- format: moment.localeData().longDateFormat('L') + ' ' + moment.localeData().longDateFormat('LT'),
- placeholder: t('polls', 'Click to add a date'),
- confirm: true,
- lang: {
- formatLocale: {
- firstDayOfWeek: this.firstDOW,
- months: moment.months(),
- monthsShort: moment.monthsShort(),
- weekdays: moment.weekdays(),
- weekdaysMin: moment.weekdaysMin(),
+ if (this.useDuration) {
+ return {
+ editable: false,
+ minuteStep: 5,
+ type: 'datetime',
+ range: true,
+ format: moment.localeData().longDateFormat('L') + ' ' + moment.localeData().longDateFormat('LT'),
+ placeholder: t('polls', 'Click to add a date'),
+ confirm: true,
+ lang: {
+ formatLocale: {
+ firstDayOfWeek: this.firstDOW,
+ months: moment.months(),
+ monthsShort: moment.monthsShort(),
+ weekdays: moment.weekdays(),
+ weekdaysMin: moment.weekdaysMin(),
+ },
},
- },
+ }
+
+ } else {
+ return {
+ editable: false,
+ minuteStep: 5,
+ type: 'datetime',
+ format: moment.localeData().longDateFormat('L') + ' ' + moment.localeData().longDateFormat('LT'),
+ placeholder: t('polls', 'Click to add a date'),
+ confirm: true,
+ lang: {
+ formatLocale: {
+ firstDayOfWeek: this.firstDOW,
+ months: moment.months(),
+ monthsShort: moment.monthsShort(),
+ weekdays: moment.weekdays(),
+ weekdaysMin: moment.weekdaysMin(),
+ },
+ },
+ }
}
},
},
methods: {
- addOption(pollOptionText) {
+ addOption(dateOption) {
+ let pollOptionText = ''
+ let duration = 0
+ if (this.useDuration) {
+ pollOptionText = dateOption[0]
+ duration = moment(dateOption[1]).diff(moment(dateOption[0]), 'seconds')
+ } else {
+ pollOptionText = dateOption
+ duration = 0
+ }
+
if (moment(pollOptionText).isValid()) {
this.$store.dispatch('poll/options/add', {
pollOptionText: pollOptionText,
timestamp: moment(pollOptionText).unix(),
+ duration: duration,
})
}
},