MOBILE-4025 mainmenu: Navigate when tab disappears
parent
dd9ee9c1fc
commit
4f394fb407
|
@ -95,6 +95,17 @@ class behat_app extends behat_app_helper {
|
||||||
$this->prepare_browser(['skiponboarding' => empty($runtime)]);
|
$this->prepare_browser(['skiponboarding' => empty($runtime)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restart the app.
|
||||||
|
*
|
||||||
|
* @When I restart the app
|
||||||
|
*/
|
||||||
|
public function i_restart_the_app() {
|
||||||
|
$this->getSession()->visit($this->ionicurl);
|
||||||
|
|
||||||
|
$this->i_wait_the_app_to_restart();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then I wait the app to restart
|
* @Then I wait the app to restart
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -121,7 +121,7 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
|
||||||
// Remove the handlers that should only appear in the More menu.
|
// Remove the handlers that should only appear in the More menu.
|
||||||
this.allHandlers = handlers;
|
this.allHandlers = handlers;
|
||||||
|
|
||||||
this.initHandlers();
|
this.updateHandlers();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.badgeUpdateObserver = CoreEvents.on(CoreMainMenuProvider.MAIN_MENU_HANDLER_BADGE_UPDATED, (data) => {
|
this.badgeUpdateObserver = CoreEvents.on(CoreMainMenuProvider.MAIN_MENU_HANDLER_BADGE_UPDATED, (data) => {
|
||||||
|
@ -131,7 +131,7 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.resizeListener = CoreDom.onWindowResize(() => {
|
this.resizeListener = CoreDom.onWindowResize(() => {
|
||||||
this.initHandlers();
|
this.updateHandlers();
|
||||||
});
|
});
|
||||||
document.addEventListener('ionBackButton', this.backButtonFunction);
|
document.addEventListener('ionBackButton', this.backButtonFunction);
|
||||||
|
|
||||||
|
@ -140,11 +140,11 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
|
||||||
// Init handlers again once keyboard is closed since the resize event doesn't have the updated height.
|
// Init handlers again once keyboard is closed since the resize event doesn't have the updated height.
|
||||||
this.keyboardObserver = CoreEvents.on(CoreEvents.KEYBOARD_CHANGE, (kbHeight: number) => {
|
this.keyboardObserver = CoreEvents.on(CoreEvents.KEYBOARD_CHANGE, (kbHeight: number) => {
|
||||||
if (kbHeight === 0) {
|
if (kbHeight === 0) {
|
||||||
this.initHandlers();
|
this.updateHandlers();
|
||||||
|
|
||||||
// If the device is slow it can take a bit more to update the window height. Retry in a few ms.
|
// If the device is slow it can take a bit more to update the window height. Retry in a few ms.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.initHandlers();
|
this.updateHandlers();
|
||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -152,9 +152,9 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init handlers on change (size or handlers).
|
* Update handlers on change (size or handlers).
|
||||||
*/
|
*/
|
||||||
async initHandlers(): Promise<void> {
|
async updateHandlers(): Promise<void> {
|
||||||
if (!this.allHandlers) {
|
if (!this.allHandlers) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +166,7 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
|
||||||
.slice(0, CoreMainMenu.getNumItems()); // Get main handlers.
|
.slice(0, CoreMainMenu.getNumItems()); // Get main handlers.
|
||||||
|
|
||||||
// Re-build the list of tabs. If a handler is already in the list, use existing object to prevent re-creating the tab.
|
// Re-build the list of tabs. If a handler is already in the list, use existing object to prevent re-creating the tab.
|
||||||
|
const previousTabs = this.tabs.map(tab => tab.page);
|
||||||
const newTabs: CoreMainMenuHandlerToDisplay[] = [];
|
const newTabs: CoreMainMenuHandlerToDisplay[] = [];
|
||||||
|
|
||||||
for (let i = 0; i < handlers.length; i++) {
|
for (let i = 0; i < handlers.length; i++) {
|
||||||
|
@ -188,9 +189,12 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
this.updateMoreBadge();
|
this.updateMoreBadge();
|
||||||
|
|
||||||
|
const removedTabs = previousTabs.filter(page => !this.tabs.some(tab => tab.page === page));
|
||||||
|
const mainMenuTab = CoreNavigator.getCurrentMainMenuTab();
|
||||||
|
|
||||||
this.loaded = CoreMainMenuDelegate.areHandlersLoaded();
|
this.loaded = CoreMainMenuDelegate.areHandlersLoaded();
|
||||||
|
|
||||||
if (this.loaded && !CoreNavigator.getCurrentMainMenuTab()) {
|
if (this.loaded && (!mainMenuTab || removedTabs.includes(mainMenuTab))) {
|
||||||
// No tab selected, select the first one.
|
// No tab selected, select the first one.
|
||||||
await CoreUtils.nextTick();
|
await CoreUtils.nextTick();
|
||||||
|
|
||||||
|
@ -199,7 +203,7 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
|
||||||
this.logger.debug(`Select first tab: ${tabPage}.`, this.tabs);
|
this.logger.debug(`Select first tab: ${tabPage}.`, this.tabs);
|
||||||
|
|
||||||
// Use navigate instead of mainTabs.select to be able to pass page params.
|
// Use navigate instead of mainTabs.select to be able to pass page params.
|
||||||
CoreNavigator.navigate(tabPage, {
|
CoreNavigator.navigateToSitePath(tabPage, {
|
||||||
params: {
|
params: {
|
||||||
urlToOpen: this.urlToOpen,
|
urlToOpen: this.urlToOpen,
|
||||||
redirectPath: this.redirectPath,
|
redirectPath: this.redirectPath,
|
||||||
|
|
|
@ -16,8 +16,8 @@ Feature: Main Menu opens the right page
|
||||||
Scenario: Opens Site Home when defaulthomepage is set to Site
|
Scenario: Opens Site Home when defaulthomepage is set to Site
|
||||||
Given the following config values are set as admin:
|
Given the following config values are set as admin:
|
||||||
| defaulthomepage | 0 |
|
| defaulthomepage | 0 |
|
||||||
Given I entered the app as "student"
|
And I entered the app as "student"
|
||||||
When "Site home" should be selected in the app
|
Then "Site home" should be selected in the app
|
||||||
And I should find "Available courses" in the app
|
And I should find "Available courses" in the app
|
||||||
And "Site home" "text" should appear before "Dashboard" "text" in the ".core-tabs-bar" "css_element"
|
And "Site home" "text" should appear before "Dashboard" "text" in the ".core-tabs-bar" "css_element"
|
||||||
And "Home" "text" should appear before "My courses" "text" in the ".mainmenu-tabs" "css_element"
|
And "Home" "text" should appear before "My courses" "text" in the ".mainmenu-tabs" "css_element"
|
||||||
|
@ -26,8 +26,8 @@ Feature: Main Menu opens the right page
|
||||||
Scenario: Opens Dashboard when defaulthomepage is set to Dashboard
|
Scenario: Opens Dashboard when defaulthomepage is set to Dashboard
|
||||||
Given the following config values are set as admin:
|
Given the following config values are set as admin:
|
||||||
| defaulthomepage | 1 |
|
| defaulthomepage | 1 |
|
||||||
Given I entered the app as "student"
|
And I entered the app as "student"
|
||||||
When "Dashboard" should be selected in the app
|
Then "Dashboard" should be selected in the app
|
||||||
And I should find "Timeline" in the app
|
And I should find "Timeline" in the app
|
||||||
And "Dashboard" "text" should appear before "Site home" "text" in the ".core-tabs-bar" "css_element"
|
And "Dashboard" "text" should appear before "Site home" "text" in the ".core-tabs-bar" "css_element"
|
||||||
And "Home" "text" should appear before "My courses" "text" in the ".mainmenu-tabs" "css_element"
|
And "Home" "text" should appear before "My courses" "text" in the ".mainmenu-tabs" "css_element"
|
||||||
|
@ -36,7 +36,19 @@ Feature: Main Menu opens the right page
|
||||||
Scenario: Opens My Courses when defaulthomepage is set to My Courses
|
Scenario: Opens My Courses when defaulthomepage is set to My Courses
|
||||||
Given the following config values are set as admin:
|
Given the following config values are set as admin:
|
||||||
| defaulthomepage | 3 |
|
| defaulthomepage | 3 |
|
||||||
Given I entered the app as "student"
|
And I entered the app as "student"
|
||||||
When "My courses" near "Home" should be selected in the app
|
Then "My courses" near "Home" should be selected in the app
|
||||||
And I should find "Course 1" in the app
|
And I should find "Course 1" in the app
|
||||||
And "My courses" "text" should appear before "Home" "text" in the ".mainmenu-tabs" "css_element"
|
And "My courses" "text" should appear before "Home" "text" in the ".mainmenu-tabs" "css_element"
|
||||||
|
|
||||||
|
@lms_from4.0
|
||||||
|
Scenario: Opens first tab after Site Home, Dashboard, and My Courses are disabled
|
||||||
|
Given I entered the app as "student"
|
||||||
|
Then "Dashboard" should be selected in the app
|
||||||
|
|
||||||
|
When the following config values are set as admin:
|
||||||
|
| disabledfeatures | $mmSideMenuDelegate_mmaFrontpage,CoreMainMenuDelegate_CoreCoursesDashboard,$mmSideMenuDelegate_mmCourses | tool_mobile |
|
||||||
|
And I restart the app
|
||||||
|
Then I should find "Contacts" in the app
|
||||||
|
But I should not find "Home" in the app
|
||||||
|
And I should not find "My courses" in the app
|
||||||
|
|
Loading…
Reference in New Issue