Skip to content

Commit

Permalink
Improve: Make sure smart menu "locations" is filled with value, resolves
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace authored and abias committed May 11, 2024
1 parent 497bebd commit 58446af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
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 location field required
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"
And I should see "Required" in the "#fitem_id_location" "css_element"
Then I set the field "Menu location(s)" to "Main"
And I click on "Save and return" "button"
And 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 58446af

Please sign in to comment.