summaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-09-03 15:41:06 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-09-03 15:42:44 +0200
commit285104379b3b1415e3cf814749720e5219fb15ea (patch)
treece8a662b5552d9a8e4e22775f038f78198c78473 /src/components
parent5a1b11179d9f0b82d93ff2108751d203aa96556e (diff)
Use checkbox for omit year action
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Actions/ActionToggleYear.vue44
1 files changed, 15 insertions, 29 deletions
diff --git a/src/components/Actions/ActionToggleYear.vue b/src/components/Actions/ActionToggleYear.vue
index 2e43310d..9c204fbd 100644
--- a/src/components/Actions/ActionToggleYear.vue
+++ b/src/components/Actions/ActionToggleYear.vue
@@ -21,18 +21,19 @@
-->
<template>
- <ActionButton :icon="icon" @click="toggleYear">
- {{ omitYear ? t('contacts', 'Add year') : t('contacts', 'Omit year') }}
- </ActionButton>
+ <ActionCheckbox :checked="omitYear"
+ @check="removeYear" @uncheck="addYear">
+ {{ t('contacts', 'Omit year') }}
+ </ActionCheckbox>
</template>
<script>
-import { ActionButton } from 'nextcloud-vue'
+import { ActionCheckbox } from 'nextcloud-vue'
import ActionsMixin from 'Mixins/ActionsMixin'
export default {
name: 'ActionToggleYear',
components: {
- ActionButton
+ ActionCheckbox
},
mixins: [ActionsMixin],
data() {
@@ -41,37 +42,18 @@ export default {
}
},
- computed: {
- icon() {
- return this.omitYear
- ? 'icon-calendar-dark'
- : 'icon-no-calendar'
- },
- text() {
- return this.omitYear
- ? t('contacts', 'Add year')
- : t('contacts', 'Omit year')
- }
- },
-
beforeMount() {
this.omitYear = !!this.component.property.getFirstParameter('x-apple-omit-year')
|| !this.component.value.year // if null
},
methods: {
- toggleYear() {
+ removeYear() {
const dateObject = this.component.localValue.toJSON()
- // year was already ignored: adding it back
- if (this.omitYear) {
- this.$nextTick(() => {
- this.component.updateValue(dateObject, true)
- })
-
- } else if (this.component.localContact.version === '4.0') {
- // year was already displayed: removing it
- // and use --0124 format
+ // year was already displayed: removing it
+ // and use --0124 format
+ if (this.component.localContact.version === '4.0') {
dateObject.year = null
this.component.updateValue(dateObject)
} else {
@@ -85,7 +67,11 @@ export default {
})
}
}
-
+ this.omitYear = !this.omitYear
+ },
+ addYear() {
+ const dateObject = this.component.localValue.toJSON()
+ this.component.updateValue(dateObject, true)
this.omitYear = !this.omitYear
}
}