Moderator notes WIP (#144)

This commit is contained in:
John Livingston
2024-07-30 18:36:53 +02:00
parent 31c4e5a646
commit 704e660f37
11 changed files with 164 additions and 21 deletions

View File

@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
//
// SPDX-License-Identifier: AGPL-3.0-only
import { CustomElement } from 'shared/components/element.js'
import { tplMucNoteOccupant } from '../templates/muc-note-occupant'
import { api } from '@converse/headless'
import '../styles/muc-note-occupant.scss'
export default class MUCNoteOccupantView extends CustomElement {
static get properties () {
return {
model: { type: Object, attribute: true },
full_display: { type: Boolean, attribute: true }
}
}
async initialize () {
this.listenTo(this.model, 'change', () => this.requestUpdate())
}
render () {
return tplMucNoteOccupant(this, this.model)
}
}
api.elements.define('livechat-converse-muc-note-occupant', MUCNoteOccupantView)

View File

@ -14,7 +14,8 @@ export default class MUCNotesView extends DraggablesCustomElement {
return {
model: { type: Object, attribute: true },
create_note_error_message: { type: String, attribute: false },
create_note_opened: { type: Boolean, attribute: false }
create_note_opened: { type: Boolean, attribute: false },
create_note_for_occupant: { type: Object, attribute: false }
}
}
@ -41,9 +42,10 @@ export default class MUCNotesView extends DraggablesCustomElement {
return tplMucNotes(this, this.model)
}
async openCreateNoteForm (ev) {
async openCreateNoteForm (ev, occupant) {
ev?.preventDefault?.()
this.create_note_opened = true
this.create_note_for_occupant = occupant ?? undefined
await this.updateComplete
const textarea = this.querySelector('.notes-create-note textarea[name="description"]')
if (textarea) {
@ -54,6 +56,7 @@ export default class MUCNotesView extends DraggablesCustomElement {
closeCreateNoteForm (ev) {
ev?.preventDefault?.()
this.create_note_opened = false
this.create_note_for_occupant = undefined
}
async submitCreateNote (ev) {