MOBILE-4616 glossary: Move glossary constants to a file

main
Pau Ferrer Ocaña 2024-07-11 22:40:59 +02:00
parent c836e94101
commit 94743ed700
16 changed files with 126 additions and 100 deletions

View File

@ -20,9 +20,9 @@ import {
AddonModGlossaryGetEntriesOptions,
AddonModGlossaryGetEntriesWSResponse,
AddonModGlossaryGlossary,
AddonModGlossaryProvider,
} from '../services/glossary';
import { AddonModGlossaryOffline, AddonModGlossaryOfflineEntry } from '../services/glossary-offline';
import { ADDON_MOD_GLOSSARY_LIMIT_ENTRIES } from '../constants';
/**
* Provides a collection of glossary entries.
@ -259,7 +259,7 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
* @inheritdoc
*/
protected getPageLength(): number {
return AddonModGlossaryProvider.LIMIT_ENTRIES;
return ADDON_MOD_GLOSSARY_LIMIT_ENTRIES;
}
/**

View File

@ -42,10 +42,6 @@ import {
AddonModGlossaryEntry,
AddonModGlossaryEntryWithCategory,
AddonModGlossaryGlossary,
AddonModGlossaryProvider,
GLOSSARY_ENTRY_ADDED,
GLOSSARY_ENTRY_DELETED,
GLOSSARY_ENTRY_UPDATED,
} from '../../services/glossary';
import { AddonModGlossaryOfflineEntry } from '../../services/glossary-offline';
import {
@ -53,10 +49,16 @@ import {
AddonModGlossarySyncResult,
GLOSSARY_AUTO_SYNCED,
} from '../../services/glossary-sync';
import { AddonModGlossaryModuleHandlerService } from '../../services/handlers/module';
import { AddonModGlossaryPrefetchHandler } from '../../services/handlers/prefetch';
import { AddonModGlossaryModePickerPopoverComponent } from '../mode-picker/mode-picker';
import { CoreTime } from '@singletons/time';
import {
ADDON_MOD_GLOSSARY_COMPONENT,
ADDON_MOD_GLOSSARY_ENTRY_ADDED,
ADDON_MOD_GLOSSARY_ENTRY_DELETED,
ADDON_MOD_GLOSSARY_ENTRY_UPDATED,
ADDON_MOD_GLOSSARY_PAGE_NAME,
} from '../../constants';
/**
* Component that displays a glossary entry page.
@ -71,7 +73,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
component = AddonModGlossaryProvider.COMPONENT;
component = ADDON_MOD_GLOSSARY_COMPONENT;
pluginName = 'glossary';
canAdd = false;
@ -128,7 +130,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
// Initialize entries manager.
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(
AddonModGlossaryEntriesSource,
[this.courseId, this.module.id, this.courseContentsPage ? `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` : ''],
[this.courseId, this.module.id, this.courseContentsPage ? `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` : ''],
);
this.promisedEntries.resolve(new AddonModGlossaryEntriesManager(source, this));
@ -142,7 +144,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
// When an entry is added, we reload the data.
this.observers = [
CoreEvents.on(GLOSSARY_ENTRY_ADDED, ({ glossaryId }) => {
CoreEvents.on(ADDON_MOD_GLOSSARY_ENTRY_ADDED, ({ glossaryId }) => {
if (this.glossary?.id !== glossaryId) {
return;
}
@ -152,14 +154,14 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
this.showLoadingAndRefresh(false);
}),
CoreEvents.on(GLOSSARY_ENTRY_UPDATED, ({ glossaryId }) => {
CoreEvents.on(ADDON_MOD_GLOSSARY_ENTRY_UPDATED, ({ glossaryId }) => {
if (this.glossary?.id !== glossaryId) {
return;
}
this.showLoadingAndRefresh(false);
}),
CoreEvents.on(GLOSSARY_ENTRY_DELETED, ({ glossaryId }) => {
CoreEvents.on(ADDON_MOD_GLOSSARY_ENTRY_DELETED, ({ glossaryId }) => {
if (this.glossary?.id !== glossaryId) {
return;
}

View File

@ -0,0 +1,23 @@
// (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_GLOSSARY_COMPONENT = 'mmaModGlossary';
export const ADDON_MOD_GLOSSARY_PAGE_NAME = 'mod_glossary';
export const ADDON_MOD_GLOSSARY_ENTRY_ADDED = 'addon_mod_glossary_entry_added';
export const ADDON_MOD_GLOSSARY_ENTRY_UPDATED = 'addon_mod_glossary_entry_updated';
export const ADDON_MOD_GLOSSARY_ENTRY_DELETED = 'addon_mod_glossary_entry_deleted';
export const ADDON_MOD_GLOSSARY_LIMIT_ENTRIES = 25;
export const ADDON_MOD_GLOSSARY_LIMIT_CATEGORIES = 10;

View File

@ -35,4 +35,4 @@ const routes: Routes = [{
CoreEditorComponentsModule,
],
})
export class AddonModGlossaryEditLazyModule {}
export default class AddonModGlossaryEditLazyModule {}

View File

@ -37,4 +37,4 @@ const routes: Routes = [{
CoreTagComponentsModule,
],
})
export class AddonModGlossaryEntryLazyModule {}
export default class AddonModGlossaryEntryLazyModule {}

View File

@ -28,7 +28,7 @@ const mobileRoutes: Routes = [
},
{
path: ':courseId/:cmId/entry/:entrySlug',
loadChildren: () => import('./glossary-entry-lazy.module').then(m => m.AddonModGlossaryEntryLazyModule),
loadChildren: () => import('./glossary-entry-lazy.module'),
},
];
@ -39,7 +39,7 @@ const tabletRoutes: Routes = [
children: [
{
path: 'entry/:entrySlug',
loadChildren: () => import('./glossary-entry-lazy.module').then(m => m.AddonModGlossaryEntryLazyModule),
loadChildren: () => import('./glossary-entry-lazy.module'),
},
],
},
@ -48,11 +48,11 @@ const tabletRoutes: Routes = [
const routes: Routes = [
{
path: ':courseId/:cmId/entry/new',
loadChildren: () => import('./glossary-edit-lazy.module').then(m => m.AddonModGlossaryEditLazyModule),
loadChildren: () => import('./glossary-edit-lazy.module'),
},
{
path: ':courseId/:cmId/entry/:entrySlug/edit',
loadChildren: () => import('./glossary-edit-lazy.module').then(m => m.AddonModGlossaryEditLazyModule),
loadChildren: () => import('./glossary-edit-lazy.module'),
},
...conditionalRoutes(mobileRoutes, () => CoreScreen.isMobile),
...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet),
@ -68,4 +68,4 @@ const routes: Routes = [
AddonModGlossaryIndexPage,
],
})
export class AddonModGlossaryLazyModule {}
export default class AddonModGlossaryLazyModule {}

View File

@ -27,45 +27,45 @@ import { CoreCronDelegate } from '@services/cron';
import { CoreScreen } from '@services/screen';
import { CORE_SITE_SCHEMAS } from '@services/sites';
import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/database/glossary';
import { AddonModGlossaryProvider } from './services/glossary';
import { AddonModGlossaryEditLinkHandler } from './services/handlers/edit-link';
import { AddonModGlossaryEntryLinkHandler } from './services/handlers/entry-link';
import { AddonModGlossaryIndexLinkHandler } from './services/handlers/index-link';
import { AddonModGlossaryListLinkHandler } from './services/handlers/list-link';
import { AddonModGlossaryModuleHandler, AddonModGlossaryModuleHandlerService } from './services/handlers/module';
import { AddonModGlossaryModuleHandler } from './services/handlers/module';
import { AddonModGlossaryPrefetchHandler } from './services/handlers/prefetch';
import { AddonModGlossarySyncCronHandler } from './services/handlers/sync-cron';
import { AddonModGlossaryTagAreaHandler } from './services/handlers/tag-area';
import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_PAGE_NAME } from './constants';
const mainMenuRoutes: Routes = [
// Link handlers navigation.
{
path: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/:entrySlug`,
loadChildren: () => import('./glossary-entry-lazy.module').then(m => m.AddonModGlossaryEntryLazyModule),
path: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug`,
loadChildren: () => import('./glossary-entry-lazy.module'),
},
// Course activity navigation.
{
path: AddonModGlossaryModuleHandlerService.PAGE_NAME,
loadChildren: () => import('./glossary-lazy.module').then(m => m.AddonModGlossaryLazyModule),
path: ADDON_MOD_GLOSSARY_PAGE_NAME,
loadChildren: () => import('./glossary-lazy.module'),
},
// Single Activity format navigation.
{
path: `${COURSE_CONTENTS_PATH}/${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/new`,
loadChildren: () => import('./glossary-edit-lazy.module').then(m => m.AddonModGlossaryEditLazyModule),
data: { glossaryPathPrefix: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` },
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/new`,
loadChildren: () => import('./glossary-edit-lazy.module'),
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
},
{
path: `${COURSE_CONTENTS_PATH}/${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/:entrySlug/edit`,
loadChildren: () => import('./glossary-edit-lazy.module').then(m => m.AddonModGlossaryEditLazyModule),
data: { glossaryPathPrefix: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` },
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug/edit`,
loadChildren: () => import('./glossary-edit-lazy.module'),
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
},
...conditionalRoutes(
[{
path: `${COURSE_CONTENTS_PATH}/${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/:entrySlug`,
loadChildren: () => import('./glossary-entry-lazy.module').then(m => m.AddonModGlossaryEntryLazyModule),
data: { glossaryPathPrefix: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` },
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug`,
loadChildren: () => import('./glossary-entry-lazy.module'),
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
}],
() => CoreScreen.isMobile,
),
@ -74,9 +74,9 @@ const mainMenuRoutes: Routes = [
// Single Activity format navigation.
const courseContentsRoutes: Routes = conditionalRoutes(
[{
path: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/:entrySlug`,
loadChildren: () => import('./glossary-entry-lazy.module').then(m => m.AddonModGlossaryEntryLazyModule),
data: { glossaryPathPrefix: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` },
path: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug`,
loadChildren: () => import('./glossary-entry-lazy.module'),
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
}],
() => CoreScreen.isTablet,
);
@ -105,7 +105,7 @@ const courseContentsRoutes: Routes = conditionalRoutes(
CoreContentLinksDelegate.registerHandler(AddonModGlossaryEntryLinkHandler.instance);
CoreTagAreaDelegate.registerHandler(AddonModGlossaryTagAreaHandler.instance);
CoreCourseHelper.registerModuleReminderClick(AddonModGlossaryProvider.COMPONENT);
CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_GLOSSARY_COMPONENT);
},
},
],

View File

@ -36,11 +36,11 @@ import {
AddonModGlossaryEntry,
AddonModGlossaryEntryOption,
AddonModGlossaryGlossary,
AddonModGlossaryProvider,
} from '../../services/glossary';
import { AddonModGlossaryHelper } from '../../services/glossary-helper';
import { AddonModGlossaryOffline } from '../../services/glossary-offline';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_GLOSSARY_COMPONENT } from '../../constants';
/**
* Page that displays the edit form.
@ -53,7 +53,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
@ViewChild('editFormEl') formElement?: ElementRef;
component = AddonModGlossaryProvider.COMPONENT;
component = ADDON_MOD_GLOSSARY_COMPONENT;
cmId!: number;
courseId!: number;
loaded = false;
@ -305,7 +305,7 @@ abstract class AddonModGlossaryFormHandler {
const data = this.page.data;
const itemId = await CoreFileUploader.uploadOrReuploadFiles(
data.attachments,
AddonModGlossaryProvider.COMPONENT,
ADDON_MOD_GLOSSARY_COMPONENT,
glossary.id,
);

View File

@ -35,11 +35,10 @@ import {
AddonModGlossary,
AddonModGlossaryEntry,
AddonModGlossaryGlossary,
AddonModGlossaryProvider,
GLOSSARY_ENTRY_UPDATED,
} from '../../services/glossary';
import { CoreTime } from '@singletons/time';
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_ENTRY_UPDATED } from '../../constants';
/**
* Page that displays a glossary entry.
@ -52,7 +51,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
@ViewChild(CoreCommentsCommentsComponent) comments?: CoreCommentsCommentsComponent;
component = AddonModGlossaryProvider.COMPONENT;
component = ADDON_MOD_GLOSSARY_COMPONENT;
componentId?: number;
onlineEntry?: AddonModGlossaryEntry;
offlineEntry?: AddonModGlossaryOfflineEntry;
@ -125,7 +124,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
return;
}
this.entryUpdatedObserver = CoreEvents.on(GLOSSARY_ENTRY_UPDATED, data => {
this.entryUpdatedObserver = CoreEvents.on(ADDON_MOD_GLOSSARY_ENTRY_UPDATED, data => {
if (data.glossaryId !== this.glossary?.id) {
return;
}

View File

@ -21,7 +21,8 @@ import { makeSingleton } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { CorePath } from '@singletons/path';
import { AddonModGlossaryOfflineEntryDBRecord, OFFLINE_ENTRIES_TABLE_NAME } from './database/glossary';
import { AddonModGlossaryEntryOption, GLOSSARY_ENTRY_ADDED, GLOSSARY_ENTRY_DELETED, GLOSSARY_ENTRY_UPDATED } from './glossary';
import { AddonModGlossaryEntryOption } from './glossary';
import { ADDON_MOD_GLOSSARY_ENTRY_DELETED, ADDON_MOD_GLOSSARY_ENTRY_ADDED, ADDON_MOD_GLOSSARY_ENTRY_UPDATED } from '../constants';
/**
* Service to handle offline glossary.
@ -47,7 +48,7 @@ export class AddonModGlossaryOfflineProvider {
await site.getDb().deleteRecords(OFFLINE_ENTRIES_TABLE_NAME, conditions);
CoreEvents.trigger(GLOSSARY_ENTRY_DELETED, { glossaryId, timecreated });
CoreEvents.trigger(ADDON_MOD_GLOSSARY_ENTRY_DELETED, { glossaryId, timecreated });
}
/**
@ -188,7 +189,7 @@ export class AddonModGlossaryOfflineProvider {
await site.getDb().insertRecord(OFFLINE_ENTRIES_TABLE_NAME, entry);
CoreEvents.trigger(GLOSSARY_ENTRY_ADDED, { glossaryId, timecreated }, siteId);
CoreEvents.trigger(ADDON_MOD_GLOSSARY_ENTRY_ADDED, { glossaryId, timecreated }, siteId);
return false;
}
@ -223,7 +224,7 @@ export class AddonModGlossaryOfflineProvider {
userid: site.getUserId(),
});
CoreEvents.trigger(GLOSSARY_ENTRY_UPDATED, {
CoreEvents.trigger(ADDON_MOD_GLOSSARY_ENTRY_UPDATED, {
glossaryId: originalEntry.glossaryid,
timecreated: originalEntry.timecreated,
});

View File

@ -25,11 +25,12 @@ import { CoreSync, CoreSyncResult } from '@services/sync';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton, Translate } from '@singletons';
import { CoreEvents } from '@singletons/events';
import { AddonModGlossary, AddonModGlossaryProvider } from './glossary';
import { AddonModGlossary } from './glossary';
import { AddonModGlossaryHelper } from './glossary-helper';
import { AddonModGlossaryOffline, AddonModGlossaryOfflineEntry } from './glossary-offline';
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { CoreFileEntry } from '@services/file-helper';
import { ADDON_MOD_GLOSSARY_COMPONENT } from '../constants';
export const GLOSSARY_AUTO_SYNCED = 'addon_mod_glossary_auto_synced';
@ -148,7 +149,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv
}
// Verify that glossary isn't blocked.
if (CoreSync.isBlocked(AddonModGlossaryProvider.COMPONENT, syncId, siteId)) {
if (CoreSync.isBlocked(ADDON_MOD_GLOSSARY_COMPONENT, syncId, siteId)) {
this.logger.debug('Cannot sync glossary ' + glossaryId + ' because it is blocked.');
throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
@ -173,7 +174,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv
const syncId = this.getGlossarySyncId(glossaryId, userId);
// Sync offline logs.
await CoreUtils.ignoreErrors(CoreCourseLogHelper.syncActivity(AddonModGlossaryProvider.COMPONENT, glossaryId, siteId));
await CoreUtils.ignoreErrors(CoreCourseLogHelper.syncActivity(ADDON_MOD_GLOSSARY_COMPONENT, glossaryId, siteId));
// Get offline responses to be sent.
const entries = await CoreUtils.ignoreErrors(
@ -317,7 +318,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv
files = files.concat(storedFiles);
}
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModGlossaryProvider.COMPONENT, glossaryId, siteId);
return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_GLOSSARY_COMPONENT, glossaryId, siteId);
}
/**

View File

@ -29,10 +29,14 @@ import { CoreEvents } from '@singletons/events';
import { AddonModGlossaryEntryDBRecord, ENTRIES_TABLE_NAME } from './database/glossary';
import { AddonModGlossaryOffline } from './glossary-offline';
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
export const GLOSSARY_ENTRY_ADDED = 'addon_mod_glossary_entry_added';
export const GLOSSARY_ENTRY_UPDATED = 'addon_mod_glossary_entry_updated';
export const GLOSSARY_ENTRY_DELETED = 'addon_mod_glossary_entry_deleted';
import {
ADDON_MOD_GLOSSARY_COMPONENT,
ADDON_MOD_GLOSSARY_ENTRY_ADDED,
ADDON_MOD_GLOSSARY_ENTRY_DELETED,
ADDON_MOD_GLOSSARY_ENTRY_UPDATED,
ADDON_MOD_GLOSSARY_LIMIT_CATEGORIES,
ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
} from '../constants';
/**
* Service that provides some features for glossaries.
@ -40,12 +44,8 @@ export const GLOSSARY_ENTRY_DELETED = 'addon_mod_glossary_entry_deleted';
@Injectable({ providedIn: 'root' })
export class AddonModGlossaryProvider {
static readonly COMPONENT = 'mmaModGlossary';
static readonly LIMIT_ENTRIES = 25;
static readonly LIMIT_CATEGORIES = 10;
private static readonly SHOW_ALL_CATEGORIES = 0;
private static readonly ROOT_CACHE_KEY = 'mmaModGlossary:';
protected static readonly SHOW_ALL_CATEGORIES = 0;
protected static readonly ROOT_CACHE_KEY = 'mmaModGlossary:';
/**
* Get the course glossary cache key.
@ -73,7 +73,7 @@ export class AddonModGlossaryProvider {
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getCourseGlossariesCacheKey(courseId),
updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModGlossaryProvider.COMPONENT,
component: ADDON_MOD_GLOSSARY_COMPONENT,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -129,12 +129,12 @@ export class AddonModGlossaryProvider {
field: 'LASTNAME',
sort: 'ASC',
from: options.from || 0,
limit: options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES,
limit: options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getEntriesByAuthorCacheKey(glossaryId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModGlossaryProvider.COMPONENT,
component: ADDON_MOD_GLOSSARY_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -173,12 +173,12 @@ export class AddonModGlossaryProvider {
id: glossaryId,
categoryid: AddonModGlossaryProvider.SHOW_ALL_CATEGORIES,
from: options.from || 0,
limit: options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES,
limit: options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getEntriesByCategoryCacheKey(glossaryId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModGlossaryProvider.COMPONENT,
component: ADDON_MOD_GLOSSARY_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -243,12 +243,12 @@ export class AddonModGlossaryProvider {
order: order,
sort: 'DESC',
from: options.from || 0,
limit: options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES,
limit: options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getEntriesByDateCacheKey(glossaryId, order),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModGlossaryProvider.COMPONENT,
component: ADDON_MOD_GLOSSARY_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -293,7 +293,7 @@ export class AddonModGlossaryProvider {
options: AddonModGlossaryGetEntriesOptions = {},
): Promise<AddonModGlossaryGetEntriesWSResponse> {
const from = options.from || 0;
const limit = options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES;
const limit = options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES;
const site = await CoreSites.getSite(options.siteId);
@ -306,7 +306,7 @@ export class AddonModGlossaryProvider {
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getEntriesByLetterCacheKey(glossaryId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModGlossaryProvider.COMPONENT,
component: ADDON_MOD_GLOSSARY_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -317,7 +317,7 @@ export class AddonModGlossaryProvider {
preSets,
);
if (limit === AddonModGlossaryProvider.LIMIT_ENTRIES) {
if (limit === ADDON_MOD_GLOSSARY_LIMIT_ENTRIES) {
// Store entries in background, don't block the user for this.
CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, from, site.getId()));
}
@ -375,12 +375,12 @@ export class AddonModGlossaryProvider {
order: 'CONCEPT',
sort: 'ASC',
from: options.from || 0,
limit: options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES,
limit: options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
};
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getEntriesBySearchCacheKey(glossaryId, query, fullSearch),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModGlossaryProvider.COMPONENT,
component: ADDON_MOD_GLOSSARY_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -448,7 +448,7 @@ export class AddonModGlossaryProvider {
options: AddonModGlossaryGetCategoriesOptions = {},
): Promise<AddonModGlossaryCategory[]> {
const from = options.from || 0;
const limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES;
const limit = options.limit || ADDON_MOD_GLOSSARY_LIMIT_CATEGORIES;
const params: AddonModGlossaryGetCategoriesWSParams = {
id: glossaryId,
@ -458,7 +458,7 @@ export class AddonModGlossaryProvider {
const preSets: CoreSiteWSPreSets = {
cacheKey: this.getCategoriesCacheKey(glossaryId),
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
component: AddonModGlossaryProvider.COMPONENT,
component: ADDON_MOD_GLOSSARY_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -515,7 +515,7 @@ export class AddonModGlossaryProvider {
const preSets = {
cacheKey: this.getEntryCacheKey(entryId),
updateFrequency: CoreSite.FREQUENCY_RARELY,
component: AddonModGlossaryProvider.COMPONENT,
component: ADDON_MOD_GLOSSARY_COMPONENT,
componentId: options.cmId,
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
};
@ -919,7 +919,7 @@ export class AddonModGlossaryProvider {
const response = await site.write<AddonModGlossaryAddEntryWSResponse>('mod_glossary_add_entry', params);
CoreEvents.trigger(GLOSSARY_ENTRY_ADDED, { glossaryId, entryId: response.entryid }, siteId);
CoreEvents.trigger(ADDON_MOD_GLOSSARY_ENTRY_ADDED, { glossaryId, entryId: response.entryid }, siteId);
return response.entryid;
}
@ -967,7 +967,7 @@ export class AddonModGlossaryProvider {
throw new CoreError(response.warnings?.[0].message ?? 'Error updating entry');
}
CoreEvents.trigger(GLOSSARY_ENTRY_UPDATED, { glossaryId, entryId }, siteId);
CoreEvents.trigger(ADDON_MOD_GLOSSARY_ENTRY_UPDATED, { glossaryId, entryId }, siteId);
}
/**
@ -981,7 +981,7 @@ export class AddonModGlossaryProvider {
await site.write('mod_glossary_delete_entry', { entryid: entryId });
CoreEvents.trigger(GLOSSARY_ENTRY_DELETED, { glossaryId, entryId });
CoreEvents.trigger(ADDON_MOD_GLOSSARY_ENTRY_DELETED, { glossaryId, entryId });
}
/**
@ -1033,7 +1033,7 @@ export class AddonModGlossaryProvider {
await CoreCourseLogHelper.log(
'mod_glossary_view_glossary',
params,
AddonModGlossaryProvider.COMPONENT,
ADDON_MOD_GLOSSARY_COMPONENT,
glossaryId,
siteId,
);
@ -1054,7 +1054,7 @@ export class AddonModGlossaryProvider {
await CoreCourseLogHelper.log(
'mod_glossary_view_entry',
params,
AddonModGlossaryProvider.COMPONENT,
ADDON_MOD_GLOSSARY_COMPONENT,
glossaryId,
siteId,
);
@ -1109,15 +1109,15 @@ declare module '@singletons/events' {
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
*/
export interface CoreEventsData {
[GLOSSARY_ENTRY_ADDED]: AddonModGlossaryEntryAddedEventData;
[GLOSSARY_ENTRY_UPDATED]: AddonModGlossaryEntryUpdatedEventData;
[GLOSSARY_ENTRY_DELETED]: AddonModGlossaryEntryDeletedEventData;
[ADDON_MOD_GLOSSARY_ENTRY_ADDED]: AddonModGlossaryEntryAddedEventData;
[ADDON_MOD_GLOSSARY_ENTRY_UPDATED]: AddonModGlossaryEntryUpdatedEventData;
[ADDON_MOD_GLOSSARY_ENTRY_DELETED]: AddonModGlossaryEntryDeletedEventData;
}
}
/**
* GLOSSARY_ENTRY_ADDED event payload.
* ADDON_MOD_GLOSSARY_ENTRY_ADDED event payload.
*/
export type AddonModGlossaryEntryAddedEventData = {
glossaryId: number;
@ -1126,7 +1126,7 @@ export type AddonModGlossaryEntryAddedEventData = {
};
/**
* GLOSSARY_ENTRY_UPDATED event payload.
* ADDON_MOD_GLOSSARY_ENTRY_UPDATED event payload.
*/
export type AddonModGlossaryEntryUpdatedEventData = {
glossaryId: number;
@ -1135,7 +1135,7 @@ export type AddonModGlossaryEntryUpdatedEventData = {
};
/**
* GLOSSARY_ENTRY_DELETED event payload.
* ADDON_MOD_GLOSSARY_ENTRY_DELETED event payload.
*/
export type AddonModGlossaryEntryDeletedEventData = {
glossaryId: number;
@ -1451,7 +1451,7 @@ export type AddonModGlossaryAddEntryOptions = {
*/
export type AddonModGlossaryGetEntriesOptions = CoreCourseCommonModWSOptions & {
from?: number; // Start returning records from here. Defaults to 0.
limit?: number; // Number of records to return. Defaults to AddonModGlossaryProvider.LIMIT_ENTRIES.
limit?: number; // Number of records to return. Defaults to ADDON_MOD_GLOSSARY_LIMIT_ENTRIES.
};
/**
@ -1459,7 +1459,7 @@ export type AddonModGlossaryGetEntriesOptions = CoreCourseCommonModWSOptions & {
*/
export type AddonModGlossaryGetCategoriesOptions = CoreCourseCommonModWSOptions & {
from?: number; // Start returning records from here. Defaults to 0.
limit?: number; // Number of records to return. Defaults to AddonModGlossaryProvider.LIMIT_CATEGORIES.
limit?: number; // Number of records to return. Defaults to ADDON_MOD_GLOSSARY_LIMIT_CATEGORIES.
};
/**

View File

@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons';
import { AddonModGlossaryModuleHandlerService } from './module';
import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants';
/**
* Content links handler for glossary new entry.
@ -51,7 +51,7 @@ export class AddonModGlossaryEditLinkHandlerService extends CoreContentLinksHand
);
await CoreNavigator.navigateToSitePath(
AddonModGlossaryModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/entry/new`,
`${ADDON_MOD_GLOSSARY_PAGE_NAME}/${module.course}/${module.id}/entry/new`,
{ siteId },
);
} catch (error) {

View File

@ -21,7 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreDomUtils } from '@services/utils/dom';
import { makeSingleton } from '@singletons';
import { AddonModGlossary } from '../glossary';
import { AddonModGlossaryModuleHandlerService } from './module';
import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants';
/**
* Handler to treat links to glossary entries.
@ -56,7 +56,7 @@ export class AddonModGlossaryEntryLinkHandlerService extends CoreContentLinksHan
);
await CoreNavigator.navigateToSitePath(
`${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/${entryId}`,
`${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/${entryId}`,
{
siteId,
params: {

View File

@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
import { makeSingleton } from '@singletons';
import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants';
/**
* Handler to support glossary modules.
@ -24,11 +25,9 @@ import { makeSingleton } from '@singletons';
@Injectable({ providedIn: 'root' })
export class AddonModGlossaryModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
static readonly PAGE_NAME = 'mod_glossary';
name = 'AddonModGlossary';
modName = 'glossary';
protected pageName = AddonModGlossaryModuleHandlerService.PAGE_NAME;
protected pageName = ADDON_MOD_GLOSSARY_PAGE_NAME;
supportedFeatures = {
[CoreConstants.FEATURE_GROUPS]: false,

View File

@ -23,9 +23,10 @@ import { CoreSitesReadingStrategy } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreWSFile } from '@services/ws';
import { makeSingleton } from '@singletons';
import { AddonModGlossary, AddonModGlossaryEntry, AddonModGlossaryGlossary, AddonModGlossaryProvider } from '../glossary';
import { AddonModGlossary, AddonModGlossaryEntry, AddonModGlossaryGlossary } from '../glossary';
import { AddonModGlossarySync, AddonModGlossarySyncResult } from '../glossary-sync';
import { ContextLevel } from '@/core/constants';
import { ADDON_MOD_GLOSSARY_COMPONENT } from '../../constants';
/**
* Handler to prefetch forums.
@ -35,7 +36,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
name = 'AddonModGlossary';
modName = 'glossary';
component = AddonModGlossaryProvider.COMPONENT;
component = ADDON_MOD_GLOSSARY_COMPONENT;
updatesNames = /^configuration$|^.*files$|^entries$/;
/**