Added notice when recipient is banned.
This commit is contained in:
parent
8ef11afe02
commit
eb81ed7a82
4 changed files with 21 additions and 0 deletions
|
@ -160,6 +160,7 @@ const MszMessages = () => {
|
||||||
if(msgsRecipient !== undefined)
|
if(msgsRecipient !== undefined)
|
||||||
msgsRecipient.onUpdate(async info => {
|
msgsRecipient.onUpdate(async info => {
|
||||||
msgsReply.setRecipient(typeof info.id === 'string' ? info.id : '');
|
msgsReply.setRecipient(typeof info.id === 'string' ? info.id : '');
|
||||||
|
msgsReply.setWarning(info.ban ? `${(typeof info.name === 'string' ? info.name : 'This user')} has been banned and will be unable to respond to your messages.` : undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
msgsReply.onSubmit(async form => {
|
msgsReply.onSubmit(async form => {
|
||||||
|
|
|
@ -11,6 +11,8 @@ const MszMessagesReply = function(element) {
|
||||||
const parserSelect = form.querySelector('.js-messages-reply-parser');
|
const parserSelect = form.querySelector('.js-messages-reply-parser');
|
||||||
const saveBtn = form.querySelector('.js-messages-reply-save');
|
const saveBtn = form.querySelector('.js-messages-reply-save');
|
||||||
const sendBtn = form.querySelector('.js-messages-reply-send');
|
const sendBtn = form.querySelector('.js-messages-reply-send');
|
||||||
|
const warnElem = form.querySelector('.js-reply-form-warning');
|
||||||
|
const warnText = warnElem instanceof Element ? warnElem.querySelector('.js-reply-form-warning-text') : undefined;
|
||||||
|
|
||||||
let submitHandler;
|
let submitHandler;
|
||||||
form.addEventListener('submit', ev => {
|
form.addEventListener('submit', ev => {
|
||||||
|
@ -133,6 +135,18 @@ const MszMessagesReply = function(element) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getElement: () => element,
|
getElement: () => element,
|
||||||
|
setWarning: text => {
|
||||||
|
if(warnElem === undefined || warnText === undefined)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(text === undefined) {
|
||||||
|
warnElem.hidden = true;
|
||||||
|
warnText.textContent = '';
|
||||||
|
} else {
|
||||||
|
warnElem.hidden = false;
|
||||||
|
warnText.textContent = text;
|
||||||
|
}
|
||||||
|
},
|
||||||
setRecipient: userId => {
|
setRecipient: userId => {
|
||||||
for(const field of form.elements)
|
for(const field of form.elements)
|
||||||
if(field.name === 'recipient') {
|
if(field.name === 'recipient') {
|
||||||
|
|
|
@ -174,6 +174,7 @@ class MessagesRoutes extends RouteHandler {
|
||||||
return [
|
return [
|
||||||
'id' => $userInfo->getId(),
|
'id' => $userInfo->getId(),
|
||||||
'name' => $userInfo->getName(),
|
'name' => $userInfo->getName(),
|
||||||
|
'ban' => $this->usersCtx->hasActiveBan($userInfo),
|
||||||
'avatar' => $this->urls->format('user-avatar', [
|
'avatar' => $this->urls->format('user-avatar', [
|
||||||
'user' => $userInfo->getId(),
|
'user' => $userInfo->getId(),
|
||||||
'res' => 200,
|
'res' => 200,
|
||||||
|
|
|
@ -40,6 +40,11 @@
|
||||||
|
|
||||||
<form class="messages-reply-form js-messages-reply-form">
|
<form class="messages-reply-form js-messages-reply-form">
|
||||||
{{ input_hidden('recipient', '') }}
|
{{ input_hidden('recipient', '') }}
|
||||||
|
<div class="warning js-reply-form-warning" hidden>
|
||||||
|
<div class="warning__content">
|
||||||
|
<p class="js-reply-form-warning-text"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="messages-reply-subject">
|
<div class="messages-reply-subject">
|
||||||
{{ input_text('title', 'messages-reply-subject-input', '', 'text', 'Subject', true) }}
|
{{ input_text('title', 'messages-reply-subject-input', '', 'text', 'Subject', true) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue