Task lists WIP:

* front-end
This commit is contained in:
John Livingston
2024-05-06 15:57:42 +02:00
parent 9d5d59e9bc
commit 964b8854f6
11 changed files with 155 additions and 19 deletions

View File

@ -23,7 +23,27 @@ class ChatRoomTaskList extends Model {
}
async deleteItem () {
return this.collection.chatroom.taskManager.deleteItem(this)
const tasks = this.getTasks()
return this.collection.chatroom.taskManager.deleteItems([...tasks, this])
}
async createTask (data) {
// Cloning data to avoid side effects:
data = Object.assign({}, data)
const name = data?.name
if (!name) { throw new Error('Missing name') }
data.list = this.get('id')
if (!data.order) {
data.order = 1 + Math.max(...this.getTasks().map(t => t.get('order') ?? 0))
}
console.log('Creating task ' + name + '...')
const chatroom = this.collection.chatroom
const tasksCollection = chatroom.tasks
await chatroom.taskManager.createItem(tasksCollection, data)
console.log('Task list ' + name + ' created.')
}
}