Skip to content

Commit

Permalink
Improvement: Make sure smart menu "locations" is filled with value, r…
Browse files Browse the repository at this point in the history
…esolves #404 (#636)
  • Loading branch information
prasanna-lmsace authored May 11, 2024
1 parent 497bebd commit af0be32
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2024-05-11 - Improvement: Smart menu "locations" must be filled with a value, resolves #404
* 2024-05-10 - Bugfix: Do not show empty smart menus to users, resolves #405
* 2024-05-09 - Bugfix: Smart menu menubar overlaid course index, resolves #607
* 2024-04-27 - Improvement: Add navigation to policy overview page, resolves #633
Expand Down
6 changes: 6 additions & 0 deletions classes/form/smartmenu_edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function definition() {
$locationtypes);
$mform->addHelpButton('location', 'smartmenusmenulocation', 'theme_boost_union');
$location->setMultiple(true);
$mform->addRule('location', get_string('required'), 'required');

// Add mode as select element.
$modeoptions = [
Expand Down Expand Up @@ -320,6 +321,11 @@ public function validation($data, $files) {
}
}

// Validate the smart menu location is filled.
if (empty($data['location'])) {
$errors['location'] = get_string('required');
}

// Return errors.
return $errors;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Feature: Configuring the theme_boost_union plugin on the "Smart menus" page, man
And I click on "Create menu" "button"
And I set the following fields to these values:
| Title | Links |
| Menu location(s) | Main |
And I click on "Save and return" "button"
And I should see "Links" in the "smartmenus" "table"
And ".action-delete" "css_element" should exist in the "smartmenus" "table"
Expand Down Expand Up @@ -109,21 +110,41 @@ Feature: Configuring the theme_boost_union plugin on the "Smart menus" page, man
And I click on ".action-show" "css_element" in the "Links" "table_row"
Then I should see smart menu "Links" in location "Main, Menu, User, Bottom"

@javascript
Scenario: Smartmenus: Menus: Management - Move an existing smart menu up and down
When I log in as "admin"
And I navigate to smart menus
And I click on "Create menu" "button"
And I set the following fields to these values:
| Title | Enrolled courses |
| Menu location(s) | Main |
And I click on "Save and return" "button"
And I should see "Enrolled courses" in the "smartmenus" "table"
And I click on "Create menu" "button"
And I set the following fields to these values:
| Title | Completed courses |
| Menu location(s) | Main |
And I click on "Save and return" "button"
And I should see "Completed courses" in the "smartmenus" "table"
And "Enrolled courses" "table_row" should appear before "Completed courses" "table_row"
And I click on ".sort-smartmenus-up-action" "css_element" in the "Completed courses" "table_row"
Then "Enrolled courses" "table_row" should appear after "Completed courses" "table_row"
And I click on ".sort-smartmenus-up-action" "css_element" in the "Enrolled courses" "table_row"
And "Enrolled courses" "table_row" should appear before "Completed courses" "table_row"

@javascript
Scenario: Smartmenus: Menus: Management - Make sure that location field is filled
When I log in as "admin"
And I navigate to smart menus
And I click on "Create menu" "button"
And I set the following fields to these values:
| Title | Links |
And I click on "Save and return" "button"
Then I should see "Required" in the "#fitem_id_location" "css_element"
And I set the field "Menu location(s)" to "Main"
And I click on "Save and return" "button"
Then I should see "Links" in the "smartmenus" "table"
And I set "Links" smart menu items with the following fields to these values:
| Title | Info |
| Menu item type | Heading |
Then I should see smart menu "Links" in location "Main"

0 comments on commit af0be32

Please sign in to comment.