MOBILE-2309 sitehome: Implement and apply items
parent
58a872f992
commit
8a3f7053e5
|
@ -0,0 +1,4 @@
|
|||
<a *ngIf="show" ion-item text-wrap [navPush]="'CoreCoursesAvailableCoursesPage'">
|
||||
<ion-icon name="ionic" item-start></ion-icon>
|
||||
<h2>{{ 'core.courses.availablecourses' | translate}}</h2>
|
||||
</a>
|
|
@ -0,0 +1,32 @@
|
|||
// (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 { Component, Input } from '@angular/core';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
import { CoreCoursesProvider } from '../../../courses/providers/courses';
|
||||
|
||||
/**
|
||||
* Component to open the page to view the list of all courses.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'core-sitehome-all-course-list',
|
||||
templateUrl: 'all-course-list.html',
|
||||
})
|
||||
export class CoreSiteHomeAllCourseListComponent {
|
||||
show: boolean;
|
||||
|
||||
constructor(coursesProvider: CoreCoursesProvider) {
|
||||
this.show = coursesProvider.isGetCoursesByFieldAvailable();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<a *ngIf="show" ion-item text-wrap [navPush]="'CoreCoursesCategoriesPage'">
|
||||
<ion-icon name="folder" item-start></ion-icon>
|
||||
<h2>{{ 'core.courses.categories' | translate}}</h2>
|
||||
</a>
|
|
@ -0,0 +1,32 @@
|
|||
// (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 { Component, Input } from '@angular/core';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
import { CoreCoursesProvider } from '../../../courses/providers/courses';
|
||||
|
||||
/**
|
||||
* Component to open the page to view the list of categories.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'core-sitehome-categories',
|
||||
templateUrl: 'categories.html',
|
||||
})
|
||||
export class CoreSiteHomeCategoriesComponent {
|
||||
show: boolean;
|
||||
|
||||
constructor(coursesProvider: CoreCoursesProvider) {
|
||||
this.show = coursesProvider.isGetCoursesByFieldAvailable();
|
||||
}
|
||||
}
|
|
@ -20,10 +20,20 @@ import { CoreComponentsModule } from '../../../components/components.module';
|
|||
import { CoreDirectivesModule } from '../../../directives/directives.module';
|
||||
import { CoreCourseComponentsModule } from '../../course/components/components.module';
|
||||
import { CoreSiteHomeIndexComponent } from './index/index';
|
||||
import { CoreSiteHomeAllCourseListComponent } from './all-course-list/all-course-list';
|
||||
import { CoreSiteHomeCategoriesComponent } from './categories/categories';
|
||||
import { CoreSiteHomeCourseSearchComponent } from './course-search/course-search';
|
||||
import { CoreSiteHomeEnrolledCourseListComponent } from './enrolled-course-list/enrolled-course-list';
|
||||
import { CoreSiteHomeNewsComponent } from './news/news';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
CoreSiteHomeIndexComponent
|
||||
CoreSiteHomeIndexComponent,
|
||||
CoreSiteHomeAllCourseListComponent,
|
||||
CoreSiteHomeCategoriesComponent,
|
||||
CoreSiteHomeCourseSearchComponent,
|
||||
CoreSiteHomeEnrolledCourseListComponent,
|
||||
CoreSiteHomeNewsComponent
|
||||
],
|
||||
imports: [
|
||||
CommonModule,
|
||||
|
@ -34,7 +44,12 @@ import { CoreSiteHomeIndexComponent } from './index/index';
|
|||
CoreCourseComponentsModule
|
||||
],
|
||||
exports: [
|
||||
CoreSiteHomeIndexComponent
|
||||
CoreSiteHomeIndexComponent,
|
||||
CoreSiteHomeAllCourseListComponent,
|
||||
CoreSiteHomeCategoriesComponent,
|
||||
CoreSiteHomeCourseSearchComponent,
|
||||
CoreSiteHomeEnrolledCourseListComponent,
|
||||
CoreSiteHomeNewsComponent
|
||||
]
|
||||
})
|
||||
export class CoreSiteHomeComponentsModule {}
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<a *ngIf="show" ion-item text-wrap [navPush]="'CoreCoursesSearchPage'">
|
||||
<ion-icon name="search" item-start></ion-icon>
|
||||
<h2>{{ 'core.courses.searchcourses' | translate}}</h2>
|
||||
</a>
|
|
@ -0,0 +1,32 @@
|
|||
// (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 { Component, Input } from '@angular/core';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
import { CoreCoursesProvider } from '../../../courses/providers/courses';
|
||||
|
||||
/**
|
||||
* Component to open the page to search courses.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'core-sitehome-course-search',
|
||||
templateUrl: 'course-search.html',
|
||||
})
|
||||
export class CoreSiteHomeCourseSearchComponent {
|
||||
show: boolean;
|
||||
|
||||
constructor(coursesProvider: CoreCoursesProvider) {
|
||||
this.show = !coursesProvider.isSearchCoursesDisabledInSite();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<a *ngIf="show" ion-item text-wrap [navPush]="'CoreCoursesMyCoursesPage'">
|
||||
<ion-icon name="ionic" item-start></ion-icon>
|
||||
<h2>{{ 'core.courses.mycourses' | translate}}</h2>
|
||||
</a>
|
|
@ -0,0 +1,43 @@
|
|||
// (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 { Component, Input, OnInit } from '@angular/core';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
import { CoreCoursesProvider } from '../../../courses/providers/courses';
|
||||
|
||||
/**
|
||||
* Component to open the page to view the list of courses the user is enrolled in.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'core-sitehome-enrolled-course-list',
|
||||
templateUrl: 'enrolled-course-list.html',
|
||||
})
|
||||
export class CoreSiteHomeEnrolledCourseListComponent implements OnInit {
|
||||
show: boolean;
|
||||
|
||||
constructor(private coursesProvider: CoreCoursesProvider) {}
|
||||
|
||||
/**
|
||||
* Component being initialized.
|
||||
*/
|
||||
ngOnInit() {
|
||||
if (this.coursesProvider.isMyCoursesDisabledInSite()) {
|
||||
this.show = false;
|
||||
} else {
|
||||
return this.coursesProvider.getUserCourses().then((courses) => {
|
||||
this.show = courses.length > 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
<core-loading [hideUntil]="dataLoaded">
|
||||
|
||||
<!-- Site home main contents. -->
|
||||
<ion-card *ngIf="section && section.hasContent">
|
||||
<ion-item text-wrap *ngIf="section.summary">
|
||||
<core-format-text [text]="section.summary"></core-format-text>
|
||||
|
@ -13,9 +14,18 @@
|
|||
<core-course-module *ngFor="let module of section.modules" [module]="module" [courseId]="siteHomeId"></core-course-module>
|
||||
</ion-card>
|
||||
|
||||
<!-- @todo: Frontpage items. -->
|
||||
<!-- <mma-frontpage-item ng-repeat="item in items" name="{{item}}"></mma-frontpage-item> -->
|
||||
<!-- Site home items: news, categories, courses, etc. -->
|
||||
<ion-card *ngIf="items.length > 0">
|
||||
<ng-container *ngFor="let item of items">
|
||||
<core-sitehome-all-course-list *ngIf="item == 'all-course-list'"></core-sitehome-all-course-list>
|
||||
<core-sitehome-categories *ngIf="item == 'categories'"></core-sitehome-categories>
|
||||
<core-sitehome-course-search *ngIf="item == 'course-search'"></core-sitehome-course-search>
|
||||
<core-sitehome-enrolled-course-list *ngIf="item == 'enrolled-course-list'"></core-sitehome-enrolled-course-list>
|
||||
<core-sitehome-news *ngIf="item == 'news'"></core-sitehome-news>
|
||||
</ng-container>
|
||||
</ion-card>
|
||||
|
||||
<!-- Site home block. -->
|
||||
<ion-card *ngIf="block && block.hasContent">
|
||||
<ion-item text-wrap *ngIf="block.summary">
|
||||
<core-format-text [text]="block.summary"></core-format-text>
|
||||
|
|
|
@ -60,10 +60,16 @@ export class CoreSiteHomeIndexComponent implements OnInit {
|
|||
* @param {any} refresher Refresher.
|
||||
*/
|
||||
doRefresh(refresher: any) {
|
||||
const promises = [];
|
||||
const promises = [],
|
||||
currentSite = this.sitesProvider.getCurrentSite();
|
||||
|
||||
promises.push(this.courseProvider.invalidateSections(this.siteHomeId));
|
||||
promises.push(this.sitesProvider.getCurrentSite().invalidateConfig());
|
||||
promises.push(currentSite.invalidateConfig().then(() => {
|
||||
// Config invalidated, fetch it again.
|
||||
return currentSite.getConfig().then((config) => {
|
||||
currentSite.setConfig(config);
|
||||
});
|
||||
}));
|
||||
|
||||
if (this.sectionsLoaded) {
|
||||
// Invalidate modules prefetch data.
|
||||
|
@ -89,21 +95,21 @@ export class CoreSiteHomeIndexComponent implements OnInit {
|
|||
if (config.frontpageloggedin) {
|
||||
// Items with index 1 and 3 were removed on 2.5 and not being supported in the app.
|
||||
let frontpageItems = [
|
||||
'mma-frontpage-item-news', // News items.
|
||||
'news', // News items.
|
||||
false,
|
||||
'mma-frontpage-item-categories', // List of categories.
|
||||
'categories', // List of categories.
|
||||
false,
|
||||
'mma-frontpage-item-categories', // Combo list.
|
||||
'mma-frontpage-item-enrolled-course-list', // Enrolled courses.
|
||||
'mma-frontpage-item-all-course-list', // List of courses.
|
||||
'mma-frontpage-item-course-search' // Course search box.
|
||||
'categories', // Combo list.
|
||||
'enrolled-course-list', // Enrolled courses.
|
||||
'all-course-list', // List of courses.
|
||||
'course-search' // Course search box.
|
||||
],
|
||||
items = config.frontpageloggedin.split(',');
|
||||
|
||||
this.items = [];
|
||||
|
||||
items.forEach((itemNumber) => {
|
||||
// Get the frontpage item directive to render itself.
|
||||
// Get the frontpage item "name".
|
||||
const item = frontpageItems[parseInt(itemNumber, 10)];
|
||||
if (!item || this.items.indexOf(item) >= 0) {
|
||||
return;
|
||||
|
@ -112,7 +118,6 @@ export class CoreSiteHomeIndexComponent implements OnInit {
|
|||
this.hasContent = true;
|
||||
this.items.push(item);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return this.courseProvider.getSections(this.siteHomeId, false, true).then((sections) => {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<core-course-module class="core-sitehome-news" *ngIf="show" [module]="module" [courseId]="siteHomeId"></core-course-module>
|
|
@ -0,0 +1,67 @@
|
|||
// (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 { Component, OnInit, Input } from '@angular/core';
|
||||
import { IonicPage } from 'ionic-angular';
|
||||
import { CoreSitesProvider } from '../../../../providers/sites';
|
||||
|
||||
/**
|
||||
* Component that displays site home news.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'core-sitehome-news',
|
||||
templateUrl: 'news.html',
|
||||
})
|
||||
export class CoreSiteHomeNewsComponent implements OnInit {
|
||||
module: any;
|
||||
show: boolean;
|
||||
siteHomeId: number;
|
||||
|
||||
constructor(private sitesProvider: CoreSitesProvider) {
|
||||
this.siteHomeId = sitesProvider.getCurrentSite().getSiteHomeId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Component being initialized.
|
||||
*/
|
||||
ngOnInit() {
|
||||
// Get number of news items to show.
|
||||
const newsItems = this.sitesProvider.getCurrentSite().getStoredConfig('newsitems') || 0;
|
||||
if (!newsItems) {
|
||||
return;
|
||||
}
|
||||
|
||||
// @todo: Implement it once forum is supported.
|
||||
// $mmaModForum = $mmAddonManager.get('$mmaModForum');
|
||||
// if ($mmaModForum) {
|
||||
// return $mmaModForum.getCourseForums(courseId).then(function(forums) {
|
||||
// for (var x in forums) {
|
||||
// if (forums[x].type == 'news') {
|
||||
// return forums[x];
|
||||
// }
|
||||
// }
|
||||
// }).then(function(forum) {
|
||||
// if (forum) {
|
||||
// return $mmCourse.getModuleBasicInfo(forum.cmid).then(function(module) {
|
||||
// scope.show = true;
|
||||
// scope.module = module;
|
||||
// scope.module._controller =
|
||||
// $mmCourseDelegate.getContentHandlerControllerFor(module.modname, module, courseId,
|
||||
// module.section);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue