From fa294d713507e57bdb6ed4f206d74021d2aa49da Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 23 Nov 2020 11:25:13 +0100 Subject: [PATCH] MOBILE-3592 user: Adapt user feature to new folder structure --- src/app/core/user/user.module.ts | 24 ------------------- .../user-avatar/core-user-avatar.html | 0 .../components/user-avatar/user-avatar.scss | 0 .../components/user-avatar/user-avatar.ts | 2 +- src/{app => core}/directives/user-link.ts | 0 src/core/features/features.module.ts | 2 ++ .../core => core/features}/user/lang/en.json | 0 .../features}/user/pages/about/about.html | 0 .../user/pages/about/about.module.ts} | 0 .../features}/user/pages/about/about.page.ts | 4 ++-- .../features}/user/pages/profile/profile.html | 0 .../user/pages/profile/profile.module.ts} | 0 .../user/pages/profile/profile.page.ts | 12 +++++----- .../features}/user/pages/profile/profile.scss | 0 .../features/user/services/db/user.ts} | 9 ++----- .../features/user/services/user-delegate.ts} | 0 .../features/user/services/user-helper.ts} | 2 +- .../features/user/services/user-offline.ts} | 4 ++-- .../features}/user/services/user.ts | 6 ++--- .../features/user/user-lazy.module.ts} | 7 +++--- .../features/user/user.module.ts} | 21 ++++++++++------ 21 files changed, 36 insertions(+), 57 deletions(-) delete mode 100644 src/app/core/user/user.module.ts rename src/{app => core}/components/user-avatar/core-user-avatar.html (100%) rename src/{app => core}/components/user-avatar/user-avatar.scss (100%) rename src/{app => core}/components/user-avatar/user-avatar.ts (99%) rename src/{app => core}/directives/user-link.ts (100%) rename src/{app/core => core/features}/user/lang/en.json (100%) rename src/{app/core => core/features}/user/pages/about/about.html (100%) rename src/{app/core/user/pages/about/about.page.module.ts => core/features/user/pages/about/about.module.ts} (100%) rename src/{app/core => core/features}/user/pages/about/about.page.ts (96%) rename src/{app/core => core/features}/user/pages/profile/profile.html (100%) rename src/{app/core/user/pages/profile/profile.page.module.ts => core/features/user/pages/profile/profile.module.ts} (100%) rename src/{app/core => core/features}/user/pages/profile/profile.page.ts (96%) rename src/{app/core => core/features}/user/pages/profile/profile.scss (100%) rename src/{app/core/user/services/user.db.ts => core/features/user/services/db/user.ts} (90%) rename src/{app/core/user/services/user.delegate.ts => core/features/user/services/user-delegate.ts} (100%) rename src/{app/core/user/services/user.helper.ts => core/features/user/services/user-helper.ts} (96%) rename src/{app/core/user/services/user.offline.ts => core/features/user/services/user-offline.ts} (97%) rename src/{app/core => core/features}/user/services/user.ts (99%) rename src/{app/core/user/user-routing.module.ts => core/features/user/user-lazy.module.ts} (76%) rename src/{app/core/user/user-init.module.ts => core/features/user/user.module.ts} (56%) diff --git a/src/app/core/user/user.module.ts b/src/app/core/user/user.module.ts deleted file mode 100644 index 2ea4d7f42..000000000 --- a/src/app/core/user/user.module.ts +++ /dev/null @@ -1,24 +0,0 @@ -// (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. - -import { NgModule } from '@angular/core'; - -import { CoreUserRoutingModule } from './user-routing.module'; - -@NgModule({ - imports: [ - CoreUserRoutingModule, - ], -}) -export class CoreUserModule {} diff --git a/src/app/components/user-avatar/core-user-avatar.html b/src/core/components/user-avatar/core-user-avatar.html similarity index 100% rename from src/app/components/user-avatar/core-user-avatar.html rename to src/core/components/user-avatar/core-user-avatar.html diff --git a/src/app/components/user-avatar/user-avatar.scss b/src/core/components/user-avatar/user-avatar.scss similarity index 100% rename from src/app/components/user-avatar/user-avatar.scss rename to src/core/components/user-avatar/user-avatar.scss diff --git a/src/app/components/user-avatar/user-avatar.ts b/src/core/components/user-avatar/user-avatar.ts similarity index 99% rename from src/app/components/user-avatar/user-avatar.ts rename to src/core/components/user-avatar/user-avatar.ts index 95e634275..565971a9a 100644 --- a/src/app/components/user-avatar/user-avatar.ts +++ b/src/core/components/user-avatar/user-avatar.ts @@ -21,7 +21,7 @@ import { CoreSites } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreObject } from '@singletons/object'; -import { CoreUserProvider, CoreUserBasicData, CoreUserProfilePictureUpdatedData } from '@core/user/services/user'; +import { CoreUserProvider, CoreUserBasicData, CoreUserProfilePictureUpdatedData } from '@features/user/services/user'; /** * Component to display a "user avatar". diff --git a/src/app/directives/user-link.ts b/src/core/directives/user-link.ts similarity index 100% rename from src/app/directives/user-link.ts rename to src/core/directives/user-link.ts diff --git a/src/core/features/features.module.ts b/src/core/features/features.module.ts index aaf9d1cf5..2219597d1 100644 --- a/src/core/features/features.module.ts +++ b/src/core/features/features.module.ts @@ -23,6 +23,7 @@ import { CoreMainMenuModule } from './mainmenu/mainmenu.module'; import { CoreSettingsModule } from './settings/settings.module'; import { CoreSiteHomeModule } from './sitehome/sitehome.module'; import { CoreTagModule } from './tag/tag.module'; +import { CoreUserModule } from './user/user.module'; @NgModule({ imports: [ @@ -35,6 +36,7 @@ import { CoreTagModule } from './tag/tag.module'; CoreSettingsModule, CoreSiteHomeModule, CoreTagModule, + CoreUserModule, ], }) export class CoreFeaturesModule {} diff --git a/src/app/core/user/lang/en.json b/src/core/features/user/lang/en.json similarity index 100% rename from src/app/core/user/lang/en.json rename to src/core/features/user/lang/en.json diff --git a/src/app/core/user/pages/about/about.html b/src/core/features/user/pages/about/about.html similarity index 100% rename from src/app/core/user/pages/about/about.html rename to src/core/features/user/pages/about/about.html diff --git a/src/app/core/user/pages/about/about.page.module.ts b/src/core/features/user/pages/about/about.module.ts similarity index 100% rename from src/app/core/user/pages/about/about.page.module.ts rename to src/core/features/user/pages/about/about.module.ts diff --git a/src/app/core/user/pages/about/about.page.ts b/src/core/features/user/pages/about/about.page.ts similarity index 96% rename from src/app/core/user/pages/about/about.page.ts rename to src/core/features/user/pages/about/about.page.ts index c7730eb83..816081331 100644 --- a/src/app/core/user/pages/about/about.page.ts +++ b/src/core/features/user/pages/about/about.page.ts @@ -22,8 +22,8 @@ import { CoreDomUtils } from '@services/utils/dom'; import { CoreTextUtils } from '@services/utils/text'; import { CoreUtils } from '@services/utils/utils'; import { CoreEvents } from '@singletons/events'; -import { CoreUser, CoreUserProfile, CoreUserProfileRefreshedData, CoreUserProvider } from '@core/user/services/user'; -import { CoreUserHelper } from '@core/user/services/user.helper'; +import { CoreUser, CoreUserProfile, CoreUserProfileRefreshedData, CoreUserProvider } from '@features/user/services/user'; +import { CoreUserHelper } from '@features/user/services/user-helper'; /** * Page that displays info about a user. diff --git a/src/app/core/user/pages/profile/profile.html b/src/core/features/user/pages/profile/profile.html similarity index 100% rename from src/app/core/user/pages/profile/profile.html rename to src/core/features/user/pages/profile/profile.html diff --git a/src/app/core/user/pages/profile/profile.page.module.ts b/src/core/features/user/pages/profile/profile.module.ts similarity index 100% rename from src/app/core/user/pages/profile/profile.page.module.ts rename to src/core/features/user/pages/profile/profile.module.ts diff --git a/src/app/core/user/pages/profile/profile.page.ts b/src/core/features/user/pages/profile/profile.page.ts similarity index 96% rename from src/app/core/user/pages/profile/profile.page.ts rename to src/core/features/user/pages/profile/profile.page.ts index 96627a18b..537ce68c8 100644 --- a/src/app/core/user/pages/profile/profile.page.ts +++ b/src/core/features/user/pages/profile/profile.page.ts @@ -21,7 +21,7 @@ import { CoreSite } from '@classes/site'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; -import { Translate } from '@singletons/core.singletons'; +import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreUser, @@ -29,12 +29,12 @@ import { CoreUserProfilePictureUpdatedData, CoreUserProfileRefreshedData, CoreUserProvider, -} from '@core/user/services/user'; -import { CoreUserHelper } from '@core/user/services/user.helper'; -import { CoreUserDelegate, CoreUserProfileHandlerData } from '@core/user/services/user.delegate'; -import { CoreFileUploaderHelper } from '@core/fileuploader/services/fileuploader.helper'; +} from '@features/user/services/user'; +import { CoreUserHelper } from '@features/user/services/user-helper'; +import { CoreUserDelegate, CoreUserProfileHandlerData } from '@features/user/services/user-delegate'; +import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; import { CoreIonLoadingElement } from '@classes/ion-loading'; -import { CoreUtils } from '@/app/services/utils/utils'; +import { CoreUtils } from '@services/utils/utils'; @Component({ selector: 'page-core-user-profile', diff --git a/src/app/core/user/pages/profile/profile.scss b/src/core/features/user/pages/profile/profile.scss similarity index 100% rename from src/app/core/user/pages/profile/profile.scss rename to src/core/features/user/pages/profile/profile.scss diff --git a/src/app/core/user/services/user.db.ts b/src/core/features/user/services/db/user.ts similarity index 90% rename from src/app/core/user/services/user.db.ts rename to src/core/features/user/services/db/user.ts index 8f19b47fd..7fc2e7a1c 100644 --- a/src/app/core/user/services/user.db.ts +++ b/src/core/features/user/services/db/user.ts @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CoreSiteSchema, registerSiteSchema } from '@services/sites'; -import { CoreUserBasicData } from './user'; +import { CoreSiteSchema } from '@services/sites'; +import { CoreUserBasicData } from '../user'; /** * Database variables for CoreUser service. @@ -88,8 +88,3 @@ export type CoreUserPreferenceDBRecord = { value: string; onlinevalue: string; }; - -export const initCoreUserDB = (): void => { - registerSiteSchema(SITE_SCHEMA); - registerSiteSchema(OFFLINE_SITE_SCHEMA); -}; diff --git a/src/app/core/user/services/user.delegate.ts b/src/core/features/user/services/user-delegate.ts similarity index 100% rename from src/app/core/user/services/user.delegate.ts rename to src/core/features/user/services/user-delegate.ts diff --git a/src/app/core/user/services/user.helper.ts b/src/core/features/user/services/user-helper.ts similarity index 96% rename from src/app/core/user/services/user.helper.ts rename to src/core/features/user/services/user-helper.ts index 8403939f8..ffd636c6b 100644 --- a/src/app/core/user/services/user.helper.ts +++ b/src/core/features/user/services/user-helper.ts @@ -14,7 +14,7 @@ import { Injectable } from '@angular/core'; -import { makeSingleton, Translate } from '@singletons/core.singletons'; +import { makeSingleton, Translate } from '@singletons'; import { CoreUserRole } from './user'; /** diff --git a/src/app/core/user/services/user.offline.ts b/src/core/features/user/services/user-offline.ts similarity index 97% rename from src/app/core/user/services/user.offline.ts rename to src/core/features/user/services/user-offline.ts index fbc298cc6..5afd27b7c 100644 --- a/src/app/core/user/services/user.offline.ts +++ b/src/core/features/user/services/user-offline.ts @@ -15,8 +15,8 @@ import { Injectable } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { makeSingleton } from '@singletons/core.singletons'; -import { PREFERENCES_TABLE_NAME, CoreUserPreferenceDBRecord } from './user.db'; +import { makeSingleton } from '@singletons'; +import { PREFERENCES_TABLE_NAME, CoreUserPreferenceDBRecord } from './db/user'; /** * Service to handle offline user preferences. diff --git a/src/app/core/user/services/user.ts b/src/core/features/user/services/user.ts similarity index 99% rename from src/app/core/user/services/user.ts rename to src/core/features/user/services/user.ts index 4bec34d76..2f1e074ab 100644 --- a/src/app/core/user/services/user.ts +++ b/src/core/features/user/services/user.ts @@ -18,14 +18,14 @@ import { CoreApp } from '@services/app'; import { CoreFilepool } from '@services/filepool'; import { CoreSites } from '@services/sites'; import { CoreUtils } from '@services/utils/utils'; -import { CoreUserOffline } from './user.offline'; +import { CoreUserOffline } from './user-offline'; import { CoreLogger } from '@singletons/logger'; import { CoreSite, CoreSiteWSPreSets } from '@classes/site'; -import { makeSingleton, Translate } from '@singletons/core.singletons'; +import { makeSingleton } from '@singletons'; import { CoreEvents, CoreEventUserDeletedData } from '@singletons/events'; import { CoreStatusWithWarningsWSResponse, CoreWSExternalWarning } from '@services/ws'; import { CoreError } from '@classes/errors/error'; -import { USERS_TABLE_NAME, CoreUserDBRecord } from './user.db'; +import { USERS_TABLE_NAME, CoreUserDBRecord } from './db/user'; const ROOT_CACHE_KEY = 'mmUser:'; diff --git a/src/app/core/user/user-routing.module.ts b/src/core/features/user/user-lazy.module.ts similarity index 76% rename from src/app/core/user/user-routing.module.ts rename to src/core/features/user/user-lazy.module.ts index 75a460cd6..b7f04d730 100644 --- a/src/app/core/user/user-routing.module.ts +++ b/src/core/features/user/user-lazy.module.ts @@ -23,16 +23,15 @@ const routes: Routes = [ }, { path: 'profile', - loadChildren: () => import('./pages/profile/profile.page.module').then( m => m.CoreUserProfilePageModule), + loadChildren: () => import('./pages/profile/profile.module').then( m => m.CoreUserProfilePageModule), }, { path: 'about', - loadChildren: () => import('./pages/about/about.page.module').then( m => m.CoreUserAboutPageModule), + loadChildren: () => import('./pages/about/about.module').then( m => m.CoreUserAboutPageModule), }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], - exports: [RouterModule], }) -export class CoreUserRoutingModule {} +export class CoreUserLazyModule {} diff --git a/src/app/core/user/user-init.module.ts b/src/core/features/user/user.module.ts similarity index 56% rename from src/app/core/user/user-init.module.ts rename to src/core/features/user/user.module.ts index 5a98299d0..26f0e6c98 100644 --- a/src/app/core/user/user-init.module.ts +++ b/src/core/features/user/user.module.ts @@ -15,23 +15,30 @@ import { NgModule } from '@angular/core'; import { Routes } from '@angular/router'; -import { CoreMainMenuRoutingModule } from '@core/mainmenu/mainmenu-routing.module'; +import { CoreMainMenuMoreRoutingModule } from '@features/mainmenu/pages/more/more-routing.module'; +import { CORE_SITE_SCHEMAS } from '@services/sites'; +import { SITE_SCHEMA, OFFLINE_SITE_SCHEMA } from './services/db/user'; const routes: Routes = [ { path: 'user', - loadChildren: () => import('@core/user/user.module').then(m => m.CoreUserModule), + loadChildren: () => import('@features/user/user-lazy.module').then(m => m.CoreUserLazyModule), }, ]; @NgModule({ imports: [ - CoreMainMenuRoutingModule.forChild(routes), - ], - exports: [ - CoreMainMenuRoutingModule, + CoreMainMenuMoreRoutingModule.forChild({ siblings: routes }), ], providers: [ + { + provide: CORE_SITE_SCHEMAS, + useValue: [ + SITE_SCHEMA, + OFFLINE_SITE_SCHEMA, + ], + multi: true, + }, ], }) -export class CoreUserInitModule {} +export class CoreUserModule {}