MOBILE-2201 course: Tag area handler for activities and resources

main
Albert Gasset 2019-07-08 12:07:18 +02:00
parent eed78c8b6f
commit fdae95d294
5 changed files with 65 additions and 2 deletions

View File

@ -1796,6 +1796,7 @@
"core.success": "moodle",
"core.tablet": "local_moodlemobileapp",
"core.tag.tagarea_course": "moodle",
"core.tag.tagarea_course_modules": "moodle",
"core.tag.tags": "moodle",
"core.teachers": "moodle",
"core.thereisdatatosync": "local_moodlemobileapp",

View File

@ -1796,6 +1796,7 @@
"core.success": "Success",
"core.tablet": "Tablet",
"core.tag.tagarea_course": "Courses",
"core.tag.tagarea_course_modules": "Activities and resources",
"core.tag.tags": "Tags",
"core.teachers": "Teachers",
"core.thereisdatatosync": "There are offline {{$a}} to be synchronised.",

View File

@ -35,6 +35,7 @@ import { CoreCourseSyncCronHandler } from './providers/sync-cron-handler';
import { CoreCourseLogCronHandler } from './providers/log-cron-handler';
import { CoreTagAreaDelegate } from '@core/tag/providers/area-delegate';
import { CoreCourseTagAreaHandler } from './providers/course-tag-area-handler';
import { CoreCourseModulesTagAreaHandler } from './providers/modules-tag-area-handler';
// List of providers (without handlers).
export const CORE_COURSE_PROVIDERS: any[] = [
@ -71,17 +72,19 @@ export const CORE_COURSE_PROVIDERS: any[] = [
CoreCourseModuleDefaultHandler,
CoreCourseSyncCronHandler,
CoreCourseLogCronHandler,
CoreCourseTagAreaHandler
CoreCourseTagAreaHandler,
CoreCourseModulesTagAreaHandler
],
exports: []
})
export class CoreCourseModule {
constructor(cronDelegate: CoreCronDelegate, syncHandler: CoreCourseSyncCronHandler, logHandler: CoreCourseLogCronHandler,
platform: Platform, eventsProvider: CoreEventsProvider, tagAreaDelegate: CoreTagAreaDelegate,
courseTagAreaHandler: CoreCourseTagAreaHandler) {
courseTagAreaHandler: CoreCourseTagAreaHandler, modulesTagAreaHandler: CoreCourseModulesTagAreaHandler) {
cronDelegate.register(syncHandler);
cronDelegate.register(logHandler);
tagAreaDelegate.registerHandler(courseTagAreaHandler);
tagAreaDelegate.registerHandler(modulesTagAreaHandler);
platform.resume.subscribe(() => {
// Log the app is open to keep user in online status.

View File

@ -0,0 +1,57 @@
// (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, Injector } from '@angular/core';
import { CoreTagAreaHandler } from '@core/tag/providers/area-delegate';
import { CoreTagHelperProvider } from '@core/tag/providers/helper';
import { CoreTagFeedComponent } from '@core/tag/components/feed/feed';
/**
* Handler to support tags.
*/
@Injectable()
export class CoreCourseModulesTagAreaHandler implements CoreTagAreaHandler {
name = 'CoreCourseModulesTagAreaHandler';
type = 'core/course_modules';
constructor(protected tagHelper: CoreTagHelperProvider) {}
/**
* Whether or not the handler is enabled on a site level.
* @return {boolean|Promise<boolean>} Whether or not the handler is enabled on a site level.
*/
isEnabled(): boolean | Promise<boolean> {
return true;
}
/**
* Parses the rendered content of a tag index and returns the items.
*
* @param {string} content Rendered content.
* @return {any[]|Promise<any[]>} Area items (or promise resolved with the items).
*/
parseContent(content: string): any[] | Promise<any[]> {
return this.tagHelper.parseFeedContent(content);
}
/**
* Get the component to use to display items.
*
* @param {Injector} injector Injector.
* @return {any|Promise<any>} The component (or promise resolved with component) to use, undefined if not found.
*/
getComponent(injector: Injector): any | Promise<any> {
return CoreTagFeedComponent;
}
}

View File

@ -1,4 +1,5 @@
{
"tagarea_course": "Courses",
"tagarea_course_modules": "Activities and resources",
"tags": "Tags"
}