MOBILE-2616 dashboard: Reunite Frontpage and courses on 3.1, 3.2
parent
7e2f2dfd4f
commit
d2383c72d2
|
@ -1139,7 +1139,6 @@
|
||||||
"core.courses.cannotretrievemorecategories": "local_moodlemobileapp",
|
"core.courses.cannotretrievemorecategories": "local_moodlemobileapp",
|
||||||
"core.courses.categories": "moodle",
|
"core.courses.categories": "moodle",
|
||||||
"core.courses.confirmselfenrol": "local_moodlemobileapp",
|
"core.courses.confirmselfenrol": "local_moodlemobileapp",
|
||||||
"core.courses.courseoverview": "moodle",
|
|
||||||
"core.courses.courses": "moodle",
|
"core.courses.courses": "moodle",
|
||||||
"core.courses.downloadcourses": "local_moodlemobileapp",
|
"core.courses.downloadcourses": "local_moodlemobileapp",
|
||||||
"core.courses.enrolme": "local_moodlemobileapp",
|
"core.courses.enrolme": "local_moodlemobileapp",
|
||||||
|
@ -1150,6 +1149,7 @@
|
||||||
"core.courses.filtermycourses": "local_moodlemobileapp",
|
"core.courses.filtermycourses": "local_moodlemobileapp",
|
||||||
"core.courses.frontpage": "admin",
|
"core.courses.frontpage": "admin",
|
||||||
"core.courses.mycourses": "moodle",
|
"core.courses.mycourses": "moodle",
|
||||||
|
"core.courses.mymoodle": "admin",
|
||||||
"core.courses.nocourses": "my",
|
"core.courses.nocourses": "my",
|
||||||
"core.courses.nocoursesyet": "moodle",
|
"core.courses.nocoursesyet": "moodle",
|
||||||
"core.courses.nosearchresults": "wiki",
|
"core.courses.nosearchresults": "wiki",
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
|
|
||||||
<core-loading [hideUntil]="loaded" class="core-loading-center">
|
<core-loading [hideUntil]="loaded" class="core-loading-center">
|
||||||
<!-- "Time" selector. -->
|
<!-- "Time" selector. -->
|
||||||
<div padding class="clearfix" [hidden]="showFilter" ion-row justify-content-between>
|
<div padding class="clearfix" [hidden]="showFilter" ion-row justify-content-end>
|
||||||
<ion-select float-start [title]="'core.show' | translate" [(ngModel)]="selectedFilter" ion-col (ngModelChange)="selectedChanged()" interface="popover" class="core-button-select">
|
<ion-select [hidden]="!showSelectorFilter" [title]="'core.show' | translate" [(ngModel)]="selectedFilter" ion-col (ngModelChange)="selectedChanged()" interface="popover" class="core-button-select">
|
||||||
<ion-option value="inprogress">{{ 'addon.block_myoverview.inprogress' | translate }}</ion-option>
|
<ion-option value="inprogress">{{ 'addon.block_myoverview.inprogress' | translate }}</ion-option>
|
||||||
<ion-option value="future">{{ 'addon.block_myoverview.future' | translate }}</ion-option>
|
<ion-option value="future">{{ 'addon.block_myoverview.future' | translate }}</ion-option>
|
||||||
<ion-option value="past">{{ 'addon.block_myoverview.past' | translate }}</ion-option>
|
<ion-option value="past">{{ 'addon.block_myoverview.past' | translate }}</ion-option>
|
||||||
</ion-select>
|
</ion-select>
|
||||||
<!-- Download all courses. -->
|
<!-- Download all courses. -->
|
||||||
<div *ngIf="downloadAllCoursesEnabled && courses[selectedFilter] && courses[selectedFilter].length > 1" class="core-button-spinner">
|
<div *ngIf="downloadAllCoursesEnabled && courses[selectedFilter] && courses[selectedFilter].length > 1" class="core-button-spinner" ion-col text-end col-1>
|
||||||
<button *ngIf="prefetchCoursesData[selectedFilter].icon && prefetchCoursesData[selectedFilter].icon != 'spinner'" ion-button icon-only clear color="dark" (click)="prefetchCourses()">
|
<button *ngIf="prefetchCoursesData[selectedFilter].icon && prefetchCoursesData[selectedFilter].icon != 'spinner'" ion-button icon-only clear color="dark" (click)="prefetchCourses()">
|
||||||
<core-icon [name]="prefetchCoursesData[selectedFilter].icon"></core-icon>
|
<core-icon [name]="prefetchCoursesData[selectedFilter].icon"></core-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -49,6 +49,7 @@ export class AddonBlockMyOverviewComponent extends AddonBlockComponent implement
|
||||||
future: {}
|
future: {}
|
||||||
};
|
};
|
||||||
showFilter = false;
|
showFilter = false;
|
||||||
|
showSelectorFilter = false;
|
||||||
|
|
||||||
protected prefetchIconsInitialized = false;
|
protected prefetchIconsInitialized = false;
|
||||||
protected isDestroyed;
|
protected isDestroyed;
|
||||||
|
@ -157,6 +158,7 @@ export class AddonBlockMyOverviewComponent extends AddonBlockComponent implement
|
||||||
|
|
||||||
this.courses.filter = '';
|
this.courses.filter = '';
|
||||||
this.showFilter = false;
|
this.showFilter = false;
|
||||||
|
this.showSelectorFilter = (this.courses.past.length + this.courses.future.length) > 0;
|
||||||
this.filteredCourses = this.courses[this.selectedFilter];
|
this.filteredCourses = this.courses[this.selectedFilter];
|
||||||
|
|
||||||
this.initPrefetchCoursesIcons();
|
this.initPrefetchCoursesIcons();
|
||||||
|
|
|
@ -1139,7 +1139,6 @@
|
||||||
"core.courses.cannotretrievemorecategories": "Categories deeper than level {{$a}} cannot be retrieved.",
|
"core.courses.cannotretrievemorecategories": "Categories deeper than level {{$a}} cannot be retrieved.",
|
||||||
"core.courses.categories": "Course categories",
|
"core.courses.categories": "Course categories",
|
||||||
"core.courses.confirmselfenrol": "Are you sure you want to enrol yourself in this course?",
|
"core.courses.confirmselfenrol": "Are you sure you want to enrol yourself in this course?",
|
||||||
"core.courses.courseoverview": "Course overview",
|
|
||||||
"core.courses.courses": "Courses",
|
"core.courses.courses": "Courses",
|
||||||
"core.courses.downloadcourses": "Download courses",
|
"core.courses.downloadcourses": "Download courses",
|
||||||
"core.courses.enrolme": "Enrol me",
|
"core.courses.enrolme": "Enrol me",
|
||||||
|
@ -1150,6 +1149,7 @@
|
||||||
"core.courses.filtermycourses": "Filter my courses",
|
"core.courses.filtermycourses": "Filter my courses",
|
||||||
"core.courses.frontpage": "Front page",
|
"core.courses.frontpage": "Front page",
|
||||||
"core.courses.mycourses": "My courses",
|
"core.courses.mycourses": "My courses",
|
||||||
|
"core.courses.mymoodle": "Dashboard",
|
||||||
"core.courses.nocourses": "No course information to show.",
|
"core.courses.nocourses": "No course information to show.",
|
||||||
"core.courses.nocoursesyet": "No courses in this category",
|
"core.courses.nocoursesyet": "No courses in this category",
|
||||||
"core.courses.nosearchresults": "No results",
|
"core.courses.nosearchresults": "No results",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<core-loading [hideUntil]="hideUntil" class="core-loading-center">
|
<core-loading [hideUntil]="hideUntil" class="core-loading-center">
|
||||||
<div class="core-tabs-bar" #topTabs [hidden]="!tabs || tabs.length < 2">
|
<div class="core-tabs-bar" #topTabs [hidden]="!tabs || numTabsShown < 2">
|
||||||
<ion-row>
|
<ion-row>
|
||||||
<ion-col class="col-with-arrow" (click)="slidePrev()" no-padding col-1>
|
<ion-col class="col-with-arrow" (click)="slidePrev()" no-padding col-1>
|
||||||
<ion-icon *ngIf="showPrevButton" name="arrow-back" md="ios-arrow-back"></ion-icon>
|
<ion-icon *ngIf="showPrevButton" name="arrow-back" md="ios-arrow-back"></ion-icon>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CoreCoursesProvider } from './providers/courses';
|
import { CoreCoursesProvider } from './providers/courses';
|
||||||
import { CoreCoursesHelperProvider } from './providers/helper';
|
import { CoreCoursesHelperProvider } from './providers/helper';
|
||||||
import { CoreCoursesMainMenuHandler } from './providers/mainmenu-handler';
|
import { CoreDashboardMainMenuHandler } from './providers/mainmenu-handler';
|
||||||
import { CoreCoursesDashboardProvider } from './providers/dashboard';
|
import { CoreCoursesDashboardProvider } from './providers/dashboard';
|
||||||
import { CoreCoursesCourseLinkHandler } from './providers/course-link-handler';
|
import { CoreCoursesCourseLinkHandler } from './providers/course-link-handler';
|
||||||
import { CoreCoursesIndexLinkHandler } from './providers/courses-index-link-handler';
|
import { CoreCoursesIndexLinkHandler } from './providers/courses-index-link-handler';
|
||||||
|
@ -38,7 +38,7 @@ export const CORE_COURSES_PROVIDERS: any[] = [
|
||||||
CoreCoursesProvider,
|
CoreCoursesProvider,
|
||||||
CoreCoursesDashboardProvider,
|
CoreCoursesDashboardProvider,
|
||||||
CoreCoursesHelperProvider,
|
CoreCoursesHelperProvider,
|
||||||
CoreCoursesMainMenuHandler,
|
CoreDashboardMainMenuHandler,
|
||||||
CoreCoursesCourseLinkHandler,
|
CoreCoursesCourseLinkHandler,
|
||||||
CoreCoursesIndexLinkHandler,
|
CoreCoursesIndexLinkHandler,
|
||||||
CoreCoursesDashboardLinkHandler
|
CoreCoursesDashboardLinkHandler
|
||||||
|
@ -47,7 +47,7 @@ export const CORE_COURSES_PROVIDERS: any[] = [
|
||||||
})
|
})
|
||||||
export class CoreCoursesModule {
|
export class CoreCoursesModule {
|
||||||
constructor(mainMenuDelegate: CoreMainMenuDelegate, contentLinksDelegate: CoreContentLinksDelegate,
|
constructor(mainMenuDelegate: CoreMainMenuDelegate, contentLinksDelegate: CoreContentLinksDelegate,
|
||||||
mainMenuHandler: CoreCoursesMainMenuHandler, courseLinkHandler: CoreCoursesCourseLinkHandler,
|
mainMenuHandler: CoreDashboardMainMenuHandler, courseLinkHandler: CoreCoursesCourseLinkHandler,
|
||||||
indexLinkHandler: CoreCoursesIndexLinkHandler, dashboardLinkHandler: CoreCoursesDashboardLinkHandler) {
|
indexLinkHandler: CoreCoursesIndexLinkHandler, dashboardLinkHandler: CoreCoursesDashboardLinkHandler) {
|
||||||
mainMenuDelegate.registerHandler(mainMenuHandler);
|
mainMenuDelegate.registerHandler(mainMenuHandler);
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
"cannotretrievemorecategories": "Categories deeper than level {{$a}} cannot be retrieved.",
|
"cannotretrievemorecategories": "Categories deeper than level {{$a}} cannot be retrieved.",
|
||||||
"categories": "Course categories",
|
"categories": "Course categories",
|
||||||
"confirmselfenrol": "Are you sure you want to enrol yourself in this course?",
|
"confirmselfenrol": "Are you sure you want to enrol yourself in this course?",
|
||||||
"courseoverview": "Course overview",
|
|
||||||
"courses": "Courses",
|
"courses": "Courses",
|
||||||
|
"mymoodle": "Dashboard",
|
||||||
"downloadcourses": "Download courses",
|
"downloadcourses": "Download courses",
|
||||||
"enrolme": "Enrol me",
|
"enrolme": "Enrol me",
|
||||||
"errorloadcategories": "An error occurred while loading categories.",
|
"errorloadcategories": "An error occurred while loading categories.",
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</core-tab>
|
</core-tab>
|
||||||
|
|
||||||
<!-- Courses tab. -->
|
<!-- Courses tab. -->
|
||||||
<core-tab [title]="'core.courses.courses' | translate" (ionSelect)="tabChanged('courses')">
|
<core-tab [show]="coursesEnabled" [title]="'core.courses.courses' | translate" (ionSelect)="tabChanged('courses')">
|
||||||
<ng-template>
|
<ng-template>
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<ion-refresher [enabled]="!!blockMyOverview && blockMyOverview.loaded" (ionRefresh)="blockMyOverview.doRefresh($event)">
|
<ion-refresher [enabled]="!!blockMyOverview && blockMyOverview.loaded" (ionRefresh)="blockMyOverview.doRefresh($event)">
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
</core-tab>
|
</core-tab>
|
||||||
|
|
||||||
<!-- Timeline tab. -->
|
<!-- Timeline tab. -->
|
||||||
<core-tab [title]="'core.courses.timeline' | translate" (ionSelect)="tabChanged('timeline')">
|
<core-tab [show]="timelineEnabled" [title]="'core.courses.timeline' | translate" (ionSelect)="tabChanged('timeline')">
|
||||||
<ng-template>
|
<ng-template>
|
||||||
<ion-content>
|
<ion-content>
|
||||||
<ion-refresher [enabled]="!!blockTimeline && blockTimeline.loaded" (ionRefresh)="blockTimeline.doRefresh($event)">
|
<ion-refresher [enabled]="!!blockTimeline && blockTimeline.loaded" (ionRefresh)="blockTimeline.doRefresh($event)">
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { AddonBlockMyOverviewComponent } from '@addon/block/myoverview/component
|
||||||
import { AddonBlockTimelineComponent } from '@addon/block/timeline/components/timeline/timeline';
|
import { AddonBlockTimelineComponent } from '@addon/block/timeline/components/timeline/timeline';
|
||||||
import { CoreTabsComponent } from '@components/tabs/tabs';
|
import { CoreTabsComponent } from '@components/tabs/tabs';
|
||||||
import { CoreSiteHomeIndexComponent } from '@core/sitehome/components/index/index';
|
import { CoreSiteHomeIndexComponent } from '@core/sitehome/components/index/index';
|
||||||
|
import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/timeline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays the dashboard.
|
* Page that displays the dashboard.
|
||||||
|
@ -38,7 +39,9 @@ export class CoreCoursesDashboardPage implements OnDestroy {
|
||||||
@ViewChild(AddonBlockTimelineComponent) blockTimeline: AddonBlockTimelineComponent;
|
@ViewChild(AddonBlockTimelineComponent) blockTimeline: AddonBlockTimelineComponent;
|
||||||
|
|
||||||
firstSelectedTab: number;
|
firstSelectedTab: number;
|
||||||
siteHomeEnabled: boolean;
|
siteHomeEnabled = false;
|
||||||
|
timelineEnabled = false;
|
||||||
|
coursesEnabled = false;
|
||||||
tabsReady = false;
|
tabsReady = false;
|
||||||
tabShown = 'courses';
|
tabShown = 'courses';
|
||||||
searchEnabled: boolean;
|
searchEnabled: boolean;
|
||||||
|
@ -51,7 +54,7 @@ export class CoreCoursesDashboardPage implements OnDestroy {
|
||||||
|
|
||||||
constructor(private navCtrl: NavController, private coursesProvider: CoreCoursesProvider,
|
constructor(private navCtrl: NavController, private coursesProvider: CoreCoursesProvider,
|
||||||
private sitesProvider: CoreSitesProvider, private siteHomeProvider: CoreSiteHomeProvider,
|
private sitesProvider: CoreSitesProvider, private siteHomeProvider: CoreSiteHomeProvider,
|
||||||
private eventsProvider: CoreEventsProvider) {
|
private eventsProvider: CoreEventsProvider, private timelineProvider: AddonBlockTimelineProvider) {
|
||||||
this.loadSiteName();
|
this.loadSiteName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,13 +70,29 @@ export class CoreCoursesDashboardPage implements OnDestroy {
|
||||||
this.loadSiteName();
|
this.loadSiteName();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Decide which tab to load first.
|
const promises = [];
|
||||||
this.siteHomeProvider.isAvailable().then((enabled) => {
|
|
||||||
const site = this.sitesProvider.getCurrentSite(),
|
|
||||||
displaySiteHome = site.getInfo() && site.getInfo().userhomepage === 0;
|
|
||||||
|
|
||||||
|
// Decide which tab to load first.
|
||||||
|
promises.push(this.siteHomeProvider.isAvailable().then((enabled) => {
|
||||||
this.siteHomeEnabled = enabled;
|
this.siteHomeEnabled = enabled;
|
||||||
this.firstSelectedTab = displaySiteHome ? 0 : 1;
|
}));
|
||||||
|
|
||||||
|
promises.push(this.timelineProvider.isAvailable().then((enabled) => {
|
||||||
|
this.timelineEnabled = enabled;
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.coursesEnabled = !this.coursesProvider.isMyCoursesDisabledInSite();
|
||||||
|
|
||||||
|
Promise.all(promises).finally(() => {
|
||||||
|
if (this.siteHomeEnabled && (this.coursesEnabled || this.timelineEnabled)) {
|
||||||
|
const site = this.sitesProvider.getCurrentSite(),
|
||||||
|
displaySiteHome = site.getInfo() && site.getInfo().userhomepage === 0;
|
||||||
|
|
||||||
|
this.firstSelectedTab = displaySiteHome ? 0 : 1;
|
||||||
|
} else {
|
||||||
|
this.firstSelectedTab = this.siteHomeEnabled ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.tabsReady = true;
|
this.tabsReady = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { CoreSitesProvider } from '@providers/sites';
|
import { CoreCoursesProvider } from './courses';
|
||||||
import { CoreSite } from '@classes/site';
|
|
||||||
import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/timeline';
|
import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/timeline';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +22,7 @@ import { AddonBlockTimelineProvider } from '@addon/block/timeline/providers/time
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CoreCoursesDashboardProvider {
|
export class CoreCoursesDashboardProvider {
|
||||||
|
|
||||||
constructor(private sitesProvider: CoreSitesProvider, private timelineProvider: AddonBlockTimelineProvider) { }
|
constructor(private coursesProvider: CoreCoursesProvider, private timelineProvider: AddonBlockTimelineProvider) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether or not My Overview is available for a certain site.
|
* Returns whether or not My Overview is available for a certain site.
|
||||||
|
@ -35,25 +34,13 @@ export class CoreCoursesDashboardProvider {
|
||||||
return this.timelineProvider.isAvailable(siteId);
|
return this.timelineProvider.isAvailable(siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if My Overview is disabled in a certain site.
|
|
||||||
*
|
|
||||||
* @param {CoreSite} [site] Site. If not defined, use current site.
|
|
||||||
* @return {boolean} Whether it's disabled.
|
|
||||||
*/
|
|
||||||
isDisabledInSite(site?: CoreSite): boolean {
|
|
||||||
site = site || this.sitesProvider.getCurrentSite();
|
|
||||||
|
|
||||||
return site.isFeatureDisabled('CoreMainMenuDelegate_CoreCourses');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if My Overview is available and not disabled.
|
* Check if My Overview is available and not disabled.
|
||||||
*
|
*
|
||||||
* @return {Promise<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
|
* @return {Promise<boolean>} Promise resolved with true if enabled, resolved with false otherwise.
|
||||||
*/
|
*/
|
||||||
isEnabled(): Promise<boolean> {
|
isEnabled(): Promise<boolean> {
|
||||||
if (!this.isDisabledInSite()) {
|
if (!this.coursesProvider.isMyCoursesDisabledInSite()) {
|
||||||
return this.isAvailable().catch(() => {
|
return this.isAvailable().catch(() => {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,17 +16,18 @@ import { Injectable } from '@angular/core';
|
||||||
import { CoreCoursesProvider } from './courses';
|
import { CoreCoursesProvider } from './courses';
|
||||||
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@core/mainmenu/providers/delegate';
|
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@core/mainmenu/providers/delegate';
|
||||||
import { CoreCoursesDashboardProvider } from '../providers/dashboard';
|
import { CoreCoursesDashboardProvider } from '../providers/dashboard';
|
||||||
|
import { CoreSiteHomeProvider } from '@core/sitehome/providers/sitehome';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to add My Courses or My Overview into main menu.
|
* Handler to add Dashboard into main menu.
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CoreCoursesMainMenuHandler implements CoreMainMenuHandler {
|
export class CoreDashboardMainMenuHandler implements CoreMainMenuHandler {
|
||||||
name = 'CoreCourses';
|
name = 'CoreDashboard'; // Old name CoreCourses cannot be used because it would be all disabled by site.
|
||||||
priority = 1100;
|
priority = 1100;
|
||||||
isDashboardEnabled: boolean;
|
|
||||||
|
|
||||||
constructor(private coursesProvider: CoreCoursesProvider, private dashboardProvider: CoreCoursesDashboardProvider) { }
|
constructor(private coursesProvider: CoreCoursesProvider, private dashboardProvider: CoreCoursesDashboardProvider,
|
||||||
|
private siteHomeProvider: CoreSiteHomeProvider) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the handler is enabled on a site level.
|
* Check if the handler is enabled on a site level.
|
||||||
|
@ -36,13 +37,19 @@ export class CoreCoursesMainMenuHandler implements CoreMainMenuHandler {
|
||||||
isEnabled(): boolean | Promise<boolean> {
|
isEnabled(): boolean | Promise<boolean> {
|
||||||
// Check if my overview is enabled.
|
// Check if my overview is enabled.
|
||||||
return this.dashboardProvider.isEnabled().then((enabled) => {
|
return this.dashboardProvider.isEnabled().then((enabled) => {
|
||||||
this.isDashboardEnabled = enabled;
|
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// My overview not enabled, check if my courses is enabled.
|
return this.siteHomeProvider.isAvailable().then((enabled) => {
|
||||||
return !this.coursesProvider.isMyCoursesDisabledInSite();
|
// Show in case siteHome is enabled.
|
||||||
|
if (enabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// My overview not enabled, check if my courses is enabled.
|
||||||
|
return !this.coursesProvider.isMyCoursesDisabledInSite();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,20 +59,11 @@ export class CoreCoursesMainMenuHandler implements CoreMainMenuHandler {
|
||||||
* @return {CoreMainMenuHandlerData} Data needed to render the handler.
|
* @return {CoreMainMenuHandlerData} Data needed to render the handler.
|
||||||
*/
|
*/
|
||||||
getDisplayData(): CoreMainMenuHandlerData {
|
getDisplayData(): CoreMainMenuHandlerData {
|
||||||
if (this.isDashboardEnabled) {
|
return {
|
||||||
return {
|
icon: 'home',
|
||||||
icon: 'home',
|
title: 'core.courses.mymoodle',
|
||||||
title: 'core.courses.courseoverview',
|
page: 'CoreCoursesDashboardPage',
|
||||||
page: 'CoreCoursesDashboardPage',
|
class: 'core-dashboard-handler'
|
||||||
class: 'core-courseoverview-handler'
|
};
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
icon: 'fa-graduation-cap',
|
|
||||||
title: 'core.courses.mycourses',
|
|
||||||
page: 'CoreCoursesMyCoursesPage',
|
|
||||||
class: 'core-mycourses-handler'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,6 @@ export class CoreMainMenuPage implements OnDestroy {
|
||||||
|
|
||||||
this.showTabs = true;
|
this.showTabs = true;
|
||||||
|
|
||||||
const site = this.sitesProvider.getCurrentSite(),
|
|
||||||
displaySiteHome = site.getInfo() && site.getInfo().userhomepage === 0;
|
|
||||||
|
|
||||||
this.subscription = this.menuDelegate.getHandlers().subscribe((handlers) => {
|
this.subscription = this.menuDelegate.getHandlers().subscribe((handlers) => {
|
||||||
handlers = handlers.slice(0, CoreMainMenuProvider.NUM_MAIN_HANDLERS); // Get main handlers.
|
handlers = handlers.slice(0, CoreMainMenuProvider.NUM_MAIN_HANDLERS); // Get main handlers.
|
||||||
|
|
||||||
|
@ -83,31 +80,28 @@ export class CoreMainMenuPage implements OnDestroy {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof this.initialTab == 'undefined' && !this.loaded) {
|
if (typeof this.initialTab == 'undefined' && !this.loaded) {
|
||||||
|
this.initialTab = 0;
|
||||||
|
|
||||||
// Calculate the tab to load.
|
// Calculate the tab to load.
|
||||||
if (this.redirectPage) {
|
if (this.redirectPage) {
|
||||||
// Check if the redirect page is the root page of any of the tabs.
|
// Check if the redirect page is the root page of any of the tabs.
|
||||||
this.initialTab = 0;
|
const i = this.tabs.findIndex((tab, i) => {
|
||||||
|
return tab.page == this.redirectPage;
|
||||||
for (let i = 0; i < this.tabs.length; i++) {
|
});
|
||||||
const tab = this.tabs[i];
|
if (i >= 0) {
|
||||||
if (tab.page == this.redirectPage) {
|
// Tab found. Set the params and unset the redirect page.
|
||||||
// Tab found. Set the params and unset the redirect page.
|
this.initialTab = i + 1;
|
||||||
this.initialTab = i + 1;
|
this.tabs[i].pageParams = Object.assign(this.tabs[i].pageParams || {}, this.redirectParams);
|
||||||
tab.pageParams = Object.assign(tab.pageParams || {}, this.redirectParams);
|
this.redirectPage = null;
|
||||||
this.redirectPage = null;
|
this.redirectParams = null;
|
||||||
this.redirectParams = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// By default, course overview will be loaded (3.3+). Check if we need to select Site Home or My Courses.
|
const i = handlers.findIndex((handler, i) => {
|
||||||
for (let i = 0; i < this.tabs.length; i++) {
|
return handler.name == 'CoreDashboard';
|
||||||
const handler = handlers[i];
|
});
|
||||||
if ((displaySiteHome && handler.name == 'CoreSiteHome') ||
|
|
||||||
(!displaySiteHome && handler.name == 'CoreCourses')) {
|
if (i >= 0) {
|
||||||
this.initialTab = i;
|
this.initialTab = i;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import { CoreSiteHomeProvider } from '../../providers/sitehome';
|
||||||
templateUrl: 'core-sitehome-index.html',
|
templateUrl: 'core-sitehome-index.html',
|
||||||
})
|
})
|
||||||
export class CoreSiteHomeIndexComponent implements OnInit {
|
export class CoreSiteHomeIndexComponent implements OnInit {
|
||||||
dataLoaded: boolean;
|
dataLoaded = false;
|
||||||
section: any;
|
section: any;
|
||||||
block: any;
|
block: any;
|
||||||
hasContent: boolean;
|
hasContent: boolean;
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
// (C) Copyright 2015 Martin Dougiamas
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { CoreSiteHomeProvider } from './sitehome';
|
|
||||||
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@core/mainmenu/providers/delegate';
|
|
||||||
import { CoreCoursesDashboardProvider } from '@core/courses/providers/dashboard';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handler to add Site Home into main menu.
|
|
||||||
*/
|
|
||||||
@Injectable()
|
|
||||||
export class CoreSiteHomeMainMenuHandler implements CoreMainMenuHandler {
|
|
||||||
name = 'CoreSiteHome';
|
|
||||||
priority = 1200;
|
|
||||||
|
|
||||||
constructor(private siteHomeProvider: CoreSiteHomeProvider, private dashboardProvider: CoreCoursesDashboardProvider) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the handler is enabled on a site level.
|
|
||||||
*
|
|
||||||
* @return {boolean} Whether or not the handler is enabled on a site level.
|
|
||||||
*/
|
|
||||||
isEnabled(): boolean | Promise<boolean> {
|
|
||||||
// Check if my overview is enabled.
|
|
||||||
return this.dashboardProvider.isEnabled().then((enabled) => {
|
|
||||||
if (enabled) {
|
|
||||||
// My overview is enabled, Site Home will be inside the overview page.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// My overview not enabled, check if site home is enabled.
|
|
||||||
return this.siteHomeProvider.isAvailable();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the data needed to render the handler.
|
|
||||||
*
|
|
||||||
* @return {CoreMainMenuHandlerData} Data needed to render the handler.
|
|
||||||
*/
|
|
||||||
getDisplayData(): CoreMainMenuHandlerData {
|
|
||||||
return {
|
|
||||||
icon: 'home',
|
|
||||||
title: 'core.sitehome.sitehome',
|
|
||||||
page: 'CoreSiteHomeIndexPage',
|
|
||||||
class: 'core-sitehome-handler'
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -14,9 +14,7 @@
|
||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { CoreSiteHomeProvider } from './providers/sitehome';
|
import { CoreSiteHomeProvider } from './providers/sitehome';
|
||||||
import { CoreSiteHomeMainMenuHandler } from './providers/mainmenu-handler';
|
|
||||||
import { CoreSiteHomeIndexLinkHandler } from './providers/index-link-handler';
|
import { CoreSiteHomeIndexLinkHandler } from './providers/index-link-handler';
|
||||||
import { CoreMainMenuDelegate } from '@core/mainmenu/providers/delegate';
|
|
||||||
import { CoreContentLinksDelegate } from '@core/contentlinks/providers/delegate';
|
import { CoreContentLinksDelegate } from '@core/contentlinks/providers/delegate';
|
||||||
|
|
||||||
// List of providers (without handlers).
|
// List of providers (without handlers).
|
||||||
|
@ -30,15 +28,12 @@ export const CORE_SITEHOME_PROVIDERS: any[] = [
|
||||||
],
|
],
|
||||||
providers: [
|
providers: [
|
||||||
CoreSiteHomeProvider,
|
CoreSiteHomeProvider,
|
||||||
CoreSiteHomeMainMenuHandler,
|
|
||||||
CoreSiteHomeIndexLinkHandler
|
CoreSiteHomeIndexLinkHandler
|
||||||
],
|
],
|
||||||
exports: []
|
exports: []
|
||||||
})
|
})
|
||||||
export class CoreSiteHomeModule {
|
export class CoreSiteHomeModule {
|
||||||
constructor(mainMenuDelegate: CoreMainMenuDelegate, contentLinksDelegate: CoreContentLinksDelegate,
|
constructor(contentLinksDelegate: CoreContentLinksDelegate, indexLinkHandler: CoreSiteHomeIndexLinkHandler) {
|
||||||
mainMenuHandler: CoreSiteHomeMainMenuHandler, indexLinkHandler: CoreSiteHomeIndexLinkHandler) {
|
|
||||||
mainMenuDelegate.registerHandler(mainMenuHandler);
|
|
||||||
contentLinksDelegate.registerHandler(indexLinkHandler);
|
contentLinksDelegate.registerHandler(indexLinkHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue