diff options
author | René Gieling <github@dartcafe.de> | 2022-04-27 23:36:25 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-27 23:36:25 +0300 |
commit | c6c511d3e0c0c673324632edaad2862dae1b41cf (patch) | |
tree | bb44e9fbf2b9670ac0b77d12e9c6eff6695002b5 /src | |
parent | 7dd24332fd65050e825ea9e391c1154bc3907357 (diff) | |
parent | 9c665a5f075f3bf5dc2e85ab3d9fb3d042866f79 (diff) |
Merge pull request #2390 from nextcloud/ref/add-validators
Refactoring
Diffstat (limited to 'src')
-rw-r--r-- | src/js/components/Base/RadioGroupDiv.vue | 14 | ||||
-rw-r--r-- | src/js/components/Combo/ComboTable.vue | 3 | ||||
-rw-r--r-- | src/js/components/Options/OptionItem.vue | 56 | ||||
-rw-r--r-- | src/js/components/User/UserItem.vue | 15 | ||||
-rw-r--r-- | src/js/components/VoteTable/VoteTable.vue | 3 |
5 files changed, 64 insertions, 27 deletions
diff --git a/src/js/components/Base/RadioGroupDiv.vue b/src/js/components/Base/RadioGroupDiv.vue index 8e876b44..bb8de9e1 100644 --- a/src/js/components/Base/RadioGroupDiv.vue +++ b/src/js/components/Base/RadioGroupDiv.vue @@ -24,8 +24,9 @@ <div class="radio-group-div"> <CheckboxRadioSwitch v-for="(option, index) in options" :key="option.value" + :checked.sync="selectedValue" + :value="option.value" :name="id + '_' + index" - :checked="option.value === value" type="radio" @update:checked="$emit('input', option.value)"> {{ option.label }} @@ -59,5 +60,16 @@ export default { default: null, }, }, + + computed: { + selectedValue: { + get() { + return this.value + }, + set(value) { + this.$emit('input', value) + }, + }, + }, } </script> diff --git a/src/js/components/Combo/ComboTable.vue b/src/js/components/Combo/ComboTable.vue index a85dda92..3d3fdf8b 100644 --- a/src/js/components/Combo/ComboTable.vue +++ b/src/js/components/Combo/ComboTable.vue @@ -58,6 +58,9 @@ export default { viewMode: { type: String, default: 'table-view', + validator(value) { + return ['table-view', 'list-view'].includes(value) + }, }, }, diff --git a/src/js/components/Options/OptionItem.vue b/src/js/components/Options/OptionItem.vue index de51ec15..27bffef8 100644 --- a/src/js/components/Options/OptionItem.vue +++ b/src/js/components/Options/OptionItem.vue @@ -30,41 +30,39 @@ <div v-if="show === 'textBox'" v-tooltip.auto="optionTooltip" class="option-item__option--text" - v-html="optionText"> - {{ optionText }} - </div> + v-html="optionText" /> <!-- eslint-enable vue/no-v-html --> <div v-if="show === 'dateBox'" v-tooltip.auto="dateLocalFormatUTC" class="option-item__option--datebox"> <div class="event-date"> <div class="event-from"> <div class="month"> - {{ event.from.month }} + {{ eventOption.from.month }} </div> <div class="day"> - {{ event.from.dow }} {{ event.from.day }} + {{ eventOption.from.dow }} {{ eventOption.from.day }} </div> - <div v-if="!event.dayLong" class="time"> - {{ event.from.time }} - <span v-if="!event.dayLong && option.duration && event.to.sameDay"> - - {{ event.to.time }} + <div v-if="!eventOption.dayLong" class="time"> + {{ eventOption.from.time }} + <span v-if="!eventOption.dayLong && option.duration && eventOption.to.sameDay"> + - {{ eventOption.to.time }} </span> </div> </div> - <div v-if="option.duration && !event.to.sameDay" class="devider"> + <div v-if="option.duration && !eventOption.to.sameDay" class="devider"> - </div> - <div v-if="option.duration && !event.to.sameDay" class="event-to"> + <div v-if="option.duration && !eventOption.to.sameDay" class="event-to"> <div class="month"> - {{ event.to.month }} + {{ eventOption.to.month }} </div> <div class="day"> - {{ event.to.dow }} {{ event.to.day }} + {{ eventOption.to.dow }} {{ eventOption.to.day }} </div> - <div v-if="!event.dayLong" class="time"> - {{ event.to.time }} + <div v-if="!eventOption.dayLong" class="time"> + {{ eventOption.to.time }} </div> </div> </div> @@ -102,10 +100,16 @@ export default { display: { type: String, default: 'textBox', + validator(value) { + return ['textBox', 'dateBox'].includes(value) + }, }, pollType: { type: String, default: 'textPoll', + validator(value) { + return ['textPoll', 'datePoll'].includes(value) + }, }, }, @@ -114,7 +118,7 @@ export default { return this.draggable }, - event() { + eventOption() { const from = moment.unix(this.option.timestamp) const to = moment.unix(this.option.timestamp + Math.max(0, this.option.duration)) // does the event start at 00:00 local time and @@ -162,30 +166,30 @@ export default { } if (this.option.duration === 0) { - return this.event.from.dateTime + return this.eventOption.from.dateTime } - if (this.event.dayLong && this.event.to.sameDay) { - return this.event.from.date + if (this.eventOption.dayLong && this.eventOption.to.sameDay) { + return this.eventOption.from.date } - if (this.event.dayLong && !this.event.to.sameDay) { - return `${this.event.from.date} - ${this.event.to.date}` + if (this.eventOption.dayLong && !this.eventOption.to.sameDay) { + return `${this.eventOption.from.date} - ${this.eventOption.to.date}` } - if (this.event.to.sameDay) { - return `${this.event.from.dateTime} - ${this.event.to.time}` + if (this.eventOption.to.sameDay) { + return `${this.eventOption.from.dateTime} - ${this.eventOption.to.time}` } - return `${this.event.from.dateTime} - ${this.event.to.dateTime}` + return `${this.eventOption.from.dateTime} - ${this.eventOption.to.dateTime}` }, dateLocalFormatUTC() { if (this.option.duration) { - return `${this.event.from.utc} - ${this.event.to.utc} UTC` + return `${this.eventOption.from.utc} - ${this.eventOption.to.utc} UTC` } - return `${this.event.from.utc} UTC` + return `${this.eventOption.from.utc} UTC` }, optionTooltip() { diff --git a/src/js/components/User/UserItem.vue b/src/js/components/User/UserItem.vue index 4ca590ee..2e7b9e22 100644 --- a/src/js/components/User/UserItem.vue +++ b/src/js/components/User/UserItem.vue @@ -111,6 +111,21 @@ export default { type: { type: String, default: 'user', + validator(value) { + return [ + 'public', + 'internalAccess', + 'user', + 'admin', + 'group', + 'contact', + 'contactGroup', + 'circle', + 'external', + 'email', + ].includes(value) + }, + }, isNoUser: { type: Boolean, diff --git a/src/js/components/VoteTable/VoteTable.vue b/src/js/components/VoteTable/VoteTable.vue index 16ae5191..375f67f5 100644 --- a/src/js/components/VoteTable/VoteTable.vue +++ b/src/js/components/VoteTable/VoteTable.vue @@ -73,6 +73,9 @@ export default { viewMode: { type: String, default: 'table-view', + validator(value) { + return ['table-view', 'list-view'].includes(value) + }, }, }, |