This commit is contained in:
Dan Poltawski 2013-11-19 11:43:39 +08:00
commit f7b47f1c0c
9 changed files with 635 additions and 18 deletions

View File

@ -209,7 +209,8 @@ class core_course_management_renderer extends plugin_renderer_base {
'name' => 'bcat[]',
'value' => $category->id,
'class' => 'bulk-action-checkbox',
'aria-label' => get_string('bulkactionselect', 'moodle', $text)
'aria-label' => get_string('bulkactionselect', 'moodle', $text),
'data-action' => 'select'
);
if (!$category->can_resort_subcategories() && !$category->has_manage_capability()) {
@ -615,7 +616,8 @@ class core_course_management_renderer extends plugin_renderer_base {
'name' => 'bc[]',
'value' => $course->id,
'class' => 'bulk-action-checkbox',
'aria-label' => get_string('bulkactionselect', 'moodle', $text)
'aria-label' => get_string('bulkactionselect', 'moodle', $text),
'data-action' => 'select'
);
if (!$category->has_manage_capability()) {
// Very very hardcoded here.

View File

@ -946,7 +946,7 @@ class behat_course extends behat_base {
protected function get_management_category_listing_node_by_name($name, $link = false) {
$selector = "//div[@id='category-listing']//li[contains(concat(' ', normalize-space(@class), ' '), ' listitem-category ')]//a[text()='{$name}']";
if ($link === false) {
$selector .= "/ancestor::li[@data-id]";
$selector .= "/ancestor::li[@data-id][1]";
}
return $this->find('xpath', $selector);
}
@ -1001,39 +1001,70 @@ class behat_course extends behat_base {
}
/**
* Clicks on a category checkbox in the management interface.
* Clicks on a category checkbox in the management interface, if not checked.
*
* @Given /^I select category "(?P<name>[^"]*)" in the management interface$/
* @param string $name
*/
public function i_select_category_in_the_management_interface($name) {
$node = $this->get_management_category_listing_node_by_name($name);
$node->checkField('bcat[]');
$node = $node->findField('bcat[]');
if (!$node->isChecked()) {
$node->click();
}
}
/**
* Clicks course checkbox in the management interface.
* Clicks on a category checkbox in the management interface, if checked.
*
* @Given /^I unselect category "(?P<name>[^"]*)" in the management interface$/
* @param string $name
*/
public function i_unselect_category_in_the_management_interface($name) {
$node = $this->get_management_category_listing_node_by_name($name);
$node = $node->findField('bcat[]');
if ($node->isChecked()) {
$node->click();
}
}
/**
* Clicks course checkbox in the management interface, if not checked.
*
* @Given /^I select course "(?P<name>[^"]*)" in the management interface$/
* @param string $name
*/
public function i_select_course_in_the_management_interface($name) {
$node = $this->get_management_course_listing_node_by_name($name);
$node->checkField('bc[]');
$node = $node->findField('bc[]');
if (!$node->isChecked()) {
$node->click();
}
}
/**
* Clicks course checkbox in the management interface, if checked.
*
* @Given /^I unselect course "(?P<name>[^"]*)" in the management interface$/
* @param string $name
*/
public function i_unselect_course_in_the_management_interface($name) {
$node = $this->get_management_course_listing_node_by_name($name);
$node = $node->findField('bc[]');
if ($node->isChecked()) {
$node->click();
}
}
/**
* Move selected categories to top level in the management interface.
*
* @Given /^I move category "(?P<idnumber>[^"]*)" to top level in the management interface$/
* @param string $idnumber
* @Given /^I move category "(?P<name>[^"]*)" to top level in the management interface$/
* @param string $name
* @return Given[]
*/
public function i_move_category_to_top_level_in_the_management_interface($idnumber) {
$id = $this->get_category_id($idnumber);
$selector = sprintf('.listitem-category[data-id="%d"] > div', $id);
$node = $this->find('css', $selector);
$node->checkField('bcat[]');
public function i_move_category_to_top_level_in_the_management_interface($name) {
$this->i_select_category_in_the_management_interface($name);
return array(
new Given('I select "' . coursecat::get(0)->get_formatted_name() . '" from "menumovecategoriesto"'),
new Given('I press "bulkmovecategories"'),

View File

@ -231,7 +231,104 @@ Feature: Test category management actions
And I click on category "Cat 1" in the management interface
# Redirect
Then I should see category "CAT3" as subcategory of "CAT1" in the management interface
And I move category "CAT3" to top level in the management interface
And I move category "Cat 3" to top level in the management interface
# Redirect
And I should not see category "CAT3" as subcategory of "CAT1" in the management interface
Then I should see category "CAT2" as subcategory of "CAT1" in the management interface
@javascript
Scenario: Test bulk action is shown only when some category/course is selected
Given the following "categories" exists:
| name | category | idnumber |
| Cat 1 | 0 | CAT1 |
| Cat 2 | 0 | CAT2 |
| Cat 3 | 0 | CAT3 |
And the following "courses" exists:
| category | fullname | shortname | idnumber |
| CAT3 | Course 1 | Course 1 | C1 |
| CAT3 | Course 2 | Course 2 | C2 |
And I log in as "admin"
And I go to the courses management page
And I should see the "Course categories" management page
And I should see "Cat 1" in the "#category-listing ul.ml" "css_element"
And I should see "Cat 2" in the "#category-listing ul.ml" "css_element"
And I should see "Cat 3" in the "#category-listing ul.ml" "css_element"
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
When I select "allcategories" from "selectsortby"
Then the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And the "movecategoriesto" "select" should be disabled
And I select category "Cat 2" in the management interface
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I select "selectedcategories" from "selectsortby"
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect category "Cat 2" in the management interface
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And I select category "Cat 3" in the management interface
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I select category "Cat 2" in the management interface
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect category "Cat 2" in the management interface
And I unselect category "Cat 3" in the management interface
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And I click on category "Cat 1" in the management interface
# Redirect.
And I should see the "Course categories and courses" management page
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And the "movecoursesto" "select" should be disabled
And I click on category "Cat 3" in the management interface
#Redirect
And I should see the "Course categories and courses" management page
And I should see "Course 1" in the "#course-listing ul.ml" "css_element"
And I should see "Course 2" in the "#course-listing ul.ml" "css_element"
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And the "movecoursesto" "select" should be disabled
And I select course "Course 1" in the management interface
And the "movecoursesto" "select" should be enabled
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And I select course "Course 2" in the management interface
And the "movecoursesto" "select" should be enabled
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled
And I select category "Cat 3" in the management interface
And the "movecoursesto" "select" should be enabled
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect course "Course 2" in the management interface
And the "movecoursesto" "select" should be enabled
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect course "Course 1" in the management interface
And the "movecoursesto" "select" should be disabled
And the "movecategoriesto" "select" should be enabled
And the "resortcategoriesby" "select" should be enabled
And the "resortcoursesby" "select" should be enabled
And I unselect category "Cat 3" in the management interface
And the "movecoursesto" "select" should be disabled
And the "movecategoriesto" "select" should be disabled
And the "resortcategoriesby" "select" should be disabled
And the "resortcoursesby" "select" should be disabled

View File

@ -252,6 +252,21 @@ Console.prototype = {
if (!listing) {
return false;
}
// Disable category bulk actions as nothing will be selected on initialise.
var menumovecatto = listing.one('#menumovecategoriesto');
if (menumovecatto) {
menumovecatto.setAttribute('disabled', true);
}
var menuresortcategoriesby = listing.one('#menuresortcategoriesby');
if (menuresortcategoriesby) {
menuresortcategoriesby.setAttribute('disabled', true);
}
var menuresortcoursesby = listing.one('#menuresortcoursesby');
if (menuresortcoursesby) {
menuresortcoursesby.setAttribute('disabled', true);
}
listing.all('.listitem[data-id]').each(function(node){
this.set('categories', new Category({
node : node,
@ -261,6 +276,8 @@ Console.prototype = {
}, this);
if (!this.categoriesinit) {
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'a[data-action]', this);
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'input[name="bcat[]"]', this);
this.get('categorylisting').delegate('click', this.handleBulkSortByaction, '#menuselectsortby', this);
this.categoriesinit = true;
Y.log(count+' categories being managed', 'info', 'moodle-course-management');
} else {
@ -281,6 +298,13 @@ Console.prototype = {
if (!listing) {
return false;
}
// Disable course move to bulk action as nothing will be selected on initialise.
var menumovecoursesto = listing.one('#menumovecoursesto');
if (menumovecoursesto) {
menumovecoursesto.setAttribute('disabled', true);
}
listing.all('.listitem[data-id]').each(function(node){
this.registerCourse(new Course({
node : node,
@ -290,6 +314,7 @@ Console.prototype = {
count++;
}, this);
listing.delegate('click', this.handleCourseDelegation, 'a[data-action]', this);
listing.delegate('click', this.handleCourseDelegation, 'input[name="bc[]"]', this);
Y.log(count+' courses being managed', 'info', 'moodle-course-management');
},
@ -342,6 +367,118 @@ Console.prototype = {
}
},
/**
* Check if any course is selected.
*
* @method isCourseSelected
* @param {Node} checkboxnode Checkbox node on which action happened.
* @return bool
*/
isCourseSelected : function(checkboxnode) {
var selected = false;
// If any course selected then show move to category select box.
if (checkboxnode && checkboxnode.get('checked')) {
selected = true;
} else {
var i,
course,
courses = this.get('courses'),
length = courses.length;
for (i = 0; i < length; i++) {
if (courses.hasOwnProperty(i)) {
course = courses[i];
if (course.get('node').one('input[name="bc[]"]').get('checked')) {
selected = true;
break;
}
}
}
}
return selected;
},
/**
* Check if any category is selected.
*
* @method isCategorySelected
* @param {Node} checkboxnode Checkbox node on which action happened.
* @return bool
*/
isCategorySelected : function(checkboxnode) {
var selected = false;
// If any category selected then show move to category select box.
if (checkboxnode && checkboxnode.get('checked')) {
selected = true;
} else {
var i,
category,
categories = this.get('categories'),
length = categories.length;
for (i = 0; i < length; i++) {
if (categories.hasOwnProperty(i)) {
category = categories[i];
if (category.get('node').one('input[name="bcat[]"]').get('checked')) {
selected = true;
break;
}
}
}
}
return selected;
},
/**
* Handle bulk sort action.
*
* @method handleBulkSortByaction
* @protected
* @param {EventFacade} e
*/
handleBulkSortByaction : function(e) {
var sortcategoryby = this.get('categorylisting').one('#menuresortcategoriesby'),
sortcourseby = this.get('categorylisting').one('#menuresortcoursesby'),
sortbybutton = this.get('categorylisting').one('input[name="bulksort"]');
sortby = e;
if (!sortby) {
sortby = this.get('categorylisting').one('#menuselectsortby');
} else {
if (e && e.currentTarget) {
sortby = e.currentTarget;
}
}
// If no sortby select found then return as we can't do anything.
if (!sortby) {
return;
}
if ((this.get('categories').length <= 1) || (!this.isCategorySelected() &&
(sortby.get("options").item(sortby.get('selectedIndex')).getAttribute('value') === 'selectedcategories'))) {
if (sortcategoryby) {
sortcategoryby.setAttribute('disabled', true);
}
if (sortcourseby) {
sortcourseby.setAttribute('disabled', true);
}
if (sortbybutton) {
sortbybutton.setAttribute('disabled', true);
}
} else {
if (sortcategoryby) {
sortcategoryby.removeAttribute('disabled');
}
if (sortcourseby) {
sortcourseby.removeAttribute('disabled');
}
if (sortbybutton) {
sortbybutton.removeAttribute('disabled');
}
}
},
/**
* Returns the category with the given ID.
* @method getCategoryById
@ -1168,6 +1305,20 @@ Category.prototype = {
e.preventDefault();
this.collapse();
break;
case 'select':
var c = this.get('console'),
movecategoryto = c.get('categorylisting').one('#menumovecategoriesto');
// If any category is selected and there are more then one categories.
if (movecategoryto) {
if (c.isCategorySelected(e.currentTarget) &&
c.get('categories').length > 1) {
movecategoryto.removeAttribute('disabled');
} else {
movecategoryto.setAttribute('disabled', true);
}
c.handleBulkSortByaction();
}
break;
default:
Y.log('Invalid AJAX action requested of managed category.', 'warn', 'moodle-course-management');
return false;
@ -1569,6 +1720,17 @@ Course.prototype = {
e.halt();
managementconsole.performAjaxAction('hidecourse', args, this.hide, this);
break;
case 'select':
var c = this.get('console'),
movetonode = c.get('courselisting').one('#menumovecoursesto');
if (movetonode) {
if (c.isCourseSelected(e.currentTarget)) {
movetonode.removeAttribute('disabled');
} else {
movetonode.setAttribute('disabled', true);
}
}
break;
default:
Y.log('Invalid AJAX action requested of managed course.', 'warn', 'moodle-course-management');
return false;

File diff suppressed because one or more lines are too long

View File

@ -251,6 +251,21 @@ Console.prototype = {
if (!listing) {
return false;
}
// Disable category bulk actions as nothing will be selected on initialise.
var menumovecatto = listing.one('#menumovecategoriesto');
if (menumovecatto) {
menumovecatto.setAttribute('disabled', true);
}
var menuresortcategoriesby = listing.one('#menuresortcategoriesby');
if (menuresortcategoriesby) {
menuresortcategoriesby.setAttribute('disabled', true);
}
var menuresortcoursesby = listing.one('#menuresortcoursesby');
if (menuresortcoursesby) {
menuresortcoursesby.setAttribute('disabled', true);
}
listing.all('.listitem[data-id]').each(function(node){
this.set('categories', new Category({
node : node,
@ -260,6 +275,8 @@ Console.prototype = {
}, this);
if (!this.categoriesinit) {
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'a[data-action]', this);
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'input[name="bcat[]"]', this);
this.get('categorylisting').delegate('click', this.handleBulkSortByaction, '#menuselectsortby', this);
this.categoriesinit = true;
} else {
}
@ -278,6 +295,13 @@ Console.prototype = {
if (!listing) {
return false;
}
// Disable course move to bulk action as nothing will be selected on initialise.
var menumovecoursesto = listing.one('#menumovecoursesto');
if (menumovecoursesto) {
menumovecoursesto.setAttribute('disabled', true);
}
listing.all('.listitem[data-id]').each(function(node){
this.registerCourse(new Course({
node : node,
@ -287,6 +311,7 @@ Console.prototype = {
count++;
}, this);
listing.delegate('click', this.handleCourseDelegation, 'a[data-action]', this);
listing.delegate('click', this.handleCourseDelegation, 'input[name="bc[]"]', this);
},
/**
@ -336,6 +361,118 @@ Console.prototype = {
}
},
/**
* Check if any course is selected.
*
* @method isCourseSelected
* @param {Node} checkboxnode Checkbox node on which action happened.
* @return bool
*/
isCourseSelected : function(checkboxnode) {
var selected = false;
// If any course selected then show move to category select box.
if (checkboxnode && checkboxnode.get('checked')) {
selected = true;
} else {
var i,
course,
courses = this.get('courses'),
length = courses.length;
for (i = 0; i < length; i++) {
if (courses.hasOwnProperty(i)) {
course = courses[i];
if (course.get('node').one('input[name="bc[]"]').get('checked')) {
selected = true;
break;
}
}
}
}
return selected;
},
/**
* Check if any category is selected.
*
* @method isCategorySelected
* @param {Node} checkboxnode Checkbox node on which action happened.
* @return bool
*/
isCategorySelected : function(checkboxnode) {
var selected = false;
// If any category selected then show move to category select box.
if (checkboxnode && checkboxnode.get('checked')) {
selected = true;
} else {
var i,
category,
categories = this.get('categories'),
length = categories.length;
for (i = 0; i < length; i++) {
if (categories.hasOwnProperty(i)) {
category = categories[i];
if (category.get('node').one('input[name="bcat[]"]').get('checked')) {
selected = true;
break;
}
}
}
}
return selected;
},
/**
* Handle bulk sort action.
*
* @method handleBulkSortByaction
* @protected
* @param {EventFacade} e
*/
handleBulkSortByaction : function(e) {
var sortcategoryby = this.get('categorylisting').one('#menuresortcategoriesby'),
sortcourseby = this.get('categorylisting').one('#menuresortcoursesby'),
sortbybutton = this.get('categorylisting').one('input[name="bulksort"]');
sortby = e;
if (!sortby) {
sortby = this.get('categorylisting').one('#menuselectsortby');
} else {
if (e && e.currentTarget) {
sortby = e.currentTarget;
}
}
// If no sortby select found then return as we can't do anything.
if (!sortby) {
return;
}
if ((this.get('categories').length <= 1) || (!this.isCategorySelected() &&
(sortby.get("options").item(sortby.get('selectedIndex')).getAttribute('value') === 'selectedcategories'))) {
if (sortcategoryby) {
sortcategoryby.setAttribute('disabled', true);
}
if (sortcourseby) {
sortcourseby.setAttribute('disabled', true);
}
if (sortbybutton) {
sortbybutton.setAttribute('disabled', true);
}
} else {
if (sortcategoryby) {
sortcategoryby.removeAttribute('disabled');
}
if (sortcourseby) {
sortcourseby.removeAttribute('disabled');
}
if (sortbybutton) {
sortbybutton.removeAttribute('disabled');
}
}
},
/**
* Returns the category with the given ID.
* @method getCategoryById
@ -1144,6 +1281,20 @@ Category.prototype = {
e.preventDefault();
this.collapse();
break;
case 'select':
var c = this.get('console'),
movecategoryto = c.get('categorylisting').one('#menumovecategoriesto');
// If any category is selected and there are more then one categories.
if (movecategoryto) {
if (c.isCategorySelected(e.currentTarget) &&
c.get('categories').length > 1) {
movecategoryto.removeAttribute('disabled');
} else {
movecategoryto.setAttribute('disabled', true);
}
c.handleBulkSortByaction();
}
break;
default:
return false;
}
@ -1531,6 +1682,17 @@ Course.prototype = {
e.halt();
managementconsole.performAjaxAction('hidecourse', args, this.hide, this);
break;
case 'select':
var c = this.get('console'),
movetonode = c.get('courselisting').one('#menumovecoursesto');
if (movetonode) {
if (c.isCourseSelected(e.currentTarget)) {
movetonode.removeAttribute('disabled');
} else {
movetonode.setAttribute('disabled', true);
}
}
break;
default:
return false;
}

View File

@ -136,6 +136,20 @@ Category.prototype = {
e.preventDefault();
this.collapse();
break;
case 'select':
var c = this.get('console'),
movecategoryto = c.get('categorylisting').one('#menumovecategoriesto');
// If any category is selected and there are more then one categories.
if (movecategoryto) {
if (c.isCategorySelected(e.currentTarget) &&
c.get('categories').length > 1) {
movecategoryto.removeAttribute('disabled');
} else {
movecategoryto.setAttribute('disabled', true);
}
c.handleBulkSortByaction();
}
break;
default:
Y.log('Invalid AJAX action requested of managed category.', 'warn', 'moodle-course-management');
return false;

View File

@ -250,6 +250,21 @@ Console.prototype = {
if (!listing) {
return false;
}
// Disable category bulk actions as nothing will be selected on initialise.
var menumovecatto = listing.one('#menumovecategoriesto');
if (menumovecatto) {
menumovecatto.setAttribute('disabled', true);
}
var menuresortcategoriesby = listing.one('#menuresortcategoriesby');
if (menuresortcategoriesby) {
menuresortcategoriesby.setAttribute('disabled', true);
}
var menuresortcoursesby = listing.one('#menuresortcoursesby');
if (menuresortcoursesby) {
menuresortcoursesby.setAttribute('disabled', true);
}
listing.all('.listitem[data-id]').each(function(node){
this.set('categories', new Category({
node : node,
@ -259,6 +274,8 @@ Console.prototype = {
}, this);
if (!this.categoriesinit) {
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'a[data-action]', this);
this.get('categorylisting').delegate('click', this.handleCategoryDelegation, 'input[name="bcat[]"]', this);
this.get('categorylisting').delegate('click', this.handleBulkSortByaction, '#menuselectsortby', this);
this.categoriesinit = true;
Y.log(count+' categories being managed', 'info', 'moodle-course-management');
} else {
@ -279,6 +296,13 @@ Console.prototype = {
if (!listing) {
return false;
}
// Disable course move to bulk action as nothing will be selected on initialise.
var menumovecoursesto = listing.one('#menumovecoursesto');
if (menumovecoursesto) {
menumovecoursesto.setAttribute('disabled', true);
}
listing.all('.listitem[data-id]').each(function(node){
this.registerCourse(new Course({
node : node,
@ -288,6 +312,7 @@ Console.prototype = {
count++;
}, this);
listing.delegate('click', this.handleCourseDelegation, 'a[data-action]', this);
listing.delegate('click', this.handleCourseDelegation, 'input[name="bc[]"]', this);
Y.log(count+' courses being managed', 'info', 'moodle-course-management');
},
@ -340,6 +365,118 @@ Console.prototype = {
}
},
/**
* Check if any course is selected.
*
* @method isCourseSelected
* @param {Node} checkboxnode Checkbox node on which action happened.
* @return bool
*/
isCourseSelected : function(checkboxnode) {
var selected = false;
// If any course selected then show move to category select box.
if (checkboxnode && checkboxnode.get('checked')) {
selected = true;
} else {
var i,
course,
courses = this.get('courses'),
length = courses.length;
for (i = 0; i < length; i++) {
if (courses.hasOwnProperty(i)) {
course = courses[i];
if (course.get('node').one('input[name="bc[]"]').get('checked')) {
selected = true;
break;
}
}
}
}
return selected;
},
/**
* Check if any category is selected.
*
* @method isCategorySelected
* @param {Node} checkboxnode Checkbox node on which action happened.
* @return bool
*/
isCategorySelected : function(checkboxnode) {
var selected = false;
// If any category selected then show move to category select box.
if (checkboxnode && checkboxnode.get('checked')) {
selected = true;
} else {
var i,
category,
categories = this.get('categories'),
length = categories.length;
for (i = 0; i < length; i++) {
if (categories.hasOwnProperty(i)) {
category = categories[i];
if (category.get('node').one('input[name="bcat[]"]').get('checked')) {
selected = true;
break;
}
}
}
}
return selected;
},
/**
* Handle bulk sort action.
*
* @method handleBulkSortByaction
* @protected
* @param {EventFacade} e
*/
handleBulkSortByaction : function(e) {
var sortcategoryby = this.get('categorylisting').one('#menuresortcategoriesby'),
sortcourseby = this.get('categorylisting').one('#menuresortcoursesby'),
sortbybutton = this.get('categorylisting').one('input[name="bulksort"]');
sortby = e;
if (!sortby) {
sortby = this.get('categorylisting').one('#menuselectsortby');
} else {
if (e && e.currentTarget) {
sortby = e.currentTarget;
}
}
// If no sortby select found then return as we can't do anything.
if (!sortby) {
return;
}
if ((this.get('categories').length <= 1) || (!this.isCategorySelected() &&
(sortby.get("options").item(sortby.get('selectedIndex')).getAttribute('value') === 'selectedcategories'))) {
if (sortcategoryby) {
sortcategoryby.setAttribute('disabled', true);
}
if (sortcourseby) {
sortcourseby.setAttribute('disabled', true);
}
if (sortbybutton) {
sortbybutton.setAttribute('disabled', true);
}
} else {
if (sortcategoryby) {
sortcategoryby.removeAttribute('disabled');
}
if (sortcourseby) {
sortcourseby.removeAttribute('disabled');
}
if (sortbybutton) {
sortbybutton.removeAttribute('disabled');
}
}
},
/**
* Returns the category with the given ID.
* @method getCategoryById

View File

@ -110,6 +110,17 @@ Course.prototype = {
e.halt();
managementconsole.performAjaxAction('hidecourse', args, this.hide, this);
break;
case 'select':
var c = this.get('console'),
movetonode = c.get('courselisting').one('#menumovecoursesto');
if (movetonode) {
if (c.isCourseSelected(e.currentTarget)) {
movetonode.removeAttribute('disabled');
} else {
movetonode.setAttribute('disabled', true);
}
}
break;
default:
Y.log('Invalid AJAX action requested of managed course.', 'warn', 'moodle-course-management');
return false;