Skip to content

Commit

Permalink
MDL-59758 core_user: Pluralise bulk actions
Browse files Browse the repository at this point in the history
Don't say 1 people.
  • Loading branch information
Damyon Wiese committed Nov 7, 2017
1 parent 81aa5e1 commit a6943eb
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 11 deletions.
4 changes: 3 additions & 1 deletion lang/en/message.php
Expand Up @@ -112,7 +112,9 @@
$string['sendingviawhen'] = 'Sending "{$a->provider}" via "{$a->processor}" when {$a->state}';
$string['sendmessage'] = 'Send message';
$string['sendbulkmessage'] = 'Send message to {$a} people';
$string['sendbulkmessagesent'] = 'Message sent to {$a} people.';
$string['sendbulkmessagesingle'] = 'Send message to 1 person';
$string['sendbulkmessagesent'] = 'Message sent to {$a} people';
$string['sendbulkmessagesentsingle'] = 'Message sent to 1 person';
$string['sendmessageto'] = 'Send message to {$a}';
$string['sendmessagetopopup'] = 'Send message to {$a} - new window';
$string['settings'] = 'Settings';
Expand Down
2 changes: 2 additions & 0 deletions lang/en/notes.php
Expand Up @@ -25,7 +25,9 @@

$string['addnewnote'] = 'Add a new note';
$string['addbulknote'] = 'Add a new note to {$a} people';
$string['addbulknotesingle'] = 'Add a new note to 1 person';
$string['addbulknotedone'] = 'Note added to {$a} people';
$string['addbulknotedonesingle'] = 'Note added to 1 person';
$string['addnewnoteselect'] = 'Select users to write notes about';
$string['bynameondate'] = 'by {$a->name} - {$a->date}';
$string['configenablenotes'] = 'Enable storing of notes about individual users.';
Expand Down
6 changes: 3 additions & 3 deletions notes/tests/behat/participants_notes.feature
Expand Up @@ -36,17 +36,17 @@ Feature: Add notes to course participants
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 1')]//input[@type='checkbox']" to "1"
And I choose "Add a new note" from the participants page bulk action menu
And I set the field "bulk-note" to "Student 1 needs to pick up his game"
And I press "Add a new note to 1 people"
And I press "Add a new note to 1 person"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 1')]//input[@type='checkbox']" to "0"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 2')]//input[@type='checkbox']" to "1"
And I choose "Add a new note" from the participants page bulk action menu
And I set the field "bulk-note" to ""
And I press "Add a new note to 1 people"
And I press "Add a new note to 1 person"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 2')]//input[@type='checkbox']" to "0"
And I set the field with xpath "//tr[contains(normalize-space(.), 'Student 3')]//input[@type='checkbox']" to "1"
And I choose "Add a new note" from the participants page bulk action menu
And I set the field "bulk-note" to " "
And I press "Add a new note to 1 people"
And I press "Add a new note to 1 person"
And I follow "Student 1"
And I follow "Notes"
# Student 1 has note from Teacher
Expand Down
2 changes: 1 addition & 1 deletion user/amd/build/participants.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 25 additions & 6 deletions user/amd/src/participants.js
Expand Up @@ -151,13 +151,19 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/modal_events', 'core/t
}

var context = {stateNames: states, stateHelpIcon: this.stateHelpIcon};
var titlePromise = null;
if (users.length == 1) {
titlePromise = Str.get_string('addbulknotesingle', 'core_notes');
} else {
titlePromise = Str.get_string('addbulknote', 'core_notes', users.length);
}

return $.when(
ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,
body: Templates.render('core_user/add_bulk_note', context)
}),
Str.get_string('addbulknote', 'core_notes', users.length)
titlePromise
).then(function(modal, title) {
// Keep a reference to the modal.
this.modal = modal;
Expand Down Expand Up @@ -205,7 +211,11 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/modal_events', 'core/t
methodname: 'core_notes_create_notes',
args: {notes: notes}
}])[0].then(function(noteIds) {
return Str.get_string('addbulknotedone', 'core_notes', noteIds.length);
if (noteIds.length == 1) {
return Str.get_string('addbulknotedonesingle', 'core_notes');
} else {
return Str.get_string('addbulknotedone', 'core_notes', noteIds.length);
}
}).then(function(msg) {
Notification.addNotification({
message: msg,
Expand All @@ -229,14 +239,19 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/modal_events', 'core/t
// Nothing to do.
return $.Deferred().resolve().promise();
}
var bodyPromise = Templates.render('core_user/send_bulk_message', {});
var titlePromise = null;
if (users.length == 1) {
titlePromise = Str.get_string('sendbulkmessagesingle', 'core_message');
} else {
titlePromise = Str.get_string('sendbulkmessage', 'core_message', users.length);
}

return $.when(
ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,
body: bodyPromise
body: Templates.render('core_user/send_bulk_message', {})
}),
Str.get_string('sendbulkmessage', 'core_message', users.length)
titlePromise
).then(function(modal, title) {
// Keep a reference to the modal.
this.modal = modal;
Expand Down Expand Up @@ -282,7 +297,11 @@ define(['jquery', 'core/str', 'core/modal_factory', 'core/modal_events', 'core/t
methodname: 'core_message_send_instant_messages',
args: {messages: messages}
}])[0].then(function(messageIds) {
return Str.get_string('sendbulkmessagesent', 'core_message', messageIds.length);
if (messageIds.length == 1) {
return Str.get_string('sendbulkmessagesentsingle', 'core_message');
} else {
return Str.get_string('sendbulkmessagesent', 'core_message', messageIds.length);
}
}).then(function(msg) {
Notification.addNotification({
message: msg,
Expand Down

0 comments on commit a6943eb

Please sign in to comment.