Skip to content

Commit 120574b

Browse files
prasanna-lmsaceabias
authored andcommitted
Improvement: Make sure smart menu "locations" is filled with value, resolves #404 (#636)
1 parent 4f6057f commit 120574b

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changes
66

77
### Unreleased
88

9+
* 2024-05-11 - Improvement: Smart menu "locations" must be filled with a value, resolves #404
910
* 2024-05-10 - Bugfix: Do not show empty smart menus to users, resolves #405
1011
* 2024-05-09 - Bugfix: Smart menu menubar overlaid course index, resolves #607
1112
* 2024-04-27 - Improvement: Add navigation to policy overview page, resolves #633

classes/form/smartmenu_edit_form.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public function definition() {
7777
$locationtypes);
7878
$mform->addHelpButton('location', 'smartmenusmenulocation', 'theme_boost_union');
7979
$location->setMultiple(true);
80+
$mform->addRule('location', get_string('required'), 'required');
8081

8182
// Add mode as select element.
8283
$modeoptions = [
@@ -320,6 +321,11 @@ public function validation($data, $files) {
320321
}
321322
}
322323

324+
// Validate the smart menu location is filled.
325+
if (empty($data['location'])) {
326+
$errors['location'] = get_string('required');
327+
}
328+
323329
// Return errors.
324330
return $errors;
325331
}

tests/behat/theme_boost_union_smartmenusettings_menus_management.feature

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ Feature: Configuring the theme_boost_union plugin on the "Smart menus" page, man
6262
And I click on "Create menu" "button"
6363
And I set the following fields to these values:
6464
| Title | Links |
65+
| Menu location(s) | Main |
6566
And I click on "Save and return" "button"
6667
And I should see "Links" in the "smartmenus" "table"
6768
And ".action-delete" "css_element" should exist in the "smartmenus" "table"
@@ -109,21 +110,41 @@ Feature: Configuring the theme_boost_union plugin on the "Smart menus" page, man
109110
And I click on ".action-show" "css_element" in the "Links" "table_row"
110111
Then I should see smart menu "Links" in location "Main, Menu, User, Bottom"
111112

113+
@javascript
112114
Scenario: Smartmenus: Menus: Management - Move an existing smart menu up and down
113115
When I log in as "admin"
114116
And I navigate to smart menus
115117
And I click on "Create menu" "button"
116118
And I set the following fields to these values:
117119
| Title | Enrolled courses |
120+
| Menu location(s) | Main |
118121
And I click on "Save and return" "button"
119122
And I should see "Enrolled courses" in the "smartmenus" "table"
120123
And I click on "Create menu" "button"
121124
And I set the following fields to these values:
122125
| Title | Completed courses |
126+
| Menu location(s) | Main |
123127
And I click on "Save and return" "button"
124128
And I should see "Completed courses" in the "smartmenus" "table"
125129
And "Enrolled courses" "table_row" should appear before "Completed courses" "table_row"
126130
And I click on ".sort-smartmenus-up-action" "css_element" in the "Completed courses" "table_row"
127131
Then "Enrolled courses" "table_row" should appear after "Completed courses" "table_row"
128132
And I click on ".sort-smartmenus-up-action" "css_element" in the "Enrolled courses" "table_row"
129133
And "Enrolled courses" "table_row" should appear before "Completed courses" "table_row"
134+
135+
@javascript
136+
Scenario: Smartmenus: Menus: Management - Make sure that location field is filled
137+
When I log in as "admin"
138+
And I navigate to smart menus
139+
And I click on "Create menu" "button"
140+
And I set the following fields to these values:
141+
| Title | Links |
142+
And I click on "Save and return" "button"
143+
Then I should see "Required" in the "#fitem_id_location" "css_element"
144+
And I set the field "Menu location(s)" to "Main"
145+
And I click on "Save and return" "button"
146+
Then I should see "Links" in the "smartmenus" "table"
147+
And I set "Links" smart menu items with the following fields to these values:
148+
| Title | Info |
149+
| Menu item type | Heading |
150+
Then I should see smart menu "Links" in location "Main"

0 commit comments

Comments
 (0)