muc: Add JID validation to the occupant invite form
This commit is contained in:
parent
0bd69b3baa
commit
59edcb2393
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
### New features and improvements
|
### New features and improvements
|
||||||
- Add support for Emojis (either native, or via <a href="https://www.emojione.com/">Emojione</a>). [jcbrand]
|
- Add support for Emojis (either native, or via <a href="https://www.emojione.com/">Emojione</a>). [jcbrand]
|
||||||
- Add JID validation in the contact add form. [jcbrand]
|
- Add JID validation to the contact add form and the occupant invite form. [jcbrand]
|
||||||
- #896 Consistently use `XMPP username` in user-facing text (instead of JID, Jabber ID etc.). [jcbrand]
|
- #896 Consistently use `XMPP username` in user-facing text (instead of JID, Jabber ID etc.). [jcbrand]
|
||||||
|
|
||||||
### New configuration settings
|
### New configuration settings
|
||||||
|
@ -2140,6 +2140,7 @@
|
|||||||
if (_.isNull(form)) {
|
if (_.isNull(form)) {
|
||||||
const heading = this.el.querySelector('.occupants-heading');
|
const heading = this.el.querySelector('.occupants-heading');
|
||||||
form = tpl_chatroom_invite({
|
form = tpl_chatroom_invite({
|
||||||
|
'error_message': null,
|
||||||
'label_invitation': __('Invite'),
|
'label_invitation': __('Invite'),
|
||||||
});
|
});
|
||||||
heading.insertAdjacentHTML('afterend', form);
|
heading.insertAdjacentHTML('afterend', form);
|
||||||
@ -2329,17 +2330,31 @@
|
|||||||
if (reason !== null) {
|
if (reason !== null) {
|
||||||
this.chatroomview.directInvite(suggestion.text.value, reason);
|
this.chatroomview.directInvite(suggestion.text.value, reason);
|
||||||
}
|
}
|
||||||
|
const form = suggestion.target.form,
|
||||||
|
error = form.querySelector('.pure-form-message.error');
|
||||||
|
if (!_.isNull(error)) {
|
||||||
|
error.parentNode.removeChild(error);
|
||||||
|
}
|
||||||
suggestion.target.value = '';
|
suggestion.target.value = '';
|
||||||
},
|
},
|
||||||
|
|
||||||
inviteFormSubmitted (evt) {
|
inviteFormSubmitted (evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const el = evt.target.querySelector('input.invited-contact');
|
const el = evt.target.querySelector('input.invited-contact'),
|
||||||
|
jid = el.value;
|
||||||
|
if (!jid || _.filter(jid.split('@')).length < 2) {
|
||||||
|
evt.target.outerHTML = tpl_chatroom_invite({
|
||||||
|
'error_message': __('Please enter a valid XMPP username'),
|
||||||
|
'label_invitation': __('Invite'),
|
||||||
|
});
|
||||||
|
this.initInviteWidget();
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.promptForInvite({
|
this.promptForInvite({
|
||||||
'target': el,
|
'target': el,
|
||||||
'text': {
|
'text': {
|
||||||
'label': el.value,
|
'label': jid,
|
||||||
'value': el.value
|
'value': jid
|
||||||
}});
|
}});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2365,7 +2380,8 @@
|
|||||||
'minChars': 1,
|
'minChars': 1,
|
||||||
'list': list
|
'list': list
|
||||||
});
|
});
|
||||||
el.addEventListener('awesomplete-selectcomplete', this.promptForInvite.bind(this));
|
el.addEventListener('awesomplete-selectcomplete',
|
||||||
|
this.promptForInvite.bind(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
<form class="pure-form room-invite">
|
<form class="pure-form room-invite">
|
||||||
|
{[ if (error_message) { ]}
|
||||||
|
<span class="pure-form-message error">{{{error_message}}}</span>
|
||||||
|
{[ } ]}
|
||||||
<input class="invited-contact" placeholder="{{{label_invitation}}}" type="text"/>
|
<input class="invited-contact" placeholder="{{{label_invitation}}}" type="text"/>
|
||||||
</form>
|
</form>
|
||||||
|
Loading…
Reference in New Issue
Block a user