MOBILE-4616 page: Move page constants to a file
parent
b93dcfb87f
commit
eb2555e5ad
|
@ -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;
|
||||
|
|
|
@ -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';
|
|
@ -36,4 +36,4 @@ const routes: Routes = [
|
|||
AddonModPageIndexPage,
|
||||
],
|
||||
})
|
||||
export class AddonModPageLazyModule {}
|
||||
export default class AddonModPageLazyModule {}
|
||||
|
|
|
@ -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'),
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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$/;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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<void>[] = [];
|
||||
|
||||
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,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue