diff --git a/src/components/TheDetails.vue b/src/components/TheDetails.vue
index 3e227f4e..7995fe57 100644
--- a/src/components/TheDetails.vue
+++ b/src/components/TheDetails.vue
@@ -88,7 +88,7 @@ License along with this library. If not, see .
:type="'date'" :placeholder="$t('tasks', 'Set start date')"
class="date" @change="setStartDate"
/>
- .
:type="'date'" :placeholder="$t('tasks', 'Set due date')"
class="date" @change="setDueDate"
/>
- .
class="checkbox"
name="isAllDayPossible"
:class="{'disabled': task.calendar.readOnly}"
- :aria-checked="task.allDay"
- :checked="task.allDay"
+ :aria-checked="allDay"
+ :checked="allDay"
:disabled="task.calendar.readOnly"
@click="toggleAllDay(task)"
>
@@ -433,10 +433,23 @@ export default {
}
},
computed: {
+ /**
+ * Whether the dates of a task are all-day
+ * When no dates are set, we consider the last used value.
+ *
+ * @returns {Boolean} Are the dates all-day
+ */
+ allDay: function() {
+ if (this.task.startMoment.isValid() || this.task.dueMoment.isValid()) {
+ return this.task.allDay
+ } else {
+ return this.$store.state.settings.settings.allDay
+ }
+ },
startDateString: function() {
const $t = this.$t
if (this.task.startMoment.isValid()) {
- if (this.task.allDay) {
+ if (this.allDay) {
return this.task.startMoment.calendar(null, {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets.
sameDay: this.$t('tasks', '[Starts today]'),
@@ -495,7 +508,7 @@ export default {
dueDateString: function() {
const $t = this.$t
if (this.task.dueMoment.isValid()) {
- if (this.task.allDay) {
+ if (this.allDay) {
return this.task.dueMoment.calendar(null, {
// TRANSLATORS This is a string for moment.js. The square brackets escape the string from moment.js. Please translate the string and keep the brackets.
sameDay: this.$t('tasks', '[Due today]'),
@@ -787,10 +800,10 @@ export default {
this.setPercentComplete({ task: this.task, complete: value })
break
case 'start':
- this.setStart({ task: this.task, start: value })
+ this.setStart({ task: this.task, start: value, allDay: this.allDay })
break
case 'due':
- this.setDue({ task: this.task, due: value })
+ this.setDue({ task: this.task, due: value, allDay: this.allDay })
break
}
this.edit = ''
@@ -809,7 +822,7 @@ export default {
if (due.isBefore(reference)) {
reference = due.subtract(1, 'm')
}
- reference.startOf(this.task.allDay ? 'day' : 'hour')
+ reference.startOf(this.allDay ? 'day' : 'hour')
return reference
}
return start
@@ -825,7 +838,7 @@ export default {
if (!due.isValid()) {
var start = this.task.startMoment
var reference = start.isAfter() ? start : moment()
- if (this.task.allDay) {
+ if (this.allDay) {
reference.startOf('day').add(1, 'd')
} else {
reference.startOf('hour').add(1, 'h')
diff --git a/src/models/task.js b/src/models/task.js
index 7a5e14c3..f5106913 100644
--- a/src/models/task.js
+++ b/src/models/task.js
@@ -405,6 +405,9 @@ export default class Task {
this.updateLastModified()
this._start = this.vtodo.getFirstPropertyValue('dtstart')
this._startMoment = moment(this._start, 'YYYYMMDDTHHmmss')
+ // Check all day setting
+ var d = this._due || this._start
+ this._allDay = d !== null && d.isDate
}
get startMoment() {
@@ -424,6 +427,9 @@ export default class Task {
this.updateLastModified()
this._due = this.vtodo.getFirstPropertyValue('due')
this._dueMoment = moment(this._due, 'YYYYMMDDTHHmmss')
+ // Check all day setting
+ var d = this._due || this._start
+ this._allDay = d !== null && d.isDate
}
get dueMoment() {
diff --git a/src/store/tasks.js b/src/store/tasks.js
index 389570a9..12758074 100644
--- a/src/store/tasks.js
+++ b/src/store/tasks.js
@@ -446,8 +446,9 @@ const mutations = {
* @param {Object} state The store data
* @param {Task} task The task
* @param {Moment} due The due date moment
+ * @param {Boolean} allDay Whether the date is all-day
*/
- setDue(state, { task, due }) {
+ setDue(state, { task, due, allDay }) {
if (due === null) {
// If the date is null, just set (remove) it.
Vue.set(task, 'due', due)
@@ -462,10 +463,10 @@ const mutations = {
} else {
start = due.clone()
}
- Vue.set(task, 'start', momentToICALTime(start, task.allDay))
+ Vue.set(task, 'start', momentToICALTime(start, allDay))
}
// Set the due date, convert it to ICALTime first.
- Vue.set(task, 'due', momentToICALTime(due, task.allDay))
+ Vue.set(task, 'due', momentToICALTime(due, allDay))
}
},
@@ -475,8 +476,9 @@ const mutations = {
* @param {Object} state The store data
* @param {Task} task The task
* @param {Moment} start The start date moment
+ * @param {Boolean} allDay Whether the date is all-day
*/
- setStart(state, { task, start }) {
+ setStart(state, { task, start, allDay }) {
if (start === null) {
// If the date is null, just set (remove) it.
Vue.set(task, 'start', start)
@@ -491,10 +493,10 @@ const mutations = {
} else {
due = start.clone()
}
- Vue.set(task, 'due', momentToICALTime(due, task.allDay))
+ Vue.set(task, 'due', momentToICALTime(due, allDay))
}
// Set the due date, convert it to ICALTime first.
- Vue.set(task, 'start', momentToICALTime(start, task.allDay))
+ Vue.set(task, 'start', momentToICALTime(start, allDay))
}
},
@@ -1008,8 +1010,8 @@ const actions = {
* @param {Object} context The store context
* @param {Task} task The task to update
*/
- async setDue(context, { task, due }) {
- context.commit('setDue', { task: task, due: due })
+ async setDue(context, { task, due, allDay }) {
+ context.commit('setDue', { task: task, due: due, allDay: allDay })
context.dispatch('scheduleTaskUpdate', task)
},
@@ -1019,8 +1021,8 @@ const actions = {
* @param {Object} context The store context
* @param {Task} task The task to update
*/
- async setStart(context, { task, start }) {
- context.commit('setStart', { task: task, start: start })
+ async setStart(context, { task, start, allDay }) {
+ context.commit('setStart', { task: task, start: start, allDay: allDay })
context.dispatch('scheduleTaskUpdate', task)
},