Commit baa90648 authored by Adrian Greeve's avatar Adrian Greeve
Browse files

Merge branch 'MDL-66025' of git://github.com/paulholden/moodle

parents 98fa5b64 3112712e
......@@ -118,6 +118,7 @@ $string['messagedrawerviewsettings'] = 'Message settings';
$string['messagepreferences'] = 'Message preferences';
$string['messages'] = 'Messages';
$string['messagesselected:'] = 'Messages selected:';
$string['messagetextrequired'] = 'Please enter message text';
$string['messagingdatahasnotbeenmigrated'] = 'Your messages are temporarily unavailable due to upgrades in the messaging infrastructure. Please wait for them to be migrated.';
$string['muteconversation'] = 'Mute';
$string['mutedconversation'] = 'Muted conversation';
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -26,6 +26,7 @@ import * as Repository from 'core_user/repository';
import * as Str from 'core/str';
import ModalEvents from 'core/modal_events';
import ModalFactory from 'core/modal_factory';
import Notification from 'core/notification';
import Templates from 'core/templates';
import {add as notifyUser} from 'core/toast';
......@@ -151,8 +152,15 @@ export const showSendMessage = users => {
removeOnClose: true,
})
.then(modal => {
modal.getRoot().on(ModalEvents.save, () => {
submitSendMessage(modal, users);
modal.getRoot().on(ModalEvents.save, (e) => {
const text = modal.getRoot().find('form textarea').val();
if (text.trim() === '') {
modal.getRoot().find('[data-role="messagetextrequired"]').removeAttr('hidden');
e.preventDefault();
return;
}
submitSendMessage(modal, users, text);
});
modal.show();
......@@ -166,11 +174,10 @@ export const showSendMessage = users => {
*
* @param {Modal} modal
* @param {Number[]} users
* @param {String} text
* @return {Promise}
*/
const submitSendMessage = (modal, users) => {
const text = modal.getRoot().find('form textarea').val();
const submitSendMessage = (modal, users, text) => {
const messages = users.map(touserid => {
return {
touserid,
......
......@@ -33,6 +33,9 @@
</label>
<textarea id="bulk-message" rows="3" data-max-rows="10" data-auto-rows="true" cols="30" class="form-control"></textarea>
</p>
<div class="text-danger" data-role="messagetextrequired" hidden>
{{#str}} messagetextrequired, core_message {{/str}}
</div>
</form>
{{#js}}
require(['core/auto_rows'], function(AutoRows) {
......
......@@ -25,8 +25,11 @@ Feature: Bulk message
And I navigate to course participants
And I click on "Select all" "checkbox"
And I set the field "With selected users..." to "Send a message"
And I should see "Send message to 3 people"
And "Send message to 3 people" "dialogue" should exist
# Try to send an empty message.
When I press "Send message to 3 people"
Then I should see "Please enter message text"
And I set the following fields to these values:
| bulk-message | "Hello world!" |
When I press "Send message to 3 people"
Then I should see "Message sent to 3 people"
And I press "Send message to 3 people"
And I should see "Message sent to 3 people"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment