Merge pull request #1510 from nextcloud/fix/noid/clear-status

Allow to remove status property
This commit is contained in:
Raimund Schlüßler 2021-04-19 21:59:59 +02:00 committed by GitHub
commit 771c79a9cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -336,14 +336,18 @@ export default class Task {
} else if (this.complete === 0) {
this.setComplete(1)
}
} else if (status === 'NEEDS-ACTION') {
} else if (status === 'NEEDS-ACTION' || status === null) {
this.setComplete(0)
this.setCompleted(false)
}
}
setStatus(status) {
this.vtodo.updatePropertyWithValue('status', status)
if (status === null) {
this.vtodo.removeProperty('status')
} else {
this.vtodo.updatePropertyWithValue('status', status)
}
this.updateLastModified()
this._status = this.vtodo.getFirstPropertyValue('status')
}

View File

@ -204,4 +204,12 @@ describe('task', () => {
task.categories = []
expect(task.categories.length).toEqual(0)
})
it('Should remove status property when set to null', () => {
const task = new Task(loadICS('vcalendars/vcalendar-default'), {})
task.status = null
// Check that status gets removed instead of being set to zero
const complete = task.vtodo.getFirstPropertyValue('status')
expect(complete).toEqual(null)
})
})