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 { CoreCourse } from '@features/course/services/course';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
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 { AddonModPageHelper } from '../../services/page-helper';
|
||||||
|
import { ADDON_MOD_PAGE_COMPONENT } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a page.
|
* Component that displays a page.
|
||||||
|
@ -30,7 +31,7 @@ import { AddonModPageHelper } from '../../services/page-helper';
|
||||||
})
|
})
|
||||||
export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComponent implements OnInit {
|
export class AddonModPageIndexComponent extends CoreCourseModuleMainResourceComponent implements OnInit {
|
||||||
|
|
||||||
component = AddonModPageProvider.COMPONENT;
|
component = ADDON_MOD_PAGE_COMPONENT;
|
||||||
pluginName = 'page';
|
pluginName = 'page';
|
||||||
contents?: string;
|
contents?: string;
|
||||||
displayDescription = false;
|
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,
|
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 { CorePluginFileDelegate } from '@services/plugin-file-delegate';
|
||||||
import { AddonModPageIndexLinkHandler } from './services/handlers/index-link';
|
import { AddonModPageIndexLinkHandler } from './services/handlers/index-link';
|
||||||
import { AddonModPageListLinkHandler } from './services/handlers/list-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 { AddonModPagePluginFileHandler } from './services/handlers/pluginfile';
|
||||||
import { AddonModPagePrefetchHandler } from './services/handlers/prefetch';
|
import { AddonModPagePrefetchHandler } from './services/handlers/prefetch';
|
||||||
|
import { ADDON_MOD_PAGE_PAGE_NAME } from './constants';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: AddonModPageModuleHandlerService.PAGE_NAME,
|
path: ADDON_MOD_PAGE_PAGE_NAME,
|
||||||
loadChildren: () => import('./page-lazy.module').then(m => m.AddonModPageLazyModule),
|
loadChildren: () => import('./page-lazy.module'),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { CoreCourseModuleHandler } from '@features/course/services/module-delega
|
||||||
import { CoreConstants, ModPurpose } from '@/core/constants';
|
import { CoreConstants, ModPurpose } from '@/core/constants';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
|
import { ADDON_MOD_PAGE_PAGE_NAME } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to support page modules.
|
* Handler to support page modules.
|
||||||
|
@ -25,11 +26,9 @@ import { CoreModuleHandlerBase } from '@features/course/classes/module-base-hand
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AddonModPageModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
export class AddonModPageModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
||||||
|
|
||||||
static readonly PAGE_NAME = 'mod_page';
|
|
||||||
|
|
||||||
name = 'AddonModPage';
|
name = 'AddonModPage';
|
||||||
modName = 'page';
|
modName = 'page';
|
||||||
protected pageName = AddonModPageModuleHandlerService.PAGE_NAME;
|
protected pageName = ADDON_MOD_PAGE_PAGE_NAME;
|
||||||
|
|
||||||
supportedFeatures = {
|
supportedFeatures = {
|
||||||
[CoreConstants.FEATURE_MOD_ARCHETYPE]: CoreConstants.MOD_ARCHETYPE_RESOURCE,
|
[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 { CoreCourseModuleData } from '@features/course/services/course-helper';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModPage, AddonModPageProvider } from '../page';
|
import { AddonModPage } from '../page';
|
||||||
|
import { ADDON_MOD_PAGE_COMPONENT } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to prefetch pages.
|
* Handler to prefetch pages.
|
||||||
|
@ -28,7 +29,7 @@ export class AddonModPagePrefetchHandlerService extends CoreCourseResourcePrefet
|
||||||
|
|
||||||
name = 'AddonModPage';
|
name = 'AddonModPage';
|
||||||
modName = 'page';
|
modName = 'page';
|
||||||
component = AddonModPageProvider.COMPONENT;
|
component = ADDON_MOD_PAGE_COMPONENT;
|
||||||
updatesNames = /^configuration$|^.*files$/;
|
updatesNames = /^configuration$|^.*files$/;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AddonModPageProvider } from './page';
|
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreTextUtils } from '@services/utils/text';
|
import { CoreTextUtils } from '@services/utils/text';
|
||||||
import { CoreFile } from '@services/file';
|
import { CoreFile } from '@services/file';
|
||||||
|
@ -23,6 +22,7 @@ import { CoreWS } from '@services/ws';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { CoreCourseModuleContentFile } from '@features/course/services/course';
|
import { CoreCourseModuleContentFile } from '@features/course/services/course';
|
||||||
|
import { ADDON_MOD_PAGE_COMPONENT } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features for page.
|
* Service that provides some features for page.
|
||||||
|
@ -71,7 +71,7 @@ export class AddonModPageHelperProvider {
|
||||||
CoreSites.getCurrentSiteId(),
|
CoreSites.getCurrentSiteId(),
|
||||||
indexUrl,
|
indexUrl,
|
||||||
false,
|
false,
|
||||||
AddonModPageProvider.COMPONENT,
|
ADDON_MOD_PAGE_COMPONENT,
|
||||||
moduleId,
|
moduleId,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -23,8 +23,7 @@ import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
import { CoreCourseLogHelper } from '@features/course/services/log-helper';
|
||||||
import { CoreError } from '@classes/errors/error';
|
import { CoreError } from '@classes/errors/error';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
|
import { ADDON_MOD_PAGE_COMPONENT } from '../constants';
|
||||||
const ROOT_CACHE_KEY = 'mmaModPage:';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service that provides some features for page.
|
* Service that provides some features for page.
|
||||||
|
@ -32,7 +31,7 @@ const ROOT_CACHE_KEY = 'mmaModPage:';
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AddonModPageProvider {
|
export class AddonModPageProvider {
|
||||||
|
|
||||||
static readonly COMPONENT = 'mmaModPage';
|
protected static readonly ROOT_CACHE_KEY = 'mmaModPage:';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a page by course module ID.
|
* Get a page by course module ID.
|
||||||
|
@ -69,7 +68,7 @@ export class AddonModPageProvider {
|
||||||
const preSets: CoreSiteWSPreSets = {
|
const preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getPageCacheKey(courseId),
|
cacheKey: this.getPageCacheKey(courseId),
|
||||||
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
||||||
component: AddonModPageProvider.COMPONENT,
|
component: ADDON_MOD_PAGE_COMPONENT,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
|
...CoreSites.getReadingStrategyPreSets(options.readingStrategy),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,7 +89,7 @@ export class AddonModPageProvider {
|
||||||
* @returns Cache key.
|
* @returns Cache key.
|
||||||
*/
|
*/
|
||||||
protected getPageCacheKey(courseId: number): string {
|
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>[] = [];
|
const promises: Promise<void>[] = [];
|
||||||
|
|
||||||
promises.push(this.invalidatePageData(courseId, siteId));
|
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));
|
promises.push(CoreCourse.invalidateModule(moduleId, siteId));
|
||||||
|
|
||||||
return CoreUtils.allPromises(promises);
|
return CoreUtils.allPromises(promises);
|
||||||
|
@ -153,7 +152,7 @@ export class AddonModPageProvider {
|
||||||
return CoreCourseLogHelper.log(
|
return CoreCourseLogHelper.log(
|
||||||
'mod_page_view_page',
|
'mod_page_view_page',
|
||||||
params,
|
params,
|
||||||
AddonModPageProvider.COMPONENT,
|
ADDON_MOD_PAGE_COMPONENT,
|
||||||
pageid,
|
pageid,
|
||||||
siteId,
|
siteId,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue