Implement calculating the manual sort order

Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
This commit is contained in:
Raimund Schlüßler 2019-01-27 07:24:23 +01:00
parent 26b6379918
commit 09245a16b6
No known key found for this signature in database
GPG key ID: 036FA7EB1A599178

View file

@ -105,6 +105,22 @@ export default class Task {
this._created = this.vtodo.getFirstPropertyValue('created')
this._class = this.vtodo.getFirstPropertyValue('class') || 'PUBLIC'
let sortOrder = this.vtodo.getFirstPropertyValue('x-apple-sort-order')
if (sortOrder === null) {
sortOrder = this._created.subtractDate(
new ICAL.Time({
year: 2001,
month: 1,
day: 1,
hour: 0,
minute: 0,
second: 0,
isDate: false
})
).toSeconds()
}
this._sortOrder = sortOrder
this._searchQuery = ''
this._matchesSearchQuery = true
}
@ -465,6 +481,29 @@ export default class Task {
this._class = this.vtodo.getFirstPropertyValue('class') || 'PUBLIC'
}
get sortOrder() {
return this._sortOrder
}
set sortOrder(sortOrder) {
if (sortOrder === null) {
sortOrder = this._created.subtractDate(
new ICAL.Time({
year: 2001,
month: 1,
day: 1,
hour: 0,
minute: 0,
second: 0,
isDate: false
})
).toSeconds()
}
this.vtodo.updatePropertyWithValue('x-apple-sort-order', sortOrder)
this.updateLastModified()
this._sortOrder = sortOrder
}
/**
* Checks if the task matches the search query
*