From 218f36c5c86b01e813c12f9f26f8fd711fe27f4f Mon Sep 17 00:00:00 2001 From: John Livingston Date: Mon, 6 May 2024 18:34:57 +0200 Subject: [PATCH] Task lists WIP: * front-end fixes --- conversejs/custom/plugins/tasks/muc-task-list-view.js | 7 ++++++- conversejs/custom/shared/lib/pubsub-manager.js | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/conversejs/custom/plugins/tasks/muc-task-list-view.js b/conversejs/custom/plugins/tasks/muc-task-list-view.js index 7aa12056..dc14ddf5 100644 --- a/conversejs/custom/plugins/tasks/muc-task-list-view.js +++ b/conversejs/custom/plugins/tasks/muc-task-list-view.js @@ -125,10 +125,15 @@ export default class MUCTaskListView extends CustomElement { }) await this.model.createTask({ - name + name, + description: ev.target.description.value.trim() }) this.closeAddTaskForm() + + // If the task list is collapsed, we must open it. + // Otherwise, the newly created task won't show up, and user could think that there is a bug. + if (this.collapsed) { this.collapsed = false } } catch (err) { console.error(err) } finally { diff --git a/conversejs/custom/shared/lib/pubsub-manager.js b/conversejs/custom/shared/lib/pubsub-manager.js index 4d83a340..5647f83c 100644 --- a/conversejs/custom/shared/lib/pubsub-manager.js +++ b/conversejs/custom/shared/lib/pubsub-manager.js @@ -109,10 +109,15 @@ export class PubSubManager { const data = {} for (const attr in (type.attributes ?? [])) { - data[attr] = item.get(attr) + const v = item.get(attr) + if (v === undefined) { continue } + if (type.attributes[attr] === Boolean && !v) { continue } + data[attr] = v } for (const field in (type.fields ?? [])) { - data[field] = item.get(field) + const v = item.get(field) + if (v === undefined) { continue } + data[field] = v } console.log('Saving item...')