From 7bc76533c88f7b36b00ea541f364374e531cd907 Mon Sep 17 00:00:00 2001 From: dpalou Date: Fri, 28 Sep 2018 09:48:05 +0200 Subject: [PATCH] MOBILE-2602 page: Display timemodified at the end of page --- .../mod/page/components/components.module.ts | 2 ++ .../index/addon-mod-page-index.html | 5 +++- src/addon/mod/page/components/index/index.ts | 23 ++++++++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/addon/mod/page/components/components.module.ts b/src/addon/mod/page/components/components.module.ts index 05b57e010..be48ffd8e 100644 --- a/src/addon/mod/page/components/components.module.ts +++ b/src/addon/mod/page/components/components.module.ts @@ -18,6 +18,7 @@ import { IonicModule } from 'ionic-angular'; import { TranslateModule } from '@ngx-translate/core'; import { CoreComponentsModule } from '@components/components.module'; import { CoreDirectivesModule } from '@directives/directives.module'; +import { CorePipesModule } from '@pipes/pipes.module'; import { CoreCourseComponentsModule } from '@core/course/components/components.module'; import { AddonModPageIndexComponent } from './index/index'; @@ -31,6 +32,7 @@ import { AddonModPageIndexComponent } from './index/index'; TranslateModule.forChild(), CoreComponentsModule, CoreDirectivesModule, + CorePipesModule, CoreCourseComponentsModule ], providers: [ diff --git a/src/addon/mod/page/components/index/addon-mod-page-index.html b/src/addon/mod/page/components/index/addon-mod-page-index.html index 1c4b04a58..8572f4d64 100644 --- a/src/addon/mod/page/components/index/addon-mod-page-index.html +++ b/src/addon/mod/page/components/index/addon-mod-page-index.html @@ -12,10 +12,13 @@ - +
+

+ {{ 'core.lastmodified' | translate}}: {{ page.timemodified * 1000 | coreFormatDate: "dfmediumdate" }} +

diff --git a/src/addon/mod/page/components/index/index.ts b/src/addon/mod/page/components/index/index.ts index f22e907f4..ed70412fb 100644 --- a/src/addon/mod/page/components/index/index.ts +++ b/src/addon/mod/page/components/index/index.ts @@ -14,6 +14,7 @@ import { Component, Injector } from '@angular/core'; import { CoreAppProvider } from '@providers/app'; +import { CoreUtilsProvider } from '@providers/utils/utils'; import { CoreCourseProvider } from '@core/course/providers/course'; import { CoreCourseModuleMainResourceComponent } from '@core/course/classes/main-resource-component'; import { AddonModPageProvider } from '../../providers/page'; @@ -31,11 +32,15 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp component = AddonModPageProvider.COMPONENT; canGetPage: boolean; contents: any; + displayDescription = true; + displayTimemodified = true; + page: any; + protected fetchContentDefaultError = 'addon.mod_page.errorwhileloadingthepage'; constructor(injector: Injector, private pageProvider: AddonModPageProvider, private courseProvider: CoreCourseProvider, private appProvider: CoreAppProvider, private pageHelper: AddonModPageHelperProvider, - private pagePrefetch: AddonModPagePrefetchHandler) { + private pagePrefetch: AddonModPagePrefetchHandler, private utils: CoreUtilsProvider) { super(injector); } @@ -97,6 +102,22 @@ export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComp if (page) { this.description = page.intro || page.description; this.dataRetrieved.emit(page); + + if (this.canGetPage) { + this.page = page; + + // Check if description and timemodified should be displayed. + if (page.displayoptions) { + const options = this.textUtils.unserialize(page.displayoptions) || {}; + this.displayDescription = typeof options.printintro == 'undefined' || + this.utils.isTrueOrOne(options.printintro); + this.displayTimemodified = typeof options.printlastmodified == 'undefined' || + this.utils.isTrueOrOne(options.printlastmodified); + } else { + this.displayDescription = true; + this.displayTimemodified = true; + } + } } }).catch(() => { // Ignore errors.