MOBILE-3947 chore: Decouple constants from Addons used in core folder
parent
275089850e
commit
2078c12571
|
@ -17,7 +17,7 @@ import { CoreBlockHandlerData } from '@features/block/services/block-delegate';
|
|||
import { CoreBlockOnlyTitleComponent } from '@features/block/components/only-title-block/only-title-block';
|
||||
import { CoreBlockBaseHandler } from '@features/block/classes/base-block-handler';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/forum.module';
|
||||
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/constants';
|
||||
import { CoreCourseBlock } from '@features/course/services/course';
|
||||
import { CoreSearchGlobalSearch } from '@features/search/services/global-search';
|
||||
|
||||
|
@ -60,7 +60,7 @@ export class AddonBlockSearchForumsHandlerService extends CoreBlockBaseHandler {
|
|||
title: 'addon.block_searchforums.pluginname',
|
||||
class: 'addon-block-search-forums',
|
||||
component: CoreBlockOnlyTitleComponent,
|
||||
link: FORUM_SEARCH_PAGE_NAME,
|
||||
link: ADDON_MOD_FORUM_SEARCH_PAGE_NAME,
|
||||
linkParams: { courseId: instanceId },
|
||||
};
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import { CoreCommentsComponentsModule } from '@features/comments/components/comp
|
|||
|
||||
import { CoreTagComponentsModule } from '@features/tag/components/components.module';
|
||||
import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
|
||||
import { AddonBlogMainMenuHandlerService } from './services/handlers/mainmenu';
|
||||
import { ADDON_BLOG_MAINMENU_PAGE_NAME } from './constants';
|
||||
import { CoreMainMenuComponentsModule } from '@features/mainmenu/components/components.module';
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ function buildRoutes(injector: Injector): Routes {
|
|||
return [
|
||||
...buildTabMainRoutes(injector, {
|
||||
data: {
|
||||
mainMenuTabRoot: AddonBlogMainMenuHandlerService.PAGE_NAME,
|
||||
mainMenuTabRoot: ADDON_BLOG_MAINMENU_PAGE_NAME,
|
||||
},
|
||||
component: AddonBlogEntriesPage,
|
||||
}),
|
||||
|
|
|
@ -24,13 +24,14 @@ import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate';
|
|||
import { CoreUserDelegate } from '@features/user/services/user-delegate';
|
||||
import { AddonBlogCourseOptionHandler } from './services/handlers/course-option';
|
||||
import { AddonBlogIndexLinkHandler } from './services/handlers/index-link';
|
||||
import { AddonBlogMainMenuHandler, AddonBlogMainMenuHandlerService } from './services/handlers/mainmenu';
|
||||
import { AddonBlogMainMenuHandler } from './services/handlers/mainmenu';
|
||||
import { AddonBlogTagAreaHandler } from './services/handlers/tag-area';
|
||||
import { AddonBlogUserHandler } from './services/handlers/user';
|
||||
import { ADDON_BLOG_MAINMENU_PAGE_NAME } from './constants';
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: AddonBlogMainMenuHandlerService.PAGE_NAME,
|
||||
path: ADDON_BLOG_MAINMENU_PAGE_NAME,
|
||||
loadChildren: () => import('@addons/blog/blog-lazy.module').then(m => m.AddonBlogLazyModule),
|
||||
},
|
||||
];
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// (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_BLOG_MAINMENU_PAGE_NAME = 'blog';
|
|
@ -26,7 +26,7 @@ import { CoreSites } from '@services/sites';
|
|||
import { CoreWSFile } from '@services/ws';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonBlog } from '../blog';
|
||||
import { AddonBlogMainMenuHandlerService } from './mainmenu';
|
||||
import { ADDON_BLOG_MAINMENU_PAGE_NAME } from '@addons/blog/constants';
|
||||
|
||||
/**
|
||||
* Course nav handler.
|
||||
|
@ -75,7 +75,7 @@ export class AddonBlogCourseOptionHandlerService implements CoreCourseOptionsHan
|
|||
return {
|
||||
title: 'addon.blog.blog',
|
||||
class: 'addon-blog-handler',
|
||||
page: AddonBlogMainMenuHandlerService.PAGE_NAME,
|
||||
page: ADDON_BLOG_MAINMENU_PAGE_NAME,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Injectable } from '@angular/core';
|
|||
import { CoreMainMenuHandler, CoreMainMenuHandlerData } from '@features/mainmenu/services/mainmenu-delegate';
|
||||
import { makeSingleton } from '@singletons';
|
||||
import { AddonBlog } from '../blog';
|
||||
import { ADDON_BLOG_MAINMENU_PAGE_NAME } from '@addons/blog/constants';
|
||||
|
||||
/**
|
||||
* Handler to inject an option into main menu.
|
||||
|
@ -23,8 +24,6 @@ import { AddonBlog } from '../blog';
|
|||
@Injectable({ providedIn: 'root' })
|
||||
export class AddonBlogMainMenuHandlerService implements CoreMainMenuHandler {
|
||||
|
||||
static readonly PAGE_NAME = 'blog';
|
||||
|
||||
name = 'AddonBlog';
|
||||
priority = 500;
|
||||
|
||||
|
@ -42,7 +41,7 @@ export class AddonBlogMainMenuHandlerService implements CoreMainMenuHandler {
|
|||
return {
|
||||
icon: 'far-newspaper',
|
||||
title: 'addon.blog.siteblogheading',
|
||||
page: AddonBlogMainMenuHandlerService.PAGE_NAME,
|
||||
page: ADDON_BLOG_MAINMENU_PAGE_NAME,
|
||||
class: 'addon-blog-handler',
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// (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_CALENDAR_COMPONENT = 'AddonCalendarEvents';
|
|
@ -45,6 +45,7 @@ import { CoreForms } from '@singletons/form';
|
|||
import { CoreReminders, CoreRemindersService, CoreRemindersUnits } from '@features/reminders/services/reminders';
|
||||
import { CoreRemindersSetReminderMenuComponent } from '@features/reminders/components/set-reminder-menu/set-reminder-menu';
|
||||
import moment from 'moment-timezone';
|
||||
import { ADDON_CALENDAR_COMPONENT } from '@addons/calendar/constants';
|
||||
|
||||
/**
|
||||
* Page that displays a form to create/edit an event.
|
||||
|
@ -60,7 +61,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
|
|||
@ViewChild('editEventForm') formElement!: ElementRef;
|
||||
|
||||
title = 'addon.calendar.newevent';
|
||||
component = AddonCalendarProvider.COMPONENT;
|
||||
component = ADDON_CALENDAR_COMPONENT;
|
||||
loaded = false;
|
||||
hasOffline = false;
|
||||
eventTypes: AddonCalendarEventTypeOption[] = [];
|
||||
|
@ -179,7 +180,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
|
|||
promises.push(AddonCalendarSync.waitForSync(AddonCalendarSyncProvider.SYNC_ID).then(async () => {
|
||||
// Do not block if the scope is already destroyed.
|
||||
if (!this.isDestroyed && this.eventId) {
|
||||
CoreSync.blockOperation(AddonCalendarProvider.COMPONENT, eventId);
|
||||
CoreSync.blockOperation(ADDON_CALENDAR_COMPONENT, eventId);
|
||||
}
|
||||
|
||||
let eventForm: AddonCalendarEvent | AddonCalendarOfflineEventDBRecord | undefined;
|
||||
|
@ -597,7 +598,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
|
|||
*/
|
||||
protected unblockSync(): void {
|
||||
if (this.eventId) {
|
||||
CoreSync.unblockOperation(AddonCalendarProvider.COMPONENT, this.eventId);
|
||||
CoreSync.unblockOperation(ADDON_CALENDAR_COMPONENT, this.eventId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import { CoreCategoryData } from '@features/courses/services/courses';
|
|||
import { CoreTimeUtils } from '@services/utils/time';
|
||||
import { CoreReminders, CoreRemindersService } from '@features/reminders/services/reminders';
|
||||
import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate';
|
||||
import { ADDON_CALENDAR_COMPONENT } from '../constants';
|
||||
|
||||
/**
|
||||
* Context levels enumeration.
|
||||
|
@ -330,7 +331,7 @@ export class AddonCalendarHelperProvider {
|
|||
const reminders = await CoreReminders.getReminders(
|
||||
{
|
||||
instanceId: eventId,
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
},
|
||||
siteId,
|
||||
);
|
||||
|
|
|
@ -21,7 +21,6 @@ import { CoreUtils } from '@services/utils/utils';
|
|||
import {
|
||||
AddonCalendar,
|
||||
AddonCalendarEvent,
|
||||
AddonCalendarProvider,
|
||||
AddonCalendarSubmitCreateUpdateFormDataWSParams,
|
||||
} from './calendar';
|
||||
import { AddonCalendarOffline } from './calendar-offline';
|
||||
|
@ -30,6 +29,7 @@ import { makeSingleton, Translate } from '@singletons';
|
|||
import { CoreSync, CoreSyncResult } from '@services/sync';
|
||||
import { CoreNetworkError } from '@classes/errors/network-error';
|
||||
import moment from 'moment-timezone';
|
||||
import { ADDON_CALENDAR_COMPONENT } from '../constants';
|
||||
|
||||
/**
|
||||
* Service to sync calendar.
|
||||
|
@ -173,7 +173,7 @@ export class AddonCalendarSyncProvider extends CoreSyncBaseProvider<AddonCalenda
|
|||
protected async syncOfflineEvent(eventId: number, result: AddonCalendarSyncEvents, siteId?: string): Promise<void> {
|
||||
|
||||
// Verify that event isn't blocked.
|
||||
if (CoreSync.isBlocked(AddonCalendarProvider.COMPONENT, eventId, siteId)) {
|
||||
if (CoreSync.isBlocked(ADDON_CALENDAR_COMPONENT, eventId, siteId)) {
|
||||
this.logger.debug('Cannot sync event ' + eventId + ' because it is blocked.');
|
||||
|
||||
throw new CoreSyncBlockedError(Translate.instant(
|
||||
|
|
|
@ -51,6 +51,7 @@ import {
|
|||
import { CoreReminderDBRecord } from '@features/reminders/services/database/reminders';
|
||||
import { CoreEvents } from '@singletons/events';
|
||||
import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site';
|
||||
import { ADDON_CALENDAR_COMPONENT } from '../constants';
|
||||
|
||||
const ROOT_CACHE_KEY = 'mmaCalendar:';
|
||||
|
||||
|
@ -103,7 +104,6 @@ declare module '@singletons/events' {
|
|||
export class AddonCalendarProvider {
|
||||
|
||||
static readonly DAYS_INTERVAL = 30;
|
||||
static readonly COMPONENT = 'AddonCalendarEvents';
|
||||
|
||||
static readonly STARTING_WEEK_DAY = 'addon_calendar_starting_week_day';
|
||||
static readonly NEW_EVENT_EVENT = 'addon_calendar_new_event';
|
||||
|
@ -279,7 +279,7 @@ export class AddonCalendarProvider {
|
|||
));
|
||||
promises.push(CoreReminders.removeReminders({
|
||||
instanceId: eventId,
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
} , siteId));
|
||||
|
||||
await CoreUtils.ignoreErrors(Promise.all(promises));
|
||||
|
@ -292,7 +292,7 @@ export class AddonCalendarProvider {
|
|||
*/
|
||||
async initialize(): Promise<void> {
|
||||
CoreLocalNotifications.registerClick<CoreRemindersPushNotificationData>(
|
||||
AddonCalendarProvider.COMPONENT,
|
||||
ADDON_CALENDAR_COMPONENT,
|
||||
async (notification) => {
|
||||
await ApplicationInit.donePromise;
|
||||
|
||||
|
@ -740,7 +740,7 @@ export class AddonCalendarProvider {
|
|||
|
||||
const previousReminders = await CoreReminders.getReminders({
|
||||
instanceId: event.id,
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
}, siteId);
|
||||
|
||||
if (previousReminders.some((reminder) => reminder.timebefore === timebefore)) {
|
||||
|
@ -753,7 +753,7 @@ export class AddonCalendarProvider {
|
|||
: '';
|
||||
|
||||
const reminder: CoreReminderData = {
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
instanceId: event.id,
|
||||
type: event.eventtype,
|
||||
time: event.timestart,
|
||||
|
@ -887,7 +887,7 @@ export class AddonCalendarProvider {
|
|||
async getEventReminders(eventId: number, siteId?: string): Promise<CoreReminderDBRecord[]> {
|
||||
return CoreReminders.getReminders({
|
||||
instanceId: eventId,
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
}, siteId);
|
||||
}
|
||||
|
||||
|
@ -1448,12 +1448,12 @@ export class AddonCalendarProvider {
|
|||
// The event has already started, don't schedule it.
|
||||
|
||||
// @TODO Decide when to completelly remove expired events.
|
||||
return CoreReminders.cancelReminder(event.id, AddonCalendarProvider.COMPONENT, siteId);
|
||||
return CoreReminders.cancelReminder(event.id, ADDON_CALENDAR_COMPONENT, siteId);
|
||||
}
|
||||
|
||||
const reminders = await CoreReminders.getReminders({
|
||||
instanceId: event.id,
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
}, siteId);
|
||||
|
||||
await Promise.all(reminders.map(async (reminder) => {
|
||||
|
@ -1572,7 +1572,7 @@ export class AddonCalendarProvider {
|
|||
|
||||
const reminders = await CoreReminders.getReminders({
|
||||
instanceId: event.id,
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
}, siteId);
|
||||
|
||||
if (reminders.length > 0) {
|
||||
|
@ -1725,7 +1725,7 @@ export class AddonCalendarProvider {
|
|||
{ instanceId: result.event.id },
|
||||
{
|
||||
instanceId: eventId,
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
},
|
||||
siteId,
|
||||
),
|
||||
|
|
|
@ -58,8 +58,7 @@ import { CoreListItemsManager } from '@classes/items-management/list-items-manag
|
|||
import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker';
|
||||
import { CorePromisedValue } from '@classes/promised-value';
|
||||
import { CoreNavigator } from '@services/navigator';
|
||||
import { FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/forum.module';
|
||||
|
||||
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from '@addons/mod/forum/constants';
|
||||
/**
|
||||
* Component that displays a forum entry page.
|
||||
*/
|
||||
|
@ -342,7 +341,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom
|
|||
return;
|
||||
}
|
||||
|
||||
await CoreNavigator.navigateToSitePath(FORUM_SEARCH_PAGE_NAME, {
|
||||
await CoreNavigator.navigateToSitePath(ADDON_MOD_FORUM_SEARCH_PAGE_NAME, {
|
||||
params: {
|
||||
courseId: this.courseId,
|
||||
forumId: this.forum.id,
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// (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_FORUM_SEARCH_PAGE_NAME = 'forum/search';
|
|
@ -41,6 +41,7 @@ import { AddonModForumPushClickHandler } from './services/handlers/push-click';
|
|||
import { AddonModForumProvider } from './services/forum';
|
||||
import { COURSE_CONTENTS_PATH } from '@features/course/course.module';
|
||||
import { CoreCourseHelper } from '@features/course/services/course-helper';
|
||||
import { ADDON_MOD_FORUM_SEARCH_PAGE_NAME } from './constants';
|
||||
|
||||
/**
|
||||
* Get mod Forum services.
|
||||
|
@ -61,11 +62,9 @@ export async function getModForumServices(): Promise<Type<unknown>[]> {
|
|||
];
|
||||
}
|
||||
|
||||
export const FORUM_SEARCH_PAGE_NAME = 'forum/search';
|
||||
|
||||
const mainMenuRoutes: Routes = [
|
||||
{
|
||||
path: FORUM_SEARCH_PAGE_NAME,
|
||||
path: ADDON_MOD_FORUM_SEARCH_PAGE_NAME,
|
||||
loadChildren: () => import('./forum-search-lazy.module').then(m => m.AddonModForumSearchLazyModule),
|
||||
},
|
||||
{
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
import { CoreConstants, DownloadStatus } from '@/core/constants';
|
||||
import { AddonBlog } from '@addons/blog/services/blog';
|
||||
import { AddonBlogMainMenuHandlerService } from '@addons/blog/services/handlers/mainmenu';
|
||||
import { ADDON_BLOG_MAINMENU_PAGE_NAME } from '@addons/blog/constants';
|
||||
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Params } from '@angular/router';
|
||||
import { CoreCourse } from '@features/course/services/course';
|
||||
|
@ -238,7 +238,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy {
|
|||
async gotoBlog(): Promise<void> {
|
||||
const params: Params = { cmId: this.moduleId };
|
||||
|
||||
await CoreNavigator.navigateToSitePath(AddonBlogMainMenuHandlerService.PAGE_NAME, { params });
|
||||
await CoreNavigator.navigateToSitePath(ADDON_BLOG_MAINMENU_PAGE_NAME, { params });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { Injector, NgModule } from '@angular/core';
|
||||
import { RouterModule, ROUTES, Routes } from '@angular/router';
|
||||
import { ROUTES, Routes } from '@angular/router';
|
||||
|
||||
import { CoreSharedModule } from '@/core/shared.module';
|
||||
|
||||
|
@ -56,8 +56,5 @@ function buildRoutes(injector: Injector): Routes {
|
|||
declarations: [
|
||||
CoreMainMenuHomePage,
|
||||
],
|
||||
exports: [
|
||||
RouterModule,
|
||||
],
|
||||
})
|
||||
export class CoreMainMenuHomeLazyModule {}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { AddonCalendarProvider } from '@addons/calendar/services/calendar';
|
||||
import { ADDON_CALENDAR_COMPONENT } from '@addons/calendar/constants';
|
||||
import { AddonCalendarEventDBRecord, EVENTS_TABLE } from '@addons/calendar/services/database/calendar';
|
||||
import { SQLiteDB } from '@classes/sqlitedb';
|
||||
import { CoreSiteSchema } from '@services/sites';
|
||||
|
@ -194,7 +194,7 @@ const createReminder = async (
|
|||
reminderTime: number,
|
||||
): Promise<void> => {
|
||||
const reminder: CoreReminderData = {
|
||||
component: AddonCalendarProvider.COMPONENT,
|
||||
component: ADDON_CALENDAR_COMPONENT,
|
||||
instanceId: event.id,
|
||||
type: event.eventtype,
|
||||
timebefore: reminderTime,
|
||||
|
|
|
@ -43,7 +43,6 @@ const mainMenuHomeRoutes: Routes = [
|
|||
|
||||
@NgModule({
|
||||
imports: [CoreMainMenuHomeRoutingModule.forChild({ children: mainMenuHomeRoutes })],
|
||||
exports: [CoreMainMenuHomeRoutingModule],
|
||||
providers: [
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
|
|
Loading…
Reference in New Issue