Commit 8d44fd19 authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

Merge branch 'MDL-69134-37' of git://github.com/andrewnicols/moodle into MOODLE_37_STABLE

parents 84388a2e 23a8270d
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.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -35,6 +35,8 @@ define(['core/yui'], function(Y) {
* @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).
*/
var dialogue = function(title, content, afterShow, afterHide, wide) {
M.util.js_pending('tool_lp/dialogue:dialogue');
this.yuiDialogue = null;
var parent = this;
......@@ -59,6 +61,10 @@ define(['core/yui'], function(Y) {
width: width
});
parent.yuiDialogue.before('visibleChange', function() {
M.util.js_pending('tool_lp/dialogue:before:visibleChange');
});
parent.yuiDialogue.after('visibleChange', function(e) {
if (e.newVal) {
// Delay the callback call to the next tick, otherwise it can happen that it is
......@@ -67,18 +73,25 @@ define(['core/yui'], function(Y) {
Y.soon(function() {
afterShow(parent);
parent.yuiDialogue.centerDialogue();
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
});
} else {
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
}
} else {
if ((typeof afterHide !== 'undefined')) {
Y.soon(function() {
afterHide(parent);
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
});
} else {
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
}
}
});
parent.yuiDialogue.show();
M.util.js_complete('tool_lp/dialogue:dialogue');
});
};
......
......@@ -102,6 +102,7 @@ define(['jquery',
* @return {Promise}
*/
Grade.prototype.display = function() {
M.util.js_pending('tool_lp/grade_dialogue:display');
return $.when(
Str.get_string('rate', 'tool_lp'),
this._render()
......@@ -110,7 +111,10 @@ define(['jquery',
this._popup = new Dialogue(
title,
templateResult[0],
this._afterRender.bind(this)
function() {
this._afterRender();
M.util.js_complete('tool_lp/grade_dialogue:display');
}.bind(this)
);
return this._popup;
......
......@@ -94,6 +94,7 @@ define(['jquery',
var options = [],
self = this;
M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');
var promise = ScaleValues.get_values(self._scaleId);
promise.then(function(scalevalues) {
options.push({
......@@ -134,6 +135,7 @@ define(['jquery',
.then(function(dialogue) {
self._dialogue = dialogue;
M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');
return;
})
.fail(notification.exception);
......
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.
......@@ -59,10 +59,9 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
args: {userid: userId, competencyid: competencyId, courseid: courseId},
}]);
$.when.apply($, requests).then(function(context) {
this._contextLoaded.bind(this)(context);
return;
}.bind(this)).catch(notification.exception);
$.when(requests[0], requests[1])
.then(this._contextLoaded.bind(this))
.catch(notification.exception);
};
/**
......@@ -70,23 +69,37 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
*
* @method _contextLoaded
* @param {Object} context
* @returns {Promise}
*/
GradingPopup.prototype._contextLoaded = function(context) {
var self = this;
// We have to display user info in popup.
context.displayuser = true;
templates.render('tool_lp/user_competency_summary_in_course', context).done(function(html, js) {
str.get_string('usercompetencysummary', 'report_competency').done(function(title) {
(new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));
}).fail(notification.exception);
}).fail(notification.exception);
M.util.js_pending('report_competency/grading_popup:_contextLoaded');
return $.when(
str.get_string('usercompetencysummary', 'report_competency'),
templates.render('tool_lp/user_competency_summary_in_course', context)
)
.then(function(title, templateData) {
return new Dialogue(
title,
templateData[0],
function() {
templates.runTemplateJS(templateData[1]);
M.util.js_complete('report_competency/grading_popup:_contextLoaded');
},
this._refresh.bind(this),
true
);
}.bind(this));
};
/**
* Refresh the page.
*
* @method _refresh
* @returns {Promise}
*/
GradingPopup.prototype._refresh = function() {
var region = $(this._regionSelector);
......@@ -99,7 +112,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
moduleId = 0;
}
ajax.call([{
return ajax.call([{
methodname: 'report_competency_data_for_report',
args: {courseid: courseId, userid: userId, moduleid: moduleId},
done: this._pageContextLoaded.bind(this),
......@@ -114,10 +127,13 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
* @param {Object} context
*/
GradingPopup.prototype._pageContextLoaded = function(context) {
var self = this;
templates.render('report_competency/report', context).done(function(html, js) {
templates.replaceNode(self._regionSelector, html, js);
}).fail(notification.exception);
templates.render('report_competency/report', context)
.then(function(html, js) {
templates.replaceNode(this._regionSelector, html, js);
return;
}.bind(this))
.catch(notification.exception);
};
/** @type {String} The selector for the region with the user competencies */
......
......@@ -50,6 +50,8 @@ define(['jquery'], function($) {
* @param {Event} e the event
*/
UserCourseNavigation.prototype._userChanged = function(e) {
// Note: This change causes a page reload and is intentionally not paired with a js_complete call.
M.util.js_pending('report_competency/user_course_navigation:_userChanged');
var newUserId = $(e.target).val();
var queryStr = '?user=' + newUserId + '&id=' + this._courseId + '&mod=' + this._moduleId;
document.location = this._baseUrl + queryStr;
......@@ -62,6 +64,8 @@ define(['jquery'], function($) {
* @param {Event} e the event
*/
UserCourseNavigation.prototype._moduleChanged = function(e) {
// Note: This change causes a page reload and is intentionally not paired with a js_complete call.
M.util.js_pending('report_competency/user_course_navigation:_moduleChanged');
var newModuleId = $(e.target).val();
var queryStr = '?mod=' + newModuleId + '&id=' + this._courseId + '&user=' + this._userId;
document.location = this._baseUrl + queryStr;
......
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