From 9943784c307d267f1939012616b2830826dae3de Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Tue, 23 Jul 2024 12:50:31 +0200 Subject: [PATCH] MOBILE-4596 data: Move enums to constants --- .../classes/base-field-plugin-component.ts | 3 +- .../mod/data/components/action/action.ts | 9 +++-- .../components/field-plugin/field-plugin.ts | 3 +- src/addons/mod/data/components/index/index.ts | 4 +- .../mod/data/components/search/search.ts | 2 +- src/addons/mod/data/constants.ts | 38 ++++++++++++++++++ src/addons/mod/data/pages/edit/edit.ts | 3 +- src/addons/mod/data/pages/entry/entry.ts | 4 +- src/addons/mod/data/services/data-helper.ts | 11 ++++-- src/addons/mod/data/services/data-offline.ts | 3 +- src/addons/mod/data/services/data-sync.ts | 4 +- src/addons/mod/data/services/data.ts | 39 +------------------ src/addons/mod/data/services/database/data.ts | 2 +- 13 files changed, 67 insertions(+), 58 deletions(-) diff --git a/src/addons/mod/data/classes/base-field-plugin-component.ts b/src/addons/mod/data/classes/base-field-plugin-component.ts index b045cca0b..93483a028 100644 --- a/src/addons/mod/data/classes/base-field-plugin-component.ts +++ b/src/addons/mod/data/classes/base-field-plugin-component.ts @@ -15,7 +15,8 @@ import { Input, Output, OnInit, OnChanges, SimpleChange, EventEmitter, Component } from '@angular/core'; import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { CoreFormFields } from '@singletons/form'; -import { AddonModDataData, AddonModDataEntryField, AddonModDataField, AddonModDataTemplateMode } from '../services/data'; +import { AddonModDataData, AddonModDataEntryField, AddonModDataField } from '../services/data'; +import { AddonModDataTemplateMode } from '../constants'; /** * Base class for component to render a field. diff --git a/src/addons/mod/data/components/action/action.ts b/src/addons/mod/data/components/action/action.ts index f328e90fc..10022f9f8 100644 --- a/src/addons/mod/data/components/action/action.ts +++ b/src/addons/mod/data/components/action/action.ts @@ -20,17 +20,20 @@ import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreEvents } from '@singletons/events'; import { - AddonModDataAction, AddonModDataData, AddonModDataEntry, AddonModDataGetDataAccessInformationWSResponse, - AddonModDataTemplateMode, } from '../../services/data'; import { AddonModDataHelper } from '../../services/data-helper'; import { AddonModDataOffline } from '../../services/data-offline'; import { CoreDomUtils } from '@services/utils/dom'; import { AddonModDataActionsMenuComponent, AddonModDataActionsMenuItem } from '../actionsmenu/actionsmenu'; -import { ADDON_MOD_DATA_ENTRY_CHANGED, ADDON_MOD_DATA_PAGE_NAME } from '../../constants'; +import { + ADDON_MOD_DATA_ENTRY_CHANGED, + ADDON_MOD_DATA_PAGE_NAME, + AddonModDataAction, + AddonModDataTemplateMode, +} from '../../constants'; /** * Component that displays a database action. diff --git a/src/addons/mod/data/components/field-plugin/field-plugin.ts b/src/addons/mod/data/components/field-plugin/field-plugin.ts index e6a24f99a..3527ccee3 100644 --- a/src/addons/mod/data/components/field-plugin/field-plugin.ts +++ b/src/addons/mod/data/components/field-plugin/field-plugin.ts @@ -17,8 +17,9 @@ import { FormGroup } from '@angular/forms'; import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component'; import { CoreFormFields } from '@singletons/form'; import { AddonModDataEntryFieldInitialized, AddonModDataFieldPluginBaseComponent } from '../../classes/base-field-plugin-component'; -import { AddonModDataData, AddonModDataField, AddonModDataTemplateMode } from '../../services/data'; +import { AddonModDataData, AddonModDataField } from '../../services/data'; import { AddonModDataFieldsDelegate } from '../../services/data-fields-delegate'; +import { AddonModDataTemplateMode } from '../../constants'; /** * Component that displays a database field plugin. diff --git a/src/addons/mod/data/components/index/index.ts b/src/addons/mod/data/components/index/index.ts index 6667397e0..55abc74be 100644 --- a/src/addons/mod/data/components/index/index.ts +++ b/src/addons/mod/data/components/index/index.ts @@ -31,8 +31,6 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { AddonModData, AddonModDataEntry, - AddonModDataTemplateType, - AddonModDataTemplateMode, AddonModDataField, AddonModDataGetDataAccessInformationWSResponse, AddonModDataData, @@ -51,6 +49,8 @@ import { ADDON_MOD_DATA_ENTRIES_PER_PAGE, ADDON_MOD_DATA_ENTRY_CHANGED, ADDON_MOD_DATA_PAGE_NAME, + AddonModDataTemplateType, + AddonModDataTemplateMode, } from '../../constants'; const contentToken = ''; diff --git a/src/addons/mod/data/components/search/search.ts b/src/addons/mod/data/components/search/search.ts index 22d000723..b51776d5f 100644 --- a/src/addons/mod/data/components/search/search.ts +++ b/src/addons/mod/data/components/search/search.ts @@ -23,13 +23,13 @@ import { ModalController } from '@singletons'; import { AddonModDataField, AddonModDataData, - AddonModDataTemplateType, AddonModDataSearchEntriesAdvancedField, } from '../../services/data'; import { AddonModDataFieldsDelegate } from '../../services/data-fields-delegate'; import { AddonModDataHelper } from '../../services/data-helper'; import { AddonModDataComponentsCompileModule } from '../components-compile.module'; import { AddonModDataSearchDataParams } from '../index'; +import { AddonModDataTemplateType } from '../../constants'; /** * Page that displays the search modal. diff --git a/src/addons/mod/data/constants.ts b/src/addons/mod/data/constants.ts index 9f8bcfae1..97a1384bd 100644 --- a/src/addons/mod/data/constants.ts +++ b/src/addons/mod/data/constants.ts @@ -26,3 +26,41 @@ export const ADDON_MOD_DATA_AUTO_SYNCED = 'addon_mod_data_autom_synced'; export const ADDON_MOD_DATA_PREFETCH_NAME = 'AddonModData'; export const ADDON_MOD_DATA_PREFETCH_MODNAME = 'data'; export const ADDON_MOD_DATA_PREFETCH_COMPONENT = ADDON_MOD_DATA_COMPONENT; + +export enum AddonModDataAction { + ADD = 'add', + EDIT = 'edit', + DELETE = 'delete', + APPROVE = 'approve', + DISAPPROVE = 'disapprove', + USER = 'user', + USERPICTURE = 'userpicture', + MORE = 'more', + MOREURL = 'moreurl', + COMMENTS = 'comments', + TIMEADDED = 'timeadded', + TIMEMODIFIED = 'timemodified', + TAGS = 'tags', + APPROVALSTATUS = 'approvalstatus', + APPROVALSTATUSCLASS = 'approvalstatusclass', + DELCHECK = 'delcheck', // Unused. + EXPORT = 'export', // Unused. + ACTIONSMENU = 'actionsmenu', + ID = 'id', +} + +export enum AddonModDataTemplateType { + LIST_HEADER = 'listtemplateheader', + LIST = 'listtemplate', + LIST_FOOTER = 'listtemplatefooter', + ADD = 'addtemplate', + SEARCH = 'asearchtemplate', + SINGLE = 'singletemplate', +} + +export enum AddonModDataTemplateMode { + LIST = 'list', + EDIT = 'edit', + SHOW = 'show', + SEARCH = 'search', +} diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index c48a102dc..1c1f43cf0 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -31,7 +31,6 @@ import { AddonModDataData, AddonModDataField, AddonModData, - AddonModDataTemplateType, AddonModDataEntry, AddonModDataEntryFields, AddonModDataEditEntryResult, @@ -44,7 +43,7 @@ import { AddonModDataEntryFieldInitialized } from '../../classes/base-field-plug import { CoreTextUtils } from '@services/utils/text'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; -import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED } from '../../constants'; +import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED, AddonModDataTemplateType } from '../../constants'; /** * Page that displays the view edit page. diff --git a/src/addons/mod/data/pages/entry/entry.ts b/src/addons/mod/data/pages/entry/entry.ts index 32fc339d0..d76cdab95 100644 --- a/src/addons/mod/data/pages/entry/entry.ts +++ b/src/addons/mod/data/pages/entry/entry.ts @@ -30,8 +30,6 @@ import { AddonModDataData, AddonModDataGetDataAccessInformationWSResponse, AddonModDataField, - AddonModDataTemplateType, - AddonModDataTemplateMode, AddonModDataEntry, } from '../../services/data'; import { AddonModDataHelper } from '../../services/data-helper'; @@ -42,6 +40,8 @@ import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRIES_PER_PAGE, ADDON_MOD_DATA_ENTRY_CHANGED, + AddonModDataTemplateType, + AddonModDataTemplateMode, } from '../../constants'; /** diff --git a/src/addons/mod/data/services/data-helper.ts b/src/addons/mod/data/services/data-helper.ts index a3f788310..ee443d507 100644 --- a/src/addons/mod/data/services/data-helper.ts +++ b/src/addons/mod/data/services/data-helper.ts @@ -31,19 +31,22 @@ import { AddonModDataSearchEntriesOptions, AddonModDataEntries, AddonModDataEntryFields, - AddonModDataAction, AddonModDataGetEntryFormatted, AddonModDataData, - AddonModDataTemplateType, AddonModDataGetDataAccessInformationWSResponse, - AddonModDataTemplateMode, AddonModDataField, AddonModDataEntryWSField, } from './data'; import { AddonModDataFieldsDelegate } from './data-fields-delegate'; import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline'; import { CoreFileEntry } from '@services/file-helper'; -import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED } from '../constants'; +import { + ADDON_MOD_DATA_COMPONENT, + ADDON_MOD_DATA_ENTRY_CHANGED, + AddonModDataAction, + AddonModDataTemplateType, + AddonModDataTemplateMode, +} from '../constants'; /** * Service that provides helper functions for datas. diff --git a/src/addons/mod/data/services/data-offline.ts b/src/addons/mod/data/services/data-offline.ts index f098a4f7b..c74d92633 100644 --- a/src/addons/mod/data/services/data-offline.ts +++ b/src/addons/mod/data/services/data-offline.ts @@ -20,8 +20,9 @@ import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; import { makeSingleton } from '@singletons'; import { CorePath } from '@singletons/path'; -import { AddonModDataAction, AddonModDataEntryWSField } from './data'; +import { AddonModDataEntryWSField } from './data'; import { AddonModDataEntryDBRecord, DATA_ENTRY_TABLE } from './database/data'; +import { AddonModDataAction } from '../constants'; /** * Service to handle Offline data. diff --git a/src/addons/mod/data/services/data-sync.ts b/src/addons/mod/data/services/data-sync.ts index fe5c4dbfc..973597caa 100644 --- a/src/addons/mod/data/services/data-sync.ts +++ b/src/addons/mod/data/services/data-sync.ts @@ -29,10 +29,10 @@ import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; import { Translate, makeSingleton } from '@singletons'; import { CoreEvents } from '@singletons/events'; -import { AddonModData, AddonModDataData, AddonModDataAction } from './data'; +import { AddonModData, AddonModDataData } from './data'; import { AddonModDataHelper } from './data-helper'; import { AddonModDataOffline, AddonModDataOfflineAction } from './data-offline'; -import { ADDON_MOD_DATA_AUTO_SYNCED, ADDON_MOD_DATA_COMPONENT } from '../constants'; +import { ADDON_MOD_DATA_AUTO_SYNCED, ADDON_MOD_DATA_COMPONENT, AddonModDataAction } from '../constants'; /** * Service to sync databases. diff --git a/src/addons/mod/data/services/data.ts b/src/addons/mod/data/services/data.ts index 3a35dd376..b7d1997b4 100644 --- a/src/addons/mod/data/services/data.ts +++ b/src/addons/mod/data/services/data.ts @@ -35,6 +35,7 @@ import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRIES_PER_PAGE, ADDON_MOD_DATA_ENTRY_CHANGED, + AddonModDataAction, } from '../constants'; declare module '@singletons/events' { @@ -50,44 +51,6 @@ declare module '@singletons/events' { } } -export enum AddonModDataAction { - ADD = 'add', - EDIT = 'edit', - DELETE = 'delete', - APPROVE = 'approve', - DISAPPROVE = 'disapprove', - USER = 'user', - USERPICTURE = 'userpicture', - MORE = 'more', - MOREURL = 'moreurl', - COMMENTS = 'comments', - TIMEADDED = 'timeadded', - TIMEMODIFIED = 'timemodified', - TAGS = 'tags', - APPROVALSTATUS = 'approvalstatus', - APPROVALSTATUSCLASS = 'approvalstatusclass', - DELCHECK = 'delcheck', // Unused. - EXPORT = 'export', // Unused. - ACTIONSMENU = 'actionsmenu', - ID = 'id', -} - -export enum AddonModDataTemplateType { - LIST_HEADER = 'listtemplateheader', - LIST = 'listtemplate', - LIST_FOOTER = 'listtemplatefooter', - ADD = 'addtemplate', - SEARCH = 'asearchtemplate', - SINGLE = 'singletemplate', -} - -export enum AddonModDataTemplateMode { - LIST = 'list', - EDIT = 'edit', - SHOW = 'show', - SEARCH = 'search', -} - /** * Service that provides some features for databases. */ diff --git a/src/addons/mod/data/services/database/data.ts b/src/addons/mod/data/services/database/data.ts index 8b4c8a150..b5caec8fe 100644 --- a/src/addons/mod/data/services/database/data.ts +++ b/src/addons/mod/data/services/database/data.ts @@ -13,7 +13,7 @@ // limitations under the License. import { CoreSiteSchema } from '@services/sites'; -import { AddonModDataAction } from '../data'; +import { AddonModDataAction } from '../../constants'; /** * Database variables for AddonModDataOfflineProvider.