Task lists WIP:

* new icon for the task app
* create task message action
This commit is contained in:
John Livingston
2024-05-12 18:45:51 +02:00
parent 31a95f774d
commit ac47e6314f
7 changed files with 147 additions and 10 deletions

View File

@ -25,13 +25,45 @@ export function getHeadingButtons (view, buttons) {
taskAppEl.toggleApp()
},
a_class: '',
icon_class: 'fa-list', // FIXME
icon_class: 'fa-list-check',
name: 'muc-tasks'
})
return buttons
}
export function getMessageActionButtons (messageActionsEl, buttons) {
const messageModel = messageActionsEl.model
if (messageModel.get('type') !== 'groupchat') {
// only on groupchat message.
return buttons
}
const muc = messageModel.collection?.chatbox
if (!muc?.tasklists) {
return buttons
}
// eslint-disable-next-line no-undef
const i18nCreate = __(LOC_task_create)
buttons.push({
i18n_text: i18nCreate,
handler: async (ev) => {
ev.preventDefault()
api.modal.show('livechat-converse-pick-task-list-modal', {
muc,
message: messageModel
}, ev)
},
button_class: '',
icon_class: 'fa fa-list-check',
name: 'muc-task-create-from-message'
})
return buttons
}
function _initChatRoomTaskLists (mucModel) {
if (mucModel.taskManager) {
// already initiliazed
@ -70,6 +102,10 @@ function _initChatRoomTaskLists (mucModel) {
}
)
mucModel.taskManager.start().catch(err => console.log(err))
// We must requestUpdate for all message actions, to add the "create task" button.
// FIXME: this should not be done here (but it is simplier for now)
document.querySelectorAll('converse-message-actions').forEach(el => el.requestUpdate())
}
function _destroyChatRoomTaskLists (mucModel) {
@ -81,6 +117,10 @@ function _destroyChatRoomTaskLists (mucModel) {
// mucModel.tasklists.unload() FIXME: add a method to unregister from the pubsub, and empty the tasklist.
mucModel.tasklists = undefined
mucModel.tasks = undefined
// We must requestUpdate for all message actions, to remove the "create task" button.
// FIXME: this should not be done here (but it is simplier for now)
document.querySelectorAll('converse-message-actions').forEach(el => el.requestUpdate())
}
export function initOrDestroyChatRoomTaskLists (mucModel) {