MOBILE-2735 ux: Make all link handlers open a new page
parent
04ebb8e50c
commit
08322a299d
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
||||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||||
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
|
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||||
import { AddonBadgesProvider } from './badges';
|
import { AddonBadgesProvider } from './badges';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ export class AddonBadgesBadgeLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
name = 'AddonBadgesBadgeLinkHandler';
|
name = 'AddonBadgesBadgeLinkHandler';
|
||||||
pattern = /\/badges\/badge\.php.*([\?\&]hash=)/;
|
pattern = /\/badges\/badge\.php.*([\?\&]hash=)/;
|
||||||
|
|
||||||
constructor(private badgesProvider: AddonBadgesProvider, private loginHelper: CoreLoginHelperProvider) {
|
constructor(private badgesProvider: AddonBadgesProvider, private linkHelper: CoreContentLinksHelperProvider) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,7 @@ export class AddonBadgesBadgeLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
this.linkHelper.goInSite(navCtrl, 'AddonBadgesIssuedBadgePage', {courseId: 0, badgeHash: params.hash}, siteId);
|
||||||
this.loginHelper.redirect('AddonBadgesIssuedBadgePage', {courseId: 0, badgeHash: params.hash}, siteId);
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
||||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||||
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
|
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||||
import { AddonBadgesProvider } from './badges';
|
import { AddonBadgesProvider } from './badges';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ export class AddonBadgesMyBadgesLinkHandler extends CoreContentLinksHandlerBase
|
||||||
featureName = 'CoreUserDelegate_AddonBadges';
|
featureName = 'CoreUserDelegate_AddonBadges';
|
||||||
pattern = /\/badges\/mybadges\.php/;
|
pattern = /\/badges\/mybadges\.php/;
|
||||||
|
|
||||||
constructor(private badgesProvider: AddonBadgesProvider, private loginHelper: CoreLoginHelperProvider) {
|
constructor(private badgesProvider: AddonBadgesProvider, private linkHelper: CoreContentLinksHelperProvider) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,7 @@ export class AddonBadgesMyBadgesLinkHandler extends CoreContentLinksHandlerBase
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
this.linkHelper.goInSite(navCtrl, 'AddonBadgesUserBadgesPage', {}, siteId);
|
||||||
this.loginHelper.redirect('AddonBadgesUserBadgesPage', {}, siteId);
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
||||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||||
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
|
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||||
import { AddonBlogProvider } from './blog';
|
import { AddonBlogProvider } from './blog';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ export class AddonBlogIndexLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
featureName = 'CoreUserDelegate_AddonBlog:blogs';
|
featureName = 'CoreUserDelegate_AddonBlog:blogs';
|
||||||
pattern = /\/blog\/index\.php/;
|
pattern = /\/blog\/index\.php/;
|
||||||
|
|
||||||
constructor(private blogProvider: AddonBlogProvider, private loginHelper: CoreLoginHelperProvider) {
|
constructor(private blogProvider: AddonBlogProvider, private linkHelper: CoreContentLinksHelperProvider) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,7 @@ export class AddonBlogIndexLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
this.linkHelper.goInSite(navCtrl, 'AddonBlogEntriesPage', pageParams, siteId, !Object.keys(pageParams).length);
|
||||||
this.loginHelper.redirect('AddonBlogEntriesPage', pageParams, siteId);
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ export class AddonBlogUserHandler implements CoreUserProfileHandler {
|
||||||
action: (event, navCtrl, user, courseId): void => {
|
action: (event, navCtrl, user, courseId): void => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'AddonBlogEntriesPage', { userId: user.id, courseId: courseId });
|
this.linkHelper.goInSite(navCtrl, 'AddonBlogEntriesPage', { userId: user.id, courseId: courseId });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
||||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||||
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
|
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||||
import { AddonCompetencyProvider } from './competency';
|
import { AddonCompetencyProvider } from './competency';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ export class AddonCompetencyPlansLinkHandler extends CoreContentLinksHandlerBase
|
||||||
name = 'AddonCompetencyPlansLinkHandler';
|
name = 'AddonCompetencyPlansLinkHandler';
|
||||||
pattern = /\/admin\/tool\/lp\/plans\.php/;
|
pattern = /\/admin\/tool\/lp\/plans\.php/;
|
||||||
|
|
||||||
constructor(private loginHelper: CoreLoginHelperProvider, private competencyProvider: AddonCompetencyProvider) {
|
constructor(private linkHelper: CoreContentLinksHelperProvider, private competencyProvider: AddonCompetencyProvider) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ export class AddonCompetencyPlansLinkHandler extends CoreContentLinksHandlerBase
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
this.linkHelper.goInSite(navCtrl, 'AddonCompetencyPlanListPage', { userId: params.userid }, siteId,
|
||||||
this.loginHelper.redirect('AddonCompetencyPlanListPage', { userId: params.userid }, siteId);
|
typeof params.userid == 'undefined');
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
|
||||||
action: (event, navCtrl, user, courseId): void => {
|
action: (event, navCtrl, user, courseId): void => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'AddonCompetencyCourseCompetenciesPage', {courseId, userId: user.id});
|
this.linkHelper.goInSite(navCtrl, 'AddonCompetencyCourseCompetenciesPage', {courseId, userId: user.id});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -123,7 +123,7 @@ export class AddonCompetencyUserHandler implements CoreUserProfileHandler {
|
||||||
action: (event, navCtrl, user, courseId): void => {
|
action: (event, navCtrl, user, courseId): void => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'AddonCompetencyPlanListPage', {userId: user.id});
|
this.linkHelper.goInSite(navCtrl, 'AddonCompetencyPlanListPage', {userId: user.id});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,7 +43,6 @@ export class AddonMessagesContactRequestLinkHandler extends CoreContentLinksHand
|
||||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'AddonMessagesContactsPage', {}, siteId);
|
this.linkHelper.goInSite(navCtrl, 'AddonMessagesContactsPage', {}, siteId);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -49,7 +49,6 @@ export class AddonMessagesDiscussionLinkHandler extends CoreContentLinksHandlerB
|
||||||
const stateParams = {
|
const stateParams = {
|
||||||
userId: parseInt(params.id || params.user2, 10)
|
userId: parseInt(params.id || params.user2, 10)
|
||||||
};
|
};
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'AddonMessagesDiscussionPage', stateParams, siteId);
|
this.linkHelper.goInSite(navCtrl, 'AddonMessagesDiscussionPage', stateParams, siteId);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -49,7 +49,6 @@ export class AddonMessagesIndexLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
pageName = 'AddonMessagesGroupConversationsPage';
|
pageName = 'AddonMessagesGroupConversationsPage';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, pageName, undefined, siteId);
|
this.linkHelper.goInSite(navCtrl, pageName, undefined, siteId);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -76,7 +76,6 @@ export class AddonMessagesSendMessageUserHandler implements CoreUserProfileHandl
|
||||||
showKeyboard: true,
|
showKeyboard: true,
|
||||||
userId: user.id
|
userId: user.id
|
||||||
};
|
};
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'AddonMessagesDiscussionPage', pageParams);
|
this.linkHelper.goInSite(navCtrl, 'AddonMessagesDiscussionPage', pageParams);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -99,7 +99,7 @@ export class AddonNotesUserHandler implements CoreUserProfileHandler {
|
||||||
action: (event, navCtrl, user, courseId): void => {
|
action: (event, navCtrl, user, courseId): void => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'AddonNotesListPage', { userId: user.id, courseId: courseId });
|
this.linkHelper.goInSite(navCtrl, 'AddonNotesListPage', { userId: user.id, courseId: courseId });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,6 @@ export class CoreContentLinksModuleListHandler extends CoreContentLinksHandlerBa
|
||||||
title: this.title || this.translate.instant('addon.mod_' + this.modName + '.modulenameplural')
|
title: this.title || this.translate.instant('addon.mod_' + this.modName + '.modulenameplural')
|
||||||
};
|
};
|
||||||
|
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'CoreCourseListModTypePage', stateParams, siteId);
|
this.linkHelper.goInSite(navCtrl, 'CoreCourseListModTypePage', stateParams, siteId);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { CoreConstants } from '@core/constants';
|
||||||
import { CoreConfigConstants } from '../../../configconstants';
|
import { CoreConfigConstants } from '../../../configconstants';
|
||||||
import { CoreSitePluginsProvider } from '@core/siteplugins/providers/siteplugins';
|
import { CoreSitePluginsProvider } from '@core/siteplugins/providers/siteplugins';
|
||||||
import { CoreSite } from '@classes/site';
|
import { CoreSite } from '@classes/site';
|
||||||
|
import { CoreMainMenuProvider } from '@core/mainmenu/providers/mainmenu';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features regarding content links.
|
* Service that provides some features regarding content links.
|
||||||
|
@ -42,7 +43,8 @@ export class CoreContentLinksHelperProvider {
|
||||||
private contentLinksDelegate: CoreContentLinksDelegate, private appProvider: CoreAppProvider,
|
private contentLinksDelegate: CoreContentLinksDelegate, private appProvider: CoreAppProvider,
|
||||||
private domUtils: CoreDomUtilsProvider, private urlUtils: CoreUrlUtilsProvider, private translate: TranslateService,
|
private domUtils: CoreDomUtilsProvider, private urlUtils: CoreUrlUtilsProvider, private translate: TranslateService,
|
||||||
private initDelegate: CoreInitDelegate, eventsProvider: CoreEventsProvider, private textUtils: CoreTextUtilsProvider,
|
private initDelegate: CoreInitDelegate, eventsProvider: CoreEventsProvider, private textUtils: CoreTextUtilsProvider,
|
||||||
private sitePluginsProvider: CoreSitePluginsProvider, private zone: NgZone, private utils: CoreUtilsProvider) {
|
private sitePluginsProvider: CoreSitePluginsProvider, private zone: NgZone, private utils: CoreUtilsProvider,
|
||||||
|
private mainMenuProvider: CoreMainMenuProvider) {
|
||||||
this.logger = logger.getInstance('CoreContentLinksHelperProvider');
|
this.logger = logger.getInstance('CoreContentLinksHelperProvider');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +105,10 @@ export class CoreContentLinksHelperProvider {
|
||||||
* @param {string} pageName Name of the page to go.
|
* @param {string} pageName Name of the page to go.
|
||||||
* @param {any} [pageParams] Params to send to the page.
|
* @param {any} [pageParams] Params to send to the page.
|
||||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||||
|
* @param {boolean} [checkMenu] If true, check if the root page of a main menu tab. Only the page name will be checked.
|
||||||
* @return {Promise<any>} Promise resolved when done.
|
* @return {Promise<any>} Promise resolved when done.
|
||||||
*/
|
*/
|
||||||
goInSite(navCtrl: NavController, pageName: string, pageParams: any, siteId?: string): Promise<any> {
|
goInSite(navCtrl: NavController, pageName: string, pageParams: any, siteId?: string, checkMenu?: boolean): Promise<any> {
|
||||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||||
|
|
||||||
const deferred = this.utils.promiseDefer();
|
const deferred = this.utils.promiseDefer();
|
||||||
|
@ -113,7 +116,23 @@ export class CoreContentLinksHelperProvider {
|
||||||
// Execute the code in the Angular zone, so change detection doesn't stop working.
|
// Execute the code in the Angular zone, so change detection doesn't stop working.
|
||||||
this.zone.run(() => {
|
this.zone.run(() => {
|
||||||
if (navCtrl && siteId == this.sitesProvider.getCurrentSiteId()) {
|
if (navCtrl && siteId == this.sitesProvider.getCurrentSiteId()) {
|
||||||
navCtrl.push(pageName, pageParams).then(deferred.resolve, deferred.reject);
|
if (checkMenu) {
|
||||||
|
// Check if the page is in the main menu.
|
||||||
|
this.mainMenuProvider.isCurrentMainMenuHandler(pageName, pageParams).catch(() => {
|
||||||
|
return false; // Shouldn't happen.
|
||||||
|
}).then((isInMenu) => {
|
||||||
|
if (isInMenu) {
|
||||||
|
// Just select the tab.
|
||||||
|
this.loginHelper.loadPageInMainMenu(pageName, pageParams);
|
||||||
|
|
||||||
|
deferred.resolve();
|
||||||
|
} else {
|
||||||
|
navCtrl.push(pageName, pageParams).then(deferred.resolve, deferred.reject);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
navCtrl.push(pageName, pageParams).then(deferred.resolve, deferred.reject);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.loginHelper.redirect(pageName, pageParams, siteId).then(deferred.resolve, deferred.reject);
|
this.loginHelper.redirect(pageName, pageParams, siteId).then(deferred.resolve, deferred.reject);
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,6 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy,
|
||||||
* @param {any} event Event.
|
* @param {any} event Event.
|
||||||
*/
|
*/
|
||||||
gotoBlog(event: any): void {
|
gotoBlog(event: any): void {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(this.navCtrl, 'AddonBlogEntriesPage', { cmId: this.module.id });
|
this.linkHelper.goInSite(this.navCtrl, 'AddonBlogEntriesPage', { cmId: this.module.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
loaded: boolean;
|
loaded: boolean;
|
||||||
|
|
||||||
protected sectionStatusObserver;
|
protected sectionStatusObserver;
|
||||||
|
protected selectTabObserver;
|
||||||
protected lastCourseFormat: string;
|
protected lastCourseFormat: string;
|
||||||
|
|
||||||
constructor(private cfDelegate: CoreCourseFormatDelegate, translate: TranslateService, private injector: Injector,
|
constructor(private cfDelegate: CoreCourseFormatDelegate, translate: TranslateService, private injector: Injector,
|
||||||
|
@ -124,6 +125,28 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, this.sitesProvider.getCurrentSiteId());
|
}, this.sitesProvider.getCurrentSiteId());
|
||||||
|
|
||||||
|
// Listen for select course tab events to select the right section if needed.
|
||||||
|
this.selectTabObserver = eventsProvider.on(CoreEventsProvider.SELECT_COURSE_TAB, (data) => {
|
||||||
|
|
||||||
|
if (!data.name) {
|
||||||
|
let section;
|
||||||
|
|
||||||
|
if (typeof data.sectionId != 'undefined' && data.sectionId != null && this.sections) {
|
||||||
|
section = this.sections.find((section) => {
|
||||||
|
return section.id == data.sectionId;
|
||||||
|
});
|
||||||
|
} else if (typeof data.sectionNumber != 'undefined' && data.sectionNumber != null && this.sections) {
|
||||||
|
section = this.sections.find((section) => {
|
||||||
|
return section.section == data.sectionNumber;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section) {
|
||||||
|
this.sectionChanged(section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -437,9 +460,8 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
* Component destroyed.
|
* Component destroyed.
|
||||||
*/
|
*/
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
if (this.sectionStatusObserver) {
|
this.sectionStatusObserver && this.sectionStatusObserver.off();
|
||||||
this.sectionStatusObserver.off();
|
this.selectTabObserver && this.selectTabObserver.off();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,6 +67,7 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
protected modParams: any;
|
protected modParams: any;
|
||||||
protected completionObserver;
|
protected completionObserver;
|
||||||
protected courseStatusObserver;
|
protected courseStatusObserver;
|
||||||
|
protected selectTabObserver;
|
||||||
protected syncObserver;
|
protected syncObserver;
|
||||||
protected firstTabName: string;
|
protected firstTabName: string;
|
||||||
protected isDestroyed = false;
|
protected isDestroyed = false;
|
||||||
|
@ -120,6 +121,26 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
}
|
}
|
||||||
}, sitesProvider.getCurrentSiteId());
|
}, sitesProvider.getCurrentSiteId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.selectTabObserver = eventsProvider.on(CoreEventsProvider.SELECT_COURSE_TAB, (data) => {
|
||||||
|
|
||||||
|
if (!data.name) {
|
||||||
|
// If needed, set sectionId and sectionNumber. They'll only be used if the content tabs hasn't been loaded yet.
|
||||||
|
this.sectionId = data.sectionId || this.sectionId;
|
||||||
|
this.sectionNumber = data.sectionNumber || this.sectionNumber;
|
||||||
|
|
||||||
|
// Select course contents.
|
||||||
|
this.tabsComponent && this.tabsComponent.selectTab(0);
|
||||||
|
} else if (this.courseHandlers) {
|
||||||
|
const index = this.courseHandlers.findIndex((handler) => {
|
||||||
|
return handler.name == data.name;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (index >= 0) {
|
||||||
|
this.tabsComponent && this.tabsComponent.selectTab(index + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -483,9 +504,8 @@ export class CoreCourseSectionPage implements OnDestroy {
|
||||||
*/
|
*/
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
this.isDestroyed = true;
|
this.isDestroyed = true;
|
||||||
if (this.completionObserver) {
|
this.completionObserver && this.completionObserver.off();
|
||||||
this.completionObserver.off();
|
this.selectTabObserver && this.selectTabObserver.off();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -164,6 +164,23 @@ export class CoreCourseProvider {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the current view in a NavController is a certain course initial page.
|
||||||
|
*
|
||||||
|
* @param {NavController} navCtrl NavController.
|
||||||
|
* @param {number} courseId Course ID.
|
||||||
|
* @return {boolean} Whether the current view is a certain course.
|
||||||
|
*/
|
||||||
|
currentViewIsCourse(navCtrl: NavController, courseId: number): boolean {
|
||||||
|
if (navCtrl) {
|
||||||
|
const view = navCtrl.getActive();
|
||||||
|
|
||||||
|
return view && view.id == 'CoreCourseSectionPage' && view.data && view.data.course && view.data.course.id == courseId;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get completion status of all the activities in a course for a certain user.
|
* Get completion status of all the activities in a course for a certain user.
|
||||||
*
|
*
|
||||||
|
@ -973,6 +990,19 @@ export class CoreCourseProvider {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select a certain tab in the course. Please use currentViewIsCourse() first to verify user is viewing the course.
|
||||||
|
*
|
||||||
|
* @param {string} [name] Name of the tab. If not provided, course contents.
|
||||||
|
* @param {any} [params] Other params.
|
||||||
|
*/
|
||||||
|
selectCourseTab(name?: string, params?: any): void {
|
||||||
|
params = params || {};
|
||||||
|
params.name = name || '';
|
||||||
|
|
||||||
|
this.eventsProvider.trigger(CoreEventsProvider.SELECT_COURSE_TAB, params);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the course status, setting it to the previous status.
|
* Change the course status, setting it to the previous status.
|
||||||
*
|
*
|
||||||
|
|
|
@ -119,15 +119,16 @@ export class CoreCourseHelperProvider {
|
||||||
protected logger;
|
protected logger;
|
||||||
|
|
||||||
constructor(private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider,
|
constructor(private courseProvider: CoreCourseProvider, private domUtils: CoreDomUtilsProvider,
|
||||||
private moduleDelegate: CoreCourseModuleDelegate, private prefetchDelegate: CoreCourseModulePrefetchDelegate,
|
private moduleDelegate: CoreCourseModuleDelegate, private prefetchDelegate: CoreCourseModulePrefetchDelegate,
|
||||||
private filepoolProvider: CoreFilepoolProvider, private sitesProvider: CoreSitesProvider,
|
private filepoolProvider: CoreFilepoolProvider, private sitesProvider: CoreSitesProvider,
|
||||||
private textUtils: CoreTextUtilsProvider, private timeUtils: CoreTimeUtilsProvider,
|
private textUtils: CoreTextUtilsProvider, private timeUtils: CoreTimeUtilsProvider,
|
||||||
private utils: CoreUtilsProvider, private translate: TranslateService, private loginHelper: CoreLoginHelperProvider,
|
private utils: CoreUtilsProvider, private translate: TranslateService, private loginHelper: CoreLoginHelperProvider,
|
||||||
private courseOptionsDelegate: CoreCourseOptionsDelegate, private siteHomeProvider: CoreSiteHomeProvider,
|
private courseOptionsDelegate: CoreCourseOptionsDelegate, private siteHomeProvider: CoreSiteHomeProvider,
|
||||||
private eventsProvider: CoreEventsProvider, private fileHelper: CoreFileHelperProvider,
|
private eventsProvider: CoreEventsProvider, private fileHelper: CoreFileHelperProvider,
|
||||||
private appProvider: CoreAppProvider, private fileProvider: CoreFileProvider, private injector: Injector,
|
private appProvider: CoreAppProvider, private fileProvider: CoreFileProvider, private injector: Injector,
|
||||||
private coursesProvider: CoreCoursesProvider, private courseOffline: CoreCourseOfflineProvider,
|
private coursesProvider: CoreCoursesProvider, private courseOffline: CoreCourseOfflineProvider,
|
||||||
private loggerProvider: CoreLoggerProvider) {
|
loggerProvider: CoreLoggerProvider) {
|
||||||
|
|
||||||
this.logger = loggerProvider.getInstance('CoreCourseHelperProvider');
|
this.logger = loggerProvider.getInstance('CoreCourseHelperProvider');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,7 +1171,7 @@ export class CoreCourseHelperProvider {
|
||||||
// Otherwise, we will redirect below.
|
// Otherwise, we will redirect below.
|
||||||
modal.dismiss();
|
modal.dismiss();
|
||||||
|
|
||||||
return module.handlerData.action(event, navCtrl, module, courseId);
|
return module.handlerData.action(new Event('click'), navCtrl, module, courseId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.warn('navCtrl was not passed to navigateToModule by the link handler for ' + module.modname);
|
this.logger.warn('navCtrl was not passed to navigateToModule by the link handler for ' + module.modname);
|
||||||
|
|
|
@ -40,8 +40,9 @@ export class CoreCoursesCourseLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
private domUtils: CoreDomUtilsProvider,
|
private domUtils: CoreDomUtilsProvider,
|
||||||
private translate: TranslateService, private courseProvider: CoreCourseProvider,
|
private translate: TranslateService, private courseProvider: CoreCourseProvider,
|
||||||
private textUtils: CoreTextUtilsProvider, private courseHelper: CoreCourseHelperProvider,
|
private textUtils: CoreTextUtilsProvider, private courseHelper: CoreCourseHelperProvider,
|
||||||
private loggerProvider: CoreLoggerProvider) {
|
loggerProvider: CoreLoggerProvider) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.logger = loggerProvider.getInstance('CoreCoursesCourseLinkHandler');
|
this.logger = loggerProvider.getInstance('CoreCoursesCourseLinkHandler');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +81,17 @@ export class CoreCoursesCourseLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||||
if (siteId == this.sitesProvider.getCurrentSiteId()) {
|
if (siteId == this.sitesProvider.getCurrentSiteId()) {
|
||||||
this.actionEnrol(courseId, url, pageParams, navCtrl).catch(() => {
|
// Check if we already are in the course index page.
|
||||||
// Ignore errors.
|
if (this.courseProvider.currentViewIsCourse(navCtrl, courseId)) {
|
||||||
});
|
// Current view is this course, just select the contents tab.
|
||||||
|
this.courseProvider.selectCourseTab('', pageParams);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.actionEnrol(courseId, url, pageParams, navCtrl).catch(() => {
|
||||||
|
// Ignore errors.
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Don't pass the navCtrl to make the course the new history root (to avoid "loops" in history).
|
// Don't pass the navCtrl to make the course the new history root (to avoid "loops" in history).
|
||||||
this.courseHelper.getAndOpenCourse(undefined, courseId, pageParams, siteId);
|
this.courseHelper.getAndOpenCourse(undefined, courseId, pageParams, siteId);
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
||||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||||
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
|
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||||
import { CoreCoursesProvider } from './courses';
|
import { CoreCoursesProvider } from './courses';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ export class CoreCoursesIndexLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
featureName = 'CoreMainMenuDelegate_CoreCourses';
|
featureName = 'CoreMainMenuDelegate_CoreCourses';
|
||||||
pattern = /\/course\/?(index\.php.*)?$/;
|
pattern = /\/course\/?(index\.php.*)?$/;
|
||||||
|
|
||||||
constructor(private coursesProvider: CoreCoursesProvider, private loginHelper: CoreLoginHelperProvider) {
|
constructor(private coursesProvider: CoreCoursesProvider, private linkHelper: CoreContentLinksHelperProvider) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +56,7 @@ export class CoreCoursesIndexLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
this.linkHelper.goInSite(navCtrl, page, pageParams, siteId);
|
||||||
this.loginHelper.redirect(page, pageParams, siteId);
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class CoreCoursesDashboardLinkHandler extends CoreContentLinksHandlerBase
|
||||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
// Use redirect to select the tab.
|
||||||
this.loginHelper.redirect('CoreCoursesDashboardPage', undefined, siteId);
|
this.loginHelper.redirect('CoreCoursesDashboardPage', undefined, siteId);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -24,7 +24,6 @@ import { CoreUrlUtilsProvider } from '@providers/utils/url';
|
||||||
import { CoreUtilsProvider } from '@providers/utils/utils';
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||||
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
|
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -38,8 +37,7 @@ export class CoreGradesHelperProvider {
|
||||||
private gradesProvider: CoreGradesProvider, private sitesProvider: CoreSitesProvider,
|
private gradesProvider: CoreGradesProvider, private sitesProvider: CoreSitesProvider,
|
||||||
private textUtils: CoreTextUtilsProvider, private courseProvider: CoreCourseProvider,
|
private textUtils: CoreTextUtilsProvider, private courseProvider: CoreCourseProvider,
|
||||||
private domUtils: CoreDomUtilsProvider, private urlUtils: CoreUrlUtilsProvider, private utils: CoreUtilsProvider,
|
private domUtils: CoreDomUtilsProvider, private urlUtils: CoreUrlUtilsProvider, private utils: CoreUtilsProvider,
|
||||||
private linkHelper: CoreContentLinksHelperProvider, private loginHelper: CoreLoginHelperProvider,
|
private linkHelper: CoreContentLinksHelperProvider, private courseHelper: CoreCourseHelperProvider) {
|
||||||
private courseHelper: CoreCourseHelperProvider) {
|
|
||||||
this.logger = logger.getInstance('CoreGradesHelperProvider');
|
this.logger = logger.getInstance('CoreGradesHelperProvider');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,14 +455,22 @@ export class CoreGradesHelperProvider {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// View own grades. Open the course with the grades tab selected.
|
// View own grades. Check if we already are in the course index page.
|
||||||
|
if (this.courseProvider.currentViewIsCourse(navCtrl, courseId)) {
|
||||||
|
// Current view is this course, just select the grades tab.
|
||||||
|
this.courseProvider.selectCourseTab('CoreGrades');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open the course with the grades tab selected.
|
||||||
return this.courseHelper.getCourse(courseId, siteId).then((result) => {
|
return this.courseHelper.getCourse(courseId, siteId).then((result) => {
|
||||||
const pageParams: any = {
|
const pageParams: any = {
|
||||||
course: result.course,
|
course: result.course,
|
||||||
selectedTab: 'CoreGrades'
|
selectedTab: 'CoreGrades'
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.loginHelper.redirect('CoreCourseSectionPage', pageParams, siteId).catch(() => {
|
return this.linkHelper.goInSite(navCtrl, 'CoreCourseSectionPage', pageParams, siteId).catch(() => {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,7 +43,6 @@ export class CoreGradesOverviewLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'CoreGradesCoursesPage', undefined, siteId);
|
this.linkHelper.goInSite(navCtrl, 'CoreGradesCoursesPage', undefined, siteId);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -112,7 +112,6 @@ export class CoreGradesUserHandler implements CoreUserProfileHandler {
|
||||||
courseId: courseId,
|
courseId: courseId,
|
||||||
userId: user.id
|
userId: user.id
|
||||||
};
|
};
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'CoreGradesCoursePage', pageParams);
|
this.linkHelper.goInSite(navCtrl, 'CoreGradesCoursePage', pageParams);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -629,7 +629,7 @@ export class CoreLoginHelperProvider {
|
||||||
* @param {string} page Name of the page to load.
|
* @param {string} page Name of the page to load.
|
||||||
* @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 {
|
loadPageInMainMenu(page: string, params: any): void {
|
||||||
if (!this.appProvider.isMainMenuOpen()) {
|
if (!this.appProvider.isMainMenuOpen()) {
|
||||||
// Main menu not open. Store the page to be loaded later.
|
// Main menu not open. Store the page to be loaded later.
|
||||||
this.pageToLoad = {
|
this.pageToLoad = {
|
||||||
|
|
|
@ -16,7 +16,9 @@ import { Injectable } from '@angular/core';
|
||||||
import { NavController } from 'ionic-angular';
|
import { NavController } from 'ionic-angular';
|
||||||
import { CoreLangProvider } from '@providers/lang';
|
import { CoreLangProvider } from '@providers/lang';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
|
import { CoreUtilsProvider } from '@providers/utils/utils';
|
||||||
import { CoreConfigConstants } from '../../../configconstants';
|
import { CoreConfigConstants } from '../../../configconstants';
|
||||||
|
import { CoreMainMenuDelegate, CoreMainMenuHandlerToDisplay } from './delegate';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Custom main menu item.
|
* Custom main menu item.
|
||||||
|
@ -56,10 +58,34 @@ export class CoreMainMenuProvider {
|
||||||
static ITEM_MIN_WIDTH = 72; // Min with of every item, based on 5 items on a 360 pixel wide screen.
|
static ITEM_MIN_WIDTH = 72; // Min with of every item, based on 5 items on a 360 pixel wide screen.
|
||||||
protected tablet = false;
|
protected tablet = false;
|
||||||
|
|
||||||
constructor(private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider) {
|
constructor(private langProvider: CoreLangProvider, private sitesProvider: CoreSitesProvider,
|
||||||
|
protected menuDelegate: CoreMainMenuDelegate, protected utils: CoreUtilsProvider) {
|
||||||
this.tablet = window && window.innerWidth && window.innerWidth >= 576 && window.innerHeight >= 576;
|
this.tablet = window && window.innerWidth && window.innerWidth >= 576 && window.innerHeight >= 576;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the current main menu handlers.
|
||||||
|
*
|
||||||
|
* @return {Promise<CoreMainMenuHandlerToDisplay[]>} Promise resolved with the current main menu handlers.
|
||||||
|
*/
|
||||||
|
getCurrentMainMenuHandlers(): Promise<CoreMainMenuHandlerToDisplay[]> {
|
||||||
|
const deferred = this.utils.promiseDefer();
|
||||||
|
|
||||||
|
const subscription = this.menuDelegate.getHandlers().subscribe((handlers) => {
|
||||||
|
subscription && subscription.unsubscribe();
|
||||||
|
|
||||||
|
// Remove the handlers that should only appear in the More menu.
|
||||||
|
handlers = handlers.filter((handler) => {
|
||||||
|
return !handler.onlyInMore;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Return main handlers.
|
||||||
|
deferred.resolve(handlers.slice(0, this.getNumItems()));
|
||||||
|
});
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of custom menu items for a certain site.
|
* Get a list of custom menu items for a certain site.
|
||||||
*
|
*
|
||||||
|
@ -211,6 +237,23 @@ export class CoreMainMenuProvider {
|
||||||
return tablet ? 'side' : 'bottom';
|
return tablet ? 'side' : 'bottom';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a certain page is the root of a main menu handler currently displayed.
|
||||||
|
*
|
||||||
|
* @param {string} page Name of the page.
|
||||||
|
* @param {string} [pageParams] Page params.
|
||||||
|
* @return {Promise<boolean>} Promise resolved with boolean: whether it's the root of a main menu handler.
|
||||||
|
*/
|
||||||
|
isCurrentMainMenuHandler(pageName: string, pageParams?: any): Promise<boolean> {
|
||||||
|
return this.getCurrentMainMenuHandlers().then((handlers) => {
|
||||||
|
const handler = handlers.find((handler, i) => {
|
||||||
|
return handler.page == pageName;
|
||||||
|
});
|
||||||
|
|
||||||
|
return !!handler;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if responsive main menu items is disabled in the current site.
|
* Check if responsive main menu items is disabled in the current site.
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreSitesProvider } from '@providers/sites';
|
||||||
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
||||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||||
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
|
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||||
import { CoreSiteHomeProvider } from './sitehome';
|
import { CoreSiteHomeProvider } from './sitehome';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,7 +29,7 @@ export class CoreSiteHomeIndexLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
pattern = /\/course\/view\.php.*([\?\&]id=\d+)/;
|
pattern = /\/course\/view\.php.*([\?\&]id=\d+)/;
|
||||||
|
|
||||||
constructor(private sitesProvider: CoreSitesProvider, private siteHomeProvider: CoreSiteHomeProvider,
|
constructor(private sitesProvider: CoreSitesProvider, private siteHomeProvider: CoreSiteHomeProvider,
|
||||||
private loginHelper: CoreLoginHelperProvider) {
|
private linkHelper: CoreContentLinksHelperProvider) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,7 @@ export class CoreSiteHomeIndexLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
CoreContentLinksAction[] | Promise<CoreContentLinksAction[]> {
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
this.linkHelper.goInSite(navCtrl, 'CoreSiteHomeIndexPage', undefined, siteId);
|
||||||
this.loginHelper.redirect('CoreSiteHomeIndexPage', undefined, siteId);
|
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
import { CoreDomUtilsProvider } from '@providers/utils/dom';
|
||||||
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
import { CoreContentLinksHandlerBase } from '@core/contentlinks/classes/base-handler';
|
||||||
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
import { CoreContentLinksAction } from '@core/contentlinks/providers/delegate';
|
||||||
import { CoreLoginHelperProvider } from '@core/login/providers/helper';
|
import { CoreCourseProvider } from '@core/course/providers/course';
|
||||||
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
import { CoreCourseHelperProvider } from '@core/course/providers/helper';
|
||||||
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
import { CoreContentLinksHelperProvider } from '@core/contentlinks/providers/helper';
|
||||||
import { CoreUserProvider } from './user';
|
import { CoreUserProvider } from './user';
|
||||||
|
@ -30,9 +30,9 @@ export class CoreUserParticipantsLinkHandler extends CoreContentLinksHandlerBase
|
||||||
featureName = 'CoreCourseOptionsDelegate_CoreUserParticipants';
|
featureName = 'CoreCourseOptionsDelegate_CoreUserParticipants';
|
||||||
pattern = /\/user\/index\.php/;
|
pattern = /\/user\/index\.php/;
|
||||||
|
|
||||||
constructor(private userProvider: CoreUserProvider, private loginHelper: CoreLoginHelperProvider,
|
constructor(private userProvider: CoreUserProvider,
|
||||||
private courseHelper: CoreCourseHelperProvider, private domUtils: CoreDomUtilsProvider,
|
private courseHelper: CoreCourseHelperProvider, private domUtils: CoreDomUtilsProvider,
|
||||||
private linkHelper: CoreContentLinksHelperProvider) {
|
private linkHelper: CoreContentLinksHelperProvider, private courseProvider: CoreCourseProvider) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,14 @@ export class CoreUserParticipantsLinkHandler extends CoreContentLinksHandlerBase
|
||||||
|
|
||||||
return [{
|
return [{
|
||||||
action: (siteId, navCtrl?): void => {
|
action: (siteId, navCtrl?): void => {
|
||||||
|
// Check if we already are in the course index page.
|
||||||
|
if (this.courseProvider.currentViewIsCourse(navCtrl, courseId)) {
|
||||||
|
// Current view is this course, just select the participants tab.
|
||||||
|
this.courseProvider.selectCourseTab('CoreUserParticipants');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const modal = this.domUtils.showModalLoading();
|
const modal = this.domUtils.showModalLoading();
|
||||||
|
|
||||||
this.courseHelper.getCourse(courseId, siteId).then((result) => {
|
this.courseHelper.getCourse(courseId, siteId).then((result) => {
|
||||||
|
@ -59,8 +67,9 @@ export class CoreUserParticipantsLinkHandler extends CoreContentLinksHandlerBase
|
||||||
selectedTab: 'CoreUserParticipants'
|
selectedTab: 'CoreUserParticipants'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
return this.linkHelper.goInSite(navCtrl, 'CoreCourseSectionPage', params, siteId).catch(() => {
|
||||||
return this.loginHelper.redirect('CoreCourseSectionPage', params, siteId);
|
// Ignore errors.
|
||||||
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// Cannot get course for some reason, just open the participants page.
|
// Cannot get course for some reason, just open the participants page.
|
||||||
return this.linkHelper.goInSite(navCtrl, 'CoreUserParticipantsPage', {courseId: courseId}, siteId);
|
return this.linkHelper.goInSite(navCtrl, 'CoreUserParticipantsPage', {courseId: courseId}, siteId);
|
||||||
|
|
|
@ -47,7 +47,6 @@ export class CoreUserProfileLinkHandler extends CoreContentLinksHandlerBase {
|
||||||
courseId: params.course,
|
courseId: params.course,
|
||||||
userId: parseInt(params.id, 10)
|
userId: parseInt(params.id, 10)
|
||||||
};
|
};
|
||||||
// Always use redirect to make it the new history root (to avoid "loops" in history).
|
|
||||||
this.linkHelper.goInSite(navCtrl, 'CoreUserProfilePage', pageParams, siteId);
|
this.linkHelper.goInSite(navCtrl, 'CoreUserProfilePage', pageParams, siteId);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
|
@ -60,6 +60,7 @@ export class CoreEventsProvider {
|
||||||
static LOAD_PAGE_MAIN_MENU = 'load_page_main_menu';
|
static LOAD_PAGE_MAIN_MENU = 'load_page_main_menu';
|
||||||
static SEND_ON_ENTER_CHANGED = 'send_on_enter_changed';
|
static SEND_ON_ENTER_CHANGED = 'send_on_enter_changed';
|
||||||
static MAIN_MENU_OPEN = 'main_menu_open';
|
static MAIN_MENU_OPEN = 'main_menu_open';
|
||||||
|
static SELECT_COURSE_TAB = 'select_course_tab';
|
||||||
|
|
||||||
protected logger;
|
protected logger;
|
||||||
protected observables: { [s: string]: Subject<any> } = {};
|
protected observables: { [s: string]: Subject<any> } = {};
|
||||||
|
|
Loading…
Reference in New Issue