diff options
-rw-r--r-- | src/components/Properties/PropertyDateTime.vue | 15 | ||||
-rw-r--r-- | src/models/rfcProps.js | 8 |
2 files changed, 16 insertions, 7 deletions
diff --git a/src/components/Properties/PropertyDateTime.vue b/src/components/Properties/PropertyDateTime.vue index ee341841..bfabf397 100644 --- a/src/components/Properties/PropertyDateTime.vue +++ b/src/components/Properties/PropertyDateTime.vue @@ -148,7 +148,13 @@ export default { * Debounce and send update event to parent */ updateValue: debounce(function(e) { - let rawData = moment(e).toArray() + const objMap = ['year', 'month', 'day', 'hour', 'minute', 'second'] + let rawArray = moment(e).toArray() + + const rawObject = rawArray.reduce((acc, cur, index) => { + acc[objMap[index]] = cur + return acc + }, {}) /** * Use the current year to ensure we do not lose @@ -156,9 +162,10 @@ export default { * no options to remove the year selection. * ! using this.value since this.localValue reflect the current change * ! so we need to make sure we do not use the updated data + * TODO: add option to omit year and not use already existing data */ if (this.value.year === null) { - rawData[0] = null + rawObject.year = null } /** @@ -167,10 +174,10 @@ export default { * ! since we use moment to generate our time array * ! we need to make sure the conversion to VCardTime is done well */ - rawData[1]++ + rawObject.month++ // reset the VCardTime component to the selected date/time - this.localValue.resetTo(...rawData) + this.localValue = new VCardTime(rawObject, null, this.propType) // https://vuejs.org/v2/guide/components-custom-events.html#sync-Modifier // Use moment to convert the JsDate to Object diff --git a/src/models/rfcProps.js b/src/models/rfcProps.js index c9b91c16..7daf6f12 100644 --- a/src/models/rfcProps.js +++ b/src/models/rfcProps.js @@ -112,14 +112,16 @@ const properties = component => ({ icon: 'icon-calendar-dark', force: 'date', // most ppl prefer date for birthdays, time is usually irrelevant defaultValue: { - value: new VCardTime().fromJSDate(new Date()) + value: new VCardTime(null, null, 'date').fromJSDate(new Date()) } }, anniversary: { readableName: t('contacts', 'Anniversary'), + info: t('contacts', 'The date of marriage, or equivalent, of this contact'), icon: 'icon-calendar-dark', + force: 'date', // most ppl prefer date for birthdays, time is usually irrelevant defaultValue: { - value: new VCardTime().fromJSDate(new Date()) + value: new VCardTime(null, null, 'date').fromJSDate(new Date()) } }, deathdate: { @@ -127,7 +129,7 @@ const properties = component => ({ icon: 'icon-calendar-dark', force: 'date', // most ppl prefer date for birthdays, time is usually irrelevant defaultValue: { - value: new VCardTime().fromJSDate(new Date()) + value: new VCardTime(null, null, 'date').fromJSDate(new Date()) } }, email: { |