diff --git a/src/addons/mod/page/components/index/index.ts b/src/addons/mod/page/components/index/index.ts index d139e0473..fcef8de3f 100644 --- a/src/addons/mod/page/components/index/index.ts +++ b/src/addons/mod/page/components/index/index.ts @@ -18,8 +18,9 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents import { CoreCourse } from '@features/course/services/course'; import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; -import { AddonModPageProvider, AddonModPagePage, AddonModPage } from '../../services/page'; +import { AddonModPagePage, AddonModPage } from '../../services/page'; import { AddonModPageHelper } from '../../services/page-helper'; +import { ADDON_MOD_PAGE_COMPONENT } from '../../constants'; /** * Component that displays a page. @@ -30,7 +31,7 @@ import { AddonModPageHelper } from '../../services/page-helper'; }) export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComponent implements OnInit { - component = AddonModPageProvider.COMPONENT; + component = ADDON_MOD_PAGE_COMPONENT; pluginName = 'page'; contents?: string; displayDescription = false; diff --git a/src/addons/mod/page/constants.ts b/src/addons/mod/page/constants.ts new file mode 100644 index 000000000..ba1682706 --- /dev/null +++ b/src/addons/mod/page/constants.ts @@ -0,0 +1,16 @@ +// (C) Copyright 2015 Moodle Pty Ltd. +// +// 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. + +export const ADDON_MOD_PAGE_COMPONENT = 'mmaModPage'; +export const ADDON_MOD_PAGE_PAGE_NAME = 'mod_page'; diff --git a/src/addons/mod/page/page-lazy.module.ts b/src/addons/mod/page/page-lazy.module.ts index e2e52badb..9b9fd02ac 100644 --- a/src/addons/mod/page/page-lazy.module.ts +++ b/src/addons/mod/page/page-lazy.module.ts @@ -36,4 +36,4 @@ const routes: Routes = [ AddonModPageIndexPage, ], }) -export class AddonModPageLazyModule {} +export default class AddonModPageLazyModule {} diff --git a/src/addons/mod/page/page.module.ts b/src/addons/mod/page/page.module.ts index edcd8fd94..ee4545365 100644 --- a/src/addons/mod/page/page.module.ts +++ b/src/addons/mod/page/page.module.ts @@ -21,14 +21,15 @@ import { CoreMainMenuTabRoutingModule } from '@features/mainmenu/mainmenu-tab-ro import { CorePluginFileDelegate } from '@services/plugin-file-delegate'; import { AddonModPageIndexLinkHandler } from './services/handlers/index-link'; import { AddonModPageListLinkHandler } from './services/handlers/list-link'; -import { AddonModPageModuleHandler, AddonModPageModuleHandlerService } from './services/handlers/module'; +import { AddonModPageModuleHandler } from './services/handlers/module'; import { AddonModPagePluginFileHandler } from './services/handlers/pluginfile'; import { AddonModPagePrefetchHandler } from './services/handlers/prefetch'; +import { ADDON_MOD_PAGE_PAGE_NAME } from './constants'; const routes: Routes = [ { - path: AddonModPageModuleHandlerService.PAGE_NAME, - loadChildren: () => import('./page-lazy.module').then(m => m.AddonModPageLazyModule), + path: ADDON_MOD_PAGE_PAGE_NAME, + loadChildren: () => import('./page-lazy.module'), }, ]; diff --git a/src/addons/mod/page/services/handlers/module.ts b/src/addons/mod/page/services/handlers/module.ts index a4868d08e..520c5e1d9 100644 --- a/src/addons/mod/page/services/handlers/module.ts +++ b/src/addons/mod/page/services/handlers/module.ts @@ -18,6 +18,7 @@ import { CoreCourseModuleHandler } from '@features/course/services/module-delega import { CoreConstants, ModPurpose } from '@/core/constants'; import { makeSingleton } from '@singletons'; import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler'; +import { ADDON_MOD_PAGE_PAGE_NAME } from '../../constants'; /** * Handler to support page modules. @@ -25,11 +26,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand @Injectable({ providedIn: 'root' }) export class AddonModPageModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler { - static readonly PAGE_NAME = 'mod_page'; - name = 'AddonModPage'; modName = 'page'; - protected pageName = AddonModPageModuleHandlerService.PAGE_NAME; + protected pageName = ADDON_MOD_PAGE_PAGE_NAME; supportedFeatures = { [CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE, diff --git a/src/addons/mod/page/services/handlers/prefetch.ts b/src/addons/mod/page/services/handlers/prefetch.ts index 484b0b545..f00fceb80 100644 --- a/src/addons/mod/page/services/handlers/prefetch.ts +++ b/src/addons/mod/page/services/handlers/prefetch.ts @@ -18,7 +18,8 @@ import { CoreCourse, CoreCourseAnyModuleData } from '@features/course/services/c import { CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; -import { AddonModPage, AddonModPageProvider } from '../page'; +import { AddonModPage } from '../page'; +import { ADDON_MOD_PAGE_COMPONENT } from '../../constants'; /** * Handler to prefetch pages. @@ -28,7 +29,7 @@ export class AddonModPagePrefetchHandlerService extends CoreCourseResourcePrefet name = 'AddonModPage'; modName = 'page'; - component = AddonModPageProvider.COMPONENT; + component = ADDON_MOD_PAGE_COMPONENT; updatesNames = /^configuration$|^.*files$/; /** diff --git a/src/addons/mod/page/services/page-helper.ts b/src/addons/mod/page/services/page-helper.ts index 1845b209e..406c71bcd 100644 --- a/src/addons/mod/page/services/page-helper.ts +++ b/src/addons/mod/page/services/page-helper.ts @@ -13,7 +13,6 @@ // limitations under the License. import { Injectable } from '@angular/core'; -import { AddonModPageProvider } from './page'; import { CoreError } from '@classes/errors/error'; import { CoreTextUtils } from '@services/utils/text'; import { CoreFile } from '@services/file'; @@ -23,6 +22,7 @@ import { CoreWS } from '@services/ws'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { CoreCourseModuleContentFile } from '@features/course/services/course'; +import { ADDON_MOD_PAGE_COMPONENT } from '../constants'; /** * Service that provides some features for page. @@ -71,7 +71,7 @@ export class AddonModPageHelperProvider { CoreSites.getCurrentSiteId(), indexUrl, false, - AddonModPageProvider.COMPONENT, + ADDON_MOD_PAGE_COMPONENT, moduleId, ); } else { diff --git a/src/addons/mod/page/services/page.ts b/src/addons/mod/page/services/page.ts index af285f171..cea794dd4 100644 --- a/src/addons/mod/page/services/page.ts +++ b/src/addons/mod/page/services/page.ts @@ -23,8 +23,7 @@ import { CoreUtils } from '@services/utils/utils'; import { CoreCourseLogHelper } from '@features/course/services/log-helper'; import { CoreError } from '@classes/errors/error'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; - -const ROOT_CACHE_KEY = 'mmaModPage:'; +import { ADDON_MOD_PAGE_COMPONENT } from '../constants'; /** * Service that provides some features for page. @@ -32,7 +31,7 @@ const ROOT_CACHE_KEY = 'mmaModPage:'; @Injectable({ providedIn: 'root' }) export class AddonModPageProvider { - static readonly COMPONENT = 'mmaModPage'; + protected static readonly ROOT_CACHE_KEY = 'mmaModPage:'; /** * Get a page by course module ID. @@ -69,7 +68,7 @@ export class AddonModPageProvider { const preSets: CoreSiteWSPreSets = { cacheKey: this.getPageCacheKey(courseId), updateFrequency: CoreSite.FREQUENCY_RARELY, - component: AddonModPageProvider.COMPONENT, + component: ADDON_MOD_PAGE_COMPONENT, ...CoreSites.getReadingStrategyPreSets(options.readingStrategy), }; @@ -90,7 +89,7 @@ export class AddonModPageProvider { * @returns Cache key. */ protected getPageCacheKey(courseId: number): string { - return ROOT_CACHE_KEY + 'page:' + courseId; + return AddonModPageProvider.ROOT_CACHE_KEY + 'page:' + courseId; } /** @@ -107,7 +106,7 @@ export class AddonModPageProvider { const promises: Promise[] = []; promises.push(this.invalidatePageData(courseId, siteId)); - promises.push(CoreFilepool.invalidateFilesByComponent(siteId, AddonModPageProvider.COMPONENT, moduleId)); + promises.push(CoreFilepool.invalidateFilesByComponent(siteId, ADDON_MOD_PAGE_COMPONENT, moduleId)); promises.push(CoreCourse.invalidateModule(moduleId, siteId)); return CoreUtils.allPromises(promises); @@ -153,7 +152,7 @@ export class AddonModPageProvider { return CoreCourseLogHelper.log( 'mod_page_view_page', params, - AddonModPageProvider.COMPONENT, + ADDON_MOD_PAGE_COMPONENT, pageid, siteId, );