diff --git a/CHANGES.md b/CHANGES.md index fd62a5e55..9f732bff5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 10.1.3 (Unreleased) + +- Add the ability to set roles and affiliations via the MUC occupant modal + ## 10.1.2 (2023-02-17) - #1490: Busy-loop when fetching registration form fails diff --git a/src/plugins/muc-views/modals/occupant.js b/src/plugins/muc-views/modals/occupant.js index f6329cc6c..65988e934 100644 --- a/src/plugins/muc-views/modals/occupant.js +++ b/src/plugins/muc-views/modals/occupant.js @@ -2,13 +2,16 @@ import BaseModal from "plugins/modal/modal.js"; import tplOccupantModal from "./templates/occupant.js"; import { Model } from '@converse/skeletor/src/model.js'; import { __ } from 'i18n'; -import { _converse, api } from "@converse/headless/core"; +import { _converse, api, converse } from "@converse/headless/core"; + +const { u } = converse.env; export default class OccupantModal extends BaseModal { constructor () { super(); this.addEventListener("affiliationChanged", () => this.alert(__('Affiliation changed'))); + this.addEventListener("roleChanged", () => this.alert(__('role changed'))); } initialize () { @@ -48,8 +51,15 @@ export default class OccupantModal extends BaseModal { if (jid) api.modal.show('converse-add-contact-modal', {'model': new Model({ jid })}); } - toggleForm () { - this.show_affiliation_form = !this.show_affiliation_form; + toggleForm (ev) { + const toggle = u.ancestor(ev.target, '.toggle-form'); + const form = toggle.getAttribute('data-form'); + + if (form === 'row-form') { + this.show_role_form = !this.show_role_form; + } else { + this.show_affiliation_form = !this.show_affiliation_form; + } this.render(); } } diff --git a/src/plugins/muc-views/modals/templates/occupant.js b/src/plugins/muc-views/modals/templates/occupant.js index 358890457..f728c3873 100644 --- a/src/plugins/muc-views/modals/templates/occupant.js +++ b/src/plugins/muc-views/modals/templates/occupant.js @@ -49,15 +49,23 @@ export default (el) => { data-form="affiliation-form" class="toggle-form right" color="var(--subdued-color)" - @click=${() => el.toggleForm()}> - - + @click=${(ev) => el.toggleForm(ev)}> ${ el.show_affiliation_form ? html`` : '' }
  • - ${ role ? html`
    ${__('Role')}:
    ${role}
    ` : '' } +
    ${__('Role')}:
    +
    ${role}  + ${ role ? html` + el.toggleForm(ev)}> + + ${ el.show_role_form ? html`` : '' }` : '' } +
  • ${ hats ? html`
    ${__('Hats')}:
    ${hats}
    ` : '' }