xmpp.chapril.org-conversejs/src/plugins/muc-views/password-form.js
JC Brand 15c10376b0 Rename all templates to camelCase
To conform with naming conventions regarding functions, which the
templates are.
2023-02-15 14:29:07 +01:00

40 lines
1.2 KiB
JavaScript

import tplMUCPasswordForm from "./templates/muc-password-form.js";
import { CustomElement } from 'shared/components/element';
import { _converse, api } from "@converse/headless/core";
class MUCPasswordForm extends CustomElement {
static get properties () {
return {
'jid': { type: String }
}
}
connectedCallback () {
super.connectedCallback();
this.model = _converse.chatboxes.get(this.jid);
this.listenTo(this.model, 'change:password_validation_message', this.render);
this.render();
}
render () {
return tplMUCPasswordForm({
'jid': this.model.get('jid'),
'submitPassword': ev => this.submitPassword(ev),
'validation_message': this.model.get('password_validation_message')
});
}
submitPassword (ev) {
ev.preventDefault();
const password = this.querySelector('input[type=password]').value;
this.model.join(this.model.get('nick'), password);
this.model.set('password_validation_message', null);
}
}
api.elements.define('converse-muc-password-form', MUCPasswordForm);
export default MUCPasswordForm;