mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-59758 core_user: Pluralise bulk actions
Don't say 1 people.
This commit is contained in:
parent
81aa5e196f
commit
a6943ebb59
@ -112,7 +112,9 @@ $string['sendingvia'] = 'Sending "{$a->provider}" via "{$a->processor}"';
|
||||
$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';
|
||||
|
@ -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.';
|
||||
|
@ -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
|
||||
|
2
user/amd/build/participants.min.js
vendored
2
user/amd/build/participants.min.js
vendored
@ -1 +1 @@
|
||||
define(["jquery","core/str","core/modal_factory","core/modal_events","core/templates","core/notification","core/ajax"],function(a,b,c,d,e,f,g){var h={BULKACTIONSELECT:"#formactionid",BULKUSERCHECKBOXES:"input.usercheckbox",BULKUSERNOSCHECKBOXES:"input.usercheckbox[value='0']",BULKUSERSELECTEDCHECKBOXES:"input.usercheckbox:checked",BULKACTIONFORM:"#participantsform",CHECKALLBUTTON:"#checkall",CHECKALLNOSBUTTON:"#checkallnos",CHECKALLONPAGEBUTTON:"#checkallonpage",CHECKNONEBUTTON:"#checknone"},i=function(a){this.courseId=a.courseid,this.noteStateNames=a.noteStateNames,this.stateHelpIcon=a.stateHelpIcon,this.attachEventListeners()};return i.prototype.modal=null,i.prototype.courseId=-1,i.prototype.noteStateNames={},i.prototype.stateHelpIcon="",i.prototype.attachEventListeners=function(){a(h.BULKACTIONSELECT).on("change",function(b){var c=a(b.target).val();if(c.indexOf("#")!==-1){b.preventDefault();var d=[];a(h.BULKUSERSELECTEDCHECKBOXES).each(function(b,c){var e=a(c).attr("name"),f=e.replace("user","");d.push(f)}),"#messageselect"==c?this.showSendMessage(d).fail(f.exception):"#addgroupnote"==c&&this.showAddNote(d).fail(f.exception),a(h.BULKACTIONSELECT+' option[value=""]').prop("selected","selected")}else""!==c&&(a(h.BULKUSERSELECTEDCHECKBOXES).length>0?a(h.BULKACTIONFORM).submit():a(h.BULKACTIONSELECT+' option[value=""]').prop("selected","selected"))}.bind(this)),a(h.CHECKALLBUTTON).on("click",function(){var b=a(this).data("showallink");b&&(window.location=b)}),a(h.CHECKALLNOSBUTTON).on("click",function(){a(h.BULKUSERNOSCHECKBOXES).prop("checked",!0)}),a(h.CHECKALLONPAGEBUTTON).on("click",function(){a(h.BULKUSERCHECKBOXES).prop("checked",!0)}),a(h.CHECKNONEBUTTON).on("click",function(){a(h.BULKUSERCHECKBOXES).prop("checked",!1)})},i.prototype.showAddNote=function(f){if(0==f.length)return a.Deferred().resolve().promise();var g=[];for(var i in this.noteStateNames)g.push({value:i,label:this.noteStateNames[i]});var j={stateNames:g,stateHelpIcon:this.stateHelpIcon};return a.when(c.create({type:c.types.SAVE_CANCEL,body:e.render("core_user/add_bulk_note",j)}),b.get_string("addbulknote","core_notes",f.length)).then(function(b,c){return this.modal=b,this.modal.setTitle(c),this.modal.setSaveButtonText(c),this.modal.getRoot().on(d.hidden,function(){var b=a("#user-notifications [role=alert]");b.length?b.focus():a(h.BULKACTIONSELECT).focus(),this.modal.getRoot().remove()}.bind(this)),this.modal.getRoot().on(d.save,this.submitAddNote.bind(this,f)),this.modal.show(),this.modal}.bind(this))},i.prototype.submitAddNote=function(a){var c=this.modal.getRoot().find("form textarea").val(),d=this.modal.getRoot().find("form select").val(),e=[],h=0;for(h=0;h<a.length;h++)e.push({userid:a[h],text:c,courseid:this.courseId,publishstate:d});return g.call([{methodname:"core_notes_create_notes",args:{notes:e}}])[0].then(function(a){return b.get_string("addbulknotedone","core_notes",a.length)}).then(function(a){return f.addNotification({message:a,type:"success"}),!0})["catch"](f.exception)},i.prototype.showSendMessage=function(f){if(0==f.length)return a.Deferred().resolve().promise();var g=e.render("core_user/send_bulk_message",{});return a.when(c.create({type:c.types.SAVE_CANCEL,body:g}),b.get_string("sendbulkmessage","core_message",f.length)).then(function(b,c){return this.modal=b,this.modal.setTitle(c),this.modal.setSaveButtonText(c),this.modal.getRoot().on(d.hidden,function(){a(h.BULKACTIONSELECT).focus(),this.modal.getRoot().remove()}.bind(this)),this.modal.getRoot().on(d.save,this.submitSendMessage.bind(this,f)),this.modal.show(),this.modal}.bind(this))},i.prototype.submitSendMessage=function(a){var c=this.modal.getRoot().find("form textarea").val(),d=[],e=0;for(e=0;e<a.length;e++)d.push({touserid:a[e],text:c});return g.call([{methodname:"core_message_send_instant_messages",args:{messages:d}}])[0].then(function(a){return b.get_string("sendbulkmessagesent","core_message",a.length)}).then(function(a){return f.addNotification({message:a,type:"success"}),!0})["catch"](f.exception)},{init:function(a){return new i(a)}}});
|
||||
define(["jquery","core/str","core/modal_factory","core/modal_events","core/templates","core/notification","core/ajax"],function(a,b,c,d,e,f,g){var h={BULKACTIONSELECT:"#formactionid",BULKUSERCHECKBOXES:"input.usercheckbox",BULKUSERNOSCHECKBOXES:"input.usercheckbox[value='0']",BULKUSERSELECTEDCHECKBOXES:"input.usercheckbox:checked",BULKACTIONFORM:"#participantsform",CHECKALLBUTTON:"#checkall",CHECKALLNOSBUTTON:"#checkallnos",CHECKALLONPAGEBUTTON:"#checkallonpage",CHECKNONEBUTTON:"#checknone"},i=function(a){this.courseId=a.courseid,this.noteStateNames=a.noteStateNames,this.stateHelpIcon=a.stateHelpIcon,this.attachEventListeners()};return i.prototype.modal=null,i.prototype.courseId=-1,i.prototype.noteStateNames={},i.prototype.stateHelpIcon="",i.prototype.attachEventListeners=function(){a(h.BULKACTIONSELECT).on("change",function(b){var c=a(b.target).val();if(c.indexOf("#")!==-1){b.preventDefault();var d=[];a(h.BULKUSERSELECTEDCHECKBOXES).each(function(b,c){var e=a(c).attr("name"),f=e.replace("user","");d.push(f)}),"#messageselect"==c?this.showSendMessage(d).fail(f.exception):"#addgroupnote"==c&&this.showAddNote(d).fail(f.exception),a(h.BULKACTIONSELECT+' option[value=""]').prop("selected","selected")}else""!==c&&(a(h.BULKUSERSELECTEDCHECKBOXES).length>0?a(h.BULKACTIONFORM).submit():a(h.BULKACTIONSELECT+' option[value=""]').prop("selected","selected"))}.bind(this)),a(h.CHECKALLBUTTON).on("click",function(){var b=a(this).data("showallink");b&&(window.location=b)}),a(h.CHECKALLNOSBUTTON).on("click",function(){a(h.BULKUSERNOSCHECKBOXES).prop("checked",!0)}),a(h.CHECKALLONPAGEBUTTON).on("click",function(){a(h.BULKUSERCHECKBOXES).prop("checked",!0)}),a(h.CHECKNONEBUTTON).on("click",function(){a(h.BULKUSERCHECKBOXES).prop("checked",!1)})},i.prototype.showAddNote=function(f){if(0==f.length)return a.Deferred().resolve().promise();var g=[];for(var i in this.noteStateNames)g.push({value:i,label:this.noteStateNames[i]});var j={stateNames:g,stateHelpIcon:this.stateHelpIcon},k=null;return k=1==f.length?b.get_string("addbulknotesingle","core_notes"):b.get_string("addbulknote","core_notes",f.length),a.when(c.create({type:c.types.SAVE_CANCEL,body:e.render("core_user/add_bulk_note",j)}),k).then(function(b,c){return this.modal=b,this.modal.setTitle(c),this.modal.setSaveButtonText(c),this.modal.getRoot().on(d.hidden,function(){var b=a("#user-notifications [role=alert]");b.length?b.focus():a(h.BULKACTIONSELECT).focus(),this.modal.getRoot().remove()}.bind(this)),this.modal.getRoot().on(d.save,this.submitAddNote.bind(this,f)),this.modal.show(),this.modal}.bind(this))},i.prototype.submitAddNote=function(a){var c=this.modal.getRoot().find("form textarea").val(),d=this.modal.getRoot().find("form select").val(),e=[],h=0;for(h=0;h<a.length;h++)e.push({userid:a[h],text:c,courseid:this.courseId,publishstate:d});return g.call([{methodname:"core_notes_create_notes",args:{notes:e}}])[0].then(function(a){return 1==a.length?b.get_string("addbulknotedonesingle","core_notes"):b.get_string("addbulknotedone","core_notes",a.length)}).then(function(a){return f.addNotification({message:a,type:"success"}),!0})["catch"](f.exception)},i.prototype.showSendMessage=function(f){if(0==f.length)return a.Deferred().resolve().promise();var g=null;return g=1==f.length?b.get_string("sendbulkmessagesingle","core_message"):b.get_string("sendbulkmessage","core_message",f.length),a.when(c.create({type:c.types.SAVE_CANCEL,body:e.render("core_user/send_bulk_message",{})}),g).then(function(b,c){return this.modal=b,this.modal.setTitle(c),this.modal.setSaveButtonText(c),this.modal.getRoot().on(d.hidden,function(){a(h.BULKACTIONSELECT).focus(),this.modal.getRoot().remove()}.bind(this)),this.modal.getRoot().on(d.save,this.submitSendMessage.bind(this,f)),this.modal.show(),this.modal}.bind(this))},i.prototype.submitSendMessage=function(a){var c=this.modal.getRoot().find("form textarea").val(),d=[],e=0;for(e=0;e<a.length;e++)d.push({touserid:a[e],text:c});return g.call([{methodname:"core_message_send_instant_messages",args:{messages:d}}])[0].then(function(a){return 1==a.length?b.get_string("sendbulkmessagesentsingle","core_message"):b.get_string("sendbulkmessagesent","core_message",a.length)}).then(function(a){return f.addNotification({message:a,type:"success"}),!0})["catch"](f.exception)},{init:function(a){return new i(a)}}});
|
@ -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;
|
||||
@ -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,
|
||||
@ -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;
|
||||
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user