MOBILE-4616 glossary: Move glossary constants to a file
parent
c836e94101
commit
94743ed700
|
@ -20,9 +20,9 @@ import {
|
||||||
AddonModGlossaryGetEntriesOptions,
|
AddonModGlossaryGetEntriesOptions,
|
||||||
AddonModGlossaryGetEntriesWSResponse,
|
AddonModGlossaryGetEntriesWSResponse,
|
||||||
AddonModGlossaryGlossary,
|
AddonModGlossaryGlossary,
|
||||||
AddonModGlossaryProvider,
|
|
||||||
} from '../services/glossary';
|
} from '../services/glossary';
|
||||||
import { AddonModGlossaryOffline, AddonModGlossaryOfflineEntry } from '../services/glossary-offline';
|
import { AddonModGlossaryOffline, AddonModGlossaryOfflineEntry } from '../services/glossary-offline';
|
||||||
|
import { ADDON_MOD_GLOSSARY_LIMIT_ENTRIES } from '../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a collection of glossary entries.
|
* Provides a collection of glossary entries.
|
||||||
|
@ -259,7 +259,7 @@ export class AddonModGlossaryEntriesSource extends CoreRoutedItemsManagerSource<
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
*/
|
*/
|
||||||
protected getPageLength(): number {
|
protected getPageLength(): number {
|
||||||
return AddonModGlossaryProvider.LIMIT_ENTRIES;
|
return ADDON_MOD_GLOSSARY_LIMIT_ENTRIES;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -42,10 +42,6 @@ import {
|
||||||
AddonModGlossaryEntry,
|
AddonModGlossaryEntry,
|
||||||
AddonModGlossaryEntryWithCategory,
|
AddonModGlossaryEntryWithCategory,
|
||||||
AddonModGlossaryGlossary,
|
AddonModGlossaryGlossary,
|
||||||
AddonModGlossaryProvider,
|
|
||||||
GLOSSARY_ENTRY_ADDED,
|
|
||||||
GLOSSARY_ENTRY_DELETED,
|
|
||||||
GLOSSARY_ENTRY_UPDATED,
|
|
||||||
} from '../../services/glossary';
|
} from '../../services/glossary';
|
||||||
import { AddonModGlossaryOfflineEntry } from '../../services/glossary-offline';
|
import { AddonModGlossaryOfflineEntry } from '../../services/glossary-offline';
|
||||||
import {
|
import {
|
||||||
|
@ -53,10 +49,16 @@ import {
|
||||||
AddonModGlossarySyncResult,
|
AddonModGlossarySyncResult,
|
||||||
GLOSSARY_AUTO_SYNCED,
|
GLOSSARY_AUTO_SYNCED,
|
||||||
} from '../../services/glossary-sync';
|
} from '../../services/glossary-sync';
|
||||||
import { AddonModGlossaryModuleHandlerService } from '../../services/handlers/module';
|
|
||||||
import { AddonModGlossaryPrefetchHandler } from '../../services/handlers/prefetch';
|
import { AddonModGlossaryPrefetchHandler } from '../../services/handlers/prefetch';
|
||||||
import { AddonModGlossaryModePickerPopoverComponent } from '../mode-picker/mode-picker';
|
import { AddonModGlossaryModePickerPopoverComponent } from '../mode-picker/mode-picker';
|
||||||
import { CoreTime } from '@singletons/time';
|
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.
|
* Component that displays a glossary entry page.
|
||||||
|
@ -71,7 +73,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
|
|
||||||
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
@ViewChild(CoreSplitViewComponent) splitView!: CoreSplitViewComponent;
|
||||||
|
|
||||||
component = AddonModGlossaryProvider.COMPONENT;
|
component = ADDON_MOD_GLOSSARY_COMPONENT;
|
||||||
pluginName = 'glossary';
|
pluginName = 'glossary';
|
||||||
|
|
||||||
canAdd = false;
|
canAdd = false;
|
||||||
|
@ -128,7 +130,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
// Initialize entries manager.
|
// Initialize entries manager.
|
||||||
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(
|
const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(
|
||||||
AddonModGlossaryEntriesSource,
|
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));
|
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.
|
// When an entry is added, we reload the data.
|
||||||
this.observers = [
|
this.observers = [
|
||||||
CoreEvents.on(GLOSSARY_ENTRY_ADDED, ({ glossaryId }) => {
|
CoreEvents.on(ADDON_MOD_GLOSSARY_ENTRY_ADDED, ({ glossaryId }) => {
|
||||||
if (this.glossary?.id !== glossaryId) {
|
if (this.glossary?.id !== glossaryId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -152,14 +154,14 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity
|
||||||
|
|
||||||
this.showLoadingAndRefresh(false);
|
this.showLoadingAndRefresh(false);
|
||||||
}),
|
}),
|
||||||
CoreEvents.on(GLOSSARY_ENTRY_UPDATED, ({ glossaryId }) => {
|
CoreEvents.on(ADDON_MOD_GLOSSARY_ENTRY_UPDATED, ({ glossaryId }) => {
|
||||||
if (this.glossary?.id !== glossaryId) {
|
if (this.glossary?.id !== glossaryId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.showLoadingAndRefresh(false);
|
this.showLoadingAndRefresh(false);
|
||||||
}),
|
}),
|
||||||
CoreEvents.on(GLOSSARY_ENTRY_DELETED, ({ glossaryId }) => {
|
CoreEvents.on(ADDON_MOD_GLOSSARY_ENTRY_DELETED, ({ glossaryId }) => {
|
||||||
if (this.glossary?.id !== glossaryId) {
|
if (this.glossary?.id !== glossaryId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
@ -35,4 +35,4 @@ const routes: Routes = [{
|
||||||
CoreEditorComponentsModule,
|
CoreEditorComponentsModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AddonModGlossaryEditLazyModule {}
|
export default class AddonModGlossaryEditLazyModule {}
|
||||||
|
|
|
@ -37,4 +37,4 @@ const routes: Routes = [{
|
||||||
CoreTagComponentsModule,
|
CoreTagComponentsModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AddonModGlossaryEntryLazyModule {}
|
export default class AddonModGlossaryEntryLazyModule {}
|
||||||
|
|
|
@ -28,7 +28,7 @@ const mobileRoutes: Routes = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: ':courseId/:cmId/entry/:entrySlug',
|
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: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'entry/:entrySlug',
|
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 = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: ':courseId/:cmId/entry/new',
|
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',
|
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(mobileRoutes, () => CoreScreen.isMobile),
|
||||||
...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet),
|
...conditionalRoutes(tabletRoutes, () => CoreScreen.isTablet),
|
||||||
|
@ -68,4 +68,4 @@ const routes: Routes = [
|
||||||
AddonModGlossaryIndexPage,
|
AddonModGlossaryIndexPage,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class AddonModGlossaryLazyModule {}
|
export default class AddonModGlossaryLazyModule {}
|
||||||
|
|
|
@ -27,45 +27,45 @@ import { CoreCronDelegate } from '@services/cron';
|
||||||
import { CoreScreen } from '@services/screen';
|
import { CoreScreen } from '@services/screen';
|
||||||
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
import { CORE_SITE_SCHEMAS } from '@services/sites';
|
||||||
import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/database/glossary';
|
import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/database/glossary';
|
||||||
import { AddonModGlossaryProvider } from './services/glossary';
|
|
||||||
import { AddonModGlossaryEditLinkHandler } from './services/handlers/edit-link';
|
import { AddonModGlossaryEditLinkHandler } from './services/handlers/edit-link';
|
||||||
import { AddonModGlossaryEntryLinkHandler } from './services/handlers/entry-link';
|
import { AddonModGlossaryEntryLinkHandler } from './services/handlers/entry-link';
|
||||||
import { AddonModGlossaryIndexLinkHandler } from './services/handlers/index-link';
|
import { AddonModGlossaryIndexLinkHandler } from './services/handlers/index-link';
|
||||||
import { AddonModGlossaryListLinkHandler } from './services/handlers/list-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 { AddonModGlossaryPrefetchHandler } from './services/handlers/prefetch';
|
||||||
import { AddonModGlossarySyncCronHandler } from './services/handlers/sync-cron';
|
import { AddonModGlossarySyncCronHandler } from './services/handlers/sync-cron';
|
||||||
import { AddonModGlossaryTagAreaHandler } from './services/handlers/tag-area';
|
import { AddonModGlossaryTagAreaHandler } from './services/handlers/tag-area';
|
||||||
|
import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_PAGE_NAME } from './constants';
|
||||||
|
|
||||||
const mainMenuRoutes: Routes = [
|
const mainMenuRoutes: Routes = [
|
||||||
// Link handlers navigation.
|
// Link handlers navigation.
|
||||||
{
|
{
|
||||||
path: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/:entrySlug`,
|
path: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug`,
|
||||||
loadChildren: () => import('./glossary-entry-lazy.module').then(m => m.AddonModGlossaryEntryLazyModule),
|
loadChildren: () => import('./glossary-entry-lazy.module'),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Course activity navigation.
|
// Course activity navigation.
|
||||||
{
|
{
|
||||||
path: AddonModGlossaryModuleHandlerService.PAGE_NAME,
|
path: ADDON_MOD_GLOSSARY_PAGE_NAME,
|
||||||
loadChildren: () => import('./glossary-lazy.module').then(m => m.AddonModGlossaryLazyModule),
|
loadChildren: () => import('./glossary-lazy.module'),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Single Activity format navigation.
|
// Single Activity format navigation.
|
||||||
{
|
{
|
||||||
path: `${COURSE_CONTENTS_PATH}/${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/new`,
|
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/new`,
|
||||||
loadChildren: () => import('./glossary-edit-lazy.module').then(m => m.AddonModGlossaryEditLazyModule),
|
loadChildren: () => import('./glossary-edit-lazy.module'),
|
||||||
data: { glossaryPathPrefix: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` },
|
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: `${COURSE_CONTENTS_PATH}/${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/:entrySlug/edit`,
|
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug/edit`,
|
||||||
loadChildren: () => import('./glossary-edit-lazy.module').then(m => m.AddonModGlossaryEditLazyModule),
|
loadChildren: () => import('./glossary-edit-lazy.module'),
|
||||||
data: { glossaryPathPrefix: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` },
|
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
|
||||||
},
|
},
|
||||||
...conditionalRoutes(
|
...conditionalRoutes(
|
||||||
[{
|
[{
|
||||||
path: `${COURSE_CONTENTS_PATH}/${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/:entrySlug`,
|
path: `${COURSE_CONTENTS_PATH}/${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug`,
|
||||||
loadChildren: () => import('./glossary-entry-lazy.module').then(m => m.AddonModGlossaryEntryLazyModule),
|
loadChildren: () => import('./glossary-entry-lazy.module'),
|
||||||
data: { glossaryPathPrefix: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` },
|
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
|
||||||
}],
|
}],
|
||||||
() => CoreScreen.isMobile,
|
() => CoreScreen.isMobile,
|
||||||
),
|
),
|
||||||
|
@ -74,9 +74,9 @@ const mainMenuRoutes: Routes = [
|
||||||
// Single Activity format navigation.
|
// Single Activity format navigation.
|
||||||
const courseContentsRoutes: Routes = conditionalRoutes(
|
const courseContentsRoutes: Routes = conditionalRoutes(
|
||||||
[{
|
[{
|
||||||
path: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/:entrySlug`,
|
path: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/:entrySlug`,
|
||||||
loadChildren: () => import('./glossary-entry-lazy.module').then(m => m.AddonModGlossaryEntryLazyModule),
|
loadChildren: () => import('./glossary-entry-lazy.module'),
|
||||||
data: { glossaryPathPrefix: `${AddonModGlossaryModuleHandlerService.PAGE_NAME}/` },
|
data: { glossaryPathPrefix: `${ADDON_MOD_GLOSSARY_PAGE_NAME}/` },
|
||||||
}],
|
}],
|
||||||
() => CoreScreen.isTablet,
|
() => CoreScreen.isTablet,
|
||||||
);
|
);
|
||||||
|
@ -105,7 +105,7 @@ const courseContentsRoutes: Routes = conditionalRoutes(
|
||||||
CoreContentLinksDelegate.registerHandler(AddonModGlossaryEntryLinkHandler.instance);
|
CoreContentLinksDelegate.registerHandler(AddonModGlossaryEntryLinkHandler.instance);
|
||||||
CoreTagAreaDelegate.registerHandler(AddonModGlossaryTagAreaHandler.instance);
|
CoreTagAreaDelegate.registerHandler(AddonModGlossaryTagAreaHandler.instance);
|
||||||
|
|
||||||
CoreCourseHelper.registerModuleReminderClick(AddonModGlossaryProvider.COMPONENT);
|
CoreCourseHelper.registerModuleReminderClick(ADDON_MOD_GLOSSARY_COMPONENT);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -36,11 +36,11 @@ import {
|
||||||
AddonModGlossaryEntry,
|
AddonModGlossaryEntry,
|
||||||
AddonModGlossaryEntryOption,
|
AddonModGlossaryEntryOption,
|
||||||
AddonModGlossaryGlossary,
|
AddonModGlossaryGlossary,
|
||||||
AddonModGlossaryProvider,
|
|
||||||
} from '../../services/glossary';
|
} from '../../services/glossary';
|
||||||
import { AddonModGlossaryHelper } from '../../services/glossary-helper';
|
import { AddonModGlossaryHelper } from '../../services/glossary-helper';
|
||||||
import { AddonModGlossaryOffline } from '../../services/glossary-offline';
|
import { AddonModGlossaryOffline } from '../../services/glossary-offline';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
|
import { ADDON_MOD_GLOSSARY_COMPONENT } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays the edit form.
|
* Page that displays the edit form.
|
||||||
|
@ -53,7 +53,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave {
|
||||||
|
|
||||||
@ViewChild('editFormEl') formElement?: ElementRef;
|
@ViewChild('editFormEl') formElement?: ElementRef;
|
||||||
|
|
||||||
component = AddonModGlossaryProvider.COMPONENT;
|
component = ADDON_MOD_GLOSSARY_COMPONENT;
|
||||||
cmId!: number;
|
cmId!: number;
|
||||||
courseId!: number;
|
courseId!: number;
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
@ -305,7 +305,7 @@ abstract class AddonModGlossaryFormHandler {
|
||||||
const data = this.page.data;
|
const data = this.page.data;
|
||||||
const itemId = await CoreFileUploader.uploadOrReuploadFiles(
|
const itemId = await CoreFileUploader.uploadOrReuploadFiles(
|
||||||
data.attachments,
|
data.attachments,
|
||||||
AddonModGlossaryProvider.COMPONENT,
|
ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
glossary.id,
|
glossary.id,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,10 @@ import {
|
||||||
AddonModGlossary,
|
AddonModGlossary,
|
||||||
AddonModGlossaryEntry,
|
AddonModGlossaryEntry,
|
||||||
AddonModGlossaryGlossary,
|
AddonModGlossaryGlossary,
|
||||||
AddonModGlossaryProvider,
|
|
||||||
GLOSSARY_ENTRY_UPDATED,
|
|
||||||
} from '../../services/glossary';
|
} from '../../services/glossary';
|
||||||
import { CoreTime } from '@singletons/time';
|
import { CoreTime } from '@singletons/time';
|
||||||
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics';
|
||||||
|
import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_ENTRY_UPDATED } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Page that displays a glossary entry.
|
* Page that displays a glossary entry.
|
||||||
|
@ -52,7 +51,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@ViewChild(CoreCommentsCommentsComponent) comments?: CoreCommentsCommentsComponent;
|
@ViewChild(CoreCommentsCommentsComponent) comments?: CoreCommentsCommentsComponent;
|
||||||
|
|
||||||
component = AddonModGlossaryProvider.COMPONENT;
|
component = ADDON_MOD_GLOSSARY_COMPONENT;
|
||||||
componentId?: number;
|
componentId?: number;
|
||||||
onlineEntry?: AddonModGlossaryEntry;
|
onlineEntry?: AddonModGlossaryEntry;
|
||||||
offlineEntry?: AddonModGlossaryOfflineEntry;
|
offlineEntry?: AddonModGlossaryOfflineEntry;
|
||||||
|
@ -125,7 +124,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy {
|
||||||
return;
|
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) {
|
if (data.glossaryId !== this.glossary?.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,8 @@ import { makeSingleton } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { CorePath } from '@singletons/path';
|
import { CorePath } from '@singletons/path';
|
||||||
import { AddonModGlossaryOfflineEntryDBRecord, OFFLINE_ENTRIES_TABLE_NAME } from './database/glossary';
|
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.
|
* Service to handle offline glossary.
|
||||||
|
@ -47,7 +48,7 @@ export class AddonModGlossaryOfflineProvider {
|
||||||
|
|
||||||
await site.getDb().deleteRecords(OFFLINE_ENTRIES_TABLE_NAME, conditions);
|
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);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +224,7 @@ export class AddonModGlossaryOfflineProvider {
|
||||||
userid: site.getUserId(),
|
userid: site.getUserId(),
|
||||||
});
|
});
|
||||||
|
|
||||||
CoreEvents.trigger(GLOSSARY_ENTRY_UPDATED, {
|
CoreEvents.trigger(ADDON_MOD_GLOSSARY_ENTRY_UPDATED, {
|
||||||
glossaryId: originalEntry.glossaryid,
|
glossaryId: originalEntry.glossaryid,
|
||||||
timecreated: originalEntry.timecreated,
|
timecreated: originalEntry.timecreated,
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,11 +25,12 @@ import { CoreSync, CoreSyncResult } from '@services/sync';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { makeSingleton, Translate } from '@singletons';
|
import { makeSingleton, Translate } from '@singletons';
|
||||||
import { CoreEvents } from '@singletons/events';
|
import { CoreEvents } from '@singletons/events';
|
||||||
import { AddonModGlossary, AddonModGlossaryProvider } from './glossary';
|
import { AddonModGlossary } from './glossary';
|
||||||
import { AddonModGlossaryHelper } from './glossary-helper';
|
import { AddonModGlossaryHelper } from './glossary-helper';
|
||||||
import { AddonModGlossaryOffline, AddonModGlossaryOfflineEntry } from './glossary-offline';
|
import { AddonModGlossaryOffline, AddonModGlossaryOfflineEntry } from './glossary-offline';
|
||||||
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
|
||||||
import { CoreFileEntry } from '@services/file-helper';
|
import { CoreFileEntry } from '@services/file-helper';
|
||||||
|
import { ADDON_MOD_GLOSSARY_COMPONENT } from '../constants';
|
||||||
|
|
||||||
export const GLOSSARY_AUTO_SYNCED = 'addon_mod_glossary_auto_synced';
|
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.
|
// 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.');
|
this.logger.debug('Cannot sync glossary ' + glossaryId + ' because it is blocked.');
|
||||||
|
|
||||||
throw new CoreSyncBlockedError(Translate.instant('core.errorsyncblocked', { $a: this.componentTranslate }));
|
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);
|
const syncId = this.getGlossarySyncId(glossaryId, userId);
|
||||||
|
|
||||||
// Sync offline logs.
|
// 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.
|
// Get offline responses to be sent.
|
||||||
const entries = await CoreUtils.ignoreErrors(
|
const entries = await CoreUtils.ignoreErrors(
|
||||||
|
@ -317,7 +318,7 @@ export class AddonModGlossarySyncProvider extends CoreCourseActivitySyncBaseProv
|
||||||
files = files.concat(storedFiles);
|
files = files.concat(storedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CoreFileUploader.uploadOrReuploadFiles(files, AddonModGlossaryProvider.COMPONENT, glossaryId, siteId);
|
return CoreFileUploader.uploadOrReuploadFiles(files, ADDON_MOD_GLOSSARY_COMPONENT, glossaryId, siteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,10 +29,14 @@ import { CoreEvents } from '@singletons/events';
|
||||||
import { AddonModGlossaryEntryDBRecord, ENTRIES_TABLE_NAME } from './database/glossary';
|
import { AddonModGlossaryEntryDBRecord, ENTRIES_TABLE_NAME } from './database/glossary';
|
||||||
import { AddonModGlossaryOffline } from './glossary-offline';
|
import { AddonModGlossaryOffline } from './glossary-offline';
|
||||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||||
|
import {
|
||||||
export const GLOSSARY_ENTRY_ADDED = 'addon_mod_glossary_entry_added';
|
ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
export const GLOSSARY_ENTRY_UPDATED = 'addon_mod_glossary_entry_updated';
|
ADDON_MOD_GLOSSARY_ENTRY_ADDED,
|
||||||
export const GLOSSARY_ENTRY_DELETED = 'addon_mod_glossary_entry_deleted';
|
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.
|
* Service that provides some features for glossaries.
|
||||||
|
@ -40,12 +44,8 @@ export const GLOSSARY_ENTRY_DELETED = 'addon_mod_glossary_entry_deleted';
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AddonModGlossaryProvider {
|
export class AddonModGlossaryProvider {
|
||||||
|
|
||||||
static readonly COMPONENT = 'mmaModGlossary';
|
protected static readonly SHOW_ALL_CATEGORIES = 0;
|
||||||
static readonly LIMIT_ENTRIES = 25;
|
protected static readonly ROOT_CACHE_KEY = 'mmaModGlossary:';
|
||||||
static readonly LIMIT_CATEGORIES = 10;
|
|
||||||
|
|
||||||
private static readonly SHOW_ALL_CATEGORIES = 0;
|
|
||||||
private static readonly ROOT_CACHE_KEY = 'mmaModGlossary:';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the course glossary cache key.
|
* Get the course glossary cache key.
|
||||||
|
@ -73,7 +73,7 @@ export class AddonModGlossaryProvider {
|
||||||
const preSets: CoreSiteWSPreSets = {
|
const preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getCourseGlossariesCacheKey(courseId),
|
cacheKey: this.getCourseGlossariesCacheKey(courseId),
|
||||||
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
||||||
component: AddonModGlossaryProvider.COMPONENT,
|
component: ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -129,12 +129,12 @@ export class AddonModGlossaryProvider {
|
||||||
field: 'LASTNAME',
|
field: 'LASTNAME',
|
||||||
sort: 'ASC',
|
sort: 'ASC',
|
||||||
from: options.from || 0,
|
from: options.from || 0,
|
||||||
limit: options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES,
|
limit: options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
|
||||||
};
|
};
|
||||||
const preSets: CoreSiteWSPreSets = {
|
const preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getEntriesByAuthorCacheKey(glossaryId),
|
cacheKey: this.getEntriesByAuthorCacheKey(glossaryId),
|
||||||
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
||||||
component: AddonModGlossaryProvider.COMPONENT,
|
component: ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
componentId: options.cmId,
|
componentId: options.cmId,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||||
};
|
};
|
||||||
|
@ -173,12 +173,12 @@ export class AddonModGlossaryProvider {
|
||||||
id: glossaryId,
|
id: glossaryId,
|
||||||
categoryid: AddonModGlossaryProvider.SHOW_ALL_CATEGORIES,
|
categoryid: AddonModGlossaryProvider.SHOW_ALL_CATEGORIES,
|
||||||
from: options.from || 0,
|
from: options.from || 0,
|
||||||
limit: options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES,
|
limit: options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
|
||||||
};
|
};
|
||||||
const preSets: CoreSiteWSPreSets = {
|
const preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getEntriesByCategoryCacheKey(glossaryId),
|
cacheKey: this.getEntriesByCategoryCacheKey(glossaryId),
|
||||||
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
||||||
component: AddonModGlossaryProvider.COMPONENT,
|
component: ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
componentId: options.cmId,
|
componentId: options.cmId,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||||
};
|
};
|
||||||
|
@ -243,12 +243,12 @@ export class AddonModGlossaryProvider {
|
||||||
order: order,
|
order: order,
|
||||||
sort: 'DESC',
|
sort: 'DESC',
|
||||||
from: options.from || 0,
|
from: options.from || 0,
|
||||||
limit: options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES,
|
limit: options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
|
||||||
};
|
};
|
||||||
const preSets: CoreSiteWSPreSets = {
|
const preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getEntriesByDateCacheKey(glossaryId, order),
|
cacheKey: this.getEntriesByDateCacheKey(glossaryId, order),
|
||||||
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
||||||
component: AddonModGlossaryProvider.COMPONENT,
|
component: ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
componentId: options.cmId,
|
componentId: options.cmId,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||||
};
|
};
|
||||||
|
@ -293,7 +293,7 @@ export class AddonModGlossaryProvider {
|
||||||
options: AddonModGlossaryGetEntriesOptions = {},
|
options: AddonModGlossaryGetEntriesOptions = {},
|
||||||
): Promise<AddonModGlossaryGetEntriesWSResponse> {
|
): Promise<AddonModGlossaryGetEntriesWSResponse> {
|
||||||
const from = options.from || 0;
|
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);
|
const site = await CoreSites.getSite(options.siteId);
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ export class AddonModGlossaryProvider {
|
||||||
const preSets: CoreSiteWSPreSets = {
|
const preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getEntriesByLetterCacheKey(glossaryId),
|
cacheKey: this.getEntriesByLetterCacheKey(glossaryId),
|
||||||
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
||||||
component: AddonModGlossaryProvider.COMPONENT,
|
component: ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
componentId: options.cmId,
|
componentId: options.cmId,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||||
};
|
};
|
||||||
|
@ -317,7 +317,7 @@ export class AddonModGlossaryProvider {
|
||||||
preSets,
|
preSets,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (limit === AddonModGlossaryProvider.LIMIT_ENTRIES) {
|
if (limit === ADDON_MOD_GLOSSARY_LIMIT_ENTRIES) {
|
||||||
// Store entries in background, don't block the user for this.
|
// Store entries in background, don't block the user for this.
|
||||||
CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, from, site.getId()));
|
CoreUtils.ignoreErrors(this.storeEntries(glossaryId, result.entries, from, site.getId()));
|
||||||
}
|
}
|
||||||
|
@ -375,12 +375,12 @@ export class AddonModGlossaryProvider {
|
||||||
order: 'CONCEPT',
|
order: 'CONCEPT',
|
||||||
sort: 'ASC',
|
sort: 'ASC',
|
||||||
from: options.from || 0,
|
from: options.from || 0,
|
||||||
limit: options.limit || AddonModGlossaryProvider.LIMIT_ENTRIES,
|
limit: options.limit || ADDON_MOD_GLOSSARY_LIMIT_ENTRIES,
|
||||||
};
|
};
|
||||||
const preSets: CoreSiteWSPreSets = {
|
const preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getEntriesBySearchCacheKey(glossaryId, query, fullSearch),
|
cacheKey: this.getEntriesBySearchCacheKey(glossaryId, query, fullSearch),
|
||||||
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
||||||
component: AddonModGlossaryProvider.COMPONENT,
|
component: ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
componentId: options.cmId,
|
componentId: options.cmId,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||||
};
|
};
|
||||||
|
@ -448,7 +448,7 @@ export class AddonModGlossaryProvider {
|
||||||
options: AddonModGlossaryGetCategoriesOptions = {},
|
options: AddonModGlossaryGetCategoriesOptions = {},
|
||||||
): Promise<AddonModGlossaryCategory[]> {
|
): Promise<AddonModGlossaryCategory[]> {
|
||||||
const from = options.from || 0;
|
const from = options.from || 0;
|
||||||
const limit = options.limit || AddonModGlossaryProvider.LIMIT_CATEGORIES;
|
const limit = options.limit || ADDON_MOD_GLOSSARY_LIMIT_CATEGORIES;
|
||||||
|
|
||||||
const params: AddonModGlossaryGetCategoriesWSParams = {
|
const params: AddonModGlossaryGetCategoriesWSParams = {
|
||||||
id: glossaryId,
|
id: glossaryId,
|
||||||
|
@ -458,7 +458,7 @@ export class AddonModGlossaryProvider {
|
||||||
const preSets: CoreSiteWSPreSets = {
|
const preSets: CoreSiteWSPreSets = {
|
||||||
cacheKey: this.getCategoriesCacheKey(glossaryId),
|
cacheKey: this.getCategoriesCacheKey(glossaryId),
|
||||||
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
updateFrequency: CoreSite.FREQUENCY_SOMETIMES,
|
||||||
component: AddonModGlossaryProvider.COMPONENT,
|
component: ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
componentId: options.cmId,
|
componentId: options.cmId,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
||||||
};
|
};
|
||||||
|
@ -515,7 +515,7 @@ export class AddonModGlossaryProvider {
|
||||||
const preSets = {
|
const preSets = {
|
||||||
cacheKey: this.getEntryCacheKey(entryId),
|
cacheKey: this.getEntryCacheKey(entryId),
|
||||||
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
updateFrequency: CoreSite.FREQUENCY_RARELY,
|
||||||
component: AddonModGlossaryProvider.COMPONENT,
|
component: ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
componentId: options.cmId,
|
componentId: options.cmId,
|
||||||
...CoreSites.getReadingStrategyPreSets(options.readingStrategy), // Include reading strategy preSets.
|
...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);
|
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;
|
return response.entryid;
|
||||||
}
|
}
|
||||||
|
@ -967,7 +967,7 @@ export class AddonModGlossaryProvider {
|
||||||
throw new CoreError(response.warnings?.[0].message ?? 'Error updating entry');
|
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 });
|
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(
|
await CoreCourseLogHelper.log(
|
||||||
'mod_glossary_view_glossary',
|
'mod_glossary_view_glossary',
|
||||||
params,
|
params,
|
||||||
AddonModGlossaryProvider.COMPONENT,
|
ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
glossaryId,
|
glossaryId,
|
||||||
siteId,
|
siteId,
|
||||||
);
|
);
|
||||||
|
@ -1054,7 +1054,7 @@ export class AddonModGlossaryProvider {
|
||||||
await CoreCourseLogHelper.log(
|
await CoreCourseLogHelper.log(
|
||||||
'mod_glossary_view_entry',
|
'mod_glossary_view_entry',
|
||||||
params,
|
params,
|
||||||
AddonModGlossaryProvider.COMPONENT,
|
ADDON_MOD_GLOSSARY_COMPONENT,
|
||||||
glossaryId,
|
glossaryId,
|
||||||
siteId,
|
siteId,
|
||||||
);
|
);
|
||||||
|
@ -1109,15 +1109,15 @@ declare module '@singletons/events' {
|
||||||
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
* @see https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation
|
||||||
*/
|
*/
|
||||||
export interface CoreEventsData {
|
export interface CoreEventsData {
|
||||||
[GLOSSARY_ENTRY_ADDED]: AddonModGlossaryEntryAddedEventData;
|
[ADDON_MOD_GLOSSARY_ENTRY_ADDED]: AddonModGlossaryEntryAddedEventData;
|
||||||
[GLOSSARY_ENTRY_UPDATED]: AddonModGlossaryEntryUpdatedEventData;
|
[ADDON_MOD_GLOSSARY_ENTRY_UPDATED]: AddonModGlossaryEntryUpdatedEventData;
|
||||||
[GLOSSARY_ENTRY_DELETED]: AddonModGlossaryEntryDeletedEventData;
|
[ADDON_MOD_GLOSSARY_ENTRY_DELETED]: AddonModGlossaryEntryDeletedEventData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GLOSSARY_ENTRY_ADDED event payload.
|
* ADDON_MOD_GLOSSARY_ENTRY_ADDED event payload.
|
||||||
*/
|
*/
|
||||||
export type AddonModGlossaryEntryAddedEventData = {
|
export type AddonModGlossaryEntryAddedEventData = {
|
||||||
glossaryId: number;
|
glossaryId: number;
|
||||||
|
@ -1126,7 +1126,7 @@ export type AddonModGlossaryEntryAddedEventData = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GLOSSARY_ENTRY_UPDATED event payload.
|
* ADDON_MOD_GLOSSARY_ENTRY_UPDATED event payload.
|
||||||
*/
|
*/
|
||||||
export type AddonModGlossaryEntryUpdatedEventData = {
|
export type AddonModGlossaryEntryUpdatedEventData = {
|
||||||
glossaryId: number;
|
glossaryId: number;
|
||||||
|
@ -1135,7 +1135,7 @@ export type AddonModGlossaryEntryUpdatedEventData = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GLOSSARY_ENTRY_DELETED event payload.
|
* ADDON_MOD_GLOSSARY_ENTRY_DELETED event payload.
|
||||||
*/
|
*/
|
||||||
export type AddonModGlossaryEntryDeletedEventData = {
|
export type AddonModGlossaryEntryDeletedEventData = {
|
||||||
glossaryId: number;
|
glossaryId: number;
|
||||||
|
@ -1451,7 +1451,7 @@ export type AddonModGlossaryAddEntryOptions = {
|
||||||
*/
|
*/
|
||||||
export type AddonModGlossaryGetEntriesOptions = CoreCourseCommonModWSOptions & {
|
export type AddonModGlossaryGetEntriesOptions = CoreCourseCommonModWSOptions & {
|
||||||
from?: number; // Start returning records from here. Defaults to 0.
|
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 & {
|
export type AddonModGlossaryGetCategoriesOptions = CoreCourseCommonModWSOptions & {
|
||||||
from?: number; // Start returning records from here. Defaults to 0.
|
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.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator';
|
||||||
import { CoreSitesReadingStrategy } from '@services/sites';
|
import { CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModGlossaryModuleHandlerService } from './module';
|
import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Content links handler for glossary new entry.
|
* Content links handler for glossary new entry.
|
||||||
|
@ -51,7 +51,7 @@ export class AddonModGlossaryEditLinkHandlerService extends CoreContentLinksHand
|
||||||
);
|
);
|
||||||
|
|
||||||
await CoreNavigator.navigateToSitePath(
|
await CoreNavigator.navigateToSitePath(
|
||||||
AddonModGlossaryModuleHandlerService.PAGE_NAME + `/${module.course}/${module.id}/entry/new`,
|
`${ADDON_MOD_GLOSSARY_PAGE_NAME}/${module.course}/${module.id}/entry/new`,
|
||||||
{ siteId },
|
{ siteId },
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreDomUtils } from '@services/utils/dom';
|
import { CoreDomUtils } from '@services/utils/dom';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModGlossary } from '../glossary';
|
import { AddonModGlossary } from '../glossary';
|
||||||
import { AddonModGlossaryModuleHandlerService } from './module';
|
import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to treat links to glossary entries.
|
* Handler to treat links to glossary entries.
|
||||||
|
@ -56,7 +56,7 @@ export class AddonModGlossaryEntryLinkHandlerService extends CoreContentLinksHan
|
||||||
);
|
);
|
||||||
|
|
||||||
await CoreNavigator.navigateToSitePath(
|
await CoreNavigator.navigateToSitePath(
|
||||||
`${AddonModGlossaryModuleHandlerService.PAGE_NAME}/entry/${entryId}`,
|
`${ADDON_MOD_GLOSSARY_PAGE_NAME}/entry/${entryId}`,
|
||||||
{
|
{
|
||||||
siteId,
|
siteId,
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { Injectable, Type } from '@angular/core';
|
||||||
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
import { CoreModuleHandlerBase } from '@features/course/classes/module-base-handler';
|
||||||
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
|
import { CoreCourseModuleHandler } from '@features/course/services/module-delegate';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
|
import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to support glossary modules.
|
* Handler to support glossary modules.
|
||||||
|
@ -24,11 +25,9 @@ import { makeSingleton } from '@singletons';
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class AddonModGlossaryModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
export class AddonModGlossaryModuleHandlerService extends CoreModuleHandlerBase implements CoreCourseModuleHandler {
|
||||||
|
|
||||||
static readonly PAGE_NAME = 'mod_glossary';
|
|
||||||
|
|
||||||
name = 'AddonModGlossary';
|
name = 'AddonModGlossary';
|
||||||
modName = 'glossary';
|
modName = 'glossary';
|
||||||
protected pageName = AddonModGlossaryModuleHandlerService.PAGE_NAME;
|
protected pageName = ADDON_MOD_GLOSSARY_PAGE_NAME;
|
||||||
|
|
||||||
supportedFeatures = {
|
supportedFeatures = {
|
||||||
[CoreConstants.FEATURE_GROUPS]: false,
|
[CoreConstants.FEATURE_GROUPS]: false,
|
||||||
|
|
|
@ -23,9 +23,10 @@ import { CoreSitesReadingStrategy } from '@services/sites';
|
||||||
import { CoreUtils } from '@services/utils/utils';
|
import { CoreUtils } from '@services/utils/utils';
|
||||||
import { CoreWSFile } from '@services/ws';
|
import { CoreWSFile } from '@services/ws';
|
||||||
import { makeSingleton } from '@singletons';
|
import { makeSingleton } from '@singletons';
|
||||||
import { AddonModGlossary, AddonModGlossaryEntry, AddonModGlossaryGlossary, AddonModGlossaryProvider } from '../glossary';
|
import { AddonModGlossary, AddonModGlossaryEntry, AddonModGlossaryGlossary } from '../glossary';
|
||||||
import { AddonModGlossarySync, AddonModGlossarySyncResult } from '../glossary-sync';
|
import { AddonModGlossarySync, AddonModGlossarySyncResult } from '../glossary-sync';
|
||||||
import { ContextLevel } from '@/core/constants';
|
import { ContextLevel } from '@/core/constants';
|
||||||
|
import { ADDON_MOD_GLOSSARY_COMPONENT } from '../../constants';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler to prefetch forums.
|
* Handler to prefetch forums.
|
||||||
|
@ -35,7 +36,7 @@ export class AddonModGlossaryPrefetchHandlerService extends CoreCourseActivityPr
|
||||||
|
|
||||||
name = 'AddonModGlossary';
|
name = 'AddonModGlossary';
|
||||||
modName = 'glossary';
|
modName = 'glossary';
|
||||||
component = AddonModGlossaryProvider.COMPONENT;
|
component = ADDON_MOD_GLOSSARY_COMPONENT;
|
||||||
updatesNames = /^configuration$|^.*files$|^entries$/;
|
updatesNames = /^configuration$|^.*files$|^entries$/;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue