86 lines
3.1 KiB
JavaScript
Raw Normal View History

2024-05-23 11:42:14 +02:00
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
//
// SPDX-License-Identifier: AGPL-3.0-only
// FIXME: @stylistic/indent is buggy with strings literrals.
/* eslint-disable @stylistic/indent */
2024-04-30 17:11:10 +02:00
import { html } from 'lit'
2024-04-30 18:30:44 +02:00
import { repeat } from 'lit/directives/repeat.js'
2024-05-06 00:13:20 +02:00
import { __ } from 'i18n'
2024-05-06 15:57:42 +02:00
import { tplMucAddTaskForm } from './muc-task'
2024-04-30 17:11:10 +02:00
2024-05-06 00:13:20 +02:00
export default function tplMucTaskList (el, tasklist) {
2024-04-30 18:30:44 +02:00
const tasks = tasklist.getTasks()
2024-05-06 00:13:20 +02:00
// eslint-disable-next-line no-undef
const i18nDelete = __(LOC_task_list_delete)
2024-05-06 15:57:42 +02:00
// eslint-disable-next-line no-undef
const i18nCreateTask = __(LOC_task_create)
// eslint-disable-next-line no-undef
const i18nTaskListName = __(LOC_task_list_name)
2024-04-30 18:30:44 +02:00
return html`
<div class="task-list-line draggables-line">
${el.collapsed
? html`
<button type="button" @click=${el.toggleTasks} class="task-list-toggle-tasks">
<converse-icon
color="var(--muc-toolbar-btn-color)"
2024-05-07 09:16:16 +02:00
class="fa fa-angle-right"
size="1em"></converse-icon>
</button>`
: html`
<button type="button" @click=${el.toggleTasks} class="task-list-toggle-tasks">
<converse-icon
color="var(--muc-toolbar-btn-color)"
2024-05-07 09:16:16 +02:00
class="fa fa-angle-down"
size="1em"></converse-icon>
</button>`
}
${!el.edit
? html`
<div class="task-list-name">
2024-12-10 11:25:33 +01:00
<a @click=${el.toggleTasks}><label>${tasklist.get('name')}</label></a>
</div>
<button type="button" class="task-list-action" title="${i18nCreateTask}" @click=${el.openAddTaskForm}>
2024-05-06 15:57:42 +02:00
<converse-icon class="fa fa-plus" size="1em"></converse-icon>
</button>
<button type="button" class="task-list-action" title="${__('Edit')}"
@click=${el.toggleEdit}
>
<converse-icon class="fa fa-edit" size="1em"></converse-icon>
2024-05-06 15:57:42 +02:00
</button>
<button type="button" class="task-list-action" title="${i18nDelete}"
@click=${el.deleteTaskList}
>
<converse-icon class="fa fa-trash-alt" size="1em"></converse-icon>
2024-05-06 15:57:42 +02:00
</button>`
: html`
<div class="task-list-name">
2024-05-06 15:57:42 +02:00
<form @submit=${el.saveTaskList} class="converse-form">
<input type="text" name="name"
placeholder="${__(i18nTaskListName)}"
class="form-control"
value="${tasklist.get('name')}"
/>
<input type="submit" class="btn btn-primary" value="${__('Ok')}" />
2024-05-06 15:57:42 +02:00
<input type="button" class="btn btn-secondary button-cancel"
value="${__('Cancel')}" @click=${el.toggleEdit}
/>
</form>
</div>`
}
2024-04-30 18:30:44 +02:00
</div>
<div class="task-list-tasks">
${el.collapsed
? ''
: repeat(tasks, (task) => task.get('id'), (task) => {
2024-05-09 13:54:42 +02:00
return html`<livechat-converse-muc-task .model=${task}></livechat-converse-muc-task>`
2024-04-30 18:30:44 +02:00
})
}
2024-05-06 15:57:42 +02:00
</div>
${!el.add_task_form_opened
? ''
: tplMucAddTaskForm(el, tasklist)
}`
2024-04-30 17:11:10 +02:00
}