commit
385e209190
|
@ -13,27 +13,35 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { Routes } from '@angular/router';
|
||||
import { CoreHomeRoutingModule } from '../mainmenu/pages/home/home-routing.module';
|
||||
import { CoreHomeDelegate } from '../mainmenu/services/home.delegate';
|
||||
import { CoreCoursesDashboardHandler } from './handlers/dashboard';
|
||||
import { CoreCoursesDashboardHandler } from './services/handlers/dashboard';
|
||||
import { CoreCoursesDashboardPage } from './pages/dashboard/dashboard.page';
|
||||
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'dashboard',
|
||||
component: CoreCoursesDashboardPage,
|
||||
loadChildren: () =>
|
||||
import('@core/courses/pages/dashboard/dashboard.page.module').then(m => m.CoreCoursesDashboardPageModule),
|
||||
},
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
declarations: [],
|
||||
imports: [CoreHomeRoutingModule.forChild(routes)],
|
||||
exports: [CoreHomeRoutingModule],
|
||||
providers: [
|
||||
CoreCoursesDashboardHandler,
|
||||
],
|
||||
})
|
||||
export class CoreCoursesModule {
|
||||
|
||||
constructor(homeDelegate: CoreHomeDelegate) {
|
||||
homeDelegate.registerHandler(new CoreCoursesDashboardHandler());
|
||||
constructor(
|
||||
homeDelegate: CoreHomeDelegate,
|
||||
coursesDashboardHandler: CoreCoursesDashboardHandler,
|
||||
) {
|
||||
homeDelegate.registerHandler(coursesDashboardHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreHomeHandler, CoreHomeHandlerData } from '@core/mainmenu/services/home.delegate';
|
||||
|
||||
/**
|
||||
* Handler to add Home into main menu.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreCoursesDashboardHandler implements CoreHomeHandler {
|
||||
|
||||
name = 'CoreCoursesDashboard';
|
|
@ -26,7 +26,7 @@ import { CoreMainMenuDelegate } from './services/mainmenu.delegate';
|
|||
import { CoreMainMenuRoutingModule } from './mainmenu-routing.module';
|
||||
import { CoreMainMenuPage } from './pages/menu/menu.page';
|
||||
import { CoreMainMenuMorePage } from './pages/more/more.page';
|
||||
import { CoreHomeMainMenuHandler } from './handlers/mainmenu';
|
||||
import { CoreHomeMainMenuHandler } from './services/handlers/mainmenu';
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
@ -42,11 +42,17 @@ import { CoreHomeMainMenuHandler } from './handlers/mainmenu';
|
|||
CoreMainMenuPage,
|
||||
CoreMainMenuMorePage,
|
||||
],
|
||||
providers: [
|
||||
CoreHomeMainMenuHandler,
|
||||
],
|
||||
})
|
||||
export class CoreMainMenuModule {
|
||||
|
||||
constructor(mainMenuDelegate: CoreMainMenuDelegate) {
|
||||
mainMenuDelegate.registerHandler(new CoreHomeMainMenuHandler());
|
||||
constructor(
|
||||
mainMenuDelegate: CoreMainMenuDelegate,
|
||||
homeMainMenuHandler: CoreHomeMainMenuHandler,
|
||||
) {
|
||||
mainMenuDelegate.registerHandler(homeMainMenuHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,12 +16,10 @@
|
|||
</ion-header>
|
||||
<ion-content>
|
||||
<!-- @todo -->
|
||||
<core-loading [hideUntil]="loaded" *ngIf="tabs.length > 0">
|
||||
<core-tabs [selectedIndex]="selectedTab" [hideUntil]="loaded" [tabs]="tabs"></core-tabs>
|
||||
<core-loading [hideUntil]="loaded">
|
||||
<core-tabs *ngIf="tabs.length > 0" [selectedIndex]="selectedTab" [hideUntil]="loaded" [tabs]="tabs"></core-tabs>
|
||||
<ng-container *ngIf="tabs.length == 0">
|
||||
<core-empty-box icon="fa-home" [message]="'core.courses.nocourses' | translate">
|
||||
<div>Home page</div>
|
||||
</core-empty-box>
|
||||
<core-empty-box icon="fas-home" [message]="'core.courses.nocourses' | translate"></core-empty-box>
|
||||
</ng-container>
|
||||
</core-loading>
|
||||
</ion-content>
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { IonicModule } from '@ionic/angular';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
|
@ -22,33 +21,19 @@ import { CoreComponentsModule } from '@components/components.module';
|
|||
import { CoreDirectivesModule } from '@directives/directives.module';
|
||||
|
||||
import { CoreHomePage } from './home.page';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: CoreHomePage,
|
||||
children: [
|
||||
{
|
||||
path: 'dashboard', // @todo: Add this route dynamically.
|
||||
loadChildren: () =>
|
||||
import('@core/courses/pages/dashboard/dashboard.page.module').then(m => m.CoreCoursesDashboardPageModule),
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
import { CoreHomeRoutingModule } from './home-routing.module';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forChild(routes),
|
||||
CommonModule,
|
||||
IonicModule,
|
||||
TranslateModule.forChild(),
|
||||
CoreComponentsModule,
|
||||
CoreDirectivesModule,
|
||||
CoreHomeRoutingModule,
|
||||
],
|
||||
declarations: [
|
||||
CoreHomePage,
|
||||
],
|
||||
exports: [RouterModule],
|
||||
})
|
||||
export class CoreHomePageModule {}
|
||||
|
|
|
@ -55,6 +55,8 @@ export class CoreHomePage implements OnInit {
|
|||
initHandlers(handlers: CoreHomeHandlerToDisplay[]): void {
|
||||
// Re-build the list of tabs. If a handler is already in the list, use existing object to prevent re-creating the tab.
|
||||
const newTabs: CoreHomeHandlerToDisplay[] = handlers.map((handler) => {
|
||||
handler.page = '/home/' + handler.page;
|
||||
|
||||
// Check if the handler is already in the tabs list. If so, use it.
|
||||
const tab = this.tabs.find((tab) => tab.title == handler.title);
|
||||
|
||||
|
@ -63,9 +65,10 @@ export class CoreHomePage implements OnInit {
|
|||
// Sort them by priority so new handlers are in the right position.
|
||||
.sort((a, b) => (b.priority || 0) - (a.priority || 0));
|
||||
|
||||
if (typeof this.selectedTab == 'undefined') {
|
||||
if (typeof this.selectedTab == 'undefined' && newTabs.length > 0) {
|
||||
let maxPriority = 0;
|
||||
let maxIndex = 0;
|
||||
|
||||
newTabs.forEach((tab, index) => {
|
||||
if ((tab.selectPriority || 0) > maxPriority) {
|
||||
maxPriority = tab.selectPriority || 0;
|
||||
|
|
|
@ -12,11 +12,13 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../services/mainmenu.delegate';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '../mainmenu.delegate';
|
||||
|
||||
/**
|
||||
* Handler to add Home into main menu.
|
||||
*/
|
||||
Injectable();
|
||||
export class CoreHomeMainMenuHandler implements CoreMainMenuHandler {
|
||||
|
||||
name = 'CoreHome';
|
|
@ -17,8 +17,9 @@ import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
|
|||
import { CoreSites } from '@services/sites';
|
||||
import { CoreDomUtils } from '@services/utils/dom';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { CoreSearchHistory, CoreSearchHistoryItem } from '../../services/search-history';
|
||||
import { CoreSearchHistory } from '../../services/search-history';
|
||||
import { Translate } from '@singletons/core.singletons';
|
||||
import { CoreSearchHistoryDBRecord } from '../../services/search.history.db';
|
||||
|
||||
/**
|
||||
* Component to display a "search box".
|
||||
|
@ -59,7 +60,7 @@ export class CoreSearchBoxComponent implements OnInit {
|
|||
|
||||
searched = ''; // Last search emitted.
|
||||
searchText = '';
|
||||
history: CoreSearchHistoryItem[] = [];
|
||||
history: CoreSearchHistoryDBRecord[] = [];
|
||||
historyShown = false;
|
||||
|
||||
constructor() {
|
||||
|
|
Loading…
Reference in New Issue