MDL-46570 gradereport_history: Selected users are saved across page loads
Part of MDL-46191
This commit is contained in:
committed by
Ankit Agarwal
parent
4d43f77f58
commit
36dbb5757b
@@ -44,7 +44,7 @@ class helper {
|
||||
*
|
||||
* @return output\user_button the user select button.
|
||||
*/
|
||||
public static function get_user_select_button($courseid, $currentusers = array()) {
|
||||
public static function get_user_select_button($courseid, array $currentusers = null) {
|
||||
global $PAGE;
|
||||
$button = new output\user_button($PAGE->url, get_string('selectusers', 'gradereport_history'), 'get');
|
||||
$button->class .= ' gradereport_history_plugin';
|
||||
@@ -54,7 +54,7 @@ class helper {
|
||||
'courseid' => $courseid,
|
||||
'ajaxurl' => '/grade/report/history/users_ajax.php',
|
||||
'url' => $PAGE->url->out(false),
|
||||
'userfullnames' => $currentusers,
|
||||
'selectedUsers' => $currentusers,
|
||||
);
|
||||
|
||||
$function = 'Y.M.gradereport_history.UserSelector.init';
|
||||
|
||||
@@ -95,7 +95,7 @@ foreach ($table->get_selected_users() as $key => $user) {
|
||||
$filters['userfullnames'] = implode(',', $names);
|
||||
|
||||
// Now that we have the names, reinitialise the button so its able to control them.
|
||||
$button = \gradereport_history\helper::get_user_select_button($course->id);
|
||||
$button = \gradereport_history\helper::get_user_select_button($course->id, $names);
|
||||
$userbutton = $output->render($button);
|
||||
$params = array('course' => $course, 'itemids' => $itemids, 'graders' => $graders, 'userbutton' => $userbutton);
|
||||
$mform = new \gradereport_history\filter_form(null, $params);
|
||||
|
||||
+17
-41
@@ -42,10 +42,9 @@ var USP = {
|
||||
PERPAGE: 'perPage',
|
||||
SEARCH: 'search',
|
||||
SEARCHBTN: 'searchbtn',
|
||||
SELECTEDUSERS: 'selectedusers',
|
||||
SELECTEDUSERS: 'selectedUsers',
|
||||
URL: 'url',
|
||||
USERCOUNT: 'userCount',
|
||||
USERFULLNAMES: 'userfullnames'
|
||||
USERCOUNT: 'userCount'
|
||||
};
|
||||
var CSS = {
|
||||
ACCESSHIDE: 'accesshide',
|
||||
@@ -194,9 +193,6 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
// Use standard dialogue class name. This removes the default styling of the footer.
|
||||
this.get('boundingBox').one('.moodle-dialogue-wrap').addClass('moodle-dialogue-content');
|
||||
|
||||
// Load the list of users.
|
||||
this.loadUsersFromForm();
|
||||
|
||||
// Add the event on the button that opens the dialogue.
|
||||
Y.one(SELECTORS.TRIGGER).on('click', this.show, this);
|
||||
|
||||
@@ -224,14 +220,13 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
*/
|
||||
show: function(e) {
|
||||
var bb;
|
||||
this._usersBufferList = {};
|
||||
this._usersBufferList = Y.clone(this.get(USP.SELECTEDUSERS));
|
||||
if (this._firstDisplay) {
|
||||
// Load the default list of users when the dialogue is loaded for the first time.
|
||||
this._firstDisplay = false;
|
||||
this.search(e, false);
|
||||
} else {
|
||||
// Leave the content as is, but reset the selection.
|
||||
this._usersBufferList = Y.clone(this.get(USP.USERFULLNAMES));
|
||||
bb = this.get('boundingBox');
|
||||
|
||||
// Remove all the selected users.
|
||||
@@ -497,27 +492,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
* @param {EventFacade} e The event.
|
||||
*/
|
||||
applySelection: function(e) {
|
||||
var userIds = Y.Object.values(this._usersBufferList);
|
||||
this.set(USP.SELECTEDUSERS, userIds)
|
||||
.set(USP.USERFULLNAMES, this._usersBufferList)
|
||||
var userIds = Y.Object.keys(this._usersBufferList);
|
||||
this.set(USP.SELECTEDUSERS, Y.clone(this._usersBufferList))
|
||||
.setNameDisplay();
|
||||
Y.one(SELECTORS.USERIDS).set('value', userIds.join());
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads the users from the form.
|
||||
*
|
||||
* @method loadUsersFromForm
|
||||
* @return Void
|
||||
*/
|
||||
loadUsersFromForm: function() {
|
||||
var list = Y.one(SELECTORS.USERIDS).get('value').split(',');
|
||||
if (list[0] === '') {
|
||||
list = [];
|
||||
}
|
||||
this.set(USP.SELECTEDUSERS, list);
|
||||
},
|
||||
|
||||
/**
|
||||
* Select a user.
|
||||
*
|
||||
@@ -591,7 +571,7 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
* @method setNameDisplay
|
||||
*/
|
||||
setNameDisplay: function() {
|
||||
var namelist = Y.Object.values(this.get(USP.USERFULLNAMES));
|
||||
var namelist = Y.Object.values(this.get(USP.SELECTEDUSERS));
|
||||
Y.one(SELECTORS.SELECTEDNAMES).set('innerHTML', namelist.join(', '));
|
||||
Y.one(SELECTORS.USERFULLNAMES).set('value', namelist.join());
|
||||
},
|
||||
@@ -714,28 +694,24 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* IDs of the selected users.
|
||||
*
|
||||
* @attribute selectedusers
|
||||
* @default null
|
||||
* @type Array
|
||||
*/
|
||||
selectedusers: {
|
||||
validator: Y.Lang.isArray,
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The names of the selected users.
|
||||
*
|
||||
* @attribute userfullnames
|
||||
* The keys are the user IDs, the values are their fullname.
|
||||
*
|
||||
* @attribute selectedUsers
|
||||
* @default null
|
||||
* @type Object
|
||||
*/
|
||||
userfullnames: {
|
||||
selectedUsers: {
|
||||
validator: Y.Lang.isObject,
|
||||
value: null
|
||||
value: null,
|
||||
getter: function(v) {
|
||||
if (v === null) {
|
||||
return {};
|
||||
}
|
||||
return v;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
File diff suppressed because one or more lines are too long
+17
-41
@@ -42,10 +42,9 @@ var USP = {
|
||||
PERPAGE: 'perPage',
|
||||
SEARCH: 'search',
|
||||
SEARCHBTN: 'searchbtn',
|
||||
SELECTEDUSERS: 'selectedusers',
|
||||
SELECTEDUSERS: 'selectedUsers',
|
||||
URL: 'url',
|
||||
USERCOUNT: 'userCount',
|
||||
USERFULLNAMES: 'userfullnames'
|
||||
USERCOUNT: 'userCount'
|
||||
};
|
||||
var CSS = {
|
||||
ACCESSHIDE: 'accesshide',
|
||||
@@ -194,9 +193,6 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
// Use standard dialogue class name. This removes the default styling of the footer.
|
||||
this.get('boundingBox').one('.moodle-dialogue-wrap').addClass('moodle-dialogue-content');
|
||||
|
||||
// Load the list of users.
|
||||
this.loadUsersFromForm();
|
||||
|
||||
// Add the event on the button that opens the dialogue.
|
||||
Y.one(SELECTORS.TRIGGER).on('click', this.show, this);
|
||||
|
||||
@@ -224,14 +220,13 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
*/
|
||||
show: function(e) {
|
||||
var bb;
|
||||
this._usersBufferList = {};
|
||||
this._usersBufferList = Y.clone(this.get(USP.SELECTEDUSERS));
|
||||
if (this._firstDisplay) {
|
||||
// Load the default list of users when the dialogue is loaded for the first time.
|
||||
this._firstDisplay = false;
|
||||
this.search(e, false);
|
||||
} else {
|
||||
// Leave the content as is, but reset the selection.
|
||||
this._usersBufferList = Y.clone(this.get(USP.USERFULLNAMES));
|
||||
bb = this.get('boundingBox');
|
||||
|
||||
// Remove all the selected users.
|
||||
@@ -497,27 +492,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
* @param {EventFacade} e The event.
|
||||
*/
|
||||
applySelection: function(e) {
|
||||
var userIds = Y.Object.values(this._usersBufferList);
|
||||
this.set(USP.SELECTEDUSERS, userIds)
|
||||
.set(USP.USERFULLNAMES, this._usersBufferList)
|
||||
var userIds = Y.Object.keys(this._usersBufferList);
|
||||
this.set(USP.SELECTEDUSERS, Y.clone(this._usersBufferList))
|
||||
.setNameDisplay();
|
||||
Y.one(SELECTORS.USERIDS).set('value', userIds.join());
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads the users from the form.
|
||||
*
|
||||
* @method loadUsersFromForm
|
||||
* @return Void
|
||||
*/
|
||||
loadUsersFromForm: function() {
|
||||
var list = Y.one(SELECTORS.USERIDS).get('value').split(',');
|
||||
if (list[0] === '') {
|
||||
list = [];
|
||||
}
|
||||
this.set(USP.SELECTEDUSERS, list);
|
||||
},
|
||||
|
||||
/**
|
||||
* Select a user.
|
||||
*
|
||||
@@ -591,7 +571,7 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
* @method setNameDisplay
|
||||
*/
|
||||
setNameDisplay: function() {
|
||||
var namelist = Y.Object.values(this.get(USP.USERFULLNAMES));
|
||||
var namelist = Y.Object.values(this.get(USP.SELECTEDUSERS));
|
||||
Y.one(SELECTORS.SELECTEDNAMES).set('innerHTML', namelist.join(', '));
|
||||
Y.one(SELECTORS.USERFULLNAMES).set('value', namelist.join());
|
||||
},
|
||||
@@ -712,28 +692,24 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* IDs of the selected users.
|
||||
*
|
||||
* @attribute selectedusers
|
||||
* @default null
|
||||
* @type Array
|
||||
*/
|
||||
selectedusers: {
|
||||
validator: Y.Lang.isArray,
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The names of the selected users.
|
||||
*
|
||||
* @attribute userfullnames
|
||||
* The keys are the user IDs, the values are their fullname.
|
||||
*
|
||||
* @attribute selectedUsers
|
||||
* @default null
|
||||
* @type Object
|
||||
*/
|
||||
userfullnames: {
|
||||
selectedUsers: {
|
||||
validator: Y.Lang.isObject,
|
||||
value: null
|
||||
value: null,
|
||||
getter: function(v) {
|
||||
if (v === null) {
|
||||
return {};
|
||||
}
|
||||
return v;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+17
-41
@@ -40,10 +40,9 @@ var USP = {
|
||||
PERPAGE: 'perPage',
|
||||
SEARCH: 'search',
|
||||
SEARCHBTN: 'searchbtn',
|
||||
SELECTEDUSERS: 'selectedusers',
|
||||
SELECTEDUSERS: 'selectedUsers',
|
||||
URL: 'url',
|
||||
USERCOUNT: 'userCount',
|
||||
USERFULLNAMES: 'userfullnames'
|
||||
USERCOUNT: 'userCount'
|
||||
};
|
||||
var CSS = {
|
||||
ACCESSHIDE: 'accesshide',
|
||||
@@ -192,9 +191,6 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
// Use standard dialogue class name. This removes the default styling of the footer.
|
||||
this.get('boundingBox').one('.moodle-dialogue-wrap').addClass('moodle-dialogue-content');
|
||||
|
||||
// Load the list of users.
|
||||
this.loadUsersFromForm();
|
||||
|
||||
// Add the event on the button that opens the dialogue.
|
||||
Y.one(SELECTORS.TRIGGER).on('click', this.show, this);
|
||||
|
||||
@@ -222,14 +218,13 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
*/
|
||||
show: function(e) {
|
||||
var bb;
|
||||
this._usersBufferList = {};
|
||||
this._usersBufferList = Y.clone(this.get(USP.SELECTEDUSERS));
|
||||
if (this._firstDisplay) {
|
||||
// Load the default list of users when the dialogue is loaded for the first time.
|
||||
this._firstDisplay = false;
|
||||
this.search(e, false);
|
||||
} else {
|
||||
// Leave the content as is, but reset the selection.
|
||||
this._usersBufferList = Y.clone(this.get(USP.USERFULLNAMES));
|
||||
bb = this.get('boundingBox');
|
||||
|
||||
// Remove all the selected users.
|
||||
@@ -495,27 +490,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
* @param {EventFacade} e The event.
|
||||
*/
|
||||
applySelection: function(e) {
|
||||
var userIds = Y.Object.values(this._usersBufferList);
|
||||
this.set(USP.SELECTEDUSERS, userIds)
|
||||
.set(USP.USERFULLNAMES, this._usersBufferList)
|
||||
var userIds = Y.Object.keys(this._usersBufferList);
|
||||
this.set(USP.SELECTEDUSERS, Y.clone(this._usersBufferList))
|
||||
.setNameDisplay();
|
||||
Y.one(SELECTORS.USERIDS).set('value', userIds.join());
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads the users from the form.
|
||||
*
|
||||
* @method loadUsersFromForm
|
||||
* @return Void
|
||||
*/
|
||||
loadUsersFromForm: function() {
|
||||
var list = Y.one(SELECTORS.USERIDS).get('value').split(',');
|
||||
if (list[0] === '') {
|
||||
list = [];
|
||||
}
|
||||
this.set(USP.SELECTEDUSERS, list);
|
||||
},
|
||||
|
||||
/**
|
||||
* Select a user.
|
||||
*
|
||||
@@ -589,7 +569,7 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
* @method setNameDisplay
|
||||
*/
|
||||
setNameDisplay: function() {
|
||||
var namelist = Y.Object.values(this.get(USP.USERFULLNAMES));
|
||||
var namelist = Y.Object.values(this.get(USP.SELECTEDUSERS));
|
||||
Y.one(SELECTORS.SELECTEDNAMES).set('innerHTML', namelist.join(', '));
|
||||
Y.one(SELECTORS.USERFULLNAMES).set('value', namelist.join());
|
||||
},
|
||||
@@ -712,28 +692,24 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, M.cor
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* IDs of the selected users.
|
||||
*
|
||||
* @attribute selectedusers
|
||||
* @default null
|
||||
* @type Array
|
||||
*/
|
||||
selectedusers: {
|
||||
validator: Y.Lang.isArray,
|
||||
value: null
|
||||
},
|
||||
|
||||
/**
|
||||
* The names of the selected users.
|
||||
*
|
||||
* @attribute userfullnames
|
||||
* The keys are the user IDs, the values are their fullname.
|
||||
*
|
||||
* @attribute selectedUsers
|
||||
* @default null
|
||||
* @type Object
|
||||
*/
|
||||
userfullnames: {
|
||||
selectedUsers: {
|
||||
validator: Y.Lang.isObject,
|
||||
value: null
|
||||
value: null,
|
||||
getter: function(v) {
|
||||
if (v === null) {
|
||||
return {};
|
||||
}
|
||||
return v;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user