Remember last all-day setting for initial date
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
This commit is contained in:
parent
621c87b1b9
commit
38c1c5db4e
3 changed files with 41 additions and 20 deletions
|
@ -88,7 +88,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
:type="'date'" :placeholder="$t('tasks', 'Set start date')"
|
:type="'date'" :placeholder="$t('tasks', 'Set start date')"
|
||||||
class="date" @change="setStartDate"
|
class="date" @change="setStartDate"
|
||||||
/>
|
/>
|
||||||
<DatetimePicker v-if="!task.allDay" :value="tmpTask.start" :lang="lang"
|
<DatetimePicker v-if="!allDay" :value="tmpTask.start" :lang="lang"
|
||||||
:format="timeFormat" :clearable="false" :time-picker-options="timePickerOptions"
|
:format="timeFormat" :clearable="false" :time-picker-options="timePickerOptions"
|
||||||
:type="'time'" :placeholder="$t('tasks', 'Set start time')"
|
:type="'time'" :placeholder="$t('tasks', 'Set start time')"
|
||||||
class="time" @change="setStartTime"
|
class="time" @change="setStartTime"
|
||||||
|
@ -122,7 +122,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
:type="'date'" :placeholder="$t('tasks', 'Set due date')"
|
:type="'date'" :placeholder="$t('tasks', 'Set due date')"
|
||||||
class="date" @change="setDueDate"
|
class="date" @change="setDueDate"
|
||||||
/>
|
/>
|
||||||
<DatetimePicker v-if="!task.allDay" :value="tmpTask.due" :lang="lang"
|
<DatetimePicker v-if="!allDay" :value="tmpTask.due" :lang="lang"
|
||||||
:format="timeFormat" :clearable="false" :time-picker-options="timePickerOptions"
|
:format="timeFormat" :clearable="false" :time-picker-options="timePickerOptions"
|
||||||
:type="'time'" :placeholder="$t('tasks', 'Set due time')"
|
:type="'time'" :placeholder="$t('tasks', 'Set due time')"
|
||||||
class="time" @change="setDueTime"
|
class="time" @change="setDueTime"
|
||||||
|
@ -147,8 +147,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
class="checkbox"
|
class="checkbox"
|
||||||
name="isAllDayPossible"
|
name="isAllDayPossible"
|
||||||
:class="{'disabled': task.calendar.readOnly}"
|
:class="{'disabled': task.calendar.readOnly}"
|
||||||
:aria-checked="task.allDay"
|
:aria-checked="allDay"
|
||||||
:checked="task.allDay"
|
:checked="allDay"
|
||||||
:disabled="task.calendar.readOnly"
|
:disabled="task.calendar.readOnly"
|
||||||
@click="toggleAllDay(task)"
|
@click="toggleAllDay(task)"
|
||||||
>
|
>
|
||||||
|
@ -433,10 +433,23 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
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() {
|
startDateString: function() {
|
||||||
const $t = this.$t
|
const $t = this.$t
|
||||||
if (this.task.startMoment.isValid()) {
|
if (this.task.startMoment.isValid()) {
|
||||||
if (this.task.allDay) {
|
if (this.allDay) {
|
||||||
return this.task.startMoment.calendar(null, {
|
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.
|
// 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]'),
|
sameDay: this.$t('tasks', '[Starts today]'),
|
||||||
|
@ -495,7 +508,7 @@ export default {
|
||||||
dueDateString: function() {
|
dueDateString: function() {
|
||||||
const $t = this.$t
|
const $t = this.$t
|
||||||
if (this.task.dueMoment.isValid()) {
|
if (this.task.dueMoment.isValid()) {
|
||||||
if (this.task.allDay) {
|
if (this.allDay) {
|
||||||
return this.task.dueMoment.calendar(null, {
|
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.
|
// 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]'),
|
sameDay: this.$t('tasks', '[Due today]'),
|
||||||
|
@ -787,10 +800,10 @@ export default {
|
||||||
this.setPercentComplete({ task: this.task, complete: value })
|
this.setPercentComplete({ task: this.task, complete: value })
|
||||||
break
|
break
|
||||||
case 'start':
|
case 'start':
|
||||||
this.setStart({ task: this.task, start: value })
|
this.setStart({ task: this.task, start: value, allDay: this.allDay })
|
||||||
break
|
break
|
||||||
case 'due':
|
case 'due':
|
||||||
this.setDue({ task: this.task, due: value })
|
this.setDue({ task: this.task, due: value, allDay: this.allDay })
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
this.edit = ''
|
this.edit = ''
|
||||||
|
@ -809,7 +822,7 @@ export default {
|
||||||
if (due.isBefore(reference)) {
|
if (due.isBefore(reference)) {
|
||||||
reference = due.subtract(1, 'm')
|
reference = due.subtract(1, 'm')
|
||||||
}
|
}
|
||||||
reference.startOf(this.task.allDay ? 'day' : 'hour')
|
reference.startOf(this.allDay ? 'day' : 'hour')
|
||||||
return reference
|
return reference
|
||||||
}
|
}
|
||||||
return start
|
return start
|
||||||
|
@ -825,7 +838,7 @@ export default {
|
||||||
if (!due.isValid()) {
|
if (!due.isValid()) {
|
||||||
var start = this.task.startMoment
|
var start = this.task.startMoment
|
||||||
var reference = start.isAfter() ? start : moment()
|
var reference = start.isAfter() ? start : moment()
|
||||||
if (this.task.allDay) {
|
if (this.allDay) {
|
||||||
reference.startOf('day').add(1, 'd')
|
reference.startOf('day').add(1, 'd')
|
||||||
} else {
|
} else {
|
||||||
reference.startOf('hour').add(1, 'h')
|
reference.startOf('hour').add(1, 'h')
|
||||||
|
|
|
@ -405,6 +405,9 @@ export default class Task {
|
||||||
this.updateLastModified()
|
this.updateLastModified()
|
||||||
this._start = this.vtodo.getFirstPropertyValue('dtstart')
|
this._start = this.vtodo.getFirstPropertyValue('dtstart')
|
||||||
this._startMoment = moment(this._start, 'YYYYMMDDTHHmmss')
|
this._startMoment = moment(this._start, 'YYYYMMDDTHHmmss')
|
||||||
|
// Check all day setting
|
||||||
|
var d = this._due || this._start
|
||||||
|
this._allDay = d !== null && d.isDate
|
||||||
}
|
}
|
||||||
|
|
||||||
get startMoment() {
|
get startMoment() {
|
||||||
|
@ -424,6 +427,9 @@ export default class Task {
|
||||||
this.updateLastModified()
|
this.updateLastModified()
|
||||||
this._due = this.vtodo.getFirstPropertyValue('due')
|
this._due = this.vtodo.getFirstPropertyValue('due')
|
||||||
this._dueMoment = moment(this._due, 'YYYYMMDDTHHmmss')
|
this._dueMoment = moment(this._due, 'YYYYMMDDTHHmmss')
|
||||||
|
// Check all day setting
|
||||||
|
var d = this._due || this._start
|
||||||
|
this._allDay = d !== null && d.isDate
|
||||||
}
|
}
|
||||||
|
|
||||||
get dueMoment() {
|
get dueMoment() {
|
||||||
|
|
|
@ -446,8 +446,9 @@ const mutations = {
|
||||||
* @param {Object} state The store data
|
* @param {Object} state The store data
|
||||||
* @param {Task} task The task
|
* @param {Task} task The task
|
||||||
* @param {Moment} due The due date moment
|
* @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 (due === null) {
|
||||||
// If the date is null, just set (remove) it.
|
// If the date is null, just set (remove) it.
|
||||||
Vue.set(task, 'due', due)
|
Vue.set(task, 'due', due)
|
||||||
|
@ -462,10 +463,10 @@ const mutations = {
|
||||||
} else {
|
} else {
|
||||||
start = due.clone()
|
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.
|
// 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 {Object} state The store data
|
||||||
* @param {Task} task The task
|
* @param {Task} task The task
|
||||||
* @param {Moment} start The start date moment
|
* @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 (start === null) {
|
||||||
// If the date is null, just set (remove) it.
|
// If the date is null, just set (remove) it.
|
||||||
Vue.set(task, 'start', start)
|
Vue.set(task, 'start', start)
|
||||||
|
@ -491,10 +493,10 @@ const mutations = {
|
||||||
} else {
|
} else {
|
||||||
due = start.clone()
|
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.
|
// 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 {Object} context The store context
|
||||||
* @param {Task} task The task to update
|
* @param {Task} task The task to update
|
||||||
*/
|
*/
|
||||||
async setDue(context, { task, due }) {
|
async setDue(context, { task, due, allDay }) {
|
||||||
context.commit('setDue', { task: task, due: due })
|
context.commit('setDue', { task: task, due: due, allDay: allDay })
|
||||||
context.dispatch('scheduleTaskUpdate', task)
|
context.dispatch('scheduleTaskUpdate', task)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1019,8 +1021,8 @@ const actions = {
|
||||||
* @param {Object} context The store context
|
* @param {Object} context The store context
|
||||||
* @param {Task} task The task to update
|
* @param {Task} task The task to update
|
||||||
*/
|
*/
|
||||||
async setStart(context, { task, start }) {
|
async setStart(context, { task, start, allDay }) {
|
||||||
context.commit('setStart', { task: task, start: start })
|
context.commit('setStart', { task: task, start: start, allDay: allDay })
|
||||||
context.dispatch('scheduleTaskUpdate', task)
|
context.dispatch('scheduleTaskUpdate', task)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue