mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
MDL-42629 course: moving a course now updates counts and pagination totals
This commit is contained in:
parent
83886a49a0
commit
bd7ee7ada4
5 changed files with 103 additions and 8 deletions
|
@ -1246,12 +1246,15 @@ Category.prototype = {
|
|||
*/
|
||||
completeMoveCourse : function(transactionid, response, args) {
|
||||
var outcome = this.checkAjaxResponse(transactionid, response, args),
|
||||
course;
|
||||
console = this.get('console'),
|
||||
category,
|
||||
course,
|
||||
totals;
|
||||
if (outcome === false) {
|
||||
Y.log('AJAX failed to move courses into this category: '+this.get('itemname'), 'warn', 'moodle-course-management');
|
||||
return false;
|
||||
}
|
||||
course = this.get('console').getCourseById(args.courseid);
|
||||
course = console.getCourseById(args.courseid);
|
||||
if (!course) {
|
||||
Y.log('Course was moved but the course listing could not be found to reflect this', 'warn', 'moodle-course-management');
|
||||
return false;
|
||||
|
@ -1259,6 +1262,28 @@ Category.prototype = {
|
|||
Y.log('Moved the course ('+course.getName()+') into this category ('+this.getName()+')', 'info', 'moodle-course-management');
|
||||
this.highlight();
|
||||
if (course) {
|
||||
if (outcome.paginationtotals) {
|
||||
totals = console.get('courselisting').one('.listing-pagination-totals');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', outcome.paginationtotals);
|
||||
}
|
||||
}
|
||||
if (outcome.newcatcourses !== 'undefined') {
|
||||
totals = this.get('node').one('.course-count');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.newcatcourses));
|
||||
}
|
||||
}
|
||||
if (outcome.oldcatcourses !== 'undefined') {
|
||||
category = console.get('activecategoryid');
|
||||
category = console.getCategoryById(category);
|
||||
if (category) {
|
||||
totals = category.get('node').one('.course-count');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.oldcatcourses));
|
||||
}
|
||||
}
|
||||
}
|
||||
course.remove();
|
||||
}
|
||||
return true;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1218,16 +1218,41 @@ Category.prototype = {
|
|||
*/
|
||||
completeMoveCourse : function(transactionid, response, args) {
|
||||
var outcome = this.checkAjaxResponse(transactionid, response, args),
|
||||
course;
|
||||
console = this.get('console'),
|
||||
category,
|
||||
course,
|
||||
totals;
|
||||
if (outcome === false) {
|
||||
return false;
|
||||
}
|
||||
course = this.get('console').getCourseById(args.courseid);
|
||||
course = console.getCourseById(args.courseid);
|
||||
if (!course) {
|
||||
return false;
|
||||
}
|
||||
this.highlight();
|
||||
if (course) {
|
||||
if (outcome.paginationtotals) {
|
||||
totals = console.get('courselisting').one('.listing-pagination-totals');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', outcome.paginationtotals);
|
||||
}
|
||||
}
|
||||
if (outcome.newcatcourses !== 'undefined') {
|
||||
totals = this.get('node').one('.course-count');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.newcatcourses));
|
||||
}
|
||||
}
|
||||
if (outcome.oldcatcourses !== 'undefined') {
|
||||
category = console.get('activecategoryid');
|
||||
category = console.getCategoryById(category);
|
||||
if (category) {
|
||||
totals = category.get('node').one('.course-count');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.oldcatcourses));
|
||||
}
|
||||
}
|
||||
}
|
||||
course.remove();
|
||||
}
|
||||
return true;
|
||||
|
|
29
course/yui/src/management/js/category.js
vendored
29
course/yui/src/management/js/category.js
vendored
|
@ -242,12 +242,15 @@ Category.prototype = {
|
|||
*/
|
||||
completeMoveCourse : function(transactionid, response, args) {
|
||||
var outcome = this.checkAjaxResponse(transactionid, response, args),
|
||||
course;
|
||||
console = this.get('console'),
|
||||
category,
|
||||
course,
|
||||
totals;
|
||||
if (outcome === false) {
|
||||
Y.log('AJAX failed to move courses into this category: '+this.get('itemname'), 'warn', 'moodle-course-management');
|
||||
return false;
|
||||
}
|
||||
course = this.get('console').getCourseById(args.courseid);
|
||||
course = console.getCourseById(args.courseid);
|
||||
if (!course) {
|
||||
Y.log('Course was moved but the course listing could not be found to reflect this', 'warn', 'moodle-course-management');
|
||||
return false;
|
||||
|
@ -255,6 +258,28 @@ Category.prototype = {
|
|||
Y.log('Moved the course ('+course.getName()+') into this category ('+this.getName()+')', 'info', 'moodle-course-management');
|
||||
this.highlight();
|
||||
if (course) {
|
||||
if (outcome.paginationtotals) {
|
||||
totals = console.get('courselisting').one('.listing-pagination-totals');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', outcome.paginationtotals);
|
||||
}
|
||||
}
|
||||
if (outcome.newcatcourses !== 'undefined') {
|
||||
totals = this.get('node').one('.course-count');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.newcatcourses));
|
||||
}
|
||||
}
|
||||
if (outcome.oldcatcourses !== 'undefined') {
|
||||
category = console.get('activecategoryid');
|
||||
category = console.getCategoryById(category);
|
||||
if (category) {
|
||||
totals = category.get('node').one('.course-count');
|
||||
if (totals) {
|
||||
totals.set('innerHTML', totals.get('innerHTML').replace(/^\d+/, outcome.oldcatcourses));
|
||||
}
|
||||
}
|
||||
}
|
||||
course.remove();
|
||||
}
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue