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 committed Apr 20, 2024
1 parent 5ffc920 commit e244d50
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 @@ -59,6 +59,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 @@ -112,21 +113,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 e244d50

Please sign in to comment.