MOBILE-2416 core: Fix redirect to main menu
parent
e3aee5c3d1
commit
e80f5a1301
|
@ -44,6 +44,8 @@ export class CoreIonTabsComponent extends Tabs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Input() selectedDisabled: boolean; // Whether the initial tab selected can be a disabled tab.
|
||||||
|
|
||||||
@ViewChild('originalTabs') originalTabsRef: ElementRef;
|
@ViewChild('originalTabs') originalTabsRef: ElementRef;
|
||||||
|
|
||||||
_loaded: boolean; // Whether tabs have been loaded.
|
_loaded: boolean; // Whether tabs have been loaded.
|
||||||
|
@ -135,7 +137,16 @@ export class CoreIonTabsComponent extends Tabs {
|
||||||
if (!this.initialized && (this._loaded || typeof this._loaded == 'undefined')) {
|
if (!this.initialized && (this._loaded || typeof this._loaded == 'undefined')) {
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
|
|
||||||
return super.initTabs();
|
return super.initTabs().then(() => {
|
||||||
|
// Tabs initialized. Force select the tab if it's not enabled.
|
||||||
|
if (this.selectedDisabled && typeof this.selectedIndex != 'undefined') {
|
||||||
|
const tab = this.getByIndex(this.selectedIndex);
|
||||||
|
|
||||||
|
if (tab && (!tab.enabled || !tab.show)) {
|
||||||
|
this.select(tab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
// Tabs not loaded yet. Set the tab bar position so the tab bar is shown, it'll have a spinner.
|
// Tabs not loaded yet. Set the tab bar position so the tab bar is shown, it'll have a spinner.
|
||||||
this.setTabbarPosition(-1, 0);
|
this.setTabbarPosition(-1, 0);
|
||||||
|
|
|
@ -333,13 +333,13 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
* User entered the page.
|
* User entered the page.
|
||||||
*/
|
*/
|
||||||
ionViewDidEnter(): void {
|
ionViewDidEnter(): void {
|
||||||
this.formatComponent.ionViewDidEnter();
|
this.formatComponent && this.formatComponent.ionViewDidEnter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User left the page.
|
* User left the page.
|
||||||
*/
|
*/
|
||||||
ionViewDidLeave(): void {
|
ionViewDidLeave(): void {
|
||||||
this.formatComponent.ionViewDidLeave();
|
this.formatComponent && this.formatComponent.ionViewDidLeave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Location } from '@angular/common';
|
||||||
import { Platform } from 'ionic-angular';
|
import { Platform } from 'ionic-angular';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { CoreAppProvider } from '@providers/app';
|
import { CoreAppProvider } from '@providers/app';
|
||||||
|
@ -81,7 +82,8 @@ export class CoreLoginHelperProvider {
|
||||||
private wsProvider: CoreWSProvider, private translate: TranslateService, private textUtils: CoreTextUtilsProvider,
|
private wsProvider: CoreWSProvider, private translate: TranslateService, private textUtils: CoreTextUtilsProvider,
|
||||||
private eventsProvider: CoreEventsProvider, private appProvider: CoreAppProvider, private utils: CoreUtilsProvider,
|
private eventsProvider: CoreEventsProvider, private appProvider: CoreAppProvider, private utils: CoreUtilsProvider,
|
||||||
private urlUtils: CoreUrlUtilsProvider, private configProvider: CoreConfigProvider, private platform: Platform,
|
private urlUtils: CoreUrlUtilsProvider, private configProvider: CoreConfigProvider, private platform: Platform,
|
||||||
private initDelegate: CoreInitDelegate, private sitePluginsProvider: CoreSitePluginsProvider) {
|
private initDelegate: CoreInitDelegate, private sitePluginsProvider: CoreSitePluginsProvider,
|
||||||
|
private location: Location) {
|
||||||
this.logger = logger.getInstance('CoreLoginHelper');
|
this.logger = logger.getInstance('CoreLoginHelper');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,6 +410,10 @@ export class CoreLoginHelperProvider {
|
||||||
* @return {Promise<any>} Promise resolved when done.
|
* @return {Promise<any>} Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
goToSiteInitialPage(): Promise<any> {
|
goToSiteInitialPage(): Promise<any> {
|
||||||
|
// Due to DeepLinker, we need to remove the path from the URL before going to main menu.
|
||||||
|
// IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL.
|
||||||
|
this.location.replaceState('');
|
||||||
|
|
||||||
return this.appProvider.getRootNavController().setRoot('CoreMainMenuPage');
|
return this.appProvider.getRootNavController().setRoot('CoreMainMenuPage');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,6 +603,10 @@ export class CoreLoginHelperProvider {
|
||||||
* @param {any} params Params to pass to the page.
|
* @param {any} params Params to pass to the page.
|
||||||
*/
|
*/
|
||||||
protected loadPageInMainMenu(page: string, params: any): void {
|
protected loadPageInMainMenu(page: string, params: any): void {
|
||||||
|
// Due to DeepLinker, we need to remove the path from the URL before going to main menu.
|
||||||
|
// IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL.
|
||||||
|
this.location.replaceState('');
|
||||||
|
|
||||||
this.appProvider.getRootNavController().setRoot('CoreMainMenuPage', { redirectPage: page, redirectParams: params });
|
this.appProvider.getRootNavController().setRoot('CoreMainMenuPage', { redirectPage: page, redirectParams: params });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<core-ion-tabs #mainTabs [hidden]="!showTabs" [loaded]="loaded" [selectedIndex]="initialTab" tabsPlacement="bottom" tabsLayout="title-hide">
|
<core-ion-tabs #mainTabs [hidden]="!showTabs" [loaded]="loaded" [selectedIndex]="initialTab" [selectedDisabled]="!!redirectPage" tabsPlacement="bottom" tabsLayout="title-hide">
|
||||||
<core-ion-tab [enabled]="false" [show]="false" [root]="redirectPage" [rootParams]="redirectParams"></core-ion-tab>
|
<core-ion-tab [enabled]="false" [show]="false" [root]="redirectPage" [rootParams]="redirectParams"></core-ion-tab>
|
||||||
<core-ion-tab *ngFor="let tab of tabs" [root]="tab.page" [rootParams]="tab.pageParams" [tabTitle]="tab.title | translate" [tabIcon]="tab.icon" [tabBadge]="tab.badge" class="{{tab.class}}"></core-ion-tab>
|
<core-ion-tab *ngFor="let tab of tabs" [root]="tab.page" [rootParams]="tab.pageParams" [tabTitle]="tab.title | translate" [tabIcon]="tab.icon" [tabBadge]="tab.badge" class="{{tab.class}}"></core-ion-tab>
|
||||||
<core-ion-tab root="CoreMainMenuMorePage" [tabTitle]="'core.more' | translate" tabIcon="more"></core-ion-tab>
|
<core-ion-tab root="CoreMainMenuMorePage" [tabTitle]="'core.more' | translate" tabIcon="more"></core-ion-tab>
|
||||||
|
|
Loading…
Reference in New Issue