From d8c6288a61a01cf9e620db945c8a19fd9df42626 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 9 Jan 2025 15:50:29 +0100 Subject: [PATCH 1/5] MOBILE-4724 core: Move some services to overlay subfolder --- .../recentlyaccesseditems/recentlyaccesseditems.ts | 2 +- src/addons/block/timeline/components/events/events.ts | 2 +- src/addons/blog/pages/edit-entry/edit-entry.ts | 2 +- src/addons/blog/pages/index/index.ts | 4 ++-- src/addons/calendar/pages/day/day.ts | 2 +- src/addons/calendar/pages/edit-event/edit-event.ts | 4 ++-- src/addons/calendar/pages/event/event.ts | 6 +++--- src/addons/calendar/pages/index/index.ts | 2 +- src/addons/calendar/pages/settings/settings.ts | 2 +- src/addons/coursecompletion/pages/report/report.ts | 2 +- src/addons/enrol/guest/services/enrol-handler.ts | 4 ++-- src/addons/enrol/self/services/enrol-handler.ts | 4 ++-- src/addons/messages/pages/discussion/discussion.ts | 4 ++-- src/addons/messages/pages/settings/settings.ts | 2 +- .../mod/assign/classes/base-feedback-plugin-component.ts | 2 +- src/addons/mod/assign/components/submission/submission.ts | 2 +- src/addons/mod/assign/pages/edit/edit.ts | 4 ++-- src/addons/mod/bigbluebuttonbn/components/index/index.ts | 2 +- src/addons/mod/book/pages/contents/contents.ts | 2 +- src/addons/mod/chat/pages/chat/chat.ts | 4 ++-- src/addons/mod/chat/pages/sessions/sessions.ts | 2 +- src/addons/mod/choice/components/index/index.ts | 2 +- src/addons/mod/data/components/action/action.ts | 2 +- src/addons/mod/data/components/index/index.ts | 2 +- src/addons/mod/data/fields/latlong/component/latlong.ts | 2 +- src/addons/mod/data/pages/edit/edit.ts | 2 +- src/addons/mod/data/services/data-helper.ts | 4 ++-- src/addons/mod/data/services/handlers/edit-link-lazy.ts | 2 +- src/addons/mod/data/services/handlers/show-link-lazy.ts | 2 +- src/addons/mod/feedback/pages/form/form.ts | 2 +- src/addons/mod/feedback/services/feedback-helper.ts | 2 +- .../mod/feedback/services/handlers/analysis-link.ts | 2 +- .../mod/feedback/services/handlers/complete-link.ts | 2 +- src/addons/mod/feedback/services/handlers/print-link.ts | 2 +- .../services/handlers/show-non-respondents-link.ts | 2 +- .../discussion-options-menu/discussion-options-menu.ts | 4 ++-- src/addons/mod/forum/components/index/index.ts | 6 +++--- src/addons/mod/forum/components/post/post.ts | 6 +++--- src/addons/mod/forum/pages/discussion/discussion.ts | 4 ++-- .../mod/forum/pages/new-discussion/new-discussion.ts | 2 +- src/addons/mod/forum/services/handlers/post-link.ts | 2 +- src/addons/mod/glossary/components/index/index.ts | 2 +- src/addons/mod/glossary/pages/edit/edit.ts | 2 +- src/addons/mod/glossary/pages/entry/entry.ts | 4 ++-- src/addons/mod/glossary/services/handlers/edit-link.ts | 2 +- src/addons/mod/glossary/services/handlers/entry-link.ts | 2 +- src/addons/mod/h5pactivity/components/index/index.ts | 2 +- .../mod/h5pactivity/services/handlers/report-link.ts | 2 +- src/addons/mod/imscp/pages/view/view.ts | 2 +- src/addons/mod/lesson/pages/player/player.ts | 2 +- src/addons/mod/lesson/services/handlers/grade-link.ts | 2 +- src/addons/mod/lesson/services/handlers/index-link.ts | 2 +- src/addons/mod/lesson/services/handlers/prefetch.ts | 2 +- src/addons/mod/lesson/services/handlers/report-link.ts | 2 +- src/addons/mod/lti/services/lti-helper.ts | 2 +- src/addons/mod/quiz/classes/auto-save.ts | 2 +- src/addons/mod/quiz/pages/player/player.ts | 4 ++-- src/addons/mod/quiz/pages/review/review.ts | 2 +- src/addons/mod/quiz/services/quiz-helper.ts | 4 ++-- src/addons/mod/resource/services/resource-helper.ts | 2 +- src/addons/mod/scorm/pages/player/player.ts | 2 +- src/addons/mod/subsection/services/handlers/index-link.ts | 2 +- src/addons/mod/survey/components/index/index.ts | 2 +- src/addons/mod/url/services/handlers/module.ts | 2 +- src/addons/mod/url/services/url-helper.ts | 2 +- src/addons/mod/wiki/components/index/index.ts | 4 ++-- src/addons/mod/wiki/pages/edit/edit.ts | 2 +- src/addons/mod/wiki/services/handlers/create-link-lazy.ts | 2 +- src/addons/mod/wiki/services/handlers/edit-link-lazy.ts | 2 +- .../mod/wiki/services/handlers/page-or-map-link-lazy.ts | 2 +- .../components/assessment-strategy/assessment-strategy.ts | 2 +- .../mod/workshop/components/assessment/assessment.ts | 2 +- src/addons/mod/workshop/components/index/index.ts | 2 +- src/addons/mod/workshop/pages/assessment/assessment.ts | 2 +- .../mod/workshop/pages/edit-submission/edit-submission.ts | 2 +- src/addons/mod/workshop/pages/submission/submission.ts | 2 +- src/addons/notes/components/add/add-modal.ts | 4 ++-- src/addons/notes/pages/list/list.ts | 4 ++-- src/addons/notifications/pages/settings/settings.ts | 2 +- src/addons/privatefiles/pages/index/index.ts | 6 +++--- src/addons/privatefiles/services/privatefiles-helper.ts | 4 ++-- .../report/insights/services/handlers/action-link.ts | 4 ++-- .../storagemanager/pages/course-storage/course-storage.ts | 2 +- .../pages/courses-storage/courses-storage.ts | 2 +- src/core/classes/page-loads-manager.ts | 2 +- src/core/classes/sites/authenticated-site.ts | 2 +- src/core/classes/sites/site.ts | 2 +- src/core/components/combobox/combobox.ts | 2 +- src/core/components/context-menu/context-menu.ts | 2 +- src/core/components/local-file/local-file.ts | 2 +- src/core/components/password-modal/password-modal.ts | 2 +- src/core/components/sheet-modal/sheet-modal.ts | 2 +- src/core/core.module.ts | 6 +++--- src/core/directives/download-file.ts | 2 +- src/core/directives/link.ts | 2 +- src/core/directives/reading-mode.ts | 2 +- .../components/side-blocks-button/side-blocks-button.ts | 2 +- src/core/features/comments/pages/viewer/viewer.ts | 4 ++-- .../features/contentlinks/classes/module-grade-handler.ts | 2 +- .../features/contentlinks/services/contentlinks-helper.ts | 2 +- .../features/course/classes/main-resource-component.ts | 2 +- .../course/components/course-format/course-format.ts | 2 +- .../components/module-completion/module-completion.ts | 2 +- .../components/module-navigation/module-navigation.ts | 2 +- .../course/directives/download-module-main-file.ts | 2 +- .../course/pages/module-preview/module-preview.ts | 2 +- src/core/features/course/services/course-helper.ts | 4 ++-- src/core/features/course/services/course.ts | 2 +- .../components/course-list-item/course-list-item.ts | 4 ++-- .../courses/services/handlers/base-link-handler.ts | 2 +- .../courses/services/handlers/enrol-push-click.ts | 2 +- .../courses/services/handlers/request-push-click.ts | 2 +- .../dataprivacy/components/contactdpo/contactdpo.ts | 4 ++-- .../dataprivacy/components/newrequest/newrequest.ts | 4 ++-- src/core/features/dataprivacy/pages/main/main.ts | 4 ++-- .../emulator/components/capture-media/capture-media.ts | 2 +- .../features/fileuploader/services/fileuploader-helper.ts | 4 ++-- src/core/features/fileuploader/services/fileuploader.ts | 2 +- src/core/features/grades/services/grades-helper.ts | 2 +- src/core/features/login/pages/credentials/credentials.ts | 2 +- .../features/login/pages/email-signup/email-signup.ts | 2 +- .../login/pages/forgotten-password/forgotten-password.ts | 2 +- src/core/features/login/pages/reconnect/reconnect.ts | 2 +- src/core/features/login/pages/site/site.ts | 4 ++-- src/core/features/login/pages/sites/sites.ts | 2 +- src/core/features/login/services/login-helper.ts | 2 +- .../components/user-menu-button/user-menu-button.ts | 2 +- .../features/mainmenu/components/user-menu/user-menu.ts | 2 +- src/core/features/policy/pages/acceptances/acceptances.ts | 4 ++-- src/core/features/policy/pages/site-policy/site-policy.ts | 4 ++-- .../features/rating/components/aggregate/aggregate.ts | 2 +- src/core/features/rating/components/rate/rate.ts | 4 ++-- .../reminders/components/set-button/set-button.ts | 4 ++-- .../components/set-reminder-menu/set-reminder-menu.ts | 2 +- src/core/features/reportbuilder/pages/report/report.ts | 2 +- .../features/search/pages/global-search/global-search.ts | 2 +- src/core/features/settings/pages/dev/dev.ts | 2 +- src/core/features/settings/pages/deviceinfo/deviceinfo.ts | 2 +- src/core/features/settings/pages/site/site.ts | 2 +- .../settings/pages/synchronization/synchronization.ts | 2 +- .../features/sharedfiles/services/sharedfiles-helper.ts | 2 +- src/core/features/sitehome/pages/index/index.ts | 2 +- .../siteplugins/classes/call-ws-click-directive.ts | 2 +- .../siteplugins/components/module-index/module-index.ts | 2 +- src/core/features/siteplugins/directives/call-ws.ts | 2 +- src/core/features/user/pages/about/about.ts | 2 +- src/core/features/viewer/services/viewer.ts | 2 +- src/core/services/navigator.ts | 2 +- src/core/services/{ => overlays}/loadings.ts | 0 src/core/services/{ => overlays}/modals.ts | 2 +- src/core/services/{ => overlays}/popovers.ts | 0 src/core/services/{ => overlays}/toasts.ts | 0 src/core/services/qrscan.ts | 2 +- src/core/services/urlschemes.ts | 2 +- src/core/services/utils/dom.ts | 8 ++++---- src/core/services/utils/iframe.ts | 2 +- src/core/singletons/text.ts | 2 +- src/testing/utils.ts | 2 +- src/types/config.d.ts | 2 +- 159 files changed, 199 insertions(+), 199 deletions(-) rename src/core/services/{ => overlays}/loadings.ts (100%) rename src/core/services/{ => overlays}/modals.ts (99%) rename src/core/services/{ => overlays}/popovers.ts (100%) rename src/core/services/{ => overlays}/toasts.ts (100%) diff --git a/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/recentlyaccesseditems.ts b/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/recentlyaccesseditems.ts index b6d166d85..257fb415d 100644 --- a/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/recentlyaccesseditems.ts +++ b/src/addons/block/recentlyaccesseditems/components/recentlyaccesseditems/recentlyaccesseditems.ts @@ -20,7 +20,7 @@ import { AddonBlockRecentlyAccessedItemsItemCalculatedData, } from '../../services/recentlyaccesseditems'; import { CoreText } from '@singletons/text'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreUtils } from '@singletons/utils'; import { CoreSharedModule } from '@/core/shared.module'; diff --git a/src/addons/block/timeline/components/events/events.ts b/src/addons/block/timeline/components/events/events.ts index c980dc591..4df86e7d8 100644 --- a/src/addons/block/timeline/components/events/events.ts +++ b/src/addons/block/timeline/components/events/events.ts @@ -14,7 +14,7 @@ import { Component, Input, Output, EventEmitter, OnInit, HostBinding } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreText } from '@singletons/text'; import { CoreEnrolledCourseDataWithOptions } from '@features/courses/services/courses-helper'; import { AddonBlockTimelineDayEvents } from '@addons/block/timeline/classes/section'; diff --git a/src/addons/blog/pages/edit-entry/edit-entry.ts b/src/addons/blog/pages/edit-entry/edit-entry.ts index 5f732f19c..cbfb0e3f8 100644 --- a/src/addons/blog/pages/edit-entry/edit-entry.ts +++ b/src/addons/blog/pages/edit-entry/edit-entry.ts @@ -35,7 +35,7 @@ import { CoreEditorComponentsModule } from '@features/editor/components/componen import { CoreFileUploader, CoreFileUploaderStoreFilesResult } from '@features/fileuploader/services/fileuploader'; import { CoreTagComponentsModule } from '@features/tag/components/components.module'; import { CanLeave } from '@guards/can-leave'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreNetwork } from '@services/network'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; diff --git a/src/addons/blog/pages/index/index.ts b/src/addons/blog/pages/index/index.ts index 64ef920d2..e486d4985 100644 --- a/src/addons/blog/pages/index/index.ts +++ b/src/addons/blog/pages/index/index.ts @@ -40,8 +40,8 @@ import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreArray } from '@singletons/array'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreTime } from '@singletons/time'; -import { CorePopovers } from '@services/popovers'; -import { CoreLoadings } from '@services/loadings'; +import { CorePopovers } from '@services/overlays/popovers'; +import { CoreLoadings } from '@services/overlays/loadings'; import { Subscription } from 'rxjs'; /** diff --git a/src/addons/calendar/pages/day/day.ts b/src/addons/calendar/pages/day/day.ts index 0c0acf2f7..3f8badc77 100644 --- a/src/addons/calendar/pages/day/day.ts +++ b/src/addons/calendar/pages/day/day.ts @@ -46,7 +46,7 @@ import { AddonCalendarEventsSource } from '@addons/calendar/classes/events-sourc import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreUrl } from '@singletons/url'; import { CoreTime } from '@singletons/time'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { ADDON_CALENDAR_AUTO_SYNCED, ADDON_CALENDAR_DELETED_EVENT_EVENT, diff --git a/src/addons/calendar/pages/edit-event/edit-event.ts b/src/addons/calendar/pages/edit-event/edit-event.ts index c3850c4a5..1990a141b 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.ts +++ b/src/addons/calendar/pages/edit-event/edit-event.ts @@ -50,8 +50,8 @@ import { AddonCalendarEventType, } from '@addons/calendar/constants'; import { ContextLevel } from '@/core/constants'; -import { CorePopovers } from '@services/popovers'; -import { CoreLoadings } from '@services/loadings'; +import { CorePopovers } from '@services/overlays/popovers'; +import { CoreLoadings } from '@services/overlays/loadings'; import { REMINDERS_DISABLED, CoreRemindersUnits } from '@features/reminders/constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; diff --git a/src/addons/calendar/pages/event/event.ts b/src/addons/calendar/pages/event/event.ts index 5226f55af..ddc5db7c7 100644 --- a/src/addons/calendar/pages/event/event.ts +++ b/src/addons/calendar/pages/event/event.ts @@ -41,9 +41,9 @@ import { CoreReminders } from '@features/reminders/services/reminders'; import { CoreLocalNotifications } from '@services/local-notifications'; import { CorePlatform } from '@services/platform'; import { CoreConfig } from '@services/config'; -import { CoreToasts, ToastDuration } from '@services/toasts'; -import { CorePopovers } from '@services/popovers'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; +import { CorePopovers } from '@services/overlays/popovers'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreUrl } from '@singletons/url'; import { ADDON_CALENDAR_AUTO_SYNCED, diff --git a/src/addons/calendar/pages/index/index.ts b/src/addons/calendar/pages/index/index.ts index 0ab5b077a..f67248240 100644 --- a/src/addons/calendar/pages/index/index.ts +++ b/src/addons/calendar/pages/index/index.ts @@ -30,7 +30,7 @@ import { AddonCalendarCalendarComponent } from '../../components/calendar/calend import { AddonCalendarUpcomingEventsComponent } from '../../components/upcoming-events/upcoming-events'; import { CoreNavigator } from '@services/navigator'; import { CoreConstants } from '@/core/constants'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { ADDON_CALENDAR_AUTO_SYNCED, ADDON_CALENDAR_DELETED_EVENT_EVENT, diff --git a/src/addons/calendar/pages/settings/settings.ts b/src/addons/calendar/pages/settings/settings.ts index 87237d62e..b7651acf5 100644 --- a/src/addons/calendar/pages/settings/settings.ts +++ b/src/addons/calendar/pages/settings/settings.ts @@ -13,7 +13,7 @@ // limitations under the License. import { Component, OnInit } from '@angular/core'; -import { CorePopovers } from '@services/popovers'; +import { CorePopovers } from '@services/overlays/popovers'; import { CoreReminders, CoreRemindersService, diff --git a/src/addons/coursecompletion/pages/report/report.ts b/src/addons/coursecompletion/pages/report/report.ts index d481458cb..bb1a46923 100644 --- a/src/addons/coursecompletion/pages/report/report.ts +++ b/src/addons/coursecompletion/pages/report/report.ts @@ -19,7 +19,7 @@ import { import { Component, OnInit } from '@angular/core'; import { CoreUser, CoreUserProfile } from '@features/user/services/user'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; diff --git a/src/addons/enrol/guest/services/enrol-handler.ts b/src/addons/enrol/guest/services/enrol-handler.ts index 712646143..057fb9863 100644 --- a/src/addons/enrol/guest/services/enrol-handler.ts +++ b/src/addons/enrol/guest/services/enrol-handler.ts @@ -22,10 +22,10 @@ import { import { makeSingleton } from '@singletons'; import { AddonEnrolGuest } from './guest'; import { CorePasswordModalResponse } from '@components/password-modal/password-modal'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreEnrol, CoreEnrolEnrolmentMethod } from '@features/enrol/services/enrol'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; /** * Enrol handler. diff --git a/src/addons/enrol/self/services/enrol-handler.ts b/src/addons/enrol/self/services/enrol-handler.ts index cca133662..8f6fdcef9 100644 --- a/src/addons/enrol/self/services/enrol-handler.ts +++ b/src/addons/enrol/self/services/enrol-handler.ts @@ -19,8 +19,8 @@ import { AddonEnrolSelf } from './self'; import { CorePasswordModalResponse } from '@components/password-modal/password-modal'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreEnrol, CoreEnrolEnrolmentMethod } from '@features/enrol/services/enrol'; -import { CoreModals } from '@services/modals'; -import { CoreLoadings } from '@services/loadings'; +import { CoreModals } from '@services/overlays/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CORE_COURSES_ENROL_INVALID_KEY } from '@features/courses/constants'; /** diff --git a/src/addons/messages/pages/discussion/discussion.ts b/src/addons/messages/pages/discussion/discussion.ts index 9da031d1b..fdc52d97a 100644 --- a/src/addons/messages/pages/discussion/discussion.ts +++ b/src/addons/messages/pages/discussion/discussion.ts @@ -44,8 +44,8 @@ import { CoreDom } from '@singletons/dom'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreText } from '@singletons/text'; import { CoreWait } from '@singletons/wait'; -import { CoreModals } from '@services/modals'; -import { CoreLoadings } from '@services/loadings'; +import { CoreModals } from '@services/overlays/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; import { ADDON_MESSAGES_AUTO_SYNCED, ADDON_MESSAGES_LIMIT_MESSAGES, diff --git a/src/addons/messages/pages/settings/settings.ts b/src/addons/messages/pages/settings/settings.ts index 1d8142ffb..5cdbe81be 100644 --- a/src/addons/messages/pages/settings/settings.ts +++ b/src/addons/messages/pages/settings/settings.ts @@ -28,7 +28,7 @@ import { CoreConstants } from '@/core/constants'; import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications'; import { CorePlatform } from '@services/platform'; import { CoreErrorHelper } from '@services/error-helper'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { ADDON_MESSAGES_NOTIFICATION_PREFERENCES_KEY, AddonMessagesMessagePrivacy } from '@addons/messages/constants'; /** diff --git a/src/addons/mod/assign/classes/base-feedback-plugin-component.ts b/src/addons/mod/assign/classes/base-feedback-plugin-component.ts index fd740ca95..df3e242da 100644 --- a/src/addons/mod/assign/classes/base-feedback-plugin-component.ts +++ b/src/addons/mod/assign/classes/base-feedback-plugin-component.ts @@ -15,7 +15,7 @@ import { Component, Input } from '@angular/core'; import { CoreCanceledError } from '@classes/errors/cancelederror'; import { CoreError } from '@classes/errors/error'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { AddonModAssignFeedbackCommentsTextData } from '../feedback/comments/services/handler'; import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } from '../services/assign'; import { toBoolean } from '@/core/transforms/boolean'; diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index ae4849e10..6af701742 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -69,7 +69,7 @@ import { ADDON_MOD_ASSIGN_UNLIMITED_ATTEMPTS, } from '../../constants'; import { CoreViewer } from '@features/viewer/services/viewer'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; /** diff --git a/src/addons/mod/assign/pages/edit/edit.ts b/src/addons/mod/assign/pages/edit/edit.ts index 811a677d8..51c6fbeb9 100644 --- a/src/addons/mod/assign/pages/edit/edit.ts +++ b/src/addons/mod/assign/pages/edit/edit.ts @@ -45,8 +45,8 @@ import { ADDON_MOD_ASSIGN_SUBMISSION_SAVED_EVENT, ADDON_MOD_ASSIGN_SUBMITTED_FOR_GRADING_EVENT, } from '../../constants'; -import { CoreToasts, ToastDuration } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; /** diff --git a/src/addons/mod/bigbluebuttonbn/components/index/index.ts b/src/addons/mod/bigbluebuttonbn/components/index/index.ts index e17df7e76..1482d7be9 100644 --- a/src/addons/mod/bigbluebuttonbn/components/index/index.ts +++ b/src/addons/mod/bigbluebuttonbn/components/index/index.ts @@ -32,7 +32,7 @@ import { AddonModBBBRecordingPlaybackTypes, } from '../../services/bigbluebuttonbn'; import { ADDON_MOD_BBB_COMPONENT } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener } from '@singletons/opener'; diff --git a/src/addons/mod/book/pages/contents/contents.ts b/src/addons/mod/book/pages/contents/contents.ts index b9c72d556..62ea65c69 100644 --- a/src/addons/mod/book/pages/contents/contents.ts +++ b/src/addons/mod/book/pages/contents/contents.ts @@ -37,7 +37,7 @@ import { import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreUrl } from '@singletons/url'; import { ADDON_MOD_BOOK_COMPONENT, AddonModBookNavStyle } from '../../constants'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; /** * Page that displays a book contents. diff --git a/src/addons/mod/chat/pages/chat/chat.ts b/src/addons/mod/chat/pages/chat/chat.ts index 81fb81cb7..d96d2e809 100644 --- a/src/addons/mod/chat/pages/chat/chat.ts +++ b/src/addons/mod/chat/pages/chat/chat.ts @@ -31,8 +31,8 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreWait } from '@singletons/wait'; -import { CoreModals } from '@services/modals'; -import { CoreLoadings } from '@services/loadings'; +import { CoreModals } from '@services/overlays/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays a chat session. diff --git a/src/addons/mod/chat/pages/sessions/sessions.ts b/src/addons/mod/chat/pages/sessions/sessions.ts index 517ae447e..acefafa03 100644 --- a/src/addons/mod/chat/pages/sessions/sessions.ts +++ b/src/addons/mod/chat/pages/sessions/sessions.ts @@ -25,7 +25,7 @@ import { CoreTime } from '@singletons/time'; import { Translate } from '@singletons'; import { AddonModChat } from '@addons/mod/chat/services/chat'; import { CorePromiseUtils } from '@singletons/promise-utils'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays list of chat sessions. diff --git a/src/addons/mod/choice/components/index/index.ts b/src/addons/mod/choice/components/index/index.ts index 764bb7750..104fd11e6 100644 --- a/src/addons/mod/choice/components/index/index.ts +++ b/src/addons/mod/choice/components/index/index.ts @@ -41,7 +41,7 @@ import { ADDON_MOD_CHOICE_PUBLISH_ANONYMOUS, AddonModChoiceShowResults, } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Component that displays a choice. diff --git a/src/addons/mod/data/components/action/action.ts b/src/addons/mod/data/components/action/action.ts index bcbc10a43..672e65837 100644 --- a/src/addons/mod/data/components/action/action.ts +++ b/src/addons/mod/data/components/action/action.ts @@ -26,7 +26,7 @@ import { } from '../../services/data'; import { AddonModDataHelper } from '../../services/data-helper'; import { AddonModDataOffline } from '../../services/data-offline'; -import { CorePopovers } from '@services/popovers'; +import { CorePopovers } from '@services/overlays/popovers'; import { AddonModDataActionsMenuItem } from '../actionsmenu/actionsmenu'; import { ADDON_MOD_DATA_ENTRY_CHANGED, diff --git a/src/addons/mod/data/components/index/index.ts b/src/addons/mod/data/components/index/index.ts index 92a4e4489..9109a4496 100644 --- a/src/addons/mod/data/components/index/index.ts +++ b/src/addons/mod/data/components/index/index.ts @@ -51,7 +51,7 @@ import { AddonModDataTemplateType, AddonModDataTemplateMode, } from '../../constants'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreObject } from '@singletons/object'; diff --git a/src/addons/mod/data/fields/latlong/component/latlong.ts b/src/addons/mod/data/fields/latlong/component/latlong.ts index 12365765a..a1242943b 100644 --- a/src/addons/mod/data/fields/latlong/component/latlong.ts +++ b/src/addons/mod/data/fields/latlong/component/latlong.ts @@ -19,7 +19,7 @@ import { FormBuilder } from '@angular/forms'; import { SafeUrl } from '@angular/platform-browser'; import { CoreAnyError } from '@classes/errors/error'; import { CoreGeolocation, CoreGeolocationError, CoreGeolocationErrorReason } from '@services/geolocation'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePlatform } from '@services/platform'; import { CoreDomUtils } from '@services/utils/dom'; import { DomSanitizer } from '@singletons'; diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index a24bcfa1a..30cddec7e 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -44,7 +44,7 @@ import { CoreText } from '@singletons/text'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED, AddonModDataTemplateType } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreArray } from '@singletons/array'; diff --git a/src/addons/mod/data/services/data-helper.ts b/src/addons/mod/data/services/data-helper.ts index 3abf13517..50e603456 100644 --- a/src/addons/mod/data/services/data-helper.ts +++ b/src/addons/mod/data/services/data-helper.ts @@ -47,8 +47,8 @@ import { AddonModDataTemplateType, AddonModDataTemplateMode, } from '../constants'; -import { CoreToasts, ToastDuration } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Service that provides helper functions for datas. diff --git a/src/addons/mod/data/services/handlers/edit-link-lazy.ts b/src/addons/mod/data/services/handlers/edit-link-lazy.ts index d76c88685..6b11e84ed 100644 --- a/src/addons/mod/data/services/handlers/edit-link-lazy.ts +++ b/src/addons/mod/data/services/handlers/edit-link-lazy.ts @@ -17,7 +17,7 @@ import { Params } from '@angular/router'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_DATA_FEATURE_NAME, ADDON_MOD_DATA_PAGE_NAME } from '../../constants'; import { AddonModDataEditLinkHandlerService } from '@addons/mod/data/services/handlers/edit-link'; diff --git a/src/addons/mod/data/services/handlers/show-link-lazy.ts b/src/addons/mod/data/services/handlers/show-link-lazy.ts index 3b6e441be..90d102458 100644 --- a/src/addons/mod/data/services/handlers/show-link-lazy.ts +++ b/src/addons/mod/data/services/handlers/show-link-lazy.ts @@ -17,7 +17,7 @@ import { Params } from '@angular/router'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_DATA_PAGE_NAME } from '../../constants'; import { AddonModDataShowLinkHandlerService } from '@addons/mod/data/services/handlers/show-link'; diff --git a/src/addons/mod/feedback/pages/form/form.ts b/src/addons/mod/feedback/pages/form/form.ts index 446684fec..f36b8a20d 100644 --- a/src/addons/mod/feedback/pages/form/form.ts +++ b/src/addons/mod/feedback/pages/form/form.ts @@ -42,7 +42,7 @@ import { ADDON_MOD_FEEDBACK_PAGE_NAME, AddonModFeedbackIndexTabName, } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreError } from '@classes/errors/error'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSError } from '@classes/errors/wserror'; diff --git a/src/addons/mod/feedback/services/feedback-helper.ts b/src/addons/mod/feedback/services/feedback-helper.ts index e6e88c46c..16e7cb8b4 100644 --- a/src/addons/mod/feedback/services/feedback-helper.ts +++ b/src/addons/mod/feedback/services/feedback-helper.ts @@ -40,7 +40,7 @@ import { ADDON_MOD_FEEDBACK_MULTICHOICE_HIDENOSELECT, ADDON_MOD_FEEDBACK_PAGE_NAME, } from '../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreText } from '@singletons/text'; const MODE_RESPONSETIME = 1; diff --git a/src/addons/mod/feedback/services/handlers/analysis-link.ts b/src/addons/mod/feedback/services/handlers/analysis-link.ts index 6f91ac109..b6737d42b 100644 --- a/src/addons/mod/feedback/services/handlers/analysis-link.ts +++ b/src/addons/mod/feedback/services/handlers/analysis-link.ts @@ -20,7 +20,7 @@ import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME, AddonModFeedbackIndexTabName } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Content links handler for a feedback analysis. diff --git a/src/addons/mod/feedback/services/handlers/complete-link.ts b/src/addons/mod/feedback/services/handlers/complete-link.ts index 38120de01..277df62d7 100644 --- a/src/addons/mod/feedback/services/handlers/complete-link.ts +++ b/src/addons/mod/feedback/services/handlers/complete-link.ts @@ -21,7 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Content links handler for feedback complete questions. diff --git a/src/addons/mod/feedback/services/handlers/print-link.ts b/src/addons/mod/feedback/services/handlers/print-link.ts index 5104e8465..583ac27b4 100644 --- a/src/addons/mod/feedback/services/handlers/print-link.ts +++ b/src/addons/mod/feedback/services/handlers/print-link.ts @@ -21,7 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Content links handler for feedback print questions. diff --git a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts index 603947ba7..14044111c 100644 --- a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts +++ b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts @@ -21,7 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Content links handler for feedback show non respondents. * Match mod/feedback/show_nonrespondents.php with a valid feedback id. diff --git a/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts b/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts index d974562cb..0d3b9799e 100644 --- a/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts +++ b/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts @@ -19,9 +19,9 @@ import { PopoverController } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { AddonModForum, AddonModForumDiscussion } from '../../services/forum'; import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT } from '../../constants'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; import { CoreSharedModule } from '@/core/shared.module'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * This component is meant to display a popover with the discussion options. diff --git a/src/addons/mod/forum/components/index/index.ts b/src/addons/mod/forum/components/index/index.ts index 961a9fd9d..6c5771c58 100644 --- a/src/addons/mod/forum/components/index/index.ts +++ b/src/addons/mod/forum/components/index/index.ts @@ -65,9 +65,9 @@ import { AddonModForumType, } from '@addons/mod/forum/constants'; import { CoreSearchGlobalSearch } from '@features/search/services/global-search'; -import { CoreToasts } from '@services/toasts'; -import { CorePopovers } from '@services/popovers'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts } from '@services/overlays/toasts'; +import { CorePopovers } from '@services/overlays/popovers'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Component that displays a forum entry page. */ diff --git a/src/addons/mod/forum/components/post/post.ts b/src/addons/mod/forum/components/post/post.ts index 04a356ec5..cebe03538 100644 --- a/src/addons/mod/forum/components/post/post.ts +++ b/src/addons/mod/forum/components/post/post.ts @@ -53,10 +53,10 @@ import { AddonModForumSharedPostFormData } from '../../pages/discussion/discussi import { CoreDom } from '@singletons/dom'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT, ADDON_MOD_FORUM_COMPONENT } from '../../constants'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; import { toBoolean } from '@/core/transforms/boolean'; -import { CorePopovers } from '@services/popovers'; -import { CoreLoadings } from '@services/loadings'; +import { CorePopovers } from '@services/overlays/popovers'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreWSFile } from '@services/ws'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSError } from '@classes/errors/wserror'; diff --git a/src/addons/mod/forum/pages/discussion/discussion.ts b/src/addons/mod/forum/pages/discussion/discussion.ts index df9779cb4..31778c8aa 100644 --- a/src/addons/mod/forum/pages/discussion/discussion.ts +++ b/src/addons/mod/forum/pages/discussion/discussion.ts @@ -60,8 +60,8 @@ import { AddonModForumType, } from '../../constants'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; -import { CoreToasts } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreObject } from '@singletons/object'; diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts index ab009aa9f..8001b72ea 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts @@ -52,7 +52,7 @@ import { ADDON_MOD_FORUM_NEW_DISCUSSION_EVENT, } from '../../constants'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; type NewDiscussionData = { diff --git a/src/addons/mod/forum/services/handlers/post-link.ts b/src/addons/mod/forum/services/handlers/post-link.ts index 046731b9e..5c0f08e1b 100644 --- a/src/addons/mod/forum/services/handlers/post-link.ts +++ b/src/addons/mod/forum/services/handlers/post-link.ts @@ -18,7 +18,7 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FORUM_PAGE_NAME } from '../../constants'; diff --git a/src/addons/mod/glossary/components/index/index.ts b/src/addons/mod/glossary/components/index/index.ts index 6e9a4df07..043e4c2e0 100644 --- a/src/addons/mod/glossary/components/index/index.ts +++ b/src/addons/mod/glossary/components/index/index.ts @@ -58,7 +58,7 @@ import { ADDON_MOD_GLOSSARY_PAGE_NAME, GLOSSARY_AUTO_SYNCED, } from '../../constants'; -import { CorePopovers } from '@services/popovers'; +import { CorePopovers } from '@services/overlays/popovers'; /** * Component that displays a glossary entry page. diff --git a/src/addons/mod/glossary/pages/edit/edit.ts b/src/addons/mod/glossary/pages/edit/edit.ts index 59b62abbc..702485649 100644 --- a/src/addons/mod/glossary/pages/edit/edit.ts +++ b/src/addons/mod/glossary/pages/edit/edit.ts @@ -40,7 +40,7 @@ import { AddonModGlossaryHelper } from '../../services/glossary-helper'; import { AddonModGlossaryOffline } from '../../services/glossary-offline'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_GLOSSARY_COMPONENT } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays the edit form. diff --git a/src/addons/mod/glossary/pages/entry/entry.ts b/src/addons/mod/glossary/pages/entry/entry.ts index 5c0425525..e23d765e8 100644 --- a/src/addons/mod/glossary/pages/entry/entry.ts +++ b/src/addons/mod/glossary/pages/entry/entry.ts @@ -40,8 +40,8 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_ENTRY_UPDATED, ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants'; import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; -import { CoreToasts, ToastDuration } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays a glossary entry. diff --git a/src/addons/mod/glossary/services/handlers/edit-link.ts b/src/addons/mod/glossary/services/handlers/edit-link.ts index bd6f8e908..3d9216ca1 100644 --- a/src/addons/mod/glossary/services/handlers/edit-link.ts +++ b/src/addons/mod/glossary/services/handlers/edit-link.ts @@ -21,7 +21,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Content links handler for glossary new entry. diff --git a/src/addons/mod/glossary/services/handlers/entry-link.ts b/src/addons/mod/glossary/services/handlers/entry-link.ts index f890b2b73..735edda6c 100644 --- a/src/addons/mod/glossary/services/handlers/entry-link.ts +++ b/src/addons/mod/glossary/services/handlers/entry-link.ts @@ -22,7 +22,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { AddonModGlossary } from '../glossary'; import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Handler to treat links to glossary entries. diff --git a/src/addons/mod/h5pactivity/components/index/index.ts b/src/addons/mod/h5pactivity/components/index/index.ts index 4a06bdea4..30ca179c5 100644 --- a/src/addons/mod/h5pactivity/components/index/index.ts +++ b/src/addons/mod/h5pactivity/components/index/index.ts @@ -54,7 +54,7 @@ import { ADDON_MOD_H5PACTIVITY_TRACK_COMPONENT, } from '../../constants'; import { CoreH5PMissingDependenciesError } from '@features/h5p/classes/errors/missing-dependencies-error'; -import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { Subscription } from 'rxjs'; import { NgZone, Translate } from '@singletons'; import { CoreError } from '@classes/errors/error'; diff --git a/src/addons/mod/h5pactivity/services/handlers/report-link.ts b/src/addons/mod/h5pactivity/services/handlers/report-link.ts index 1d70bfe31..acba0c538 100644 --- a/src/addons/mod/h5pactivity/services/handlers/report-link.ts +++ b/src/addons/mod/h5pactivity/services/handlers/report-link.ts @@ -24,7 +24,7 @@ import { CorePromiseUtils } from '@singletons/promise-utils'; import { makeSingleton } from '@singletons'; import { AddonModH5PActivity } from '../h5pactivity'; import { ADDON_MOD_H5PACTIVITY_PAGE_NAME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Handler to treat links to H5P activity report. diff --git a/src/addons/mod/imscp/pages/view/view.ts b/src/addons/mod/imscp/pages/view/view.ts index ad4e232ad..fba93136a 100644 --- a/src/addons/mod/imscp/pages/view/view.ts +++ b/src/addons/mod/imscp/pages/view/view.ts @@ -27,7 +27,7 @@ import { CoreErrorHelper } from '@services/error-helper'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; import { AddonModImscp, AddonModImscpImscp, AddonModImscpTocItem } from '../../services/imscp'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; /** * Page that displays a IMSCP content. diff --git a/src/addons/mod/lesson/pages/player/player.ts b/src/addons/mod/lesson/pages/player/player.ts index 618797f69..a6d879c53 100644 --- a/src/addons/mod/lesson/pages/player/player.ts +++ b/src/addons/mod/lesson/pages/player/player.ts @@ -54,7 +54,7 @@ import { AddonModLessonSync } from '../../services/lesson-sync'; import { CoreFormFields, CoreForms } from '@singletons/form'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_LESSON_COMPONENT, AddonModLessonJumpTo } from '../../constants'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreDom } from '@singletons/dom'; diff --git a/src/addons/mod/lesson/services/handlers/grade-link.ts b/src/addons/mod/lesson/services/handlers/grade-link.ts index de59e4418..539c17512 100644 --- a/src/addons/mod/lesson/services/handlers/grade-link.ts +++ b/src/addons/mod/lesson/services/handlers/grade-link.ts @@ -23,7 +23,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { AddonModLesson } from '../lesson'; import { ADDON_MOD_LESSON_PAGE_NAME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Handler to treat links to lesson grade. diff --git a/src/addons/mod/lesson/services/handlers/index-link.ts b/src/addons/mod/lesson/services/handlers/index-link.ts index adb07e876..5121a8ac6 100644 --- a/src/addons/mod/lesson/services/handlers/index-link.ts +++ b/src/addons/mod/lesson/services/handlers/index-link.ts @@ -19,7 +19,7 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { makeSingleton } from '@singletons'; import { AddonModLesson } from '../lesson'; diff --git a/src/addons/mod/lesson/services/handlers/prefetch.ts b/src/addons/mod/lesson/services/handlers/prefetch.ts index 853d3550c..8c3effc9d 100644 --- a/src/addons/mod/lesson/services/handlers/prefetch.ts +++ b/src/addons/mod/lesson/services/handlers/prefetch.ts @@ -21,7 +21,7 @@ import { CoreFilepool } from '@services/filepool'; import { CoreGroups } from '@services/groups'; import { CoreFileSizeSum, CorePluginFileDelegate } from '@services/plugin-file-delegate'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSFile } from '@services/ws'; import { makeSingleton, Translate } from '@singletons'; diff --git a/src/addons/mod/lesson/services/handlers/report-link.ts b/src/addons/mod/lesson/services/handlers/report-link.ts index e22aab6c7..c897784ee 100644 --- a/src/addons/mod/lesson/services/handlers/report-link.ts +++ b/src/addons/mod/lesson/services/handlers/report-link.ts @@ -22,7 +22,7 @@ import { CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_LESSON_PAGE_NAME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Handler to treat links to lesson report. diff --git a/src/addons/mod/lti/services/lti-helper.ts b/src/addons/mod/lti/services/lti-helper.ts index 66fe7d200..dd655edc3 100644 --- a/src/addons/mod/lti/services/lti-helper.ts +++ b/src/addons/mod/lti/services/lti-helper.ts @@ -23,7 +23,7 @@ import { makeSingleton } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { AddonModLti, AddonModLtiLti } from './lti'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Service that provides some helper functions for LTI. diff --git a/src/addons/mod/quiz/classes/auto-save.ts b/src/addons/mod/quiz/classes/auto-save.ts index 17fc9e6c0..9798d94db 100644 --- a/src/addons/mod/quiz/classes/auto-save.ts +++ b/src/addons/mod/quiz/classes/auto-save.ts @@ -18,7 +18,7 @@ import { CoreQuestionHelper } from '@features/question/services/question-helper' import { CoreQuestionsAnswers } from '@features/question/services/question'; import { CoreLogger } from '@singletons/logger'; import { AddonModQuiz, AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from '../services/quiz'; -import { CorePopovers } from '@services/popovers'; +import { CorePopovers } from '@services/overlays/popovers'; /** * Class to support auto-save in quiz. Every certain seconds, it will check if there are changes in the current page answers diff --git a/src/addons/mod/quiz/pages/player/player.ts b/src/addons/mod/quiz/pages/player/player.ts index b15811d56..7872dfd77 100644 --- a/src/addons/mod/quiz/pages/player/player.ts +++ b/src/addons/mod/quiz/pages/player/player.ts @@ -54,8 +54,8 @@ import { CoreWSError } from '@classes/errors/wserror'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_QUIZ_ATTEMPT_FINISHED_EVENT, AddonModQuizAttemptStates, ADDON_MOD_QUIZ_COMPONENT } from '../../constants'; import { CoreWait } from '@singletons/wait'; -import { CoreModals } from '@services/modals'; -import { CoreLoadings } from '@services/loadings'; +import { CoreModals } from '@services/overlays/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that allows attempting a quiz. diff --git a/src/addons/mod/quiz/pages/review/review.ts b/src/addons/mod/quiz/pages/review/review.ts index da4db89ae..e392e0b5f 100644 --- a/src/addons/mod/quiz/pages/review/review.ts +++ b/src/addons/mod/quiz/pages/review/review.ts @@ -35,7 +35,7 @@ import { import { AddonModQuizHelper } from '../../services/quiz-helper'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_QUIZ_COMPONENT } from '../../constants'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; /** * Page that allows reviewing a quiz attempt. diff --git a/src/addons/mod/quiz/services/quiz-helper.ts b/src/addons/mod/quiz/services/quiz-helper.ts index db7699497..febbe0103 100644 --- a/src/addons/mod/quiz/services/quiz-helper.ts +++ b/src/addons/mod/quiz/services/quiz-helper.ts @@ -40,8 +40,8 @@ import { import { QuestionDisplayOptionsMarks } from '@features/question/constants'; import { CoreGroups } from '@services/groups'; import { CoreTimeUtils } from '@services/utils/time'; -import { CoreModals } from '@services/modals'; -import { CoreLoadings } from '@services/loadings'; +import { CoreModals } from '@services/overlays/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { CorePromiseUtils } from '@singletons/promise-utils'; diff --git a/src/addons/mod/resource/services/resource-helper.ts b/src/addons/mod/resource/services/resource-helper.ts index 84ce659f7..970033c76 100644 --- a/src/addons/mod/resource/services/resource-helper.ts +++ b/src/addons/mod/resource/services/resource-helper.ts @@ -31,7 +31,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreText } from '@singletons/text'; import { CoreTimeUtils } from '@services/utils/time'; import { ADDON_MOD_RESOURCE_COMPONENT } from '../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreOpenerOpenFileOptions } from '@singletons/opener'; /** diff --git a/src/addons/mod/scorm/pages/player/player.ts b/src/addons/mod/scorm/pages/player/player.ts index 7e8987be4..fe96177cf 100644 --- a/src/addons/mod/scorm/pages/player/player.ts +++ b/src/addons/mod/scorm/pages/player/player.ts @@ -42,7 +42,7 @@ import { ADDON_MOD_SCORM_UPDATE_TOC_EVENT, } from '../../constants'; import { CoreWait } from '@singletons/wait'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; /** * Page that allows playing a SCORM. diff --git a/src/addons/mod/subsection/services/handlers/index-link.ts b/src/addons/mod/subsection/services/handlers/index-link.ts index 18455aca7..58f324f9b 100644 --- a/src/addons/mod/subsection/services/handlers/index-link.ts +++ b/src/addons/mod/subsection/services/handlers/index-link.ts @@ -16,7 +16,7 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/classes/module-index-handler'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreCourse } from '@features/course/services/course'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { CoreSites } from '@services/sites'; diff --git a/src/addons/mod/survey/components/index/index.ts b/src/addons/mod/survey/components/index/index.ts index ab9bf61ed..ad3c25cb8 100644 --- a/src/addons/mod/survey/components/index/index.ts +++ b/src/addons/mod/survey/components/index/index.ts @@ -38,7 +38,7 @@ import { } from '../../services/survey-sync'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { ADDON_MOD_SURVEY_AUTO_SYNCED, ADDON_MOD_SURVEY_COMPONENT } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Component that displays a survey. diff --git a/src/addons/mod/url/services/handlers/module.ts b/src/addons/mod/url/services/handlers/module.ts index 27512cf62..a66870387 100644 --- a/src/addons/mod/url/services/handlers/module.ts +++ b/src/addons/mod/url/services/handlers/module.ts @@ -20,7 +20,7 @@ import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/servic import { CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseModuleHandler, CoreCourseModuleHandlerData } from '@features/course/services/module-delegate'; import { CoreNavigationOptions } from '@services/navigator'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { makeSingleton } from '@singletons'; import { AddonModUrl } from '../url'; diff --git a/src/addons/mod/url/services/url-helper.ts b/src/addons/mod/url/services/url-helper.ts index e379b7269..710df28cc 100644 --- a/src/addons/mod/url/services/url-helper.ts +++ b/src/addons/mod/url/services/url-helper.ts @@ -13,7 +13,7 @@ // limitations under the License. import { Injectable } from '@angular/core'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; diff --git a/src/addons/mod/wiki/components/index/index.ts b/src/addons/mod/wiki/components/index/index.ts index 77bef4766..bad6d8548 100644 --- a/src/addons/mod/wiki/components/index/index.ts +++ b/src/addons/mod/wiki/components/index/index.ts @@ -58,8 +58,8 @@ import { ADDON_MOD_WIKI_PAGE_CREATED_EVENT, ADDON_MOD_WIKI_PAGE_NAME, } from '../../constants'; -import { CoreModals } from '@services/modals'; -import { CorePopovers } from '@services/popovers'; +import { CoreModals } from '@services/overlays/modals'; +import { CorePopovers } from '@services/overlays/popovers'; /** * Component that displays a wiki entry page. diff --git a/src/addons/mod/wiki/pages/edit/edit.ts b/src/addons/mod/wiki/pages/edit/edit.ts index daf0e2d40..19f13cadf 100644 --- a/src/addons/mod/wiki/pages/edit/edit.ts +++ b/src/addons/mod/wiki/pages/edit/edit.ts @@ -32,7 +32,7 @@ import { AddonModWikiOffline } from '../../services/wiki-offline'; import { AddonModWikiSync } from '../../services/wiki-sync'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_WIKI_COMPONENT, ADDON_MOD_WIKI_PAGE_CREATED_EVENT, ADDON_MOD_WIKI_RENEW_LOCK_TIME } from '../../constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreFileHelper } from '@services/file-helper'; /** diff --git a/src/addons/mod/wiki/services/handlers/create-link-lazy.ts b/src/addons/mod/wiki/services/handlers/create-link-lazy.ts index 977b10968..8187226df 100644 --- a/src/addons/mod/wiki/services/handlers/create-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/create-link-lazy.ts @@ -22,7 +22,7 @@ import { makeSingleton } from '@singletons'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiCreateLinkHandlerService } from '@addons/mod/wiki/services/handlers/create-link'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Handler to treat links to create a wiki page. diff --git a/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts b/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts index 0bdc5b3df..fcdda3e5f 100644 --- a/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts @@ -21,7 +21,7 @@ import { makeSingleton } from '@singletons'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiEditLinkHandlerService } from '@addons/mod/wiki/services/handlers/edit-link'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Handler to treat links to edit a wiki page. diff --git a/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts b/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts index d8db96fcb..7c2319b35 100644 --- a/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts @@ -22,7 +22,7 @@ import { Md5 } from 'ts-md5'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiPageOrMapLinkHandlerService } from '@addons/mod/wiki/services/handlers/page-or-map-link'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Handler to treat links to a wiki page or the wiki map. diff --git a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts index d237d0482..b7e016b05 100644 --- a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts +++ b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts @@ -42,7 +42,7 @@ import { AddonModWorkshopOverallFeedbackMode, } from '@addons/mod/workshop/constants'; import { toBoolean } from '@/core/transforms/boolean'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreObject } from '@singletons/object'; diff --git a/src/addons/mod/workshop/components/assessment/assessment.ts b/src/addons/mod/workshop/components/assessment/assessment.ts index 9be8235fd..ed8509410 100644 --- a/src/addons/mod/workshop/components/assessment/assessment.ts +++ b/src/addons/mod/workshop/components/assessment/assessment.ts @@ -26,7 +26,7 @@ import { AddonModWorkshopSubmissionDataWithOfflineData, } from '../../services/workshop-helper'; import { AddonModWorkshopOffline } from '../../services/workshop-offline'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Component that displays workshop assessment. diff --git a/src/addons/mod/workshop/components/index/index.ts b/src/addons/mod/workshop/components/index/index.ts index 20e3d6346..26223abf9 100644 --- a/src/addons/mod/workshop/components/index/index.ts +++ b/src/addons/mod/workshop/components/index/index.ts @@ -21,7 +21,7 @@ import { IonContent } from '@ionic/angular'; import { CoreGroupInfo, CoreGroups } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; import { CorePlatform } from '@services/platform'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreObject } from '@singletons/object'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { Subscription } from 'rxjs'; diff --git a/src/addons/mod/workshop/pages/assessment/assessment.ts b/src/addons/mod/workshop/pages/assessment/assessment.ts index 53f591a08..41b88263c 100644 --- a/src/addons/mod/workshop/pages/assessment/assessment.ts +++ b/src/addons/mod/workshop/pages/assessment/assessment.ts @@ -44,7 +44,7 @@ import { ADDON_MOD_WORKSHOP_COMPONENT, AddonModWorkshopPhase, } from '@addons/mod/workshop/constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays a workshop assessment. diff --git a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts index 5908e9c2e..efef8fbc0 100644 --- a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts +++ b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts @@ -44,7 +44,7 @@ import { AddonModWorkshopAction, AddonModWorkshopSubmissionType, } from '@addons/mod/workshop/constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreDom } from '@singletons/dom'; /** diff --git a/src/addons/mod/workshop/pages/submission/submission.ts b/src/addons/mod/workshop/pages/submission/submission.ts index d7977bab1..83d30b56f 100644 --- a/src/addons/mod/workshop/pages/submission/submission.ts +++ b/src/addons/mod/workshop/pages/submission/submission.ts @@ -55,7 +55,7 @@ import { AddonModWorkshopAction, AddonModWorkshopPhase, } from '@addons/mod/workshop/constants'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays a workshop submission. diff --git a/src/addons/notes/components/add/add-modal.ts b/src/addons/notes/components/add/add-modal.ts index be4d547e8..bc4ee426b 100644 --- a/src/addons/notes/components/add/add-modal.ts +++ b/src/addons/notes/components/add/add-modal.ts @@ -20,8 +20,8 @@ import { CoreForms } from '@singletons/form'; import { ModalController } from '@singletons'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreSharedModule } from '@/core/shared.module'; -import { CoreToasts, ToastDuration } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Component that displays a text area for composing a note. diff --git a/src/addons/notes/pages/list/list.ts b/src/addons/notes/pages/list/list.ts index 31e46570f..43fffa8e0 100644 --- a/src/addons/notes/pages/list/list.ts +++ b/src/addons/notes/pages/list/list.ts @@ -31,8 +31,8 @@ import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreTime } from '@singletons/time'; -import { CoreToasts, ToastDuration } from '@services/toasts'; -import { CoreModals } from '@services/modals'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; +import { CoreModals } from '@services/overlays/modals'; import { ADDON_NOTES_AUTO_SYNCED } from '@addons/notes/services/constants'; /** diff --git a/src/addons/notifications/pages/settings/settings.ts b/src/addons/notifications/pages/settings/settings.ts index f8729db9a..0484f0731 100644 --- a/src/addons/notifications/pages/settings/settings.ts +++ b/src/addons/notifications/pages/settings/settings.ts @@ -40,7 +40,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; import { CoreErrorHelper } from '@services/error-helper'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays notifications settings. diff --git a/src/addons/privatefiles/pages/index/index.ts b/src/addons/privatefiles/pages/index/index.ts index 1e4668a65..9f201a8ec 100644 --- a/src/addons/privatefiles/pages/index/index.ts +++ b/src/addons/privatefiles/pages/index/index.ts @@ -33,10 +33,10 @@ import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreNavigator } from '@services/navigator'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreFilepool } from '@services/filepool'; -import { CoreToasts, ToastDuration } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; import { AddonPrivateFilesFileComponent } from '@addons/privatefiles/components/file/file'; /** diff --git a/src/addons/privatefiles/services/privatefiles-helper.ts b/src/addons/privatefiles/services/privatefiles-helper.ts index c5d14ae9a..089e5cca6 100644 --- a/src/addons/privatefiles/services/privatefiles-helper.ts +++ b/src/addons/privatefiles/services/privatefiles-helper.ts @@ -15,12 +15,12 @@ import { Injectable } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; import { AddonPrivateFiles, AddonPrivateFilesGetUserInfoWSResult } from './privatefiles'; import { CoreError } from '@classes/errors/error'; import { makeSingleton, Translate } from '@singletons'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; /** * Service that provides some helper functions regarding private and site files. diff --git a/src/addons/report/insights/services/handlers/action-link.ts b/src/addons/report/insights/services/handlers/action-link.ts index 5bbc98433..9e1de6ae5 100644 --- a/src/addons/report/insights/services/handlers/action-link.ts +++ b/src/addons/report/insights/services/handlers/action-link.ts @@ -20,8 +20,8 @@ import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton, Translate } from '@singletons'; import { AddonReportInsights } from '../insights'; -import { CoreToasts } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; // Bulk actions supported, along with the related lang string. const BULK_ACTIONS = { diff --git a/src/addons/storagemanager/pages/course-storage/course-storage.ts b/src/addons/storagemanager/pages/course-storage/course-storage.ts index 899a2eb1d..b01ecd45d 100644 --- a/src/addons/storagemanager/pages/course-storage/course-storage.ts +++ b/src/addons/storagemanager/pages/course-storage/course-storage.ts @@ -28,7 +28,7 @@ import { CoreCourseModulePrefetchHandler } from '@features/course/services/module-prefetch-delegate'; import { CoreCourses } from '@features/courses/services/courses'; import { AccordionGroupChangeEventDetail } from '@ionic/angular'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; diff --git a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts index 857ac0d2f..ae52b8971 100644 --- a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts +++ b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts @@ -21,7 +21,7 @@ import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourses, CoreEnrolledCourseData } from '@features/courses/services/courses'; import { CoreSettingsHelper, CoreSiteSpaceUsage } from '@features/settings/services/settings-helper'; import { CoreSiteHome } from '@features/sitehome/services/sitehome'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; diff --git a/src/core/classes/page-loads-manager.ts b/src/core/classes/page-loads-manager.ts index 174f6a66d..1bf43f50b 100644 --- a/src/core/classes/page-loads-manager.ts +++ b/src/core/classes/page-loads-manager.ts @@ -13,7 +13,7 @@ // limitations under the License. import { CoreNavigator } from '@services/navigator'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { Subject } from 'rxjs'; import { AsyncDirective } from './async-directive'; import { PageLoadWatcher } from './page-load-watcher'; diff --git a/src/core/classes/sites/authenticated-site.ts b/src/core/classes/sites/authenticated-site.ts index 3d60d14f2..714272f54 100644 --- a/src/core/classes/sites/authenticated-site.ts +++ b/src/core/classes/sites/authenticated-site.ts @@ -21,7 +21,7 @@ import { CoreWSPreSetsSplitRequest, CoreWSTypeExpected, } from '@services/ws'; -import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreText } from '@singletons/text'; import { CoreUtils } from '@singletons/utils'; import { CoreCacheUpdateFrequency, CoreConstants, MINIMUM_MOODLE_VERSION, MOODLE_RELEASES } from '@/core/constants'; diff --git a/src/core/classes/sites/site.ts b/src/core/classes/sites/site.ts index 296b5d9d0..25aa422c7 100644 --- a/src/core/classes/sites/site.ts +++ b/src/core/classes/sites/site.ts @@ -54,7 +54,7 @@ import { CoreSiteInfo } from './unauthenticated-site'; import { CoreAuthenticatedSite, CoreAuthenticatedSiteOptionalData, CoreSiteWSPreSets, WSObservable } from './authenticated-site'; import { firstValueFrom } from 'rxjs'; import { CorePlatform } from '@services/platform'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; /** diff --git a/src/core/components/combobox/combobox.ts b/src/core/components/combobox/combobox.ts index 8602dec8d..c994b8ad9 100644 --- a/src/core/components/combobox/combobox.ts +++ b/src/core/components/combobox/combobox.ts @@ -15,7 +15,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Translate } from '@singletons'; import { ModalOptions } from '@ionic/core'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; import { toBoolean } from '@/core/transforms/boolean'; diff --git a/src/core/components/context-menu/context-menu.ts b/src/core/components/context-menu/context-menu.ts index 44f1d470e..353e2e1ed 100644 --- a/src/core/components/context-menu/context-menu.ts +++ b/src/core/components/context-menu/context-menu.ts @@ -15,7 +15,7 @@ import { Component, Input, OnInit, OnDestroy, ElementRef, ChangeDetectorRef } from '@angular/core'; import { Subject, Subscription } from 'rxjs'; import { auditTime } from 'rxjs/operators'; -import { CorePopovers } from '@services/popovers'; +import { CorePopovers } from '@services/overlays/popovers'; import { CoreUtils } from '@singletons/utils'; import { Translate } from '@singletons'; import { CoreContextMenuItemComponent } from './context-menu-item'; diff --git a/src/core/components/local-file/local-file.ts b/src/core/components/local-file/local-file.ts index e05d3865e..9ac652940 100644 --- a/src/core/components/local-file/local-file.ts +++ b/src/core/components/local-file/local-file.ts @@ -28,7 +28,7 @@ import { CoreForms } from '@singletons/form'; import { CorePath } from '@singletons/path'; import { CorePlatform } from '@services/platform'; import { toBoolean } from '@/core/transforms/boolean'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreFileUtils } from '@singletons/file-utils'; /** diff --git a/src/core/components/password-modal/password-modal.ts b/src/core/components/password-modal/password-modal.ts index 519a707cb..9c7a026e7 100644 --- a/src/core/components/password-modal/password-modal.ts +++ b/src/core/components/password-modal/password-modal.ts @@ -17,7 +17,7 @@ import { Component, ViewChild, ElementRef, Input } from '@angular/core'; import { CoreSites } from '@services/sites'; import { CoreForms } from '@singletons/form'; import { ModalController } from '@singletons'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Modal that asks the password. diff --git a/src/core/components/sheet-modal/sheet-modal.ts b/src/core/components/sheet-modal/sheet-modal.ts index 9870071d2..69db82b92 100644 --- a/src/core/components/sheet-modal/sheet-modal.ts +++ b/src/core/components/sheet-modal/sheet-modal.ts @@ -16,7 +16,7 @@ import { Constructor } from '@/core/utils/types'; import { AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core'; import { CoreModalComponent } from '@classes/modal-component'; import { CorePromisedValue } from '@classes/promised-value'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreWait } from '@singletons/wait'; import { AngularFrameworkDelegate } from '@singletons'; import { CoreDirectivesRegistry } from '@singletons/directives-registry'; diff --git a/src/core/core.module.ts b/src/core/core.module.ts index fee9c1c4f..35da2af97 100644 --- a/src/core/core.module.ts +++ b/src/core/core.module.ts @@ -36,7 +36,7 @@ export async function getCoreServices(): Promise[]> { const { CoreDbProvider } = await import('@services/db'); const { CoreDomUtilsProvider } = await import('@services/utils/dom'); const { CoreErrorHelperService } = await import('@services/error-helper'); - const { CoreToastsService } = await import('@services/toasts'); + const { CoreToastsService } = await import('@services/overlays/toasts'); const { CoreFileHelperProvider } = await import('@services/file-helper'); const { CoreFilepoolProvider } = await import('@services/filepool'); const { CoreFileProvider } = await import('@services/file'); @@ -49,7 +49,7 @@ export async function getCoreServices(): Promise[]> { const { CoreMimetypeUtilsProvider } = await import('@services/utils/mimetype'); const { CoreNavigatorService } = await import('@services/navigator'); const { CorePluginFileDelegateService } = await import('@services/plugin-file-delegate'); - const { CorePopoversService } = await import('@services/popovers'); + const { CorePopoversService } = await import('@services/overlays/popovers'); const { CoreScreenService } = await import('@services/screen'); const { CoreSitesProvider } = await import('@services/sites'); const { CoreSyncProvider } = await import('@services/sync'); @@ -62,7 +62,7 @@ export async function getCoreServices(): Promise[]> { const { CoreWSProvider } = await import('@services/ws'); const { CorePlatformService } = await import('@services/platform'); const { CoreQRScanService } = await import('@services/qrscan'); - const { CoreLoadingsService } = await import('@services/loadings'); + const { CoreLoadingsService } = await import('@services/overlays/loadings'); return [ CoreAppProvider, diff --git a/src/core/directives/download-file.ts b/src/core/directives/download-file.ts index dc1fd9428..376b5c4c1 100644 --- a/src/core/directives/download-file.ts +++ b/src/core/directives/download-file.ts @@ -14,7 +14,7 @@ import { Directive, Input, OnInit, ElementRef } from '@angular/core'; import { CoreFileHelper } from '@services/file-helper'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreWSFile } from '@services/ws'; diff --git a/src/core/directives/link.ts b/src/core/directives/link.ts index 02380e6f2..fd31cd937 100644 --- a/src/core/directives/link.ts +++ b/src/core/directives/link.ts @@ -27,7 +27,7 @@ import { DomSanitizer } from '@singletons'; import { CoreFilepool } from '@services/filepool'; import { CoreDom } from '@singletons/dom'; import { toBoolean } from '../transforms/boolean'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Directive to open a link in external browser or in the app. diff --git a/src/core/directives/reading-mode.ts b/src/core/directives/reading-mode.ts index f46a5f124..476efb097 100644 --- a/src/core/directives/reading-mode.ts +++ b/src/core/directives/reading-mode.ts @@ -24,7 +24,7 @@ import { CoreIcons } from '@singletons/icons'; import { CoreDom } from '@singletons/dom'; import { CoreWait } from '@singletons/wait'; import { CoreCancellablePromise } from '@classes/cancellable-promise'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreViewer } from '@features/viewer/services/viewer'; import { CoreDirectivesRegistry } from '@singletons/directives-registry'; import { CoreCollapsibleHeaderDirective } from './collapsible-header'; diff --git a/src/core/features/block/components/side-blocks-button/side-blocks-button.ts b/src/core/features/block/components/side-blocks-button/side-blocks-button.ts index 67cc3ceb4..a1d12ca5f 100644 --- a/src/core/features/block/components/side-blocks-button/side-blocks-button.ts +++ b/src/core/features/block/components/side-blocks-button/side-blocks-button.ts @@ -16,7 +16,7 @@ import { Component, ElementRef, Input, OnDestroy, OnInit } from '@angular/core'; import { CoreCancellablePromise } from '@classes/cancellable-promise'; import { CoreUserTourDirectiveOptions } from '@directives/user-tour'; import { CoreUserToursAlignment, CoreUserToursSide } from '@features/usertours/services/user-tours'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreDom } from '@singletons/dom'; import { CoreBlockSideBlocksTourComponent } from '../side-blocks-tour/side-blocks-tour'; import { ContextLevel } from '@/core/constants'; diff --git a/src/core/features/comments/pages/viewer/viewer.ts b/src/core/features/comments/pages/viewer/viewer.ts index e063f3678..e4f4f2ec9 100644 --- a/src/core/features/comments/pages/viewer/viewer.ts +++ b/src/core/features/comments/pages/viewer/viewer.ts @@ -42,8 +42,8 @@ import moment from 'moment-timezone'; import { Subscription } from 'rxjs'; import { CoreAnimations } from '@components/animations'; import { CoreKeyboard } from '@singletons/keyboard'; -import { CoreToasts, ToastDuration } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CORE_COMMENTS_AUTO_SYNCED } from '@features/comments/constants'; /** diff --git a/src/core/features/contentlinks/classes/module-grade-handler.ts b/src/core/features/contentlinks/classes/module-grade-handler.ts index 48cbec60a..218979722 100644 --- a/src/core/features/contentlinks/classes/module-grade-handler.ts +++ b/src/core/features/contentlinks/classes/module-grade-handler.ts @@ -15,7 +15,7 @@ import { CoreContentLinksAction } from '../services/contentlinks-delegate'; import { CoreContentLinksHandlerBase } from './base-handler'; import { CoreSites } from '@services/sites'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreCourseHelper } from '@features/course/services/course-helper'; /** diff --git a/src/core/features/contentlinks/services/contentlinks-helper.ts b/src/core/features/contentlinks/services/contentlinks-helper.ts index 979eb29ef..a76c68d33 100644 --- a/src/core/features/contentlinks/services/contentlinks-helper.ts +++ b/src/core/features/contentlinks/services/contentlinks-helper.ts @@ -20,7 +20,7 @@ import { CoreSite } from '@classes/sites/site'; import { makeSingleton, Translate } from '@singletons'; import { CoreNavigator } from '@services/navigator'; import { CoreCustomURLSchemes } from '@services/urlschemes'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; /** * Service that provides some features regarding content links. diff --git a/src/core/features/course/classes/main-resource-component.ts b/src/core/features/course/classes/main-resource-component.ts index 2003c1e5b..a49f8a3e2 100644 --- a/src/core/features/course/classes/main-resource-component.ts +++ b/src/core/features/course/classes/main-resource-component.ts @@ -33,7 +33,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreUrl } from '@singletons/url'; import { CoreTime } from '@singletons/time'; import { CoreText } from '@singletons/text'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreErrorHelper, CoreErrorObject } from '@services/error-helper'; import { CorePromiseUtils } from '@singletons/promise-utils'; diff --git a/src/core/features/course/components/course-format/course-format.ts b/src/core/features/course/components/course-format/course-format.ts index 83548c870..6f45c0fd0 100644 --- a/src/core/features/course/components/course-format/course-format.ts +++ b/src/core/features/course/components/course-format/course-format.ts @@ -52,7 +52,7 @@ import { CoreDom } from '@singletons/dom'; import { CoreUserTourDirectiveOptions } from '@directives/user-tour'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ContextLevel } from '@/core/constants'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreBlockComponentsModule } from '@features/block/components/components.module'; import { CoreSites } from '@services/sites'; diff --git a/src/core/features/course/components/module-completion/module-completion.ts b/src/core/features/course/components/module-completion/module-completion.ts index 55689504f..1f82c9c99 100644 --- a/src/core/features/course/components/module-completion/module-completion.ts +++ b/src/core/features/course/components/module-completion/module-completion.ts @@ -16,7 +16,7 @@ import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChange } from '@a import { CoreCourseModuleCompletionBaseComponent } from '@features/course/classes/module-completion'; import { CoreCourseModuleCompletionStatus } from '@features/course/constants'; -import { CorePopovers } from '@services/popovers'; +import { CorePopovers } from '@services/overlays/popovers'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreUser } from '@features/user/services/user'; import { Translate } from '@singletons'; diff --git a/src/core/features/course/components/module-navigation/module-navigation.ts b/src/core/features/course/components/module-navigation/module-navigation.ts index d831d2fd2..cf4f5f7f4 100644 --- a/src/core/features/course/components/module-navigation/module-navigation.ts +++ b/src/core/features/course/components/module-navigation/module-navigation.ts @@ -17,7 +17,7 @@ import { CoreCourse, CoreCourseWSSection } from '@features/course/services/cours import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; import { IonContent } from '@ionic/angular'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; diff --git a/src/core/features/course/directives/download-module-main-file.ts b/src/core/features/course/directives/download-module-main-file.ts index 82f95acab..0f8df12b8 100644 --- a/src/core/features/course/directives/download-module-main-file.ts +++ b/src/core/features/course/directives/download-module-main-file.ts @@ -17,7 +17,7 @@ import { Directive, Input, OnInit, ElementRef } from '@angular/core'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course'; import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreOpenerOpenFileOptions } from '@singletons/opener'; /** diff --git a/src/core/features/course/pages/module-preview/module-preview.ts b/src/core/features/course/pages/module-preview/module-preview.ts index b310da7b4..fec9c3a88 100644 --- a/src/core/features/course/pages/module-preview/module-preview.ts +++ b/src/core/features/course/pages/module-preview/module-preview.ts @@ -17,7 +17,7 @@ import { CoreCourseModuleSummaryResult } from '@features/course/components/modul import { CoreCourse } from '@features/course/services/course'; import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index 16f50b174..56ab342e8 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -73,8 +73,8 @@ import { CoreLocalNotifications } from '@services/local-notifications'; import { CoreEnrol } from '@features/enrol/services/enrol'; import { CoreEnrolAction, CoreEnrolDelegate } from '@features/enrol/services/enrol-delegate'; import { LazyRoutesModule } from '@/app/app-routing.module'; -import { CoreModals } from '@services/modals'; -import { CoreLoadings } from '@services/loadings'; +import { CoreModals } from '@services/overlays/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreCourseModuleCompletionTracking, CoreCourseModuleCompletionStatus, diff --git a/src/core/features/course/services/course.ts b/src/core/features/course/services/course.ts index 3db9b068f..6311590fc 100644 --- a/src/core/features/course/services/course.ts +++ b/src/core/features/course/services/course.ts @@ -57,7 +57,7 @@ import { asyncObservable } from '@/core/utils/rxjs'; import { firstValueFrom } from 'rxjs'; import { map } from 'rxjs/operators'; import { CoreSiteWSPreSets, WSObservable } from '@classes/sites/authenticated-site'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreArray } from '@singletons/array'; import { CoreText } from '@singletons/text'; import { ArrayElement } from '@/core/utils/types'; diff --git a/src/core/features/courses/components/course-list-item/course-list-item.ts b/src/core/features/courses/components/course-list-item/course-list-item.ts index 98810f867..962146b88 100644 --- a/src/core/features/courses/components/course-list-item/course-list-item.ts +++ b/src/core/features/courses/components/course-list-item/course-list-item.ts @@ -28,8 +28,8 @@ import { CoreCoursesHelper, CoreEnrolledCourseDataWithExtraInfoAndOptions } from import { CoreEnrolHelper } from '@features/enrol/services/enrol-helper'; import { CoreDownloadStatusTranslatable } from '@components/download-refresh/download-refresh'; import { toBoolean } from '@/core/transforms/boolean'; -import { CorePopovers } from '@services/popovers'; -import { CoreLoadings } from '@services/loadings'; +import { CorePopovers } from '@services/overlays/popovers'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CORE_COURSES_MY_COURSES_UPDATED_EVENT, CoreCoursesMyCoursesUpdatedEventAction, diff --git a/src/core/features/courses/services/handlers/base-link-handler.ts b/src/core/features/courses/services/handlers/base-link-handler.ts index 7e09c897a..934f54152 100644 --- a/src/core/features/courses/services/handlers/base-link-handler.ts +++ b/src/core/features/courses/services/handlers/base-link-handler.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourses } from '../courses'; diff --git a/src/core/features/courses/services/handlers/enrol-push-click.ts b/src/core/features/courses/services/handlers/enrol-push-click.ts index 424fd4e28..20000128b 100644 --- a/src/core/features/courses/services/handlers/enrol-push-click.ts +++ b/src/core/features/courses/services/handlers/enrol-push-click.ts @@ -17,7 +17,7 @@ import { Params } from '@angular/router'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CorePushNotificationsClickHandler } from '@features/pushnotifications/services/push-delegate'; import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; diff --git a/src/core/features/courses/services/handlers/request-push-click.ts b/src/core/features/courses/services/handlers/request-push-click.ts index 265cc1d80..2fcc33066 100644 --- a/src/core/features/courses/services/handlers/request-push-click.ts +++ b/src/core/features/courses/services/handlers/request-push-click.ts @@ -24,7 +24,7 @@ import { CoreUtils } from '@singletons/utils'; import { makeSingleton } from '@singletons'; import { CorePath } from '@singletons/path'; import { CoreCourses } from '../courses'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; /** diff --git a/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts b/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts index f9cce9830..b98805def 100644 --- a/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts +++ b/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts @@ -19,11 +19,11 @@ import { CoreDataPrivacy } from '@features/dataprivacy/services/dataprivacy'; import { CoreUser } from '@features/user/services/user'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; -import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { ModalController } from '@singletons'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Component that displays the contact DPO page. diff --git a/src/core/features/dataprivacy/components/newrequest/newrequest.ts b/src/core/features/dataprivacy/components/newrequest/newrequest.ts index 1c29cb690..5d0cfe975 100644 --- a/src/core/features/dataprivacy/components/newrequest/newrequest.ts +++ b/src/core/features/dataprivacy/components/newrequest/newrequest.ts @@ -21,10 +21,10 @@ import { CoreDataPrivacyGetAccessInformationWSResponse, } from '@features/dataprivacy/services/dataprivacy'; import { CoreDomUtils } from '@services/utils/dom'; -import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { ModalController } from '@singletons'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Component that displays the new request page. diff --git a/src/core/features/dataprivacy/pages/main/main.ts b/src/core/features/dataprivacy/pages/main/main.ts index 3363004b8..d28541033 100644 --- a/src/core/features/dataprivacy/pages/main/main.ts +++ b/src/core/features/dataprivacy/pages/main/main.ts @@ -19,8 +19,8 @@ import { CoreDataPrivacyGetAccessInformationWSResponse, CoreDataPrivacyRequest, } from '@features/dataprivacy/services/dataprivacy'; -import { CoreLoadings } from '@services/loadings'; -import { CoreModals } from '@services/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreModals } from '@services/overlays/modals'; import { CoreNavigator } from '@services/navigator'; import { CoreScreen } from '@services/screen'; import { CoreDomUtils } from '@services/utils/dom'; diff --git a/src/core/features/emulator/components/capture-media/capture-media.ts b/src/core/features/emulator/components/capture-media/capture-media.ts index cd83912a3..15a9e0a42 100644 --- a/src/core/features/emulator/components/capture-media/capture-media.ts +++ b/src/core/features/emulator/components/capture-media/capture-media.ts @@ -25,7 +25,7 @@ import { CoreCaptureError } from '@classes/errors/captureerror'; import { CoreCanceledError } from '@classes/errors/cancelederror'; import { CorePath } from '@singletons/path'; import { toBoolean } from '@/core/transforms/boolean'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page to capture media in browser. diff --git a/src/core/features/fileuploader/services/fileuploader-helper.ts b/src/core/features/fileuploader/services/fileuploader-helper.ts index 745b37bd7..2cf257130 100644 --- a/src/core/features/fileuploader/services/fileuploader-helper.ts +++ b/src/core/features/fileuploader/services/fileuploader-helper.ts @@ -44,8 +44,8 @@ import { CorePath } from '@singletons/path'; import { CorePromisedValue } from '@classes/promised-value'; import { CorePlatform } from '@services/platform'; import { Chooser } from '@features/native/plugins'; -import { CoreToasts } from '@services/toasts'; -import { CoreLoadings } from '@services/loadings'; +import { CoreToasts } from '@services/overlays/toasts'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreFileUtils } from '@singletons/file-utils'; /** diff --git a/src/core/features/fileuploader/services/fileuploader.ts b/src/core/features/fileuploader/services/fileuploader.ts index 6a4add07a..b00670f57 100644 --- a/src/core/features/fileuploader/services/fileuploader.ts +++ b/src/core/features/fileuploader/services/fileuploader.ts @@ -33,7 +33,7 @@ import { CoreSite } from '@classes/sites/site'; import { CoreFileEntry, CoreFileHelper } from '@services/file-helper'; import { CorePath } from '@singletons/path'; import { CorePlatform } from '@services/platform'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; /** diff --git a/src/core/features/grades/services/grades-helper.ts b/src/core/features/grades/services/grades-helper.ts index 23bc939a3..b7a1dc9b2 100644 --- a/src/core/features/grades/services/grades-helper.ts +++ b/src/core/features/grades/services/grades-helper.ts @@ -43,7 +43,7 @@ import { CoreError } from '@classes/errors/error'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; import { CoreCourseAccess } from '@features/course/services/course-options-delegate'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { CoreCourseAccessDataType } from '@features/course/constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index 57ac284cb..a1909859c 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -41,7 +41,7 @@ import { import { CoreCustomURLSchemes } from '@services/urlschemes'; import { CoreSiteError } from '@classes/errors/siteerror'; import { CoreKeyboard } from '@singletons/keyboard'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page to enter the user credentials. diff --git a/src/core/features/login/pages/email-signup/email-signup.ts b/src/core/features/login/pages/email-signup/email-signup.ts index 2604de18c..bdc00321e 100644 --- a/src/core/features/login/pages/email-signup/email-signup.ts +++ b/src/core/features/login/pages/email-signup/email-signup.ts @@ -37,7 +37,7 @@ import { CoreSitesFactory } from '@services/sites-factory'; import { EMAIL_SIGNUP_FEATURE_NAME } from '@features/login/constants'; import { CoreInputErrorsMessages } from '@components/input-errors/input-errors'; import { CoreViewer } from '@features/viewer/services/viewer'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener } from '@singletons/opener'; diff --git a/src/core/features/login/pages/forgotten-password/forgotten-password.ts b/src/core/features/login/pages/forgotten-password/forgotten-password.ts index 1e29997db..54f35172a 100644 --- a/src/core/features/login/pages/forgotten-password/forgotten-password.ts +++ b/src/core/features/login/pages/forgotten-password/forgotten-password.ts @@ -25,7 +25,7 @@ import { CoreSitePublicConfigResponse, CoreUnauthenticatedSite } from '@classes/ import { CoreUserSupportConfig } from '@features/user/classes/support/support-config'; import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config'; import { CoreSitesFactory } from '@services/sites-factory'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page to recover a forgotten password. diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index 4c9cb9a69..b2e365ac4 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -33,7 +33,7 @@ import { SafeHtml } from '@angular/platform-browser'; import { CoreSitePublicConfigResponse } from '@classes/sites/unauthenticated-site'; import { ALWAYS_SHOW_LOGIN_FORM_CHANGED, FORGOTTEN_PASSWORD_FEATURE_NAME } from '@features/login/constants'; import { CoreKeyboard } from '@singletons/keyboard'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreLoginMethodsComponent, CoreLoginMethodsCurrentLogin } from '@features/login/components/login-methods/login-methods'; /** diff --git a/src/core/features/login/pages/site/site.ts b/src/core/features/login/pages/site/site.ts index 71051aa74..f6e1c8432 100644 --- a/src/core/features/login/pages/site/site.ts +++ b/src/core/features/login/pages/site/site.ts @@ -46,9 +46,9 @@ import { CoreSitesFactory } from '@services/sites-factory'; import { ONBOARDING_DONE } from '@features/login/constants'; import { CoreUnauthenticatedSite } from '@classes/sites/unauthenticated-site'; import { CoreKeyboard } from '@singletons/keyboard'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreQRScan } from '@services/qrscan'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreCountries } from '@singletons/countries'; diff --git a/src/core/features/login/pages/sites/sites.ts b/src/core/features/login/pages/sites/sites.ts index 82a980ad0..f69cfbd18 100644 --- a/src/core/features/login/pages/sites/sites.ts +++ b/src/core/features/login/pages/sites/sites.ts @@ -20,7 +20,7 @@ import { CoreAccountsList, CoreLoginHelper } from '@features/login/services/logi import { CoreNavigator } from '@services/navigator'; import { CoreFilter } from '@features/filter/services/filter'; import { CoreAnimations } from '@components/animations'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays the list of sites stored in the device. diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts index fa26b1bf2..c61fb6c09 100644 --- a/src/core/features/login/services/login-helper.ts +++ b/src/core/features/login/services/login-helper.ts @@ -59,7 +59,7 @@ import { import { LazyRoutesModule } from '@/app/app-routing.module'; import { CoreSiteError } from '@classes/errors/siteerror'; import { CoreQRScan } from '@services/qrscan'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreErrorHelper } from '@services/error-helper'; import { CoreSSO } from '@singletons/sso'; import { CorePromiseUtils } from '@singletons/promise-utils'; diff --git a/src/core/features/mainmenu/components/user-menu-button/user-menu-button.ts b/src/core/features/mainmenu/components/user-menu-button/user-menu-button.ts index eaa5afad6..1216fa17f 100644 --- a/src/core/features/mainmenu/components/user-menu-button/user-menu-button.ts +++ b/src/core/features/mainmenu/components/user-menu-button/user-menu-button.ts @@ -19,7 +19,7 @@ import { CoreUserToursAlignment, CoreUserToursSide } from '@features/usertours/s import { IonRouterOutlet } from '@ionic/angular'; import { CoreScreen } from '@services/screen'; import { CoreSites } from '@services/sites'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreMainMenuUserMenuTourComponent } from '../user-menu-tour/user-menu-tour'; import { CoreMainMenuPage } from '@features/mainmenu/pages/menu/menu'; import { toBoolean } from '@/core/transforms/boolean'; diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.ts b/src/core/features/mainmenu/components/user-menu/user-menu.ts index 0cb2ba4d5..0b9b5a5ea 100644 --- a/src/core/features/mainmenu/components/user-menu/user-menu.ts +++ b/src/core/features/mainmenu/components/user-menu/user-menu.ts @@ -26,7 +26,7 @@ import { CoreUserProfileHandlerType, CoreUserDelegateContext, } from '@features/user/services/user-delegate'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; diff --git a/src/core/features/policy/pages/acceptances/acceptances.ts b/src/core/features/policy/pages/acceptances/acceptances.ts index c41bf30dd..4f145ff83 100644 --- a/src/core/features/policy/pages/acceptances/acceptances.ts +++ b/src/core/features/policy/pages/acceptances/acceptances.ts @@ -26,8 +26,8 @@ import { Subscription } from 'rxjs'; import { CORE_DATAPRIVACY_FEATURE_NAME, CORE_DATAPRIVACY_PAGE_NAME } from '@features/dataprivacy/constants'; import { CoreNavigator } from '@services/navigator'; import { CoreDataPrivacy } from '@features/dataprivacy/services/dataprivacy'; -import { CoreModals } from '@services/modals'; -import { CoreLoadings } from '@services/loadings'; +import { CoreModals } from '@services/overlays/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page to view user acceptances. diff --git a/src/core/features/policy/pages/site-policy/site-policy.ts b/src/core/features/policy/pages/site-policy/site-policy.ts index dfab2c14f..026b3314c 100644 --- a/src/core/features/policy/pages/site-policy/site-policy.ts +++ b/src/core/features/policy/pages/site-policy/site-policy.ts @@ -30,8 +30,8 @@ import { CoreScreen } from '@services/screen'; import { Subscription } from 'rxjs'; import { CoreDom } from '@singletons/dom'; import { CoreWait } from '@singletons/wait'; -import { CoreModals } from '@services/modals'; -import { CoreLoadings } from '@services/loadings'; +import { CoreModals } from '@services/overlays/modals'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; /** diff --git a/src/core/features/rating/components/aggregate/aggregate.ts b/src/core/features/rating/components/aggregate/aggregate.ts index 9687202ed..60e83099d 100644 --- a/src/core/features/rating/components/aggregate/aggregate.ts +++ b/src/core/features/rating/components/aggregate/aggregate.ts @@ -20,7 +20,7 @@ import { CoreRatingInfoItem, CoreRatingProvider, } from '@features/rating/services/rating'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreSites } from '@services/sites'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; diff --git a/src/core/features/rating/components/rate/rate.ts b/src/core/features/rating/components/rate/rate.ts index cf6729efa..71f836c0a 100644 --- a/src/core/features/rating/components/rate/rate.ts +++ b/src/core/features/rating/components/rate/rate.ts @@ -24,10 +24,10 @@ import { import { CoreRatingOffline } from '@features/rating/services/rating-offline'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; -import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Component that displays the user rating select. diff --git a/src/core/features/reminders/components/set-button/set-button.ts b/src/core/features/reminders/components/set-button/set-button.ts index f5cedf7dd..70cfd02b6 100644 --- a/src/core/features/reminders/components/set-button/set-button.ts +++ b/src/core/features/reminders/components/set-button/set-button.ts @@ -14,10 +14,10 @@ import { CoreReminderData, CoreReminders } from '@features/reminders/services/reminders'; import { Component, Input, OnInit } from '@angular/core'; -import { CorePopovers } from '@services/popovers'; +import { CorePopovers } from '@services/overlays/popovers'; import { Translate } from '@singletons'; import { CoreTimeUtils } from '@services/utils/time'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; import { REMINDERS_DISABLED } from '@features/reminders/constants'; /** diff --git a/src/core/features/reminders/components/set-reminder-menu/set-reminder-menu.ts b/src/core/features/reminders/components/set-reminder-menu/set-reminder-menu.ts index e43530cb0..8284f0902 100644 --- a/src/core/features/reminders/components/set-reminder-menu/set-reminder-menu.ts +++ b/src/core/features/reminders/components/set-reminder-menu/set-reminder-menu.ts @@ -18,7 +18,7 @@ import { CoreRemindersService, CoreReminderValueAndUnit, } from '@features/reminders/services/reminders'; -import { CorePopovers } from '@services/popovers'; +import { CorePopovers } from '@services/overlays/popovers'; import { CoreWait } from '@singletons/wait'; import { PopoverController } from '@singletons'; import { CoreSharedModule } from '@/core/shared.module'; diff --git a/src/core/features/reportbuilder/pages/report/report.ts b/src/core/features/reportbuilder/pages/report/report.ts index 1321e4629..403529cba 100644 --- a/src/core/features/reportbuilder/pages/report/report.ts +++ b/src/core/features/reportbuilder/pages/report/report.ts @@ -14,7 +14,7 @@ import { Component, OnInit } from '@angular/core'; import { CoreReportBuilderReportDetail } from '@features/reportbuilder/services/reportbuilder'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreNavigator } from '@services/navigator'; @Component({ diff --git a/src/core/features/search/pages/global-search/global-search.ts b/src/core/features/search/pages/global-search/global-search.ts index 69f3205e9..2e05b430f 100644 --- a/src/core/features/search/pages/global-search/global-search.ts +++ b/src/core/features/search/pages/global-search/global-search.ts @@ -29,7 +29,7 @@ import { } from '@features/search/services/global-search'; import { CoreNavigator } from '@services/navigator'; import { CoreSearchBoxComponent } from '@features/search/components/search-box/search-box'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; @Component({ diff --git a/src/core/features/settings/pages/dev/dev.ts b/src/core/features/settings/pages/dev/dev.ts index 6f781f668..138c1083b 100644 --- a/src/core/features/settings/pages/dev/dev.ts +++ b/src/core/features/settings/pages/dev/dev.ts @@ -30,7 +30,7 @@ import { CoreNavigator } from '@services/navigator'; import { CorePlatform } from '@services/platform'; import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; -import { CoreToasts, ToastDuration } from '@services/toasts'; +import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreText } from '@singletons/text'; /** diff --git a/src/core/features/settings/pages/deviceinfo/deviceinfo.ts b/src/core/features/settings/pages/deviceinfo/deviceinfo.ts index d4e0e3ecd..6314c3f52 100644 --- a/src/core/features/settings/pages/deviceinfo/deviceinfo.ts +++ b/src/core/features/settings/pages/deviceinfo/deviceinfo.ts @@ -23,7 +23,7 @@ import { CorePromiseUtils } from '@singletons/promise-utils'; import { Subscription } from 'rxjs'; import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications'; import { CoreConfig } from '@services/config'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; import { CoreNavigator } from '@services/navigator'; import { CorePlatform } from '@services/platform'; import { CoreNetwork } from '@services/network'; diff --git a/src/core/features/settings/pages/site/site.ts b/src/core/features/settings/pages/site/site.ts index a3575362c..8037d28ba 100644 --- a/src/core/features/settings/pages/site/site.ts +++ b/src/core/features/settings/pages/site/site.ts @@ -29,7 +29,7 @@ import { NgZone } from '@singletons'; import { CoreConstants } from '@/core/constants'; import { CoreConfig } from '@services/config'; import { CoreSettingsHandlersSource } from '@features/settings/classes/settings-handlers-source'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; /** * Page that displays the list of site settings pages. diff --git a/src/core/features/settings/pages/synchronization/synchronization.ts b/src/core/features/settings/pages/synchronization/synchronization.ts index 2b778e6d3..90ec7b52d 100644 --- a/src/core/features/settings/pages/synchronization/synchronization.ts +++ b/src/core/features/settings/pages/synchronization/synchronization.ts @@ -25,7 +25,7 @@ import { CoreAccountsList, CoreLoginHelper } from '@features/login/services/logi import { CoreNetwork } from '@services/network'; import { Subscription } from 'rxjs'; import { CoreNavigator } from '@services/navigator'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; /** * Page that displays the synchronization settings. diff --git a/src/core/features/sharedfiles/services/sharedfiles-helper.ts b/src/core/features/sharedfiles/services/sharedfiles-helper.ts index 325bfd63a..ded3dad88 100644 --- a/src/core/features/sharedfiles/services/sharedfiles-helper.ts +++ b/src/core/features/sharedfiles/services/sharedfiles-helper.ts @@ -30,7 +30,7 @@ import { SHAREDFILES_PAGE_NAME } from '../constants'; import { CoreSharedFilesChooseSitePage } from '../pages/choose-site/choose-site'; import { CoreError } from '@classes/errors/error'; import { CorePlatform } from '@services/platform'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; /** * Helper service to share files with the app. diff --git a/src/core/features/sitehome/pages/index/index.ts b/src/core/features/sitehome/pages/index/index.ts index 07672dbe9..3de7c9f64 100644 --- a/src/core/features/sitehome/pages/index/index.ts +++ b/src/core/features/sitehome/pages/index/index.ts @@ -31,7 +31,7 @@ import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ContextLevel } from '@/core/constants'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; /** * Page that displays site home index. diff --git a/src/core/features/siteplugins/classes/call-ws-click-directive.ts b/src/core/features/siteplugins/classes/call-ws-click-directive.ts index bb656d9c3..0dca4e0b1 100644 --- a/src/core/features/siteplugins/classes/call-ws-click-directive.ts +++ b/src/core/features/siteplugins/classes/call-ws-click-directive.ts @@ -20,7 +20,7 @@ import { Translate } from '@singletons'; import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content'; import { CoreSitePluginsCallWSBaseDirective } from './call-ws-directive'; import { toBoolean } from '@/core/transforms/boolean'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Base class for directives to call a WS when the element is clicked. diff --git a/src/core/features/siteplugins/components/module-index/module-index.ts b/src/core/features/siteplugins/components/module-index/module-index.ts index 4ffd03c41..ba424a0fd 100644 --- a/src/core/features/siteplugins/components/module-index/module-index.ts +++ b/src/core/features/siteplugins/components/module-index/module-index.ts @@ -28,7 +28,7 @@ import { CoreSitePluginsContent, CoreSitePluginsCourseModuleHandlerData, } from '@features/siteplugins/services/siteplugins'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreUtils } from '@singletons/utils'; import { CoreSitePluginsPluginContentComponent, CoreSitePluginsPluginContentLoadedData } from '../plugin-content/plugin-content'; import { CoreCompileHtmlComponentModule } from '@features/compile/components/compile-html/compile-html.module'; diff --git a/src/core/features/siteplugins/directives/call-ws.ts b/src/core/features/siteplugins/directives/call-ws.ts index 8b29b4d6b..b18162b7a 100644 --- a/src/core/features/siteplugins/directives/call-ws.ts +++ b/src/core/features/siteplugins/directives/call-ws.ts @@ -15,7 +15,7 @@ import { Directive, Input, ElementRef, Optional } from '@angular/core'; import { Translate } from '@singletons'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; import { CoreNavigator } from '@services/navigator'; import { CoreSitePluginsCallWSOnClickBaseDirective } from '../classes/call-ws-click-directive'; import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content'; diff --git a/src/core/features/user/pages/about/about.ts b/src/core/features/user/pages/about/about.ts index a0b3b092d..37860bd11 100644 --- a/src/core/features/user/pages/about/about.ts +++ b/src/core/features/user/pages/about/about.ts @@ -32,7 +32,7 @@ import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuplo import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { Translate } from '@singletons'; import { CoreUrl } from '@singletons/url'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreTime } from '@singletons/time'; /** diff --git a/src/core/features/viewer/services/viewer.ts b/src/core/features/viewer/services/viewer.ts index 9efcfc277..94b7ac3bc 100644 --- a/src/core/features/viewer/services/viewer.ts +++ b/src/core/features/viewer/services/viewer.ts @@ -16,7 +16,7 @@ import { ContextLevel } from '@/core/constants'; import { Injectable } from '@angular/core'; import { ModalOptions } from '@ionic/angular'; import { CoreConfig } from '@services/config'; -import { CoreModals } from '@services/modals'; +import { CoreModals } from '@services/overlays/modals'; import { CoreNavigator } from '@services/navigator'; import { CoreWSFile } from '@services/ws'; import { makeSingleton } from '@singletons'; diff --git a/src/core/services/navigator.ts b/src/core/services/navigator.ts index 0c840b043..a6ea83392 100644 --- a/src/core/services/navigator.ts +++ b/src/core/services/navigator.ts @@ -32,7 +32,7 @@ import { CorePlatform } from '@services/platform'; import { filter } from 'rxjs/operators'; import { CorePromisedValue } from '@classes/promised-value'; import { BehaviorSubject } from 'rxjs'; -import { CoreLoadings } from './loadings'; +import { CoreLoadings } from './overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; /** diff --git a/src/core/services/loadings.ts b/src/core/services/overlays/loadings.ts similarity index 100% rename from src/core/services/loadings.ts rename to src/core/services/overlays/loadings.ts diff --git a/src/core/services/modals.ts b/src/core/services/overlays/modals.ts similarity index 99% rename from src/core/services/modals.ts rename to src/core/services/overlays/modals.ts index b8d5bc69a..0f68b2aa3 100644 --- a/src/core/services/modals.ts +++ b/src/core/services/overlays/modals.ts @@ -22,7 +22,7 @@ import { AngularFrameworkDelegate, makeSingleton, ModalController, Router } from import { CoreDirectivesRegistry } from '@singletons/directives-registry'; import { Subscription, filter } from 'rxjs'; import { Md5 } from 'ts-md5'; -import { fixOverlayAriaHidden } from '../utils/fix-aria-hidden'; +import { fixOverlayAriaHidden } from '../../utils/fix-aria-hidden'; import { ModalOptions } from '@ionic/angular'; import { CoreCanceledError } from '@classes/errors/cancelederror'; import { CoreWSError } from '@classes/errors/wserror'; diff --git a/src/core/services/popovers.ts b/src/core/services/overlays/popovers.ts similarity index 100% rename from src/core/services/popovers.ts rename to src/core/services/overlays/popovers.ts diff --git a/src/core/services/toasts.ts b/src/core/services/overlays/toasts.ts similarity index 100% rename from src/core/services/toasts.ts rename to src/core/services/overlays/toasts.ts diff --git a/src/core/services/qrscan.ts b/src/core/services/qrscan.ts index c4699e1b4..f46d46ae1 100644 --- a/src/core/services/qrscan.ts +++ b/src/core/services/qrscan.ts @@ -17,7 +17,7 @@ import { makeSingleton } from '@singletons'; import { CoreCanceledError } from '@classes/errors/cancelederror'; import { CorePromisedValue } from '@classes/promised-value'; import { QRScanner } from '@features/native/plugins'; -import { CoreModals } from './modals'; +import { CoreModals } from './overlays/modals'; import { CorePlatform } from './platform'; import { Subscription } from 'rxjs'; import { CoreCustomURLSchemes } from './urlschemes'; diff --git a/src/core/services/urlschemes.ts b/src/core/services/urlschemes.ts index 05b4cca6a..a6a9d351d 100644 --- a/src/core/services/urlschemes.ts +++ b/src/core/services/urlschemes.ts @@ -29,7 +29,7 @@ import { CoreSiteCheckResponse, CoreSites } from './sites'; import { CoreDomUtils } from './utils/dom'; import { CoreErrorHelper, CoreErrorObject } from './error-helper'; import { CoreUrl } from '@singletons/url'; -import { CoreLoadings } from './loadings'; +import { CoreLoadings } from './overlays/loadings'; /* * Provider to handle custom URL schemes. diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index 5ca591d25..5b4f403f6 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -48,12 +48,12 @@ import { CorePasswordModalParams, CorePasswordModalResponse } from '@components/ import { CoreErrorLogs } from '@singletons/error-logs'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreWait } from '@singletons/wait'; -import { CoreToasts, ToastDuration, ShowToastOptions } from '../toasts'; +import { CoreToasts, ToastDuration, ShowToastOptions } from '../overlays/toasts'; import { fixOverlayAriaHidden } from '@/core/utils/fix-aria-hidden'; -import { CoreModals, OpenModalOptions } from '@services/modals'; -import { CorePopovers, OpenPopoverOptions } from '@services/popovers'; +import { CoreModals, OpenModalOptions } from '@services/overlays/modals'; +import { CorePopovers, OpenPopoverOptions } from '@services/overlays/popovers'; import { CoreViewer } from '@features/viewer/services/viewer'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CoreErrorHelper, CoreErrorObject } from '@services/error-helper'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { CoreHTMLClasses } from '@singletons/html-classes'; diff --git a/src/core/services/utils/iframe.ts b/src/core/services/utils/iframe.ts index 327fa6a62..2cdaeace1 100644 --- a/src/core/services/utils/iframe.ts +++ b/src/core/services/utils/iframe.ts @@ -35,7 +35,7 @@ import { CoreMimetypeUtils } from './mimetype'; import { CoreFilepool } from '@services/filepool'; import { CoreSite } from '@classes/sites/site'; import { CoreNative } from '@features/native/services/native'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreFileUtils } from '@singletons/file-utils'; diff --git a/src/core/singletons/text.ts b/src/core/singletons/text.ts index 19f0c49fc..1a542bc32 100644 --- a/src/core/singletons/text.ts +++ b/src/core/singletons/text.ts @@ -13,7 +13,7 @@ // limitations under the License. import { Clipboard, Translate } from '@singletons'; -import { CoreToasts } from '@services/toasts'; +import { CoreToasts } from '@services/overlays/toasts'; import { Locutus } from './locutus'; import { CoreError } from '@classes/errors/error'; import { convertTextToHTMLElement } from '../utils/create-html-element'; diff --git a/src/testing/utils.ts b/src/testing/utils.ts index 633f6f6b2..9c4566801 100644 --- a/src/testing/utils.ts +++ b/src/testing/utils.ts @@ -27,7 +27,7 @@ import { CoreNetwork } from '@services/network'; import { CorePlatform } from '@services/platform'; import { CoreDB } from '@services/db'; import { CoreNavigator, CoreNavigatorService } from '@services/navigator'; -import { CoreLoadings } from '@services/loadings'; +import { CoreLoadings } from '@services/overlays/loadings'; import { TranslateModule, TranslateService, TranslateStore } from '@ngx-translate/core'; import { CoreIonLoadingElement } from '@classes/ion-loading'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; diff --git a/src/types/config.d.ts b/src/types/config.d.ts index c618ae9fd..99074637d 100644 --- a/src/types/config.d.ts +++ b/src/types/config.d.ts @@ -18,7 +18,7 @@ import { CoreLoginSiteInfo, CoreSitesDemoSiteData } from '@services/sites'; import { OpenFileAction } from '@singletons/opener'; import { CoreLoginSiteFinderSettings, CoreLoginSiteSelectorListMethod } from '@features/login/services/login-helper'; import { CoreDatabaseConfiguration } from '@classes/database/database-table'; -import { ToastDuration } from '@services/toasts'; +import { ToastDuration } from '@services/overlays/toasts'; /* eslint-disable @typescript-eslint/naming-convention */ From c2a500976d8349d5c7b7740a4ed2f0290c623bb9 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 13 Jan 2025 08:16:36 +0100 Subject: [PATCH 2/5] MOBILE-4724 core: Create CoreAlerts and CorePrompts --- .../badges/pages/badge-class/badge-class.ts | 4 +- .../badges/pages/issued-badge/issued-badge.ts | 4 +- .../badges/pages/user-badges/user-badges.ts | 4 +- .../components/myoverview/myoverview.ts | 7 +- .../timeline/components/timeline/timeline.ts | 6 +- .../blog/pages/edit-entry/edit-entry.ts | 12 +- src/addons/blog/pages/index/index.ts | 15 +- .../calendar/components/calendar/calendar.ts | 6 +- .../upcoming-events/upcoming-events.ts | 4 +- src/addons/calendar/pages/day/day.ts | 10 +- .../calendar/pages/edit-event/edit-event.ts | 12 +- src/addons/calendar/pages/event/event.ts | 28 +- src/addons/calendar/pages/index/index.ts | 10 +- .../pages/competencies/competencies.page.ts | 4 +- .../pages/competency/competency.page.ts | 7 +- .../competencysummary.page.ts | 7 +- .../coursecompetencies.page.ts | 6 +- src/addons/competency/pages/plan/plan.ts | 7 +- .../competency/pages/planlist/planlist.ts | 4 +- .../coursecompletion/pages/report/report.ts | 9 +- .../enrol/guest/services/enrol-handler.ts | 4 +- .../enrol/self/services/enrol-handler.ts | 17 +- .../airnotifier/pages/devices/devices.ts | 7 +- .../airnotifier/services/airnotifier.ts | 53 +- .../conversation-info.component.ts | 6 +- .../messages/pages/contacts-35/contacts.ts | 6 +- .../messages/pages/contacts/contacts.ts | 7 +- .../messages/pages/discussion/discussion.ts | 76 +-- .../pages/discussions-35/discussions.ts | 6 +- .../group-conversations.ts | 8 +- src/addons/messages/pages/search/search.ts | 5 +- .../messages/pages/settings/settings.ts | 10 +- .../edit-feedback-modal.ts | 4 +- .../mod/assign/components/index/index.ts | 5 +- .../components/submission/submission.ts | 25 +- src/addons/mod/assign/pages/edit/edit.ts | 11 +- .../pages/submission-list/submission-list.ts | 7 +- .../submission-review/submission-review.ts | 7 +- .../bigbluebuttonbn/components/index/index.ts | 17 +- .../mod/book/pages/contents/contents.ts | 7 +- .../components/users-modal/users-modal.ts | 6 +- src/addons/mod/chat/pages/chat/chat.ts | 10 +- .../session-messages/session-messages.ts | 7 +- .../mod/chat/pages/sessions/sessions.ts | 9 +- .../mod/choice/components/index/index.ts | 10 +- src/addons/mod/data/components/index/index.ts | 6 +- .../data/fields/latlong/component/latlong.ts | 8 +- src/addons/mod/data/pages/edit/edit.ts | 15 +- src/addons/mod/data/pages/entry/entry.ts | 8 +- src/addons/mod/data/services/data-helper.ts | 7 +- .../mod/feedback/pages/attempt/attempt.ts | 8 +- .../mod/feedback/pages/attempts/attempts.ts | 12 +- src/addons/mod/feedback/pages/form/form.ts | 12 +- .../pages/nonrespondents/nonrespondents.ts | 10 +- .../mod/feedback/services/feedback-helper.ts | 4 +- .../services/handlers/analysis-link.ts | 4 +- .../services/handlers/complete-link.ts | 4 +- .../feedback/services/handlers/print-link.ts | 4 +- .../handlers/show-non-respondents-link.ts | 4 +- .../discussion-options-menu.ts | 8 +- .../mod/forum/components/index/index.ts | 8 +- .../post-options-menu/post-options-menu.ts | 8 +- src/addons/mod/forum/components/post/post.ts | 24 +- .../mod/forum/pages/discussion/discussion.ts | 20 +- .../pages/new-discussion/new-discussion.ts | 23 +- src/addons/mod/forum/pages/search/search.ts | 3 +- .../mod/glossary/components/index/index.ts | 4 +- src/addons/mod/glossary/pages/edit/edit.ts | 12 +- src/addons/mod/glossary/pages/entry/entry.ts | 12 +- .../glossary/services/handlers/edit-link.ts | 6 +- .../glossary/services/handlers/entry-link.ts | 6 +- .../mod/h5pactivity/components/index/index.ts | 23 +- .../pages/attempt-results/attempt-results.ts | 7 +- .../mod/h5pactivity/pages/index/index.ts | 4 +- .../pages/user-attempts/user-attempts.ts | 7 +- .../pages/users-attempts/users-attempts.ts | 9 +- .../services/handlers/report-link.ts | 4 +- src/addons/mod/imscp/pages/view/view.ts | 9 +- .../mod/lesson/components/index/index.ts | 12 +- src/addons/mod/lesson/pages/player/player.ts | 20 +- .../lesson/pages/user-retake/user-retake.ts | 9 +- .../lesson/services/handlers/grade-link.ts | 6 +- .../mod/lesson/services/handlers/prefetch.ts | 4 +- .../lesson/services/handlers/report-link.ts | 6 +- src/addons/mod/lti/services/lti-helper.ts | 6 +- src/addons/mod/quiz/components/index/index.ts | 6 +- .../preflight-modal/preflight-modal.ts | 7 +- src/addons/mod/quiz/pages/player/player.ts | 29 +- src/addons/mod/quiz/pages/review/review.ts | 10 +- src/addons/mod/quiz/services/quiz-helper.ts | 5 +- .../mod/resource/components/index/index.ts | 9 +- .../mod/resource/services/resource-helper.ts | 4 +- .../mod/scorm/components/index/index.ts | 11 +- .../pages/online-player/online-player.ts | 8 +- src/addons/mod/scorm/pages/player/player.ts | 16 +- src/addons/mod/scorm/services/scorm-helper.ts | 4 +- .../services/handlers/index-link.ts | 4 +- .../mod/survey/components/index/index.ts | 6 +- src/addons/mod/wiki/components/index/index.ts | 4 +- src/addons/mod/wiki/pages/edit/edit.ts | 21 +- .../services/handlers/create-link-lazy.ts | 6 +- .../wiki/services/handlers/edit-link-lazy.ts | 6 +- .../handlers/page-or-map-link-lazy.ts | 6 +- .../assessment-strategy.ts | 6 +- .../components/assessment/assessment.ts | 4 +- .../workshop/pages/assessment/assessment.ts | 10 +- .../pages/edit-submission/edit-submission.ts | 20 +- .../workshop/pages/submission/submission.ts | 14 +- src/addons/notes/components/add/add-modal.ts | 4 +- src/addons/notes/pages/list/list.ts | 14 +- src/addons/notifications/pages/list/list.ts | 9 +- .../pages/notification/notification.ts | 4 +- .../notifications/pages/settings/settings.ts | 10 +- src/addons/privatefiles/pages/index/index.ts | 29 +- .../insights/services/handlers/action-link.ts | 4 +- .../pages/course-storage/course-storage.ts | 42 +- .../pages/courses-storage/courses-storage.ts | 18 +- src/core/classes/sites/site.ts | 13 +- .../components/attachments/attachments.ts | 8 +- src/core/components/file/file.ts | 15 +- src/core/components/iframe/iframe.ts | 6 +- src/core/components/local-file/local-file.ts | 11 +- src/core/directives/download-file.ts | 5 +- src/core/directives/format-text.ts | 3 +- src/core/directives/link.ts | 4 +- .../block/classes/base-block-component.ts | 5 +- .../components/side-blocks/side-blocks.ts | 5 +- .../features/comments/pages/viewer/viewer.ts | 26 +- .../components/compile-html/compile-html.ts | 3 +- .../choose-site-modal/choose-site-modal.ts | 4 +- .../services/contentlinks-helper.ts | 4 +- .../course/classes/main-activity-component.ts | 9 +- .../course/classes/main-activity-page.ts | 5 +- .../course/classes/main-resource-component.ts | 7 +- .../components/course-format/course-format.ts | 5 +- .../module-navigation/module-navigation.ts | 8 +- .../module-summary/module-summary.ts | 18 +- .../directives/download-module-main-file.ts | 6 +- .../course/pages/contents/contents.ts | 11 +- .../course-summary/course-summary.page.ts | 15 +- src/core/features/course/pages/index/index.ts | 4 +- .../pages/list-mod-type/list-mod-type.ts | 6 +- .../pages/module-preview/module-preview.ts | 5 +- .../features/course/services/course-helper.ts | 16 +- src/core/features/course/services/course.ts | 9 +- .../course-list-item/course-list-item.ts | 22 +- .../courses/pages/categories/categories.ts | 8 +- .../courses/pages/dashboard/dashboard.ts | 4 +- src/core/features/courses/pages/list/list.ts | 6 +- src/core/features/courses/pages/my/my.ts | 4 +- .../services/handlers/enrol-push-click.ts | 4 +- .../services/handlers/request-push-click.ts | 4 +- .../components/contactdpo/contactdpo.ts | 4 +- .../components/newrequest/newrequest.ts | 4 +- .../features/dataprivacy/pages/main/main.ts | 15 +- .../components/capture-media/capture-media.ts | 8 +- .../audio-recorder.component.ts | 14 +- .../services/fileuploader-helper.ts | 26 +- .../fileuploader/services/handlers/file.ts | 10 +- .../grades/pages/course/course.page.ts | 8 +- .../features/grades/pages/courses/courses.ts | 4 +- .../h5p/components/h5p-iframe/h5p-iframe.ts | 5 +- .../h5p/components/h5p-player/h5p-player.ts | 12 +- .../identity-provider/identity-provider.ts | 4 +- .../components/sites-modal/sites-modal.ts | 9 +- .../login/pages/credentials/credentials.ts | 15 +- .../login/pages/email-signup/email-signup.ts | 23 +- .../forgotten-password/forgotten-password.ts | 15 +- .../login/pages/reconnect/reconnect.ts | 8 +- src/core/features/login/pages/site/site.ts | 14 +- src/core/features/login/pages/sites/sites.ts | 10 +- .../features/login/services/login-helper.ts | 56 +- .../components/user-menu/user-menu.ts | 6 +- .../policy/pages/acceptances/acceptances.ts | 6 +- .../policy/pages/site-policy/site-policy.ts | 14 +- .../question/services/question-helper.ts | 3 +- .../features/rating/components/rate/rate.ts | 4 +- .../rating/components/ratings/ratings.ts | 4 +- .../components/report-detail/report-detail.ts | 10 +- .../features/reportbuilder/pages/list/list.ts | 8 +- src/core/features/settings/pages/dev/dev.ts | 3 +- .../settings/pages/general/general.ts | 6 +- src/core/features/settings/pages/site/site.ts | 6 +- .../pages/synchronization/synchronization.ts | 12 +- .../settings/services/settings-helper.ts | 14 +- .../pages/choose-site/choose-site.ts | 6 +- .../services/sharedfiles-helper.ts | 11 +- .../features/sitehome/pages/index/index.ts | 5 +- .../classes/call-ws-click-directive.ts | 11 +- .../plugin-content/plugin-content.ts | 5 +- .../tag/pages/index-area/index-area.ts | 4 +- src/core/features/tag/pages/index/index.ts | 4 +- src/core/features/tag/pages/search/search.ts | 7 +- src/core/features/user/pages/about/about.ts | 8 +- .../pages/participants/participants.page.ts | 10 +- .../features/user/pages/profile/profile.ts | 6 +- src/core/features/user/services/support.ts | 6 +- .../components/qr-scanner/qr-scanner.ts | 7 +- .../features/viewer/pages/iframe/iframe.ts | 5 +- .../initializers/prepare-inapp-browser.ts | 4 +- src/core/services/error-helper.ts | 54 ++ src/core/services/file-helper.ts | 15 +- src/core/services/local-notifications.ts | 4 +- src/core/services/overlays/alerts.ts | 535 ++++++++++++++++ src/core/services/overlays/modals.ts | 24 +- src/core/services/overlays/prompts.ts | 165 +++++ src/core/services/sites.ts | 20 +- .../dom.test.ts => overlays/alerts.test.ts} | 38 +- src/core/services/urlschemes.ts | 8 +- src/core/services/utils/dom.ts | 594 ++---------------- src/core/services/utils/iframe.ts | 9 +- src/core/singletons/opener.ts | 11 +- 212 files changed, 1824 insertions(+), 1612 deletions(-) create mode 100644 src/core/services/overlays/alerts.ts create mode 100644 src/core/services/overlays/prompts.ts rename src/core/services/tests/{utils/dom.test.ts => overlays/alerts.test.ts} (61%) diff --git a/src/addons/badges/pages/badge-class/badge-class.ts b/src/addons/badges/pages/badge-class/badge-class.ts index f7c6c9bbb..fe7f3ce2f 100644 --- a/src/addons/badges/pages/badge-class/badge-class.ts +++ b/src/addons/badges/pages/badge-class/badge-class.ts @@ -13,13 +13,13 @@ // limitations under the License. import { Component, OnInit } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreNavigator } from '@services/navigator'; import { ActivatedRoute } from '@angular/router'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreTime } from '@singletons/time'; import { AddonBadges, AddonBadgesBadgeClass } from '../../services/badges'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a badge class. @@ -71,7 +71,7 @@ export class AddonBadgesBadgeClassPage implements OnInit { this.logView(this.badge); } catch (message) { - CoreDomUtils.showErrorModalDefault(message, 'Error getting badge data.'); + CoreAlerts.showError(message, { default: 'Error getting badge data.' }); } } diff --git a/src/addons/badges/pages/issued-badge/issued-badge.ts b/src/addons/badges/pages/issued-badge/issued-badge.ts index 44f0e5405..da41ace7b 100644 --- a/src/addons/badges/pages/issued-badge/issued-badge.ts +++ b/src/addons/badges/pages/issued-badge/issued-badge.ts @@ -14,7 +14,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CoreTimeUtils } from '@services/utils/time'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSites } from '@services/sites'; import { CoreUser } from '@features/user/services/user'; import { AddonBadges, AddonBadgesUserBadge } from '../../services/badges'; @@ -28,6 +27,7 @@ import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreTime } from '@singletons/time'; import { CoreSharedModule } from '@/core/shared.module'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays an issued badge. @@ -141,7 +141,7 @@ export class AddonBadgesIssuedBadgePage implements OnInit, OnDestroy { this.logView(badge); } catch (message) { - CoreDomUtils.showErrorModalDefault(message, 'Error getting badge data.'); + CoreAlerts.showError(message, { default: 'Error getting badge data.' }); } } diff --git a/src/addons/badges/pages/user-badges/user-badges.ts b/src/addons/badges/pages/user-badges/user-badges.ts index 18cca0ec4..d44eb46ad 100644 --- a/src/addons/badges/pages/user-badges/user-badges.ts +++ b/src/addons/badges/pages/user-badges/user-badges.ts @@ -15,7 +15,6 @@ import { AfterViewInit, Component, OnDestroy, ViewChild } from '@angular/core'; import { AddonBadges, AddonBadgesUserBadge } from '../../services/badges'; import { CoreTimeUtils } from '@services/utils/time'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSites } from '@services/sites'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; @@ -26,6 +25,7 @@ import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreTime } from '@singletons/time'; import { Translate } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of calendar events. @@ -112,7 +112,7 @@ export class AddonBadgesUserBadgesPage implements AfterViewInit, OnDestroy { this.logView(); } catch (message) { - CoreDomUtils.showErrorModalDefault(message, 'Error loading badges'); + CoreAlerts.showError(message, { default: 'Error loading badges' }); this.badges.reset(); } diff --git a/src/addons/block/myoverview/components/myoverview/myoverview.ts b/src/addons/block/myoverview/components/myoverview/myoverview.ts index 026f61a4d..14e73f713 100644 --- a/src/addons/block/myoverview/components/myoverview/myoverview.ts +++ b/src/addons/block/myoverview/components/myoverview/myoverview.ts @@ -27,7 +27,6 @@ import { CoreCourseOptionsDelegate } from '@features/course/services/course-opti import { CoreBlockBaseComponent } from '@features/block/classes/base-block-component'; import { CoreSite } from '@classes/sites/site'; import { CorePromiseUtils } from '@singletons/promise-utils'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { AddonCourseCompletion } from '@addons/coursecompletion/services/coursecompletion'; import { IonSearchbar } from '@ionic/angular'; @@ -43,6 +42,8 @@ import { CORE_COURSES_STATE_FAVOURITE, CORE_COURSES_STATE_HIDDEN, } from '@features/courses/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; const FILTER_PRIORITY: AddonBlockMyOverviewTimeFilters[] = ['all', 'inprogress', 'future', 'past', 'favourite', 'allincludinghidden', 'hidden', 'custom']; @@ -504,7 +505,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem await CoreCourseHelper.prefetchCourses(this.filteredCourses, this.prefetchCoursesData); } catch (error) { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errordownloadingcourse') }); this.prefetchCoursesData.icon = initialIcon; } } @@ -566,7 +567,7 @@ export class AddonBlockMyOverviewComponent extends CoreBlockBaseComponent implem throw error; // Pass the error to the caller so it's treated there. } - CoreDomUtils.showErrorModalDefault(error, this.fetchContentDefaultError); + CoreAlerts.showError(error, { default: this.fetchContentDefaultError }); } finally { if (!alreadyLoading) { // Only set loaded to true if there was no other data being loaded. diff --git a/src/addons/block/timeline/components/timeline/timeline.ts b/src/addons/block/timeline/components/timeline/timeline.ts index fe552eed2..052a8a2f6 100644 --- a/src/addons/block/timeline/components/timeline/timeline.ts +++ b/src/addons/block/timeline/components/timeline/timeline.ts @@ -17,7 +17,6 @@ import { CoreSites } from '@services/sites'; import { ICoreBlockComponent } from '@features/block/classes/base-block-component'; import { AddonBlockTimeline } from '../../services/timeline'; import { CorePromiseUtils } from '@singletons/promise-utils'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCoursesHelper, CoreEnrolledCourseDataWithOptions } from '@features/courses/services/courses-helper'; import { CoreCourses } from '@features/courses/services/courses'; import { CoreCourseOptionsDelegate } from '@features/course/services/course-options-delegate'; @@ -30,6 +29,7 @@ import { CoreLogger } from '@singletons/logger'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreSearchComponentsModule } from '@features/search/components/components.module'; import { AddonBlockTimelineEventsComponent } from '../events/events'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component to render a timeline block. @@ -211,9 +211,7 @@ export class AddonBlockTimelineComponent implements OnInit, ICoreBlockComponent catchError(error => { // An error ocurred in the function, log the error and just resolve the observable so the workflow continues. this.logger.error(error); - - // Error getting data, fail. - CoreDomUtils.showErrorModalDefault(error, this.fetchContentDefaultError, true); + CoreAlerts.showError(error, { default: this.fetchContentDefaultError }); return of([] as AddonBlockTimelineSection[]); }), diff --git a/src/addons/blog/pages/edit-entry/edit-entry.ts b/src/addons/blog/pages/edit-entry/edit-entry.ts index cbfb0e3f8..778667479 100644 --- a/src/addons/blog/pages/edit-entry/edit-entry.ts +++ b/src/addons/blog/pages/edit-entry/edit-entry.ts @@ -40,7 +40,6 @@ import { CoreNavigator } from '@services/navigator'; import { CoreNetwork } from '@services/network'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreWSError } from '@classes/errors/wserror'; import { Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; @@ -48,6 +47,7 @@ import { CoreForms } from '@singletons/form'; import { CoreFileEntry } from '@services/file-helper'; import { CoreTimeUtils } from '@services/utils/time'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; @Component({ selector: 'addon-blog-edit-entry', @@ -164,7 +164,7 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr this.associatedCourse = course; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting associations, they may not be displayed correctly.'); + CoreAlerts.showError(error, { default: 'Error getting associations, they may not be displayed correctly.' }); } return; @@ -204,7 +204,7 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr this.associatedModule = await CoreCourse.getModule(this.modId); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error retrieving data.'); + CoreAlerts.showError(error, { default: 'Error retrieving data.' }); this.forceLeave = true; CoreNavigator.back(); @@ -338,7 +338,7 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr } catch (error) { if (CoreWSError.isWebServiceError(error)) { // It's a WebService error, the user cannot send the message so don't store it. - CoreDomUtils.showErrorModalDefault(error, 'Error updating entry.'); + CoreAlerts.showError(error, { default: 'Error updating entry.' }); return; } @@ -363,7 +363,7 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr } catch (error) { if (CoreWSError.isWebServiceError(error)) { // It's a WebService error, the user cannot send the message so don't store it. - CoreDomUtils.showErrorModalDefault(error, 'Error creating entry.'); + CoreAlerts.showError(error, { default: 'Error creating entry.' }); return; } @@ -412,7 +412,7 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr if ((!this.entry && this.hasDataChangedForNewEntry) || (this.entry && this.hasDataChangedForEdit)) { // Modified, confirm user wants to go back. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId()); diff --git a/src/addons/blog/pages/index/index.ts b/src/addons/blog/pages/index/index.ts index e486d4985..822973610 100644 --- a/src/addons/blog/pages/index/index.ts +++ b/src/addons/blog/pages/index/index.ts @@ -34,7 +34,6 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreNavigator } from '@services/navigator'; import { CoreNetwork } from '@services/network'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreArray } from '@singletons/array'; @@ -43,6 +42,8 @@ import { CoreTime } from '@singletons/time'; import { CorePopovers } from '@services/overlays/popovers'; import { CoreLoadings } from '@services/overlays/loadings'; import { Subscription } from 'rxjs'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays the list of blog entries. @@ -236,7 +237,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { const result = await AddonBlogSync.syncEntriesForSite(CoreSites.getCurrentSiteId()); if (result.warnings && result.warnings.length) { - CoreDomUtils.showAlert(undefined, result.warnings[0]); + CoreAlerts.show({ message: result.warnings[0] }); } if (result.updated) { @@ -244,7 +245,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { } } catch (error) { if (showSyncErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') }); } } } @@ -281,7 +282,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { this.pageLoaded++; this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.blog.errorloadentries', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.blog.errorloadentries') }); this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading. } finally { this.loaded.set(true); @@ -338,7 +339,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { this.filter.userid = !enabled ? undefined : this.currentUserId; await this.fetchEntries(true); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.blog.errorloadentries', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.blog.errorloadentries') }); this.onlyMyEntries = !enabled; this.filter.userid = !enabled ? this.currentUserId : undefined; } finally { @@ -418,7 +419,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { */ async deleteEntry(entryToRemove: AddonBlogOfflinePostFormatted | AddonBlogPostFormatted): Promise { try { - await CoreDomUtils.showDeleteConfirm('addon.blog.blogdeleteconfirm', { $a: entryToRemove.subject }); + await CoreAlerts.confirmDelete(Translate.instant('addon.blog.blogdeleteconfirm', { $a: entryToRemove.subject })); } catch { return; } @@ -434,7 +435,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy { CoreEvents.trigger(ADDON_BLOG_ENTRY_UPDATED); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.blog.errorloadentries', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.blog.errorloadentries') }); } finally { loading.dismiss(); } diff --git a/src/addons/calendar/components/calendar/calendar.ts b/src/addons/calendar/components/calendar/calendar.ts index 46840cabb..a57be8685 100644 --- a/src/addons/calendar/components/calendar/calendar.ts +++ b/src/addons/calendar/components/calendar/calendar.ts @@ -27,7 +27,6 @@ import { } from '@angular/core'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreArray } from '@singletons/array'; import { @@ -54,6 +53,7 @@ import { CoreTime } from '@singletons/time'; import { Translate } from '@singletons'; import { toBoolean } from '@/core/transforms/boolean'; import { ADDON_CALENDAR_UNDELETED_EVENT_EVENT } from '@addons/calendar/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a calendar. @@ -204,7 +204,7 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.calendar.errorloadevents') }); } this.loaded = true; @@ -358,7 +358,7 @@ export class AddonCalendarCalendarComponent implements OnInit, DoCheck, OnDestro this.swipeSlidesComponent.slideToItem(item); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.calendar.errorloadevents') }); } finally { this.loaded = true; } diff --git a/src/addons/calendar/components/upcoming-events/upcoming-events.ts b/src/addons/calendar/components/upcoming-events/upcoming-events.ts index c96493a03..eeea2122b 100644 --- a/src/addons/calendar/components/upcoming-events/upcoming-events.ts +++ b/src/addons/calendar/components/upcoming-events/upcoming-events.ts @@ -15,7 +15,6 @@ import { Component, OnDestroy, OnInit, Input, DoCheck, Output, EventEmitter, KeyValueDiffers, KeyValueDiffer } from '@angular/core'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { AddonCalendarEventToDisplay, AddonCalendar, @@ -29,6 +28,7 @@ import { CoreUrl } from '@singletons/url'; import { CoreTime } from '@singletons/time'; import { Translate } from '@singletons'; import { ADDON_CALENDAR_UNDELETED_EVENT_EVENT } from '@addons/calendar/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays upcoming events. @@ -174,7 +174,7 @@ export class AddonCalendarUpcomingEventsComponent implements OnInit, DoCheck, On this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.calendar.errorloadevents') }); } this.loaded = true; diff --git a/src/addons/calendar/pages/day/day.ts b/src/addons/calendar/pages/day/day.ts index 3f8badc77..ea254d7e9 100644 --- a/src/addons/calendar/pages/day/day.ts +++ b/src/addons/calendar/pages/day/day.ts @@ -16,7 +16,6 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { CoreNetwork } from '@services/network'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTimeUtils } from '@services/utils/time'; import { AddonCalendar, @@ -59,6 +58,7 @@ import { AddonCalendarEventType, } from '@addons/calendar/constants'; import { CoreObject } from '@singletons/object'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the calendar events for a certain day. @@ -277,7 +277,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.calendar.errorloadevents') }); } this.loaded = true; @@ -343,7 +343,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy { const result = await AddonCalendarSync.syncEvents(); if (result.warnings && result.warnings.length) { - CoreDomUtils.showAlert(undefined, result.warnings[0]); + CoreAlerts.show({ message: result.warnings[0] }); } if (result.updated) { @@ -357,7 +357,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy { } } catch (error) { if (showErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') }); } } } @@ -454,7 +454,7 @@ export class AddonCalendarDayPage implements OnInit, OnDestroy { this.swipeSlidesComponent.slideToItem(currentDay); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.calendar.errorloadevents') }); } finally { this.loaded = true; } diff --git a/src/addons/calendar/pages/edit-event/edit-event.ts b/src/addons/calendar/pages/edit-event/edit-event.ts index 1990a141b..4aeee891f 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.ts +++ b/src/addons/calendar/pages/edit-event/edit-event.ts @@ -18,7 +18,6 @@ import { CoreEvents } from '@singletons/events'; import { CoreGroup, CoreGroups } from '@services/groups'; import { CoreSites } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreUtils } from '@singletons/utils'; import { CoreCategoryData, CoreCourses, CoreCourseSearchedData, CoreEnrolledCourseData } from '@features/courses/services/courses'; @@ -54,6 +53,7 @@ import { CorePopovers } from '@services/overlays/popovers'; import { CoreLoadings } from '@services/overlays/loadings'; import { REMINDERS_DISABLED, CoreRemindersUnits } from '@features/reminders/constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a form to create/edit an event. @@ -253,7 +253,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { this.eventTypes = eventTypes; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting data.'); + CoreAlerts.showError(error, { default: 'Error getting data.' }); this.error = true; } } @@ -421,7 +421,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { this.groupControl.setValue(null); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting data.'); + CoreAlerts.showError(error, { default: 'Error getting data.' }); } modal.dismiss(); @@ -475,7 +475,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { if (error) { // Show error and stop. - CoreDomUtils.showErrorModal(Translate.instant(error)); + CoreAlerts.showError(Translate.instant(error)); return; } @@ -548,7 +548,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { this.returnToList(event); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error sending data.'); + CoreAlerts.showError(error, { default: 'Error sending data.' }); } modal.dismiss(); @@ -593,7 +593,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { async canLeave(): Promise { if (AddonCalendarHelper.hasEventDataChanged(this.form.value, this.originalData)) { // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } CoreForms.triggerFormCancelledEvent(this.formElement, this.currentSite.getId()); diff --git a/src/addons/calendar/pages/event/event.ts b/src/addons/calendar/pages/event/event.ts index ddc5db7c7..64525cce0 100644 --- a/src/addons/calendar/pages/event/event.ts +++ b/src/addons/calendar/pages/event/event.ts @@ -13,7 +13,6 @@ // limitations under the License. import { Component, OnDestroy, OnInit } from '@angular/core'; -import { AlertOptions } from '@ionic/core'; import { AddonCalendar, AddonCalendarEventToDisplay, @@ -23,7 +22,6 @@ import { AddonCalendarOffline } from '../../services/calendar-offline'; import { AddonCalendarSync, AddonCalendarSyncEvents } from '../../services/calendar-sync'; import { CoreNetwork } from '@services/network'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreSites } from '@services/sites'; import { CoreCourse } from '@features/course/services/course'; @@ -55,6 +53,7 @@ import { ADDON_CALENDAR_UNDELETED_EVENT_EVENT, } from '@addons/calendar/constants'; import { REMINDERS_DEFAULT_NOTIFICATION_TIME_CHANGED } from '@features/reminders/constants'; +import { CoreAlerts, CoreAlertsConfirmOptions } from '@services/overlays/alerts'; /** * Page that displays a single calendar event. @@ -191,7 +190,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { try { this.eventId = CoreNavigator.getRequiredRouteNumberParam('id'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -243,7 +242,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { if (this.eventId < 0) { // It's an offline event, but it wasn't found. Shouldn't happen. - CoreDomUtils.showErrorModal('Event not found.'); + CoreAlerts.showError('Event not found.'); CoreNavigator.back(); return; @@ -318,7 +317,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { await Promise.all(promises); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevent', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.calendar.errorloadevent') }); } this.eventLoaded = true; @@ -357,7 +356,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { try { const result = await AddonCalendarSync.syncEvents(); if (result.warnings && result.warnings.length) { - CoreDomUtils.showAlert(undefined, result.warnings[0]); + CoreAlerts.show({ message: result.warnings[0] }); } if (result.deleted && result.deleted.indexOf(this.eventId) != -1) { @@ -380,7 +379,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { } } catch (error) { if (showErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') }); } } @@ -427,7 +426,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { e.stopPropagation(); try { - await CoreDomUtils.showDeleteConfirm(); + await CoreAlerts.confirmDelete(Translate.instant('core.areyousure')); const modal = await CoreLoadings.show('core.deleting', true); @@ -435,7 +434,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { await CoreReminders.removeReminder(id); await this.loadReminders(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error deleting reminder'); + CoreAlerts.showError(error, { default: 'Error deleting reminder' }); } finally { modal.dismiss(); } @@ -500,9 +499,10 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { return; } - const title = Translate.instant('addon.calendar.deleteevent'); - const options: AlertOptions = {}; let message: string; + const options: CoreAlertsConfirmOptions = { + header: Translate.instant('addon.calendar.deleteevent'), + }; if (this.event.eventcount > 1) { // It's a repeated event. @@ -534,7 +534,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { let deleteAll = false; try { - deleteAll = await CoreDomUtils.showConfirm(message, title, undefined, undefined, options); + deleteAll = await CoreAlerts.confirm(message, options); } catch { // User canceled. return; @@ -583,7 +583,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { this.event.deleted = true; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error deleting event.'); + CoreAlerts.showError(error, { default: 'Error deleting event.' }); } modal.dismiss(); @@ -611,7 +611,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { this.event.deleted = false; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error undeleting event.'); + CoreAlerts.showError(error, { default: 'Error undeleting event.' }); } modal.dismiss(); diff --git a/src/addons/calendar/pages/index/index.ts b/src/addons/calendar/pages/index/index.ts index f67248240..9a92d774f 100644 --- a/src/addons/calendar/pages/index/index.ts +++ b/src/addons/calendar/pages/index/index.ts @@ -16,13 +16,12 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { CoreNetwork } from '@services/network'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCoursesHelper } from '@features/courses/services/courses-helper'; import { AddonCalendar } from '../../services/calendar'; import { AddonCalendarOffline } from '../../services/calendar-offline'; import { AddonCalendarSync } from '../../services/calendar-sync'; import { AddonCalendarFilter, AddonCalendarHelper } from '../../services/calendar-helper'; -import { NgZone } from '@singletons'; +import { NgZone, Translate } from '@singletons'; import { Subscription } from 'rxjs'; import { CoreEnrolledCourseData } from '@features/courses/services/courses'; import { ActivatedRoute, Params } from '@angular/router'; @@ -41,6 +40,7 @@ import { ADDON_CALENDAR_NEW_EVENT_EVENT, ADDON_CALENDAR_UNDELETED_EVENT_EVENT, } from '@addons/calendar/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the calendar events. @@ -207,7 +207,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy { try { const result = await AddonCalendarSync.syncEvents(); if (result.warnings && result.warnings.length) { - CoreDomUtils.showAlert(undefined, result.warnings[0]); + CoreAlerts.show({ message: result.warnings[0] }); } if (result.updated) { @@ -222,7 +222,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy { } } catch (error) { if (showErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') }); } } } @@ -255,7 +255,7 @@ export class AddonCalendarIndexPage implements OnInit, OnDestroy { await Promise.all(promises); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.calendar.errorloadevents', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.calendar.errorloadevents') }); } this.loaded = true; diff --git a/src/addons/competency/pages/competencies/competencies.page.ts b/src/addons/competency/pages/competencies/competencies.page.ts index 023fc647d..a2617f031 100644 --- a/src/addons/competency/pages/competencies/competencies.page.ts +++ b/src/addons/competency/pages/competencies/competencies.page.ts @@ -13,7 +13,6 @@ // limitations under the License. import { AfterViewInit, Component, OnDestroy, ViewChild } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { AddonCompetencyDataForPlanPageCompetency, @@ -30,6 +29,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreSites } from '@services/sites'; import { CoreTime } from '@singletons/time'; import { ContextLevel } from '@/core/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of competencies of a learning plan. @@ -111,7 +111,7 @@ export class AddonCompetencyCompetenciesPage implements AfterViewInit, OnDestroy this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting competencies data.'); + CoreAlerts.showError(error, { default: 'Error getting competencies data.' }); } } diff --git a/src/addons/competency/pages/competency/competency.page.ts b/src/addons/competency/pages/competency/competency.page.ts index 94e4c67d7..fb91515ee 100644 --- a/src/addons/competency/pages/competency/competency.page.ts +++ b/src/addons/competency/pages/competency/competency.page.ts @@ -17,7 +17,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CoreCourseModuleSummary } from '@features/course/services/course'; import { CoreUserSummary } from '@features/user/services/user'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { AddonCompetencyDataForUserCompetencySummaryWSResponse, @@ -41,6 +40,7 @@ import { AddonCompetencyCourseCompetenciesSource } from '@addons/competency/clas import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreUrl } from '@singletons/url'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the competency information. @@ -86,8 +86,7 @@ export class AddonCompetencyCompetencyPage implements OnInit, OnDestroy { this.competencies = new AddonCompetencyCompetenciesSwipeManager(source); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -163,7 +162,7 @@ export class AddonCompetencyCompetencyPage implements OnInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting competency data.'); + CoreAlerts.showError(error, { default: 'Error getting competency data.' }); } } diff --git a/src/addons/competency/pages/competencysummary/competencysummary.page.ts b/src/addons/competency/pages/competencysummary/competencysummary.page.ts index 62cdc5c5e..39602f14f 100644 --- a/src/addons/competency/pages/competencysummary/competencysummary.page.ts +++ b/src/addons/competency/pages/competencysummary/competencysummary.page.ts @@ -16,11 +16,11 @@ import { Component, OnInit } from '@angular/core'; import { ContextLevel } from '@/core/constants'; import { AddonCompetencySummary, AddonCompetency } from '@addons/competency/services/competency'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/constants'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the competency summary. @@ -71,8 +71,7 @@ export class AddonCompetencyCompetencySummaryPage implements OnInit { this.contextLevel = CoreNavigator.getRouteParam('contextLevel'); this.contextInstanceId = CoreNavigator.getRouteNumberParam('contextInstanceId'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -103,7 +102,7 @@ export class AddonCompetencyCompetencySummaryPage implements OnInit { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting competency summary data.'); + CoreAlerts.showError(error, { default: 'Error getting competency summary data.' }); } } diff --git a/src/addons/competency/pages/coursecompetencies/coursecompetencies.page.ts b/src/addons/competency/pages/coursecompetencies/coursecompetencies.page.ts index f6d4adf12..9e6b15d1e 100644 --- a/src/addons/competency/pages/coursecompetencies/coursecompetencies.page.ts +++ b/src/addons/competency/pages/coursecompetencies/coursecompetencies.page.ts @@ -19,7 +19,6 @@ import { } from '@addons/competency/services/competency'; import { CoreUserProfile } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { ContextLevel } from '@/core/constants'; import { ADDON_COMPETENCY_SUMMARY_PAGE } from '@addons/competency/constants'; import { CoreListItemsManager } from '@classes/items-management/list-items-manager'; @@ -29,6 +28,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreSites } from '@services/sites'; import { Translate } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of competencies of a course. @@ -59,7 +59,7 @@ export class AddonCompetencyCourseCompetenciesPage implements OnInit, OnDestroy this.competencies = new CoreListItemsManager(source, AddonCompetencyCourseCompetenciesPage); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -121,7 +121,7 @@ export class AddonCompetencyCourseCompetenciesPage implements OnInit, OnDestroy this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting course competencies data.'); + CoreAlerts.showError(error, { default: 'Error getting course competencies data.' }); } } diff --git a/src/addons/competency/pages/plan/plan.ts b/src/addons/competency/pages/plan/plan.ts index 9f1d1f540..7c06548c2 100644 --- a/src/addons/competency/pages/plan/plan.ts +++ b/src/addons/competency/pages/plan/plan.ts @@ -13,7 +13,6 @@ // limitations under the License. import { Component, OnDestroy, OnInit } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { AddonCompetencyDataForPlanPageCompetency, AddonCompetencyDataForPlanPageWSResponse } from '../../services/competency'; import { CoreNavigator } from '@services/navigator'; import { CoreUserProfile } from '@features/user/services/user'; @@ -24,6 +23,7 @@ import { CoreListItemsManager } from '@classes/items-management/list-items-manag import { AddonCompetencyPlanCompetenciesSource } from '@addons/competency/classes/competency-plan-competencies-source'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreTime } from '@singletons/time'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a learning plan. @@ -57,8 +57,7 @@ export class AddonCompetencyPlanPage implements OnInit, OnDestroy { this.competencies = new CoreListItemsManager(competenciesSource, AddonCompetencyPlanPage); this.plans = new CoreSwipeNavigationItemsManager(plansSource); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -101,7 +100,7 @@ export class AddonCompetencyPlanPage implements OnInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting learning plan data.'); + CoreAlerts.showError(error, { default: 'Error getting learning plan data.' }); } } diff --git a/src/addons/competency/pages/planlist/planlist.ts b/src/addons/competency/pages/planlist/planlist.ts index c725a372c..25bb56549 100644 --- a/src/addons/competency/pages/planlist/planlist.ts +++ b/src/addons/competency/pages/planlist/planlist.ts @@ -13,7 +13,6 @@ // limitations under the License. import { AfterViewInit, Component, OnDestroy, ViewChild } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreNavigator } from '@services/navigator'; import { AddonCompetencyPlanFormatted, AddonCompetencyPlansSource } from '@addons/competency/classes/competency-plans-source'; @@ -23,6 +22,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreSites } from '@services/sites'; import { Translate } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of learning plans. @@ -76,7 +76,7 @@ export class AddonCompetencyPlanListPage implements AfterViewInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting learning plans data.'); + CoreAlerts.showError(error, { default: 'Error getting learning plans data.' }); } } diff --git a/src/addons/coursecompletion/pages/report/report.ts b/src/addons/coursecompletion/pages/report/report.ts index bb1a46923..87c89d633 100644 --- a/src/addons/coursecompletion/pages/report/report.ts +++ b/src/addons/coursecompletion/pages/report/report.ts @@ -22,9 +22,9 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { CoreTime } from '@singletons/time'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the course completion report. @@ -69,8 +69,7 @@ export class AddonCourseCompletionReportPage implements OnInit { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId(); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -102,7 +101,7 @@ export class AddonCourseCompletionReportPage implements OnInit { // Not enrolled error, probably a teacher. this.tracked = false; } else { - CoreDomUtils.showErrorModalDefault(error, 'addon.coursecompletion.couldnotloadreport', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.coursecompletion.couldnotloadreport') }); } } } @@ -131,7 +130,7 @@ export class AddonCourseCompletionReportPage implements OnInit { await this.refreshCompletion(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } diff --git a/src/addons/enrol/guest/services/enrol-handler.ts b/src/addons/enrol/guest/services/enrol-handler.ts index 057fb9863..56a7ac6c5 100644 --- a/src/addons/enrol/guest/services/enrol-handler.ts +++ b/src/addons/enrol/guest/services/enrol-handler.ts @@ -25,7 +25,7 @@ import { CorePasswordModalResponse } from '@components/password-modal/password-m import { CoreLoadings } from '@services/overlays/loadings'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreEnrol, CoreEnrolEnrolmentMethod } from '@features/enrol/services/enrol'; -import { CoreModals } from '@services/overlays/modals'; +import { CorePrompts } from '@services/overlays/prompts'; /** * Enrol handler. @@ -119,7 +119,7 @@ export class AddonEnrolGuestHandlerService implements CoreEnrolGuestHandler { }; try { - const response = await CoreModals.promptPassword({ + const response = await CorePrompts.promptPassword({ title: method.name, validator: validatePassword, }); diff --git a/src/addons/enrol/self/services/enrol-handler.ts b/src/addons/enrol/self/services/enrol-handler.ts index 8f6fdcef9..dbb488fb0 100644 --- a/src/addons/enrol/self/services/enrol-handler.ts +++ b/src/addons/enrol/self/services/enrol-handler.ts @@ -17,11 +17,11 @@ import { CoreEnrolAction, CoreEnrolSelfHandler, CoreEnrolInfoIcon } from '@featu import { Translate, makeSingleton } from '@singletons'; import { AddonEnrolSelf } from './self'; import { CorePasswordModalResponse } from '@components/password-modal/password-modal'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreEnrol, CoreEnrolEnrolmentMethod } from '@features/enrol/services/enrol'; -import { CoreModals } from '@services/overlays/modals'; import { CoreLoadings } from '@services/overlays/loadings'; import { CORE_COURSES_ENROL_INVALID_KEY } from '@features/courses/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { CorePrompts } from '@services/overlays/prompts'; /** * Enrol handler. @@ -87,11 +87,10 @@ export class AddonEnrolSelfHandlerService implements CoreEnrolSelfHandler { // Don't allow self access if it requires a password if not supported. if (!info.enrolpassword) { try { - await CoreDomUtils.showConfirm( - Translate.instant('addon.enrol_self.confirmselfenrol'), - method.name, - Translate.instant('core.courses.enrolme'), - ); + await CoreAlerts.confirm(Translate.instant('addon.enrol_self.confirmselfenrol'), { + header: method.name, + okText: Translate.instant('core.courses.enrolme'), + }); } catch { // User cancelled. return false; @@ -126,7 +125,7 @@ export class AddonEnrolSelfHandlerService implements CoreEnrolSelfHandler { response.validated = false; response.error = error.message; } else { - CoreDomUtils.showErrorModalDefault(error, 'addon.enrol_self.errorselfenrol', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.enrol_self.errorselfenrol') }); throw error; } @@ -147,7 +146,7 @@ export class AddonEnrolSelfHandlerService implements CoreEnrolSelfHandler { if (!response.validated) { try { - const response = await CoreModals.promptPassword({ + const response = await CorePrompts.promptPassword({ validator: validatePassword, title: method.name, placeholder: 'addon.enrol_self.password', diff --git a/src/addons/messageoutput/airnotifier/pages/devices/devices.ts b/src/addons/messageoutput/airnotifier/pages/devices/devices.ts index 3850195ca..132209a32 100644 --- a/src/addons/messageoutput/airnotifier/pages/devices/devices.ts +++ b/src/addons/messageoutput/airnotifier/pages/devices/devices.ts @@ -13,11 +13,10 @@ // limitations under the License. import { Component, OnDestroy, OnInit } from '@angular/core'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CorePushNotifications } from '@features/pushnotifications/services/pushnotifications'; import { AddonMessageOutputAirnotifier, AddonMessageOutputAirnotifierDevice } from '../../services/airnotifier'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of devices. @@ -50,7 +49,7 @@ export class AddonMessageOutputAirnotifierDevicesPage implements OnInit, OnDestr const devices = await AddonMessageOutputAirnotifier.getUserDevices(); this.formatDevices(devices); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { this.loaded = true; } @@ -148,7 +147,7 @@ export class AddonMessageOutputAirnotifierDevicesPage implements OnInit, OnDestr this.updateDevicesAfterDelay(); } catch (error) { // Show error and revert change. - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); device.enable = !device.enable; } finally { device.updating = false; diff --git a/src/addons/messageoutput/airnotifier/services/airnotifier.ts b/src/addons/messageoutput/airnotifier/services/airnotifier.ts index 022c20a52..236f232b8 100644 --- a/src/addons/messageoutput/airnotifier/services/airnotifier.ts +++ b/src/addons/messageoutput/airnotifier/services/airnotifier.ts @@ -21,10 +21,10 @@ import { CoreError } from '@classes/errors/error'; import { CoreWSError } from '@classes/errors/wserror'; import { makeSingleton, Translate } from '@singletons'; import { CoreEvents, CoreEventSiteData } from '@singletons/events'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreOpener } from '@singletons/opener'; import { CorePath } from '@singletons/path'; import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; +import { CorePrompts } from '@services/overlays/prompts'; const ROOT_CACHE_KEY = 'mmaMessageOutputAirnotifier:'; @@ -200,34 +200,35 @@ export class AddonMessageOutputAirnotifierProvider { } // Warn the admin. - const dontShowAgain = await CoreDomUtils.showPrompt( + const dontShowAgain = await CorePrompts.show( Translate.instant('addon.messageoutput_airnotifier.pushdisabledwarning'), - undefined, - Translate.instant('core.dontshowagain'), 'checkbox', - [ - { - text: Translate.instant('core.ok'), - }, - { - text: Translate.instant('core.goto', { $a: Translate.instant('core.settings.settings') }), - handler: (data, resolve) => { - resolve(data[0]); - - const url = CorePath.concatenatePaths( - site.getURL(), - site.isVersionGreaterEqualThan('3.11') ? - 'message/output/airnotifier/checkconfiguration.php' : - 'admin/message.php', - ); - - // Don't try auto-login, admins cannot use it. - CoreOpener.openInBrowser(url, { - showBrowserWarning: false, - }); + { + placeholderOrLabel: Translate.instant('core.dontshowagain'), + buttons: [ + { + text: Translate.instant('core.ok'), }, - }, - ], + { + text: Translate.instant('core.goto', { $a: Translate.instant('core.settings.settings') }), + handler: (data, resolve) => { + resolve(data[0]); + + const url = CorePath.concatenatePaths( + site.getURL(), + site.isVersionGreaterEqualThan('3.11') ? + 'message/output/airnotifier/checkconfiguration.php' : + 'admin/message.php', + ); + + // Don't try auto-login, admins cannot use it. + CoreOpener.openInBrowser(url, { + showBrowserWarning: false, + }); + }, + }, + ], + }, ); if (dontShowAgain) { diff --git a/src/addons/messages/components/conversation-info/conversation-info.component.ts b/src/addons/messages/components/conversation-info/conversation-info.component.ts index 8ce92e481..3763d64fb 100644 --- a/src/addons/messages/components/conversation-info/conversation-info.component.ts +++ b/src/addons/messages/components/conversation-info/conversation-info.component.ts @@ -18,9 +18,9 @@ import { AddonMessagesConversationMember, AddonMessages, } from '../../services/messages'; -import { CoreDomUtils } from '@services/utils/dom'; import { ActivatedRoute } from '@angular/router'; import { ModalController } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays the list of conversations, including group conversations. @@ -67,7 +67,7 @@ export class AddonMessagesConversationInfoComponent implements OnInit { // Now get the members. await this.fetchMembers(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting members.'); + CoreAlerts.showError(error, { default: 'Error getting members.' }); } } @@ -102,7 +102,7 @@ export class AddonMessagesConversationInfoComponent implements OnInit { try { await this.fetchMembers(true); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting members.'); + CoreAlerts.showError(error, { default: 'Error getting members.' }); this.loadMoreError = true; } finally { infiniteComplete && infiniteComplete(); diff --git a/src/addons/messages/pages/contacts-35/contacts.ts b/src/addons/messages/pages/contacts-35/contacts.ts index 80d292b74..6d906cfba 100644 --- a/src/addons/messages/pages/contacts-35/contacts.ts +++ b/src/addons/messages/pages/contacts-35/contacts.ts @@ -20,7 +20,6 @@ import { AddonMessagesGetContactsContact, AddonMessages, } from '../../services/messages'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { ActivatedRoute } from '@angular/router'; import { Translate } from '@singletons'; @@ -29,6 +28,7 @@ import { CoreNavigator } from '@services/navigator'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreKeyboard } from '@singletons/keyboard'; import { ADDON_MESSAGES_MEMBER_INFO_CHANGED_EVENT } from '@addons/messages/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of contacts. @@ -163,7 +163,7 @@ export class AddonMessagesContacts35Page implements OnInit, OnDestroy { this.clearSearch(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingcontacts', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingcontacts') }); } } @@ -233,7 +233,7 @@ export class AddonMessagesContacts35Page implements OnInit, OnDestroy { this.contacts.search = this.sortUsers(result); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingcontacts', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingcontacts') }); } } diff --git a/src/addons/messages/pages/contacts/contacts.ts b/src/addons/messages/pages/contacts/contacts.ts index 2e12a7d42..ed235d6fd 100644 --- a/src/addons/messages/pages/contacts/contacts.ts +++ b/src/addons/messages/pages/contacts/contacts.ts @@ -21,9 +21,10 @@ import { } from '../../services/messages'; import { CoreNavigator } from '@services/navigator'; import { CoreScreen } from '@services/screen'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { ADDON_MESSAGES_CONTACT_REQUESTS_COUNT_EVENT, ADDON_MESSAGES_MEMBER_INFO_CHANGED_EVENT } from '@addons/messages/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays contacts and contact requests. @@ -177,7 +178,7 @@ export class AddonMessagesContactsPage implements OnInit, OnDestroy { this.confirmedCanLoadMore = result.canLoadMore; } catch (error) { this.confirmedLoadMoreError = true; - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingcontacts', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingcontacts') }); } } @@ -203,7 +204,7 @@ export class AddonMessagesContactsPage implements OnInit, OnDestroy { this.requestsCanLoadMore = result.canLoadMore; } catch (error) { this.requestsLoadMoreError = true; - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingcontacts', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingcontacts') }); } } diff --git a/src/addons/messages/pages/discussion/discussion.ts b/src/addons/messages/pages/discussion/discussion.ts index fdc52d97a..19b849270 100644 --- a/src/addons/messages/pages/discussion/discussion.ts +++ b/src/addons/messages/pages/discussion/discussion.ts @@ -14,7 +14,6 @@ import { AfterViewInit, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { IonContent } from '@ionic/angular'; -import { AlertOptions } from '@ionic/core'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; import { @@ -28,7 +27,6 @@ import { import { AddonMessagesOffline, AddonMessagesOfflineMessagesDBRecordFormatted } from '../../services/messages-offline'; import { AddonMessagesSync } from '../../services/messages-sync'; import { CoreUser } from '@features/user/services/user'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreLogger } from '@singletons/logger'; import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading'; @@ -58,6 +56,7 @@ import { AddonMessagesMessageConversationType, AddonMessagesUpdateConversationAction, } from '@addons/messages/constants'; +import { CoreAlerts, CoreAlertsConfirmOptions } from '@services/overlays/alerts'; /** * Page that displays a message discussion page. @@ -143,7 +142,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView // Show first warning if any. if (data.warnings && data.warnings[0]) { - CoreDomUtils.showAlert(undefined, data.warnings[0]); + CoreAlerts.show({ message: data.warnings[0] }); } } }, this.siteId); @@ -264,7 +263,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView try { const syncResult = await AddonMessagesSync.syncDiscussion(this.conversationId, this.userId); if (syncResult.warnings && syncResult.warnings[0]) { - CoreDomUtils.showAlert(undefined, syncResult.warnings[0]); + CoreAlerts.show({ message: syncResult.warnings[0] }); } } catch { // Ignore errors; @@ -350,7 +349,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView await Promise.all(promises); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingmessages', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingmessages') }); } finally { this.checkCanDelete(); this.loaded = true; @@ -953,7 +952,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView const canDeleteAll = this.conversation && this.conversation.candeletemessagesforallusers; const langKey = message.pending || canDeleteAll || this.isSelf ? 'core.areyousure' : 'addon.messages.deletemessageconfirmation'; - const options: AlertOptions = {}; + const options: CoreAlertsConfirmOptions = {}; if (canDeleteAll && !message.pending) { // Show delete for all checkbox. @@ -967,13 +966,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView } try { - const data: boolean[] = await CoreDomUtils.showConfirm( - Translate.instant(langKey), - undefined, - undefined, - undefined, - options, - ); + const data = await CoreAlerts.confirm(Translate.instant(langKey), options); const modal = await CoreLoadings.show('core.deleting', true); @@ -989,7 +982,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView modal.dismiss(); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errordeletemessage', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errordeletemessage') }); } } @@ -1037,7 +1030,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView } catch (error) { this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading. this.pagesLoaded--; - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingmessages', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingmessages') }); } finally { infiniteComplete && infiniteComplete(); } @@ -1192,7 +1185,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView // We want the user to be able to send multiple messages without the keyboard being closed. CoreKeyboard.close(); - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.messagenotsent', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.messagenotsent') }); this.removeMessage(message.hash!); } } @@ -1316,7 +1309,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView value: this.conversation.isfavourite, }, this.siteId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error changing favourite state.'); + CoreAlerts.showError(error, { default: 'Error changing favourite state.' }); } finally { this.favouriteIcon = 'fas-star'; done && done(); @@ -1349,7 +1342,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView }, this.siteId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error changing muted state.'); + CoreAlerts.showError(error, { default: 'Error changing muted state.' }); } finally { this.muteIcon = this.conversation.ismuted ? 'fas-bell' : 'fas-bell-slash'; done && done(); @@ -1404,16 +1397,16 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView } if (this.otherMember.canmessageevenifblocked) { - CoreDomUtils.showErrorModal(Translate.instant('addon.messages.cantblockuser', { $a: this.otherMember.fullname })); + CoreAlerts.showError(Translate.instant('addon.messages.cantblockuser', { $a: this.otherMember.fullname })); return; } - const template = Translate.instant('addon.messages.blockuserconfirm', { $a: this.otherMember.fullname }); - const okText = Translate.instant('addon.messages.blockuser'); - try { - await CoreDomUtils.showConfirm(template, undefined, okText); + await CoreAlerts.confirm(Translate.instant('addon.messages.blockuserconfirm', { $a: this.otherMember.fullname }), { + okText: Translate.instant('addon.messages.blockuser'), + }); + this.blockIcon = CoreConstants.ICON_LOADING; const modal = await CoreLoadings.show('core.sending', true); @@ -1427,7 +1420,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.showLoadingModal = false; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } finally { this.blockIcon = this.otherMember.isblocked ? 'fas-user-check' : 'fas-user-lock'; } @@ -1449,7 +1442,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView const confirmMessage = 'addon.messages.' + (this.isSelf ? 'deleteallselfconfirm' : 'deleteallconfirm'); try { - await CoreDomUtils.showDeleteConfirm(confirmMessage); + await CoreAlerts.confirmDelete(Translate.instant(confirmMessage)); this.deleteIcon = CoreConstants.ICON_LOADING; try { @@ -1470,7 +1463,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView done && done(); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error deleting conversation.'); + CoreAlerts.showError(error, { default: 'Error deleting conversation.' }); } finally { this.deleteIcon = 'fas-trash'; } @@ -1490,11 +1483,10 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView throw new CoreError('No member selected to be unblocked.'); } - const template = Translate.instant('addon.messages.unblockuserconfirm', { $a: this.otherMember.fullname }); - const okText = Translate.instant('addon.messages.unblockuser'); - try { - await CoreDomUtils.showConfirm(template, undefined, okText); + await CoreAlerts.confirm(Translate.instant('addon.messages.unblockuserconfirm', { $a: this.otherMember.fullname }), { + okText: Translate.instant('addon.messages.unblockuser'), + }); this.blockIcon = CoreConstants.ICON_LOADING; @@ -1509,7 +1501,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.showLoadingModal = false; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } finally { this.blockIcon = this.otherMember.isblocked ? 'fas-user-check' : 'fas-user-lock'; } @@ -1529,11 +1521,10 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView throw new CoreError('No member selected to be requested.'); } - const template = Translate.instant('addon.messages.addcontactconfirm', { $a: this.otherMember.fullname }); - const okText = Translate.instant('core.add'); - try { - await CoreDomUtils.showConfirm(template, undefined, okText); + await CoreAlerts.confirm(Translate.instant('addon.messages.addcontactconfirm', { $a: this.otherMember.fullname }), { + okText: Translate.instant('core.add'), + }); this.addRemoveIcon = CoreConstants.ICON_LOADING; @@ -1548,7 +1539,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.showLoadingModal = false; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } finally { this.addRemoveIcon = 'fas-user-plus'; } @@ -1579,7 +1570,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.showLoadingModal = false; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } } @@ -1605,7 +1596,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.showLoadingModal = false; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } } @@ -1620,11 +1611,10 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView throw new CoreError('No member selected to be removed.'); } - const template = Translate.instant('addon.messages.removecontactconfirm', { $a: this.otherMember.fullname }); - const okText = Translate.instant('core.remove'); - try { - await CoreDomUtils.showConfirm(template, undefined, okText); + await CoreAlerts.confirm(Translate.instant('addon.messages.removecontactconfirm', { $a: this.otherMember.fullname }), { + okText: Translate.instant('core.remove'), + }); this.addRemoveIcon = CoreConstants.ICON_LOADING; @@ -1639,7 +1629,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView this.showLoadingModal = false; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } finally { this.addRemoveIcon = 'fas-user-plus'; } diff --git a/src/addons/messages/pages/discussions-35/discussions.ts b/src/addons/messages/pages/discussions-35/discussions.ts index 2051d36d0..6e54dd0e5 100644 --- a/src/addons/messages/pages/discussions-35/discussions.ts +++ b/src/addons/messages/pages/discussions-35/discussions.ts @@ -20,7 +20,6 @@ import { AddonMessagesDiscussion, AddonMessagesMessageAreaContact, } from '../../services/messages'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { ActivatedRoute, Params } from '@angular/router'; import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications'; @@ -34,6 +33,7 @@ import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreKeyboard } from '@singletons/keyboard'; import { ADDON_MESSAGES_NEW_MESSAGE_EVENT, ADDON_MESSAGES_READ_CHANGED_EVENT } from '@addons/messages/constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of discussions. @@ -207,7 +207,7 @@ export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy { try { await Promise.all(promises); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingdiscussions') }); } this.loaded = true; @@ -241,7 +241,7 @@ export class AddonMessagesDiscussions35Page implements OnInit, OnDestroy { this.search.showResults = true; this.search.results = searchResults.messages; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingmessages', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingmessages') }); } this.loaded = true; diff --git a/src/addons/messages/pages/group-conversations/group-conversations.ts b/src/addons/messages/pages/group-conversations/group-conversations.ts index 363307e01..c92863593 100644 --- a/src/addons/messages/pages/group-conversations/group-conversations.ts +++ b/src/addons/messages/pages/group-conversations/group-conversations.ts @@ -26,7 +26,6 @@ import { AddonMessagesOffline, AddonMessagesOfflineAnyMessagesFormatted, } from '../../services/messages-offline'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUser } from '@features/user/services/user'; import { CorePushNotificationsDelegate } from '@features/pushnotifications/services/push-delegate'; import { Translate } from '@singletons'; @@ -49,6 +48,7 @@ import { AddonMessagesMessageConversationType, AddonMessagesUpdateConversationAction, } from '@addons/messages/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; const enum AddonMessagesGroupConversationOptionNames { FAVOURITES = 'favourites', @@ -381,7 +381,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { // Load the data for the expanded option. await this.fetchDataForExpandedOption(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingdiscussions') }); } this.loaded = true; } @@ -611,7 +611,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { try { await this.fetchDataForOption(option, true); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingdiscussions') }); option.loadMoreError = true; } @@ -793,7 +793,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { // Pass getCounts=true to update the counts everytime the user expands an option. this.expandOption(option, true).catch((error) => { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingdiscussions') }); }); } diff --git a/src/addons/messages/pages/search/search.ts b/src/addons/messages/pages/search/search.ts index 81d6af6aa..506bcca6f 100644 --- a/src/addons/messages/pages/search/search.ts +++ b/src/addons/messages/pages/search/search.ts @@ -20,7 +20,6 @@ import { AddonMessagesMessageAreaContact, AddonMessages, } from '../../services/messages'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreNavigator } from '@services/navigator'; import { CoreScreen } from '@services/screen'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; @@ -30,6 +29,8 @@ import { ADDON_MESSAGES_LIMIT_SEARCH, ADDON_MESSAGES_LIMIT_INITIAL_USER_SEARCH, } from '@addons/messages/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page for searching users. @@ -225,7 +226,7 @@ export class AddonMessagesSearchPage implements OnDestroy { } } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingusers', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.messages.errorwhileretrievingusers') }); if (loadMore == 'messages') { this.messages.loadMoreError = true; diff --git a/src/addons/messages/pages/settings/settings.ts b/src/addons/messages/pages/settings/settings.ts index 5cdbe81be..a10125230 100644 --- a/src/addons/messages/pages/settings/settings.ts +++ b/src/addons/messages/pages/settings/settings.ts @@ -23,13 +23,13 @@ import { CoreUser } from '@features/user/services/user'; import { CoreConfig } from '@services/config'; import { CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreConstants } from '@/core/constants'; import { AddonNotificationsPreferencesNotificationProcessorState } from '@addons/notifications/services/notifications'; import { CorePlatform } from '@services/platform'; import { CoreErrorHelper } from '@services/error-helper'; import { CoreLoadings } from '@services/overlays/loadings'; import { ADDON_MESSAGES_NOTIFICATION_PREFERENCES_KEY, AddonMessagesMessagePrivacy } from '@addons/messages/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the messages settings page. @@ -118,7 +118,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { return; } - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { this.preferencesLoaded = true; } @@ -171,7 +171,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { this.previousContactableValue = this.contactablePrivacy; } catch (message) { // Show error and revert change. - CoreDomUtils.showErrorModal(message); + CoreAlerts.showError(message); this.contactablePrivacy = this.previousContactableValue; } finally { modal.dismiss(); @@ -214,7 +214,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { this.updatePreferencesAfterDelay(); } catch (error) { // Show error and revert change. - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); processor.enabled = !processor.enabled; } finally { notification.updating = false; @@ -249,7 +249,7 @@ export class AddonMessagesSettingsPage implements OnInit, OnDestroy { this.updatePreferencesAfterDelay(); } catch (error) { // Show error and revert change. - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); processorState.checked = !processorState.checked; } finally { notification['updating'+state] = false; diff --git a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts index 9f05e1b04..361259fc7 100644 --- a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts +++ b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts @@ -14,7 +14,6 @@ import { Component, Input, ViewChild, ElementRef } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreFormFields, CoreForms } from '@singletons/form'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { ModalController, Translate } from '@singletons'; @@ -22,6 +21,7 @@ import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate'; import { CoreSharedModule } from '@/core/shared.module'; import { AddonModAssignComponentsModule } from '../components.module'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Modal that allows editing a feedback plugin. @@ -50,7 +50,7 @@ export class AddonModAssignEditFeedbackModalComponent { async closeModal(): Promise { const changed = await this.hasDataChanged(); if (changed) { - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId()); diff --git a/src/addons/mod/assign/components/index/index.ts b/src/addons/mod/assign/components/index/index.ts index 0913fd8af..9e84836dd 100644 --- a/src/addons/mod/assign/components/index/index.ts +++ b/src/addons/mod/assign/components/index/index.ts @@ -22,7 +22,6 @@ import { IonContent } from '@ionic/angular'; import { CoreGroupInfo, CoreGroups } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTimeUtils } from '@services/utils/time'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; @@ -53,6 +52,7 @@ import { ADDON_MOD_ASSIGN_WARN_GROUPS_OPTIONAL, ADDON_MOD_ASSIGN_WARN_GROUPS_REQUIRED, } from '../../constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays an assignment. @@ -397,8 +397,7 @@ export class AddonModAssignIndexComponent extends CoreCourseModuleMainActivityCo } if (syncEventData.warnings && syncEventData.warnings.length) { - // Show warnings. - CoreDomUtils.showAlert(undefined, syncEventData.warnings[0]); + CoreAlerts.show({ message: syncEventData.warnings[0] }); } return true; diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index 6af701742..ba0d03cf4 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -39,7 +39,6 @@ import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreGradesFormattedItem, CoreGradesHelper } from '@features/grades/services/grades-helper'; import { CoreMenuItem, CoreUtils } from '@singletons/utils'; import { AddonModAssignHelper, AddonModAssignSubmissionFormatted } from '../../services/assign-helper'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { CoreText } from '@singletons/text'; import { CoreCourse, CoreCourseModuleGradeInfo, CoreCourseModuleGradeOutcome } from '@features/course/services/course'; @@ -71,6 +70,7 @@ import { import { CoreViewer } from '@features/viewer/services/viewer'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays an assignment submission. @@ -296,7 +296,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can if (modified) { // Modified, confirm user wants to go back. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); await this.discardDrafts(); } @@ -315,7 +315,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can } if (!CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal('core.networkerrormsg', true); + CoreAlerts.showError(Translate.instant('core.networkerrormsg')); return; } @@ -363,7 +363,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can await this.invalidateAndRefresh(true); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } finally { modal.dismiss(); } @@ -388,12 +388,11 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can async goToEdit(afterCopyPrevious = false): Promise { if (!afterCopyPrevious && this.assign?.timelimit && (!this.userSubmission || !this.userSubmission.timestarted)) { try { - await CoreDomUtils.showConfirm( + await CoreAlerts.confirm( Translate.instant('addon.mod_assign.confirmstart', { $a: CoreTime.formatTime(this.assign.timelimit), }), - undefined, - Translate.instant('addon.mod_assign.beginassignment'), + { okText: Translate.instant('addon.mod_assign.beginassignment') }, ); } catch { return; // User canceled. @@ -421,7 +420,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can 'addon.mod_assign.removesubmissionconfirmwithtimelimit' : 'addon.mod_assign.removesubmissionconfirm'; try { - await CoreDomUtils.showDeleteConfirm(message); + await CoreAlerts.confirmDelete(Translate.instant(message)); } catch { return; } @@ -445,7 +444,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can CoreSites.getCurrentSiteId(), ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error removing submission.'); + CoreAlerts.showError(error, { default: 'Error removing submission.' }); } finally { modal.dismiss(); } @@ -650,7 +649,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can await Promise.all(promises); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting assigment data.'); + CoreAlerts.showError(error, { default: 'Error getting assigment data.' }); } finally { this.loaded = true; } @@ -936,14 +935,14 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can } if (this.assign.requiresubmissionstatement && !acceptStatement) { - CoreDomUtils.showErrorModal('addon.mod_assign.acceptsubmissionstatement', true); + CoreAlerts.showError(Translate.instant('addon.mod_assign.acceptsubmissionstatement')); return; } try { // Ask for confirmation. @todo plugin precheck_submission - await CoreDomUtils.showConfirm(Translate.instant('addon.mod_assign.confirmsubmission')); + await CoreAlerts.confirm(Translate.instant('addon.mod_assign.confirmsubmission')); const modal = await CoreLoadings.show('core.sending', true); @@ -963,7 +962,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can userId: this.currentUserId, }, this.siteId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/assign/pages/edit/edit.ts b/src/addons/mod/assign/pages/edit/edit.ts index 51c6fbeb9..645d2c4ff 100644 --- a/src/addons/mod/assign/pages/edit/edit.ts +++ b/src/addons/mod/assign/pages/edit/edit.ts @@ -20,7 +20,6 @@ import { CanLeave } from '@guards/can-leave'; import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreFormFields, CoreForms } from '@singletons/form'; import { Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; @@ -48,6 +47,7 @@ import { import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that allows adding or editing an assigment submission. @@ -101,8 +101,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); this.isBlind = !!CoreNavigator.getRouteNumberParam('blindId'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -126,7 +125,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { // Check if data has changed. const changed = await this.hasDataChanged(); if (changed) { - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } // Nothing has changed or user confirmed to leave. Clear temporary data from plugins. @@ -246,7 +245,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { url: `/mod/assign/view.php?action=editsubmission&id=${this.moduleId}`, }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting assigment data.'); + CoreAlerts.showError(error, { default: 'Error getting assigment data.' }); // Leave the player. this.leaveWithoutCheck(); @@ -376,7 +375,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { await this.saveSubmission(); this.leaveWithoutCheck(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error saving submission.'); + CoreAlerts.showError(error, { default: 'Error saving submission.' }); } } diff --git a/src/addons/mod/assign/pages/submission-list/submission-list.ts b/src/addons/mod/assign/pages/submission-list/submission-list.ts index 32043ec76..b305fbfa6 100644 --- a/src/addons/mod/assign/pages/submission-list/submission-list.ts +++ b/src/addons/mod/assign/pages/submission-list/submission-list.ts @@ -19,7 +19,6 @@ import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreGroupInfo } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { @@ -34,6 +33,7 @@ import { } from '../../services/assign-sync'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_ASSIGN_AUTO_SYNCED, ADDON_MOD_ASSIGN_GRADED_EVENT, ADDON_MOD_ASSIGN_MANUAL_SYNCED } from '../../constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a list of submissions of an assignment. @@ -107,8 +107,7 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro AddonModAssignSubmissionListPage, ); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -184,7 +183,7 @@ export class AddonModAssignSubmissionListPage implements AfterViewInit, OnDestro url: `/mod/assign/view.php?id=${this.assign.cmid}&action=grading`, }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting assigment data.'); + CoreAlerts.showError(error, { default: 'Error getting assigment data.' }); } } diff --git a/src/addons/mod/assign/pages/submission-review/submission-review.ts b/src/addons/mod/assign/pages/submission-review/submission-review.ts index a50111338..1866faab0 100644 --- a/src/addons/mod/assign/pages/submission-review/submission-review.ts +++ b/src/addons/mod/assign/pages/submission-review/submission-review.ts @@ -20,13 +20,13 @@ import { CoreCourse } from '@features/course/services/course'; import { CanLeave } from '@guards/can-leave'; import { CoreNavigator } from '@services/navigator'; import { CoreScreen } from '@services/screen'; -import { CoreDomUtils } from '@services/utils/dom'; import { AddonModAssignListFilterName, AddonModAssignSubmissionsSource } from '../../classes/submissions-source'; import { AddonModAssignSubmissionComponent } from '../../components/submission/submission'; import { AddonModAssign, AddonModAssignAssign } from '../../services/assign'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a submission. @@ -99,8 +99,7 @@ export class AddonModAssignSubmissionReviewPage implements OnInit, OnDestroy, Ca this.submissions.start(); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -231,7 +230,7 @@ export class AddonModAssignSubmissionReviewPage implements OnInit, OnDestroy, Ca CoreNavigator.back(); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } } diff --git a/src/addons/mod/bigbluebuttonbn/components/index/index.ts b/src/addons/mod/bigbluebuttonbn/components/index/index.ts index 1482d7be9..87a3839d0 100644 --- a/src/addons/mod/bigbluebuttonbn/components/index/index.ts +++ b/src/addons/mod/bigbluebuttonbn/components/index/index.ts @@ -20,7 +20,6 @@ import { IonContent } from '@ionic/angular'; import { CoreApp } from '@services/app'; import { CoreGroupInfo, CoreGroups } from '@services/groups'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreArray } from '@singletons/array'; @@ -36,6 +35,7 @@ import { CoreLoadings } from '@services/overlays/loadings'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a Big Blue Button activity. @@ -287,7 +287,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo await this.fetchRecordings(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { this.showLoading = false; } @@ -313,7 +313,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo this.updateMeetingInfo(true); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } @@ -330,11 +330,10 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo } try { - await CoreDomUtils.showConfirm( - Translate.instant('addon.mod_bigbluebuttonbn.end_session_confirm'), - Translate.instant('addon.mod_bigbluebuttonbn.end_session_confirm_title'), - Translate.instant('core.yes'), - ); + await CoreAlerts.confirm(Translate.instant('addon.mod_bigbluebuttonbn.end_session_confirm'), { + header: Translate.instant('addon.mod_bigbluebuttonbn.end_session_confirm_title'), + okText: Translate.instant('core.yes'), + }); } catch { // User canceled. return; @@ -347,7 +346,7 @@ export class AddonModBBBIndexComponent extends CoreCourseModuleMainActivityCompo this.updateMeetingInfo(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } diff --git a/src/addons/mod/book/pages/contents/contents.ts b/src/addons/mod/book/pages/contents/contents.ts index 62ea65c69..c7aad4fbc 100644 --- a/src/addons/mod/book/pages/contents/contents.ts +++ b/src/addons/mod/book/pages/contents/contents.ts @@ -24,7 +24,6 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu import { CoreTag, CoreTagItem } from '@features/tag/services/tag'; import { CoreNetwork } from '@services/network'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreErrorHelper } from '@services/error-helper'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; @@ -38,6 +37,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreUrl } from '@singletons/url'; import { ADDON_MOD_BOOK_COMPONENT, AddonModBookNavStyle } from '../../constants'; import { CoreModals } from '@services/overlays/modals'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a book contents. @@ -79,8 +79,7 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); this.initialChapterId = CoreNavigator.getRouteNumberParam('chapterId'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -136,7 +135,7 @@ export class AddonModBookContentsPage implements OnInit, OnDestroy { await source.load(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { this.loaded = true; } diff --git a/src/addons/mod/chat/components/users-modal/users-modal.ts b/src/addons/mod/chat/components/users-modal/users-modal.ts index 6f40a45fd..68edbc887 100644 --- a/src/addons/mod/chat/components/users-modal/users-modal.ts +++ b/src/addons/mod/chat/components/users-modal/users-modal.ts @@ -14,11 +14,11 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { CoreNetwork } from '@services/network'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { ModalController, NgZone } from '@singletons'; +import { ModalController, NgZone, Translate } from '@singletons'; import { Subscription } from 'rxjs'; import { AddonModChat, AddonModChatUser } from '../../services/chat'; import { CoreSharedModule } from '@/core/shared.module'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * MMdal that displays the chat session users. @@ -63,7 +63,7 @@ export class AddonModChatUsersModalComponent implements OnInit, OnDestroy { this.users = data.users; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_chat.errorwhilegettingchatusers', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_chat.errorwhilegettingchatusers') }); } finally { this.usersLoaded = true; } diff --git a/src/addons/mod/chat/pages/chat/chat.ts b/src/addons/mod/chat/pages/chat/chat.ts index d96d2e809..b3a7179d2 100644 --- a/src/addons/mod/chat/pages/chat/chat.ts +++ b/src/addons/mod/chat/pages/chat/chat.ts @@ -19,7 +19,6 @@ import { IonContent } from '@ionic/angular'; import { CoreNetwork } from '@services/network'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { NgZone, Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; @@ -33,6 +32,7 @@ import { CoreKeyboard } from '@singletons/keyboard'; import { CoreWait } from '@singletons/wait'; import { CoreModals } from '@services/overlays/modals'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a chat session. @@ -108,7 +108,7 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { this.startPolling(); this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_chat.errorwhileconnecting', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_chat.errorwhileconnecting') }); CoreNavigator.back(); } finally { this.loaded = true; @@ -294,7 +294,7 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { } catch (error) { // Fail again. Stop polling if needed. this.stopPolling(); - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_chat.errorwhileretrievingmessages', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_chat.errorwhileretrievingmessages') }); throw error; } @@ -331,7 +331,7 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { CoreKeyboard.close(); this.newMessage = text; - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_chat.errorwhilesendingmessage', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_chat.errorwhilesendingmessage') }); } finally { this.sending = false; } @@ -380,7 +380,7 @@ export class AddonModChatChatPage implements OnInit, OnDestroy, CanLeave { } // Modified, confirm user wants to go back. - await CoreDomUtils.showConfirm(Translate.instant('addon.mod_chat.confirmloss')); + await CoreAlerts.confirm(Translate.instant('addon.mod_chat.confirmloss')); return true; } diff --git a/src/addons/mod/chat/pages/session-messages/session-messages.ts b/src/addons/mod/chat/pages/session-messages/session-messages.ts index d26238d12..a3a0f0338 100644 --- a/src/addons/mod/chat/pages/session-messages/session-messages.ts +++ b/src/addons/mod/chat/pages/session-messages/session-messages.ts @@ -16,13 +16,13 @@ import { Component, OnInit } from '@angular/core'; import { CoreUser } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { AddonModChat } from '../../services/chat'; import { AddonModChatFormattedSessionMessage, AddonModChatHelper } from '../../services/chat-helper'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; import { CoreTime } from '@singletons/time'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays list of chat session messages. @@ -75,8 +75,7 @@ export class AddonModChatSessionMessagesPage implements OnInit { this.chatId = CoreNavigator.getRequiredRouteNumberParam('chatId'); this.groupId = CoreNavigator.getRouteNumberParam('groupId') || 0; } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -119,7 +118,7 @@ export class AddonModChatSessionMessagesPage implements OnInit { this.messages[this.messages.length - 1].showTail = true; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorloadingcontent', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorloadingcontent') }); } finally { this.loaded = true; } diff --git a/src/addons/mod/chat/pages/sessions/sessions.ts b/src/addons/mod/chat/pages/sessions/sessions.ts index acefafa03..d5e558ae6 100644 --- a/src/addons/mod/chat/pages/sessions/sessions.ts +++ b/src/addons/mod/chat/pages/sessions/sessions.ts @@ -18,7 +18,6 @@ import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/ import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreGroupInfo } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { AddonModChatSessionFormatted, AddonModChatSessionsSource } from '../../classes/chat-sessions-source'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreTime } from '@singletons/time'; @@ -26,6 +25,7 @@ import { Translate } from '@singletons'; import { AddonModChat } from '@addons/mod/chat/services/chat'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays list of chat sessions. @@ -73,8 +73,7 @@ export class AddonModChatSessionsPage implements OnInit, AfterViewInit, OnDestro this.sessions = new CoreListItemsManager(source, AddonModChatSessionsPage); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -119,7 +118,7 @@ export class AddonModChatSessionsPage implements OnInit, AfterViewInit, OnDestro this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorloadingcontent', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorloadingcontent') }); } } @@ -132,7 +131,7 @@ export class AddonModChatSessionsPage implements OnInit, AfterViewInit, OnDestro try { await this.sessions.reload(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorloadingcontent', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorloadingcontent') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/choice/components/index/index.ts b/src/addons/mod/choice/components/index/index.ts index 104fd11e6..fa6d2934f 100644 --- a/src/addons/mod/choice/components/index/index.ts +++ b/src/addons/mod/choice/components/index/index.ts @@ -18,7 +18,6 @@ import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { IonContent } from '@ionic/angular'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTimeUtils } from '@services/utils/time'; import { Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; @@ -42,6 +41,7 @@ import { AddonModChoiceShowResults, } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a choice. @@ -370,7 +370,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo // Only show confirm if choice doesn't allow update. if (!this.choice.allowupdate) { - await CoreDomUtils.showConfirm(Translate.instant('core.areyousure')); + await CoreAlerts.confirm(Translate.instant('core.areyousure')); } const responses: number[] = []; @@ -401,7 +401,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo await this.dataUpdated(online); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_choice.cannotsubmit', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_choice.cannotsubmit') }); } finally { modal.dismiss(); } @@ -416,7 +416,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo } try { - await CoreDomUtils.showDeleteConfirm(); + await CoreAlerts.confirmDelete(Translate.instant('core.areyousure')); } catch { // User cancelled. return; @@ -434,7 +434,7 @@ export class AddonModChoiceIndexComponent extends CoreCourseModuleMainActivityCo // Refresh the data. Don't call dataUpdated because deleting an answer doesn't mark the choice as outdated. await this.refreshContent(false); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_choice.cannotsubmit', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_choice.cannotsubmit') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/data/components/index/index.ts b/src/addons/mod/data/components/index/index.ts index 9109a4496..58e5b2917 100644 --- a/src/addons/mod/data/components/index/index.ts +++ b/src/addons/mod/data/components/index/index.ts @@ -54,6 +54,8 @@ import { import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreObject } from '@singletons/object'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; const contentToken = ''; @@ -436,7 +438,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp this.logSearch?.(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { this.showLoading = false; } @@ -484,7 +486,7 @@ export class AddonModDataIndexComponent extends CoreCourseModuleMainActivityComp try { await this.fetchEntriesData(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } } diff --git a/src/addons/mod/data/fields/latlong/component/latlong.ts b/src/addons/mod/data/fields/latlong/component/latlong.ts index a1242943b..dcfdb0643 100644 --- a/src/addons/mod/data/fields/latlong/component/latlong.ts +++ b/src/addons/mod/data/fields/latlong/component/latlong.ts @@ -19,10 +19,10 @@ import { FormBuilder } from '@angular/forms'; import { SafeUrl } from '@angular/platform-browser'; import { CoreAnyError } from '@classes/errors/error'; import { CoreGeolocation, CoreGeolocationError, CoreGeolocationErrorReason } from '@services/geolocation'; +import { CoreAlerts } from '@services/overlays/alerts'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePlatform } from '@services/platform'; -import { CoreDomUtils } from '@services/utils/dom'; -import { DomSanitizer } from '@singletons'; +import { DomSanitizer, Translate } from '@singletons'; /** * Component to render data latlong field. @@ -140,12 +140,12 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginBa */ protected showLocationErrorModal(error: CoreAnyError | CoreGeolocationError): void { if (error instanceof CoreGeolocationError) { - CoreDomUtils.showErrorModal(this.getGeolocationErrorMessage(error), true); + CoreAlerts.showError(Translate.instant(this.getGeolocationErrorMessage(error))); return; } - CoreDomUtils.showErrorModalDefault(error, 'Error getting location'); + CoreAlerts.showError(error, { default: 'Error getting location' }); } /** diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index 30cddec7e..dea968bde 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -21,7 +21,6 @@ import { IonContent } from '@ionic/angular'; import { CoreGroupInfo, CoreGroups } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreForms } from '@singletons/form'; import { CoreUtils } from '@singletons/utils'; import { Translate } from '@singletons'; @@ -47,6 +46,7 @@ import { ADDON_MOD_DATA_COMPONENT, ADDON_MOD_DATA_ENTRY_CHANGED, AddonModDataTem import { CoreLoadings } from '@services/overlays/loadings'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreArray } from '@singletons/array'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the view edit page. @@ -126,7 +126,7 @@ export class AddonModDataEditPage implements OnInit { this.entryId = CoreNavigator.getRouteNumberParam('entryId') || undefined; this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0; } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -156,7 +156,7 @@ export class AddonModDataEditPage implements OnInit { if (changed) { // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } // Delete the local files from the tmp folder. @@ -238,7 +238,7 @@ export class AddonModDataEditPage implements OnInit { if (!haveAccess) { // You shall not pass, go back. - CoreDomUtils.showErrorModal('addon.mod_data.noaccess', true); + CoreAlerts.showError(Translate.instant('addon.mod_data.noaccess')); // Go back to entry list. this.forceLeave = true; @@ -251,7 +251,7 @@ export class AddonModDataEditPage implements OnInit { this.editFormRender = this.displayEditFields(); this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } this.loaded = true; @@ -395,10 +395,9 @@ export class AddonModDataEditPage implements OnInit { this.scrollToFirstError(); if (updateEntryResult.generalnotifications?.length) { - CoreDomUtils.showAlertWithOptions({ + CoreAlerts.show({ header: Translate.instant('core.notice'), message: CoreText.buildMessage(updateEntryResult.generalnotifications), - buttons: [Translate.instant('core.ok')], }); } } @@ -406,7 +405,7 @@ export class AddonModDataEditPage implements OnInit { modal.dismiss(); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Cannot edit entry', true); + CoreAlerts.showError(error, { default: 'Cannot edit entry' }); } } diff --git a/src/addons/mod/data/pages/entry/entry.ts b/src/addons/mod/data/pages/entry/entry.ts index 4991ebf63..9e1e1504e 100644 --- a/src/addons/mod/data/pages/entry/entry.ts +++ b/src/addons/mod/data/pages/entry/entry.ts @@ -21,7 +21,6 @@ import { IonContent } from '@ionic/angular'; import { CoreGroups, CoreGroupInfo } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreArray } from '@singletons/array'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { AddonModDataComponentsCompileModule } from '../../components/components-compile.module'; @@ -44,6 +43,8 @@ import { AddonModDataTemplateMode, } from '../../constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays the view entry page. @@ -156,8 +157,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy { const sortBy = Number(CoreNavigator.getRouteParam('sortBy')); this.sortBy = isNaN(sortBy) ? this.sortBy : sortBy; } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -236,7 +236,7 @@ export class AddonModDataEntryPage implements OnInit, OnDestroy { return this.refreshAllData(isPtr); } - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { this.content?.scrollToTop(); this.entryLoaded = true; diff --git a/src/addons/mod/data/services/data-helper.ts b/src/addons/mod/data/services/data-helper.ts index 50e603456..ed0d31c59 100644 --- a/src/addons/mod/data/services/data-helper.ts +++ b/src/addons/mod/data/services/data-helper.ts @@ -49,6 +49,7 @@ import { } from '../constants'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Service that provides helper functions for datas. @@ -164,7 +165,7 @@ export class AddonModDataHelperProvider { // Approve/disapprove entry. await AddonModData.approveEntry(dataId, entryId, approve, courseId, siteId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_data.errorapproving', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_data.errorapproving') }); throw error; } @@ -856,7 +857,7 @@ export class AddonModDataHelperProvider { siteId = siteId || CoreSites.getCurrentSiteId(); try { - await CoreDomUtils.showDeleteConfirm('addon.mod_data.confirmdeleterecord'); + await CoreAlerts.confirmDelete(Translate.instant('addon.mod_data.confirmdeleterecord')); const modal = await CoreLoadings.show(); @@ -869,7 +870,7 @@ export class AddonModDataHelperProvider { await AddonModData.deleteEntry(dataId, entryId, courseId, siteId); } } catch (message) { - CoreDomUtils.showErrorModalDefault(message, 'addon.mod_data.errordeleting', true); + CoreAlerts.showError(message, { default: Translate.instant('addon.mod_data.errordeleting') }); modal.dismiss(); diff --git a/src/addons/mod/feedback/pages/attempt/attempt.ts b/src/addons/mod/feedback/pages/attempt/attempt.ts index 08016f94f..267225300 100644 --- a/src/addons/mod/feedback/pages/attempt/attempt.ts +++ b/src/addons/mod/feedback/pages/attempt/attempt.ts @@ -17,7 +17,6 @@ import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router'; import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker'; import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe-navigation-items-manager'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreFileHelper } from '@services/file-helper'; import { AddonModFeedbackAttemptsSource } from '../../classes/feedback-attempts-source'; import { @@ -29,6 +28,8 @@ import { AddonModFeedbackAttempt, AddonModFeedbackFormItem, AddonModFeedbackHelp import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_FEEDBACK_COMPONENT } from '../../constants'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays a feedback attempt review. @@ -89,8 +90,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy { try { await this.attempts.start(); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -156,7 +156,7 @@ export class AddonModFeedbackAttemptPage implements OnInit, OnDestroy { this.logView(); } catch (message) { // Some call failed on fetch, go back. - CoreDomUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true); + CoreAlerts.showError(message, { default: Translate.instant('core.course.errorgetmodule') }); CoreNavigator.back(); } finally { this.loaded = true; diff --git a/src/addons/mod/feedback/pages/attempts/attempts.ts b/src/addons/mod/feedback/pages/attempts/attempts.ts index 680d0f6cc..151f9f530 100644 --- a/src/addons/mod/feedback/pages/attempts/attempts.ts +++ b/src/addons/mod/feedback/pages/attempts/attempts.ts @@ -20,12 +20,13 @@ import { CorePromisedValue } from '@classes/promised-value'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreGroupInfo } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { AddonModFeedbackAttemptItem, AddonModFeedbackAttemptsSource } from '../../classes/feedback-attempts-source'; import { AddonModFeedbackWSAnonAttempt, AddonModFeedbackWSAttempt } from '../../services/feedback'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays feedback attempts. @@ -116,8 +117,7 @@ export class AddonModFeedbackAttemptsPage implements AfterViewInit, OnDestroy { this.promisedAttempts.resolve(new AddonModFeedbackAttemptsManager(source, this.route.component)); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -135,7 +135,7 @@ export class AddonModFeedbackAttemptsPage implements AfterViewInit, OnDestroy { } catch (error) { this.fetchFailed = true; - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } await attempts.start(this.splitView); @@ -163,7 +163,7 @@ export class AddonModFeedbackAttemptsPage implements AfterViewInit, OnDestroy { } catch (error) { this.fetchFailed = true; - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { infiniteComplete && infiniteComplete(); } @@ -186,7 +186,7 @@ export class AddonModFeedbackAttemptsPage implements AfterViewInit, OnDestroy { } catch (error) { this.fetchFailed = true; - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { refresher.complete(); } diff --git a/src/addons/mod/feedback/pages/form/form.ts b/src/addons/mod/feedback/pages/form/form.ts index f36b8a20d..935a1b3ae 100644 --- a/src/addons/mod/feedback/pages/form/form.ts +++ b/src/addons/mod/feedback/pages/form/form.ts @@ -21,7 +21,6 @@ import { IonContent } from '@ionic/angular'; import { CoreNetwork } from '@services/network'; import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { NgZone, Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; @@ -47,6 +46,7 @@ import { CoreError } from '@classes/errors/error'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreObject } from '@singletons/object'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays feedback form. @@ -109,7 +109,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { this.preview = !!CoreNavigator.getRouteBooleanParam('preview'); this.fromIndex = !!CoreNavigator.getRouteBooleanParam('fromIndex'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -119,7 +119,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { await this.fetchData(); if (!this.access || this.access.isempty && (!this.access.canedititems && !this.access.canviewreports)) { - CoreDomUtils.showErrorModal(Translate.instant('core.nopermissiontoaccesspage')); + CoreAlerts.showError(Translate.instant('core.nopermissiontoaccesspage')); CoreNavigator.back(); @@ -160,7 +160,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { if (this.items && !this.completed && this.originalData) { // Form submitted. Check if there is any change. if (!CoreObject.basicLeftCompare(responses, this.originalData, 3)) { - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } } } @@ -200,7 +200,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { await this.fetchFeedbackPageData(page); } catch (message) { - CoreDomUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true); + CoreAlerts.showError(message, { default: Translate.instant('core.course.errorgetmodule') }); this.forceLeave = true; CoreNavigator.back(); } finally { @@ -405,7 +405,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { await this.fetchFeedbackPageData(response.jumpto); } } catch (message) { - CoreDomUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true); + CoreAlerts.showError(message, { default: Translate.instant('core.course.errorgetmodule') }); } finally { this.feedbackLoaded = true; } diff --git a/src/addons/mod/feedback/pages/nonrespondents/nonrespondents.ts b/src/addons/mod/feedback/pages/nonrespondents/nonrespondents.ts index 30073a27a..63bfbfafb 100644 --- a/src/addons/mod/feedback/pages/nonrespondents/nonrespondents.ts +++ b/src/addons/mod/feedback/pages/nonrespondents/nonrespondents.ts @@ -15,12 +15,13 @@ import { Component, OnInit } from '@angular/core'; import { CoreGroupInfo, CoreGroups } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { AddonModFeedback, AddonModFeedbackWSFeedback } from '../../services/feedback'; import { AddonModFeedbackHelper, AddonModFeedbackNonRespondent } from '../../services/feedback-helper'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays feedback non respondents. @@ -70,8 +71,7 @@ export class AddonModFeedbackNonRespondentsPage implements OnInit { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); this.selectedGroup = CoreNavigator.getRouteNumberParam('group') || 0; } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -102,7 +102,7 @@ export class AddonModFeedbackNonRespondentsPage implements OnInit { this.logView(); } catch (message) { - CoreDomUtils.showErrorModalDefault(message, 'core.course.errorgetmodule', true); + CoreAlerts.showError(message, { default: Translate.instant('core.course.errorgetmodule') }); if (!refresh) { // Some call failed on first fetch, go back. @@ -162,7 +162,7 @@ export class AddonModFeedbackNonRespondentsPage implements OnInit { try { await this.loadGroupUsers(groupId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { infiniteComplete && infiniteComplete(); } diff --git a/src/addons/mod/feedback/services/feedback-helper.ts b/src/addons/mod/feedback/services/feedback-helper.ts index 16e7cb8b4..bbd050270 100644 --- a/src/addons/mod/feedback/services/feedback-helper.ts +++ b/src/addons/mod/feedback/services/feedback-helper.ts @@ -17,7 +17,6 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreUser } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreFileHelper } from '@services/file-helper'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreUtils } from '@singletons/utils'; @@ -42,6 +41,7 @@ import { } from '../constants'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreText } from '@singletons/text'; +import { CoreAlerts } from '@services/overlays/alerts'; const MODE_RESPONSETIME = 1; const MODE_COURSE = 2; @@ -216,7 +216,7 @@ export class AddonModFeedbackHelperProvider { }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error opening link.'); + CoreAlerts.showError(error, { default: 'Error opening link.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/feedback/services/handlers/analysis-link.ts b/src/addons/mod/feedback/services/handlers/analysis-link.ts index b6737d42b..21836c405 100644 --- a/src/addons/mod/feedback/services/handlers/analysis-link.ts +++ b/src/addons/mod/feedback/services/handlers/analysis-link.ts @@ -17,10 +17,10 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME, AddonModFeedbackIndexTabName } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Content links handler for a feedback analysis. @@ -65,7 +65,7 @@ export class AddonModFeedbackAnalysisLinkHandlerService extends CoreContentLinks }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error opening link.'); + CoreAlerts.showError(error, { default: 'Error opening link.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/feedback/services/handlers/complete-link.ts b/src/addons/mod/feedback/services/handlers/complete-link.ts index 277df62d7..18b167a91 100644 --- a/src/addons/mod/feedback/services/handlers/complete-link.ts +++ b/src/addons/mod/feedback/services/handlers/complete-link.ts @@ -18,10 +18,10 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Content links handler for feedback complete questions. @@ -60,7 +60,7 @@ export class AddonModFeedbackCompleteLinkHandlerService extends CoreContentLinks }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error opening link.'); + CoreAlerts.showError(error, { default: 'Error opening link.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/feedback/services/handlers/print-link.ts b/src/addons/mod/feedback/services/handlers/print-link.ts index 583ac27b4..8d319b10d 100644 --- a/src/addons/mod/feedback/services/handlers/print-link.ts +++ b/src/addons/mod/feedback/services/handlers/print-link.ts @@ -18,10 +18,10 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Content links handler for feedback print questions. @@ -60,7 +60,7 @@ export class AddonModFeedbackPrintLinkHandlerService extends CoreContentLinksHan }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error opening link.'); + CoreAlerts.showError(error, { default: 'Error opening link.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts index 14044111c..2c2418430 100644 --- a/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts +++ b/src/addons/mod/feedback/services/handlers/show-non-respondents-link.ts @@ -18,10 +18,10 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_FEEDBACK_PAGE_NAME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Content links handler for feedback show non respondents. * Match mod/feedback/show_nonrespondents.php with a valid feedback id. @@ -54,7 +54,7 @@ export class AddonModFeedbackShowNonRespondentsLinkHandlerService extends CoreCo { siteId }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error opening link.'); + CoreAlerts.showError(error, { default: 'Error opening link.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts b/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts index 0d3b9799e..d5d4edbdc 100644 --- a/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts +++ b/src/addons/mod/forum/components/discussion-options-menu/discussion-options-menu.ts @@ -14,7 +14,6 @@ import { Component, Input, OnInit } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { PopoverController } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { AddonModForum, AddonModForumDiscussion } from '../../services/forum'; @@ -22,6 +21,7 @@ import { ADDON_MOD_FORUM_CHANGE_DISCUSSION_EVENT } from '../../constants'; import { CoreToasts } from '@services/overlays/toasts'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * This component is meant to display a popover with the discussion options. @@ -86,7 +86,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { translateMessage: true, }); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); PopoverController.dismiss(); } finally { modal.dismiss(); @@ -118,7 +118,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { translateMessage: true, }); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); PopoverController.dismiss(); } finally { modal.dismiss(); @@ -150,7 +150,7 @@ export class AddonModForumDiscussionOptionsMenuComponent implements OnInit { translateMessage: true, }); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); PopoverController.dismiss(); } finally { modal.dismiss(); diff --git a/src/addons/mod/forum/components/index/index.ts b/src/addons/mod/forum/components/index/index.ts index 6c5771c58..28765fddb 100644 --- a/src/addons/mod/forum/components/index/index.ts +++ b/src/addons/mod/forum/components/index/index.ts @@ -38,7 +38,6 @@ import { } from '@addons/mod/forum/services/forum-sync'; import { CoreSites } from '@services/sites'; import { CoreUser } from '@features/user/services/user'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourse } from '@features/course/services/course'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreScreen } from '@services/screen'; @@ -68,6 +67,7 @@ import { CoreSearchGlobalSearch } from '@features/search/services/global-search' import { CoreToasts } from '@services/overlays/toasts'; import { CorePopovers } from '@services/overlays/popovers'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a forum entry page. */ @@ -475,7 +475,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom await discussions.load(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_forum.errorgetforum', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_forum.errorgetforum') }); this.fetchFailed = true; } finally { @@ -618,7 +618,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom await CoreUser.setUserPreference(ADDON_MOD_FORUM_PREFERENCE_SORTORDER, sortOrder.value.toFixed(0)); await this.showLoadingAndFetch(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error updating preference.'); + CoreAlerts.showError(error, { default: 'Error updating preference.' }); } } } @@ -679,7 +679,7 @@ export class AddonModForumIndexComponent extends CoreCourseModuleMainActivityCom this.discussions?.reload(), ]); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorloadingcontent', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorloadingcontent') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/forum/components/post-options-menu/post-options-menu.ts b/src/addons/mod/forum/components/post-options-menu/post-options-menu.ts index 6f1c532f1..930603da9 100644 --- a/src/addons/mod/forum/components/post-options-menu/post-options-menu.ts +++ b/src/addons/mod/forum/components/post-options-menu/post-options-menu.ts @@ -17,9 +17,9 @@ import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreNetwork } from '@services/network'; import { AddonModForum, AddonModForumPost } from '@addons/mod/forum/services/forum'; import { PopoverController } from '@singletons'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreNetworkError } from '@classes/errors/network-error'; import { CoreSharedModule } from '@/core/shared.module'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * This component is meant to display a popover with the post options. @@ -65,7 +65,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit { readingStrategy: CoreSitesReadingStrategy.ONLY_NETWORK, }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting discussion post.'); + CoreAlerts.showError(error, { default: 'Error getting discussion post.' }); } } else { this.loaded = true; @@ -111,7 +111,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit { deletePost(): void { if (!this.offlinePost) { if (!CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal(new CoreNetworkError()); + CoreAlerts.showError(new CoreNetworkError()); return; } @@ -127,7 +127,7 @@ export class AddonModForumPostOptionsMenuComponent implements OnInit { */ editPost(): void { if (!this.offlinePost && !CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal(new CoreNetworkError()); + CoreAlerts.showError(new CoreNetworkError()); return; } diff --git a/src/addons/mod/forum/components/post/post.ts b/src/addons/mod/forum/components/post/post.ts index cebe03538..c1ac9d34a 100644 --- a/src/addons/mod/forum/components/post/post.ts +++ b/src/addons/mod/forum/components/post/post.ts @@ -25,7 +25,6 @@ import { ViewChild, } from '@angular/core'; import { FormControl } from '@angular/forms'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; import { @@ -60,6 +59,7 @@ import { CoreLoadings } from '@services/overlays/loadings'; import { CoreWSFile } from '@services/ws'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSError } from '@classes/errors/wserror'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Components that shows a discussion post, its attachments and the action buttons allowed (reply, etc.). @@ -155,7 +155,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges this.analyticsLogEvent('mod_forum_delete_post', `/mod/forum/post.php?delete=${this.post.id}`); try { - await CoreDomUtils.showDeleteConfirm('addon.mod_forum.deletesure'); + await CoreAlerts.confirmDelete(Translate.instant('addon.mod_forum.deletesure')); const modal = await CoreLoadings.show('core.deleting', true); @@ -181,7 +181,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges translateMessage: true, }); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } @@ -364,7 +364,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges this.analyticsLogEvent('mod_forum_update_discussion_post', `/mod/forum/post.php?edit=${this.post.id}`); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_forum.errorgetpost', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_forum.errorgetpost') }); } finally { modal.dismiss(); } @@ -384,13 +384,13 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges */ async send(): Promise { if (!this.formData.subject) { - CoreDomUtils.showErrorModal('addon.mod_forum.erroremptysubject', true); + CoreAlerts.showError(Translate.instant('addon.mod_forum.erroremptysubject')); return; } if (!this.formData.message) { - CoreDomUtils.showErrorModal('addon.mod_forum.erroremptymessage', true); + CoreAlerts.showError(Translate.instant('addon.mod_forum.erroremptymessage')); return; } @@ -481,11 +481,9 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges this.unblockOperation(); } catch (error) { - CoreDomUtils.showErrorModalDefault( - error, - isEditOnline ? 'addon.mod_forum.couldnotupdate' : 'addon.mod_forum.couldnotadd', - true, - ); + CoreAlerts.showError(error, { + default: Translate.instant(isEditOnline ? 'addon.mod_forum.couldnotupdate' : 'addon.mod_forum.couldnotadd'), + }); } finally { modal.dismiss(); } @@ -589,7 +587,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges */ async discardOfflineReply(): Promise { try { - await CoreDomUtils.showDeleteConfirm(); + await CoreAlerts.confirmDelete(Translate.instant('core.areyousure')); const promises: Promise[] = []; @@ -643,7 +641,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy, OnChanges protected async confirmDiscard(): Promise { if (AddonModForumHelper.hasPostDataChanged(this.formData, this.originalData)) { // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmloss')); + await CoreAlerts.confirm(Translate.instant('core.confirmloss')); } this.unblockOperation(); diff --git a/src/addons/mod/forum/pages/discussion/discussion.ts b/src/addons/mod/forum/pages/discussion/discussion.ts index 31778c8aa..9ba5e03ae 100644 --- a/src/addons/mod/forum/pages/discussion/discussion.ts +++ b/src/addons/mod/forum/pages/discussion/discussion.ts @@ -28,7 +28,6 @@ import { CoreNetwork } from '@services/network'; import { CoreNavigator } from '@services/navigator'; import { CoreScreen } from '@services/screen'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { NgZone, Translate } from '@singletons'; import { CoreDom } from '@singletons/dom'; @@ -64,6 +63,7 @@ import { CoreToasts } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreObject } from '@singletons/object'; +import { CoreAlerts } from '@services/overlays/alerts'; type SortType = 'flat-newest' | 'flat-oldest' | 'nested'; @@ -171,7 +171,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes await this.discussions.start(); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); this.goBack(); @@ -303,7 +303,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes async canLeave(): Promise { if (AddonModForumHelper.hasPostDataChanged(this.formData, this.originalData)) { // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } // Delete the local files from the tmp folder. @@ -571,7 +571,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes this.hasOfflineRatings = await CoreRatingOffline.hasRatings('mod_forum', 'post', ContextLevel.MODULE, this.cmId, this.discussionId); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { this.discussionLoaded = true; this.refreshIcon = CoreConstants.ICON_REFRESH; @@ -616,7 +616,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes .syncDiscussionReplies(this.discussionId) .then((result) => { if (result.warnings && result.warnings.length) { - CoreDomUtils.showAlert(undefined, result.warnings[0]); + CoreAlerts.show({ message: result.warnings[0] }); } if (result && result.updated && this.forumId) { @@ -637,7 +637,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes .syncRatings(this.cmId, this.discussionId) .then((result) => { if (result.warnings && result.warnings.length) { - CoreDomUtils.showAlert(undefined, result.warnings[0]); + CoreAlerts.show({ message: result.warnings[0] }); } return; @@ -648,7 +648,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes await Promise.all(promises); } catch (error) { if (showErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') }); } throw new Error('Failed syncing discussion'); @@ -740,7 +740,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes translateMessage: true, }); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } @@ -776,7 +776,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes translateMessage: true, }); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } @@ -812,7 +812,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes translateMessage: true, }); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts index 8001b72ea..6a53b218e 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts @@ -27,7 +27,6 @@ import { import { CoreEditorRichTextEditorComponent } from '@features/editor/components/rich-text-editor/rich-text-editor'; import { AddonModForumSync } from '@addons/mod/forum/services/forum-sync'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { CoreSync } from '@services/sync'; import { AddonModForumDiscussionOptions, AddonModForumOffline } from '@addons/mod/forum/services/forum-offline'; @@ -54,6 +53,7 @@ import { import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; type NewDiscussionData = { subject: string; @@ -159,7 +159,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea await this.discussions.start(); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); this.goBack(); @@ -183,7 +183,10 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea // Refresh data if this discussion is synchronized automatically. this.syncObserver = CoreEvents.on(ADDON_MOD_FORUM_AUTO_SYNCED, data => { if (data.forumId == this.forumId && data.userId == CoreSites.getCurrentSiteUserId()) { - CoreDomUtils.showAlertTranslated('core.notice', 'core.contenteditingsynced'); + CoreAlerts.show({ + header: Translate.instant('core.notice'), + message: Translate.instant('core.contenteditingsynced'), + }); this.returnToDiscussions(); } }, CoreSites.getCurrentSiteId()); @@ -336,7 +339,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_forum.errorgetgroups', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_forum.errorgetgroups') }); this.showForm = false; } @@ -541,12 +544,12 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea }; if (!subject) { - CoreDomUtils.showErrorModal('addon.mod_forum.erroremptysubject', true); + CoreAlerts.showError(Translate.instant('addon.mod_forum.erroremptysubject')); return; } if (!message) { - CoreDomUtils.showErrorModal('addon.mod_forum.erroremptymessage', true); + CoreAlerts.showError(Translate.instant('addon.mod_forum.erroremptymessage')); return; } @@ -584,7 +587,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea if (discussionIds && discussionIds.length < groupIds.length) { // Some discussions could not be created. - CoreDomUtils.showErrorModalDefault(null, 'addon.mod_forum.errorposttoallgroups', true); + CoreAlerts.showError(Translate.instant('addon.mod_forum.errorposttoallgroups')); } CoreForms.triggerFormSubmittedEvent( @@ -595,7 +598,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea this.returnToDiscussions(discussionIds, discTimecreated); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_forum.cannotcreatediscussion', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_forum.cannotcreatediscussion') }); } finally { modal.dismiss(); } @@ -606,7 +609,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea */ async discard(): Promise { try { - await CoreDomUtils.showConfirm(Translate.instant('core.areyousure')); + await CoreAlerts.confirm(Translate.instant('core.areyousure')); const promises: Promise[] = []; @@ -659,7 +662,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea if (AddonModForumHelper.hasPostDataChanged(this.newDiscussion, this.originalData)) { // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } // Delete the local files from the tmp folder. diff --git a/src/addons/mod/forum/pages/search/search.ts b/src/addons/mod/forum/pages/search/search.ts index d95f78a12..24abb8c17 100644 --- a/src/addons/mod/forum/pages/search/search.ts +++ b/src/addons/mod/forum/pages/search/search.ts @@ -31,6 +31,7 @@ import { CoreUrl } from '@singletons/url'; import { CoreUtils } from '@singletons/utils'; import { Translate } from '@singletons'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; @Component({ selector: 'page-addon-mod-forum-search', @@ -82,7 +83,7 @@ export class AddonModForumSearchPage implements OnInit { this.resultsSource.setFilters(filters); this.ready.resolve(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; diff --git a/src/addons/mod/glossary/components/index/index.ts b/src/addons/mod/glossary/components/index/index.ts index 043e4c2e0..c83e48f5a 100644 --- a/src/addons/mod/glossary/components/index/index.ts +++ b/src/addons/mod/glossary/components/index/index.ts @@ -28,7 +28,6 @@ import { CoreRatingSyncProvider } from '@features/rating/services/rating-sync'; import { IonContent } from '@ionic/angular'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -59,6 +58,7 @@ import { GLOSSARY_AUTO_SYNCED, } from '../../constants'; import { CorePopovers } from '@services/overlays/popovers'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a glossary entry page. @@ -339,7 +339,7 @@ export class AddonModGlossaryIndexComponent extends CoreCourseModuleMainActivity await entries.load(); } catch (error) { this.loadMoreError = true; - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingentries', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_glossary.errorloadingentries') }); } finally { infiniteComplete && infiniteComplete(); } diff --git a/src/addons/mod/glossary/pages/edit/edit.ts b/src/addons/mod/glossary/pages/edit/edit.ts index 702485649..0c4800d8c 100644 --- a/src/addons/mod/glossary/pages/edit/edit.ts +++ b/src/addons/mod/glossary/pages/edit/edit.ts @@ -23,7 +23,6 @@ import { CoreFileEntry } from '@services/file-helper'; import { CoreNavigator } from '@services/navigator'; import { CoreNetwork } from '@services/network'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreWSError } from '@classes/errors/wserror'; import { Translate } from '@singletons'; @@ -41,6 +40,7 @@ import { AddonModGlossaryOffline } from '../../services/glossary-offline'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_GLOSSARY_COMPONENT } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the edit form. @@ -108,7 +108,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { this.handler = new AddonModGlossaryNewFormHandler(this); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -142,7 +142,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { url: '/mod/glossary/edit.php' + (this.entry ? `?cmid=${this.cmId}&id=${this.entry.id}` : ''), }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingglossary', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_glossary.errorloadingglossary') }); CoreNavigator.back(); } } @@ -187,7 +187,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { if (this.hasDataChanged()) { // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } // Delete the local files from the tmp folder. @@ -203,7 +203,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { */ async save(): Promise { if (!this.data.concept || !this.data.definition) { - CoreDomUtils.showErrorModal('addon.mod_glossary.fillfields', true); + CoreAlerts.showError(Translate.instant('addon.mod_glossary.fillfields')); return; } @@ -223,7 +223,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { CoreNavigator.back(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.cannoteditentry', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_glossary.cannoteditentry') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/glossary/pages/entry/entry.ts b/src/addons/mod/glossary/pages/entry/entry.ts index e23d765e8..7da33868a 100644 --- a/src/addons/mod/glossary/pages/entry/entry.ts +++ b/src/addons/mod/glossary/pages/entry/entry.ts @@ -26,7 +26,6 @@ import { CoreTag } from '@features/tag/services/tag'; import { FileEntry } from '@awesome-cordova-plugins/file/ngx'; import { CoreNavigator } from '@services/navigator'; import { CoreNetwork } from '@services/network'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -42,6 +41,7 @@ import { ADDON_MOD_GLOSSARY_COMPONENT, ADDON_MOD_GLOSSARY_ENTRY_UPDATED, ADDON_M import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a glossary entry. @@ -126,7 +126,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy { onlineEntryId = Number(this.entrySlug); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); this.goBack(); return; @@ -185,7 +185,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy { const glossaryId = this.glossary?.id; const cancelled = await CorePromiseUtils.promiseFails( - CoreDomUtils.showConfirm(Translate.instant('addon.mod_glossary.areyousuredelete')), + CoreAlerts.confirm(Translate.instant('addon.mod_glossary.areyousuredelete')), ); if (!glossaryId || cancelled) { @@ -224,7 +224,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy { await this.goBack(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errordeleting', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_glossary.errordeleting') }); } finally { modal.dismiss(); } @@ -274,7 +274,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingentry', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_glossary.errorloadingentry') }); } } @@ -298,7 +298,7 @@ export class AddonModGlossaryEntryPage implements OnInit, OnDestroy { this.canEdit = true; this.canDelete = true; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingentry', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_glossary.errorloadingentry') }); } } diff --git a/src/addons/mod/glossary/services/handlers/edit-link.ts b/src/addons/mod/glossary/services/handlers/edit-link.ts index 3d9216ca1..983543e0c 100644 --- a/src/addons/mod/glossary/services/handlers/edit-link.ts +++ b/src/addons/mod/glossary/services/handlers/edit-link.ts @@ -18,10 +18,10 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { makeSingleton } from '@singletons'; +import { makeSingleton, Translate } from '@singletons'; import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Content links handler for glossary new entry. @@ -56,7 +56,7 @@ export class AddonModGlossaryEditLinkHandlerService extends CoreContentLinksHand { siteId }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingglossary', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_glossary.errorloadingglossary') }); } finally { // Just in case. In fact we need to dismiss the modal before showing a toast or error message. modal.dismiss(); diff --git a/src/addons/mod/glossary/services/handlers/entry-link.ts b/src/addons/mod/glossary/services/handlers/entry-link.ts index 735edda6c..413af3c93 100644 --- a/src/addons/mod/glossary/services/handlers/entry-link.ts +++ b/src/addons/mod/glossary/services/handlers/entry-link.ts @@ -18,11 +18,11 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { makeSingleton } from '@singletons'; +import { makeSingleton, Translate } from '@singletons'; import { AddonModGlossary } from '../glossary'; import { ADDON_MOD_GLOSSARY_PAGE_NAME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to treat links to glossary entries. @@ -67,7 +67,7 @@ export class AddonModGlossaryEntryLinkHandlerService extends CoreContentLinksHan }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_glossary.errorloadingentry', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_glossary.errorloadingentry') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/h5pactivity/components/index/index.ts b/src/addons/mod/h5pactivity/components/index/index.ts index 30ca179c5..b402feedf 100644 --- a/src/addons/mod/h5pactivity/components/index/index.ts +++ b/src/addons/mod/h5pactivity/components/index/index.ts @@ -28,7 +28,6 @@ import { CoreNetwork } from '@services/network'; import { CoreFilepool } from '@services/filepool'; import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreWSFile } from '@services/ws'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { @@ -58,6 +57,8 @@ import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { Subscription } from 'rxjs'; import { NgZone, Translate } from '@singletons'; import { CoreError } from '@classes/errors/error'; +import { CoreErrorHelper } from '@services/error-helper'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays an H5P activity entry page. @@ -146,7 +147,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv if (this.playing && !this.fileUrl && !this.isOnline && wasOnline && this.trackComponent) { // User lost connection while playing an online package with tracking. Show an error. - this.offlineErrorAlert = await CoreDomUtils.showErrorModal( + this.offlineErrorAlert = await CoreAlerts.showError( new CoreError(Translate.instant('core.course.changesofflinemaybelost'), { title: Translate.instant('core.youreoffline'), }), @@ -398,14 +399,14 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv } if (!CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal('core.networkerrormsg', true); + CoreAlerts.showError(Translate.instant('core.networkerrormsg')); return; } try { // Confirm the download if needed. - await CoreDomUtils.confirmDownloadSize({ size: this.deployedFile.filesize || 0, total: true }); + await CoreAlerts.confirmDownloadSize({ size: this.deployedFile.filesize || 0, total: true }); await this.downloadDeployedFile(); @@ -414,7 +415,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv } } catch (error) { - if (CoreDomUtils.isCanceledError(error) || this.isDestroyed) { + if (CoreErrorHelper.isCanceledError(error) || this.isDestroyed) { // User cancelled or view destroyed, stop. return; } @@ -433,7 +434,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv return; } - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } @@ -450,7 +451,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv this.play(); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } @@ -522,7 +523,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv if (!this.fileUrl && !this.isOnline) { this.triedToPlay = true; - CoreDomUtils.showErrorModal(new CoreError(Translate.instant('core.connectandtryagain'), { + CoreAlerts.showError(new CoreError(Translate.instant('core.connectandtryagain'), { title: Translate.instant('core.course.activitynotavailableoffline'), })); @@ -697,7 +698,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv } } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error sending tracking data.'); + CoreAlerts.showError(error, { default: 'Error sending tracking data.' }); } } @@ -757,7 +758,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv this.hasOffline = !sent; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error sending tracking data.'); + CoreAlerts.showError(error, { default: 'Error sending tracking data.' }); } } @@ -778,7 +779,7 @@ export class AddonModH5PActivityIndexComponent extends CoreCourseModuleMainActiv }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error sending tracking data.'); + CoreAlerts.showError(error, { default: 'Error sending tracking data.' }); } } diff --git a/src/addons/mod/h5pactivity/pages/attempt-results/attempt-results.ts b/src/addons/mod/h5pactivity/pages/attempt-results/attempt-results.ts index dd74688b5..0cd892bf0 100644 --- a/src/addons/mod/h5pactivity/pages/attempt-results/attempt-results.ts +++ b/src/addons/mod/h5pactivity/pages/attempt-results/attempt-results.ts @@ -16,7 +16,6 @@ import { Component, OnInit } from '@angular/core'; import { CoreUser, CoreUserProfile } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { AddonModH5PActivity, @@ -26,6 +25,7 @@ import { import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_H5PACTIVITY_COMPONENT } from '../../constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays results of an attempt. @@ -78,8 +78,7 @@ export class AddonModH5PActivityAttemptResultsPage implements OnInit { this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId'); this.attemptId = CoreNavigator.getRequiredRouteNumberParam('attemptId'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -116,7 +115,7 @@ export class AddonModH5PActivityAttemptResultsPage implements OnInit { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading attempt.'); + CoreAlerts.showError(error, { default: 'Error loading attempt.' }); } finally { this.loaded = true; } diff --git a/src/addons/mod/h5pactivity/pages/index/index.ts b/src/addons/mod/h5pactivity/pages/index/index.ts index a12b552bd..b6a100c89 100644 --- a/src/addons/mod/h5pactivity/pages/index/index.ts +++ b/src/addons/mod/h5pactivity/pages/index/index.ts @@ -16,9 +16,9 @@ import { Component, OnDestroy, ViewChild } from '@angular/core'; import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; import { CanLeave } from '@guards/can-leave'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { AddonModH5PActivityIndexComponent } from '../../components/index'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays an H5P activity. @@ -45,7 +45,7 @@ export class AddonModH5PActivityIndexPage extends CoreCourseModuleMainActivityPa if (!this.canLeaveSafely) { try { - await CoreDomUtils.showConfirm(Translate.instant('core.confirmleaveunknownchanges')); + await CoreAlerts.confirm(Translate.instant('core.confirmleaveunknownchanges')); return true; } catch { diff --git a/src/addons/mod/h5pactivity/pages/user-attempts/user-attempts.ts b/src/addons/mod/h5pactivity/pages/user-attempts/user-attempts.ts index 7edad6991..1fbf891e7 100644 --- a/src/addons/mod/h5pactivity/pages/user-attempts/user-attempts.ts +++ b/src/addons/mod/h5pactivity/pages/user-attempts/user-attempts.ts @@ -17,7 +17,6 @@ import { Component, OnInit } from '@angular/core'; import { CoreUser, CoreUserProfile } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { AddonModH5PActivity, @@ -27,6 +26,7 @@ import { } from '../../services/h5pactivity'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays user attempts of a certain user. @@ -79,8 +79,7 @@ export class AddonModH5PActivityUserAttemptsPage implements OnInit { this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId'); this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId(); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -118,7 +117,7 @@ export class AddonModH5PActivityUserAttemptsPage implements OnInit { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading attempts.'); + CoreAlerts.showError(error, { default: 'Error loading attempts.' }); } finally { this.loaded = true; } diff --git a/src/addons/mod/h5pactivity/pages/users-attempts/users-attempts.ts b/src/addons/mod/h5pactivity/pages/users-attempts/users-attempts.ts index 8c7d0b889..716c60f1b 100644 --- a/src/addons/mod/h5pactivity/pages/users-attempts/users-attempts.ts +++ b/src/addons/mod/h5pactivity/pages/users-attempts/users-attempts.ts @@ -16,7 +16,6 @@ import { Component, OnInit } from '@angular/core'; import { CoreUser, CoreUserProfile } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { AddonModH5PActivity, @@ -26,6 +25,7 @@ import { import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { AddonModH5PActivityGradeMethod } from '../../constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays all users that can attempt an H5P activity. @@ -74,8 +74,7 @@ export class AddonModH5PActivityUsersAttemptsPage implements OnInit { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); this.cmId = CoreNavigator.getRequiredRouteNumberParam('cmId'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -111,7 +110,7 @@ export class AddonModH5PActivityUsersAttemptsPage implements OnInit { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading attempts.'); + CoreAlerts.showError(error, { default: 'Error loading attempts.' }); } finally { this.loaded = true; } @@ -192,7 +191,7 @@ export class AddonModH5PActivityUsersAttemptsPage implements OnInit { try { await this.fetchUsers(false); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading more users'); + CoreAlerts.showError(error, { default: 'Error loading more users' }); this.fetchMoreUsersFailed = true; } diff --git a/src/addons/mod/h5pactivity/services/handlers/report-link.ts b/src/addons/mod/h5pactivity/services/handlers/report-link.ts index acba0c538..7dd18a83d 100644 --- a/src/addons/mod/h5pactivity/services/handlers/report-link.ts +++ b/src/addons/mod/h5pactivity/services/handlers/report-link.ts @@ -19,12 +19,12 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { makeSingleton } from '@singletons'; import { AddonModH5PActivity } from '../h5pactivity'; import { ADDON_MOD_H5PACTIVITY_PAGE_NAME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to treat links to H5P activity report. @@ -65,7 +65,7 @@ export class AddonModH5PActivityReportLinkHandlerService extends CoreContentLink await this.openUserAttempts(module.id, module.course, instanceId, siteId, userId); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error processing link.'); + CoreAlerts.showError(error, { default: 'Error processing link.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/imscp/pages/view/view.ts b/src/addons/mod/imscp/pages/view/view.ts index fba93136a..6a891c3b5 100644 --- a/src/addons/mod/imscp/pages/view/view.ts +++ b/src/addons/mod/imscp/pages/view/view.ts @@ -22,12 +22,12 @@ import { CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreCourseModulePrefetchDelegate } from '@features/course/services/module-prefetch-delegate'; import { CoreNetwork } from '@services/network'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreErrorHelper } from '@services/error-helper'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; import { AddonModImscp, AddonModImscpImscp, AddonModImscpTocItem } from '../../services/imscp'; import { CoreModals } from '@services/overlays/modals'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a IMSCP content. @@ -61,8 +61,7 @@ export class AddonModImscpViewPage implements OnInit { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); this.initialItemHref = CoreNavigator.getRouteParam('initialHref'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -118,7 +117,7 @@ export class AddonModImscpViewPage implements OnInit { try { await this.loadItemHref(this.currentHref); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_imscp.deploymenterror', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_imscp.deploymenterror') }); return; } @@ -130,7 +129,7 @@ export class AddonModImscpViewPage implements OnInit { this.warning = ''; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { this.loaded = true; } diff --git a/src/addons/mod/lesson/components/index/index.ts b/src/addons/mod/lesson/components/index/index.ts index 350bbcd82..ecf708ad8 100644 --- a/src/addons/mod/lesson/components/index/index.ts +++ b/src/addons/mod/lesson/components/index/index.ts @@ -22,7 +22,6 @@ import { CoreUser } from '@features/user/services/user'; import { IonContent, IonInput } from '@ionic/angular'; import { CoreGroupInfo, CoreGroups } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreForms } from '@singletons/form'; import { CoreText } from '@singletons/text'; import { CorePromiseUtils } from '@singletons/promise-utils'; @@ -52,6 +51,7 @@ import { ADDON_MOD_LESSON_DATA_SENT_EVENT, ADDON_MOD_LESSON_PAGE_NAME, } from '../../constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a lesson entry page. @@ -126,7 +126,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo try { await this.setGroup(groupId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting report.'); + CoreAlerts.showError(error, { default: 'Error getting report.' }); } finally { this.reportLoaded = true; } @@ -464,7 +464,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo if (!this.groupInfo) { this.fetchReportData().catch((error) => { - CoreDomUtils.showErrorModalDefault(error, 'Error getting report.'); + CoreAlerts.showError(error, { default: 'Error getting report.' }); }); } @@ -613,7 +613,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo // Error downloading but there is something offline, allow continuing it. this.playLesson(continueLast); } else { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } finally { this.showSpinner = false; @@ -632,7 +632,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo const password = passwordEl?.value; if (!password) { - CoreDomUtils.showErrorModal('addon.mod_lesson.emptypassword', true); + CoreAlerts.showError(Translate.instant('addon.mod_lesson.emptypassword')); return; } @@ -652,7 +652,7 @@ export class AddonModLessonIndexComponent extends CoreCourseModuleMainActivityCo // Log view now that we have the password. this.logActivity(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { this.showLoading = false; diff --git a/src/addons/mod/lesson/pages/player/player.ts b/src/addons/mod/lesson/pages/player/player.ts index a6d879c53..6ed71931e 100644 --- a/src/addons/mod/lesson/pages/player/player.ts +++ b/src/addons/mod/lesson/pages/player/player.ts @@ -22,7 +22,6 @@ import { CoreNetwork } from '@services/network'; import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesCommonWSOptions, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CoreObject } from '@singletons/object'; import { CoreWSExternalFile } from '@services/ws'; @@ -58,6 +57,7 @@ import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreDom } from '@singletons/dom'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that allows attempting and reviewing a lesson. @@ -131,7 +131,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { this.currentPage = CoreNavigator.getRouteNumberParam('pageId'); this.retakeToReview = CoreNavigator.getRouteNumberParam('retake'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -173,7 +173,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { if (this.question && !this.eolData && !this.processData && this.originalData) { // Question shown. Check if there is any change. if (!CoreObject.basicLeftCompare(this.questionForm.getRawValue(), this.originalData, 3)) { - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } } @@ -258,7 +258,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { try { await this.loadPage(pageId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading page'); + CoreAlerts.showError(error, { default: 'Error loading page' }); } finally { this.loaded = true; } @@ -363,7 +363,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { await AddonModLessonSync.deleteRetakeFinishedInSync(this.lesson!.id); } - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); this.forceLeave = true; CoreNavigator.back(); @@ -406,7 +406,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { } // Retake hasn't changed, show the warning and finish the retake in offline. - CoreDomUtils.showAlert(undefined, result.warnings[0]); + CoreAlerts.show({ message: result.warnings[0] }); } this.offline = false; @@ -546,7 +546,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { this.lessonPages = pages.map((entry) => entry.page); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading menu.'); + CoreAlerts.showError(error, { default: 'Error loading menu.' }); } finally { this.loadingMenu = false; } @@ -763,7 +763,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { this.logContinuePageLoaded(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error processing page'); + CoreAlerts.showError(error, { default: 'Error processing page' }); } finally { this.loaded = true; } @@ -782,7 +782,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { try { await this.loadPage(pageId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading page'); + CoreAlerts.showError(error, { default: 'Error loading page' }); } finally { this.loaded = true; } @@ -818,7 +818,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { try { await this.finishRetake(true); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error finishing attempt'); + CoreAlerts.showError(error, { default: 'Error finishing attempt' }); } finally { this.loaded = true; } diff --git a/src/addons/mod/lesson/pages/user-retake/user-retake.ts b/src/addons/mod/lesson/pages/user-retake/user-retake.ts index 8a7510062..875792da3 100644 --- a/src/addons/mod/lesson/pages/user-retake/user-retake.ts +++ b/src/addons/mod/lesson/pages/user-retake/user-retake.ts @@ -18,7 +18,6 @@ import { CoreError } from '@classes/errors/error'; import { CoreUser } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreErrorHelper } from '@services/error-helper'; import { Translate } from '@singletons'; @@ -36,6 +35,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_LESSON_COMPONENT } from '../../constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a retake made by a certain user. @@ -76,8 +76,7 @@ export class AddonModLessonUserRetakePage implements OnInit { this.userId = CoreNavigator.getRouteNumberParam('userId') || CoreSites.getCurrentSiteUserId(); this.retakeNumber = CoreNavigator.getRouteNumberParam('retake'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -103,7 +102,7 @@ export class AddonModLessonUserRetakePage implements OnInit { this.performLogView(); } catch (error) { this.selectedRetake = this.previousSelectedRetake ?? this.selectedRetake; - CoreDomUtils.showErrorModal(CoreErrorHelper.addDataNotDownloadedError(error, 'Error getting attempt.')); + CoreAlerts.showError(CoreErrorHelper.addDataNotDownloadedError(error, 'Error getting attempt.')); } finally { this.loaded = true; } @@ -171,7 +170,7 @@ export class AddonModLessonUserRetakePage implements OnInit { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting data.', true); + CoreAlerts.showError(error, { default: Translate.instant('Error getting data.') }); } } diff --git a/src/addons/mod/lesson/services/handlers/grade-link.ts b/src/addons/mod/lesson/services/handlers/grade-link.ts index 539c17512..ef9edd5e4 100644 --- a/src/addons/mod/lesson/services/handlers/grade-link.ts +++ b/src/addons/mod/lesson/services/handlers/grade-link.ts @@ -19,11 +19,11 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreCourseHelper } from '@features/course/services/course-helper'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { makeSingleton } from '@singletons'; +import { makeSingleton, Translate } from '@singletons'; import { AddonModLesson } from '../lesson'; import { ADDON_MOD_LESSON_PAGE_NAME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to treat links to lesson grade. @@ -84,7 +84,7 @@ export class AddonModLessonGradeLinkHandlerService extends CoreContentLinksModul }); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/lesson/services/handlers/prefetch.ts b/src/addons/mod/lesson/services/handlers/prefetch.ts index 8c3effc9d..7e66b436c 100644 --- a/src/addons/mod/lesson/services/handlers/prefetch.ts +++ b/src/addons/mod/lesson/services/handlers/prefetch.ts @@ -21,7 +21,6 @@ import { CoreFilepool } from '@services/filepool'; import { CoreGroups } from '@services/groups'; import { CoreFileSizeSum, CorePluginFileDelegate } from '@services/plugin-file-delegate'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSFile } from '@services/ws'; import { makeSingleton, Translate } from '@singletons'; @@ -33,6 +32,7 @@ import { } from '../lesson'; import { AddonModLessonSync, AddonModLessonSyncResult } from '../lesson-sync'; import { ADDON_MOD_LESSON_COMPONENT, AddonModLessonJumpTo, AddonModLessonPageSubtype } from '../../constants'; +import { CorePrompts } from '@services/overlays/prompts'; /** * Handler to prefetch lessons. @@ -136,7 +136,7 @@ export class AddonModLessonPrefetchHandlerService extends CoreCourseActivityPref } // Create and show the modal. - const response = await CoreModals.promptPassword({ + const response = await CorePrompts.promptPassword({ title: 'addon.mod_lesson.enterpassword', placeholder: 'core.login.password', submit: 'addon.mod_lesson.continue', diff --git a/src/addons/mod/lesson/services/handlers/report-link.ts b/src/addons/mod/lesson/services/handlers/report-link.ts index c897784ee..dc0463844 100644 --- a/src/addons/mod/lesson/services/handlers/report-link.ts +++ b/src/addons/mod/lesson/services/handlers/report-link.ts @@ -19,10 +19,10 @@ import { CoreContentLinksAction } from '@features/contentlinks/services/contentl import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { ADDON_MOD_LESSON_PAGE_NAME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to treat links to lesson report. @@ -111,7 +111,7 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand { params, siteId }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error processing link.'); + CoreAlerts.showError(error, { default: 'Error processing link.' }); } finally { modal.dismiss(); } @@ -150,7 +150,7 @@ export class AddonModLessonReportLinkHandlerService extends CoreContentLinksHand { params, siteId }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error processing link.'); + CoreAlerts.showError(error, { default: 'Error processing link.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/lti/services/lti-helper.ts b/src/addons/mod/lti/services/lti-helper.ts index dd655edc3..9a83f8c5b 100644 --- a/src/addons/mod/lti/services/lti-helper.ts +++ b/src/addons/mod/lti/services/lti-helper.ts @@ -18,12 +18,12 @@ import { CoreCourse } from '@features/course/services/course'; import { CoreCourseModuleData } from '@features/course/services/course-helper'; import { CorePlatform } from '@services/platform'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { makeSingleton } from '@singletons'; +import { makeSingleton, Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { AddonModLti, AddonModLtiLti } from './lti'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Service that provides some helper functions for LTI. @@ -93,7 +93,7 @@ export class AddonModLtiHelperProvider { // Launch LTI. return AddonModLti.launch(launchData.endpoint, launchData.parameters); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_lti.errorgetlti', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_lti.errorgetlti') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/quiz/components/index/index.ts b/src/addons/mod/quiz/components/index/index.ts index 453d459ba..30515e84b 100644 --- a/src/addons/mod/quiz/components/index/index.ts +++ b/src/addons/mod/quiz/components/index/index.ts @@ -21,7 +21,6 @@ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents import { CoreQuestionBehaviourDelegate } from '@features/question/services/behaviour-delegate'; import { IonContent } from '@ionic/angular'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; @@ -51,6 +50,7 @@ import { AddonModQuizAttemptStates, } from '../../constants'; import { QuestionDisplayOptionsMarks } from '@features/question/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a quiz entry page. @@ -167,7 +167,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp // If the site doesn't support check updates, continue too because we cannot tell if there's something new. this.openQuiz(); } else { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } finally { this.showStatusSpinner = false; @@ -192,7 +192,7 @@ export class AddonModQuizIndexComponent extends CoreCourseModuleMainActivityComp if (warnings?.length) { // Show warnings and delete them so they aren't shown again. - CoreDomUtils.showErrorModal(CoreText.buildMessage(warnings)); + CoreAlerts.showError(CoreText.buildMessage(warnings)); await AddonModQuizSync.setSyncWarnings(quiz.id, []); } diff --git a/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts b/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts index 975f4ae42..39eee8709 100644 --- a/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts +++ b/src/addons/mod/quiz/components/preflight-modal/preflight-modal.ts @@ -15,8 +15,6 @@ import { Component, OnInit, ViewChild, ElementRef, Input, Type } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { CoreSites } from '@services/sites'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CoreForms } from '@singletons/form'; import { ModalController, Translate } from '@singletons'; import { AddonModQuizAccessRuleDelegate } from '../../services/access-rules-delegate'; @@ -24,6 +22,7 @@ import { AddonModQuizAttemptWSData, AddonModQuizQuizWSData } from '../../service import { CoreDom } from '@singletons/dom'; import { CoreSharedModule } from '@/core/shared.module'; import { toBoolean } from '@/core/transforms/boolean'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Modal that renders the access rules for a quiz. @@ -107,7 +106,7 @@ export class AddonModQuizPreflightModalComponent implements OnInit { })); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading rules'); + CoreAlerts.showError(error, { default: 'Error loading rules' }); } finally { this.loaded = true; } @@ -130,7 +129,7 @@ export class AddonModQuizPreflightModalComponent implements OnInit { if (!hasScrolled) { // Input not found, show an error modal. - CoreDomUtils.showErrorModal('core.errorinvalidform', true); + CoreAlerts.showError(Translate.instant('core.errorinvalidform')); } } else { CoreForms.triggerFormSubmittedEvent(this.formElement, false, this.siteId); diff --git a/src/addons/mod/quiz/pages/player/player.ts b/src/addons/mod/quiz/pages/player/player.ts index 7872dfd77..0c977fad8 100644 --- a/src/addons/mod/quiz/pages/player/player.ts +++ b/src/addons/mod/quiz/pages/player/player.ts @@ -27,7 +27,6 @@ import { CoreQuestionBehaviourButton, CoreQuestionHelper } from '@features/quest import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { ModalController, Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; @@ -56,6 +55,7 @@ import { ADDON_MOD_QUIZ_ATTEMPT_FINISHED_EVENT, AddonModQuizAttemptStates, ADDON import { CoreWait } from '@singletons/wait'; import { CoreModals } from '@services/overlays/modals'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that allows attempting a quiz. @@ -124,7 +124,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); this.moduleUrl = CoreNavigator.getRouteParam('moduleUrl'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -178,7 +178,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { // Save attempt failed. Show confirmation. modal.dismiss(); - await CoreDomUtils.showConfirm(Translate.instant('addon.mod_quiz.confirmleavequizonerror')); + await CoreAlerts.confirm(Translate.instant('addon.mod_quiz.confirmleavequizonerror')); CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId()); } finally { @@ -219,7 +219,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { try { // Confirm that the user really wants to do it. - await CoreDomUtils.showConfirm(Translate.instant('core.areyousure')); + await CoreAlerts.confirm(Translate.instant('core.areyousure')); modal = await CoreLoadings.show('core.sending', true); @@ -253,7 +253,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { } } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error performing action.'); + CoreAlerts.showError(error, { default: 'Error performing action.' }); } finally { modal?.dismiss(); } @@ -303,7 +303,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { modal.dismiss(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorsaveattempt', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_quiz.errorsaveattempt') }); modal.dismiss(); return; @@ -330,7 +330,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { this.autoSave.startCheckChangesProcess(this.quiz, this.attempt, this.preflightData, this.offline); } - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorgetquestions', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_quiz.errorgetquestions') }); } finally { this.loaded = true; @@ -437,11 +437,10 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { `; } - await CoreDomUtils.showConfirm( - message, - Translate.instant('addon.mod_quiz.submitallandfinish'), - Translate.instant('core.submit'), - ); + await CoreAlerts.confirm(message, { + header: Translate.instant('addon.mod_quiz.submitallandfinish'), + okText: Translate.instant('core.submit'), + }); } modal = await CoreLoadings.show('core.sending', true); @@ -471,8 +470,8 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { } } catch (error) { // eslint-disable-next-line promise/catch-or-return - CoreDomUtils - .showErrorModalDefault(error, 'addon.mod_quiz.errorsaveattempt', true) + CoreAlerts + .showError(error, { default: Translate.instant('addon.mod_quiz.errorsaveattempt') }) .then(async alert => { await alert?.onWillDismiss(); @@ -882,7 +881,7 @@ export class AddonModQuizPlayerPage implements OnInit, OnDestroy, CanLeave { // Quiz data has been loaded, try to start or continue. await this.startOrContinueAttempt(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorgetquiz', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_quiz.errorgetquiz') }); } finally { this.loaded = true; } diff --git a/src/addons/mod/quiz/pages/review/review.ts b/src/addons/mod/quiz/pages/review/review.ts index e392e0b5f..82124e211 100644 --- a/src/addons/mod/quiz/pages/review/review.ts +++ b/src/addons/mod/quiz/pages/review/review.ts @@ -17,7 +17,6 @@ import { CoreQuestionQuestionForView } from '@features/question/services/questio import { CoreQuestionHelper } from '@features/question/services/question-helper'; import { IonContent } from '@ionic/angular'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreDom } from '@singletons/dom'; import { CoreTime } from '@singletons/time'; @@ -36,6 +35,8 @@ import { AddonModQuizHelper } from '../../services/quiz-helper'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_QUIZ_COMPONENT } from '../../constants'; import { CoreModals } from '@services/overlays/modals'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that allows reviewing a quiz attempt. @@ -92,8 +93,7 @@ export class AddonModQuizReviewPage implements OnInit { this.currentPage = CoreNavigator.getRouteNumberParam('page') || -1; this.showAll = this.currentPage == -1; } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -131,7 +131,7 @@ export class AddonModQuizReviewPage implements OnInit { this.performLogView(false, { page }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorgetquestions', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_quiz.errorgetquestions') }); } finally { this.loaded = true; @@ -163,7 +163,7 @@ export class AddonModQuizReviewPage implements OnInit { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_quiz.errorgetquiz', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_quiz.errorgetquiz') }); } } diff --git a/src/addons/mod/quiz/services/quiz-helper.ts b/src/addons/mod/quiz/services/quiz-helper.ts index febbe0103..85ba4d505 100644 --- a/src/addons/mod/quiz/services/quiz-helper.ts +++ b/src/addons/mod/quiz/services/quiz-helper.ts @@ -44,6 +44,7 @@ import { CoreModals } from '@services/overlays/modals'; import { CoreLoadings } from '@services/overlays/loadings'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Helper service that provides some features for quiz. @@ -233,7 +234,7 @@ export class AddonModQuizHelperProvider { // Show error and ask for the preflight again. // Wait to show the error because we want it to be shown over the preflight modal. setTimeout(() => { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); }, 100); return this.getAndCheckPreflightData(quiz, accessInfo, preflightData, { @@ -362,7 +363,7 @@ export class AddonModQuizHelperProvider { }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'An error occurred while loading the required data.'); + CoreAlerts.showError(error, { default: 'An error occurred while loading the required data.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/resource/components/index/index.ts b/src/addons/mod/resource/components/index/index.ts index 58a961e56..31c79bad0 100644 --- a/src/addons/mod/resource/components/index/index.ts +++ b/src/addons/mod/resource/components/index/index.ts @@ -22,7 +22,6 @@ import { CoreCourseModulePrefetchDelegate } from '@features/course/services/modu import { CoreNetwork } from '@services/network'; import { CoreFileHelper } from '@services/file-helper'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreText } from '@singletons/text'; import { NgZone, Translate } from '@singletons'; @@ -36,6 +35,7 @@ import { CorePlatform } from '@services/platform'; import { ADDON_MOD_RESOURCE_COMPONENT } from '../../constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { OpenFileAction } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a resource. @@ -214,10 +214,9 @@ export class AddonModResourceIndexComponent extends CoreCourseModuleMainResource if (downloadable) { if (this.currentStatus === DownloadStatus.OUTDATED && !this.isOnline && !this.isExternalFile) { // Warn the user that the file isn't updated. - const alert = await CoreDomUtils.showAlert( - undefined, - Translate.instant('addon.mod_resource.resourcestatusoutdatedconfirm'), - ); + const alert = await CoreAlerts.show({ + message: Translate.instant('addon.mod_resource.resourcestatusoutdatedconfirm'), + }); await alert.onWillDismiss(); } diff --git a/src/addons/mod/resource/services/resource-helper.ts b/src/addons/mod/resource/services/resource-helper.ts index 970033c76..e068655a1 100644 --- a/src/addons/mod/resource/services/resource-helper.ts +++ b/src/addons/mod/resource/services/resource-helper.ts @@ -22,7 +22,6 @@ import { CoreFile } from '@services/file'; import { CoreFileHelper } from '@services/file-helper'; import { CoreFilepool } from '@services/filepool'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { makeSingleton, Translate } from '@singletons'; import { CorePath } from '@singletons/path'; @@ -33,6 +32,7 @@ import { CoreTimeUtils } from '@services/utils/time'; import { ADDON_MOD_RESOURCE_COMPONENT } from '../constants'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreOpenerOpenFileOptions } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Service that provides helper functions for resources. @@ -220,7 +220,7 @@ export class AddonModResourceHelperProvider { url: `/mod/resource/view.php?id=${module.id}`, }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_resource.errorwhileloadingthecontent', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_resource.errorwhileloadingthecontent') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/scorm/components/index/index.ts b/src/addons/mod/scorm/components/index/index.ts index 87e7bb36c..1967d6393 100644 --- a/src/addons/mod/scorm/components/index/index.ts +++ b/src/addons/mod/scorm/components/index/index.ts @@ -21,7 +21,6 @@ import { CoreCourse } from '@features/course/services/course'; import { IonContent } from '@ionic/angular'; import { CoreNavigator } from '@services/navigator'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreObject } from '@singletons/object'; import { NgZone, Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -53,6 +52,7 @@ import { CoreWait } from '@singletons/wait'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreNetwork } from '@services/network'; import { Subscription } from 'rxjs'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a SCORM entry page. @@ -463,7 +463,7 @@ export class AddonModScormIndexComponent extends CoreCourseModuleMainActivityCom try { await this.loadOrganizationToc(this.scorm, this.currentOrganization.identifier); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, this.fetchContentDefaultError, true); + CoreAlerts.showError(error, { default: Translate.instant(this.fetchContentDefaultError) }); } } @@ -549,10 +549,9 @@ export class AddonModScormIndexComponent extends CoreCourseModuleMainActivityCom } } catch (error) { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault( - error, - Translate.instant('addon.mod_scorm.errordownloadscorm', { name: scorm.name }), - ); + CoreAlerts.showError(error, { + default: Translate.instant('addon.mod_scorm.errordownloadscorm', { name: scorm.name }), + }); } } } diff --git a/src/addons/mod/scorm/pages/online-player/online-player.ts b/src/addons/mod/scorm/pages/online-player/online-player.ts index 41e2115db..4e02a4b37 100644 --- a/src/addons/mod/scorm/pages/online-player/online-player.ts +++ b/src/addons/mod/scorm/pages/online-player/online-player.ts @@ -15,7 +15,6 @@ import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreEvents } from '@singletons/events'; import { AddonModScorm, @@ -33,6 +32,7 @@ import { NgZone, Translate } from '@singletons'; import { CoreError } from '@classes/errors/error'; import { CoreWait } from '@singletons/wait'; import { CoreIframeComponent } from '@components/iframe/iframe'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that allows playing a SCORM in online, served from the server. @@ -78,7 +78,7 @@ export default class AddonModScormOnlinePlayerPage implements OnInit, OnDestroy if (!isOnline && wasOnline) { // User lost connection while playing an online package. Show an error. - CoreDomUtils.showErrorModal(new CoreError(Translate.instant('core.course.changesofflinemaybelost'), { + CoreAlerts.showError(new CoreError(Translate.instant('core.course.changesofflinemaybelost'), { title: Translate.instant('core.youreoffline'), })); @@ -101,7 +101,7 @@ export default class AddonModScormOnlinePlayerPage implements OnInit, OnDestroy this.organizationId = CoreNavigator.getRouteParam('organizationId'); this.initialScoId = CoreNavigator.getRouteNumberParam('scoId'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -221,7 +221,7 @@ export default class AddonModScormOnlinePlayerPage implements OnInit, OnDestroy newAttempt: this.newAttempt, }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_scorm.errorgetscorm') }); } } diff --git a/src/addons/mod/scorm/pages/player/player.ts b/src/addons/mod/scorm/pages/player/player.ts index fe96177cf..daa4b1534 100644 --- a/src/addons/mod/scorm/pages/player/player.ts +++ b/src/addons/mod/scorm/pages/player/player.ts @@ -17,7 +17,6 @@ import { CoreNavigationBarItem } from '@components/navigation-bar/navigation-bar import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTimeUtils } from '@services/utils/time'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -43,6 +42,8 @@ import { } from '../../constants'; import { CoreWait } from '@singletons/wait'; import { CoreModals } from '@services/overlays/modals'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that allows playing a SCORM. @@ -102,8 +103,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { this.initialScoId = CoreNavigator.getRouteNumberParam('scoId'); this.siteId = CoreSites.getRequiredCurrentSite().getId(); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -124,7 +124,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { try { await this.setStartTime(this.currentSco.id); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_scorm.errorgetscorm') }); } } @@ -214,7 +214,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { try { AddonModScormHelper.convertAttemptToOffline(this.scorm, this.attempt); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } this.refreshToc(); @@ -338,7 +338,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { this.userData = data; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_scorm.errorgetscorm') }); } } @@ -494,7 +494,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { await AddonModScorm.saveTracks(sco.id, this.attempt, tracks, this.scorm, true); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.error', true); + CoreAlerts.showError(error, { default: Translate.instant('core.error') }); } } finally { // Refresh TOC, some prerequisites might have changed. @@ -537,7 +537,7 @@ export class AddonModScormPlayerPage implements OnInit, OnDestroy { await this.fetchToc(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_scorm.errorgetscorm', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_scorm.errorgetscorm') }); } } diff --git a/src/addons/mod/scorm/services/scorm-helper.ts b/src/addons/mod/scorm/services/scorm-helper.ts index adadfc273..a1155073c 100644 --- a/src/addons/mod/scorm/services/scorm-helper.ts +++ b/src/addons/mod/scorm/services/scorm-helper.ts @@ -16,7 +16,6 @@ import { Injectable } from '@angular/core'; import { CoreError } from '@classes/errors/error'; import { CoreCourseCommonModWSOptions } from '@features/course/services/course'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { makeSingleton, Translate } from '@singletons'; import { @@ -34,6 +33,7 @@ import { import { AddonModScormOffline } from './scorm-offline'; import { AddonModScormMode } from '../constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; // List of elements we want to ignore when copying attempts (they're calculated). const elementsToIgnore = [ @@ -72,7 +72,7 @@ export class AddonModScormHelperProvider { scorm.packagesize = size; } - return CoreDomUtils.confirmDownloadSize({ size: size, total: true }); + return CoreAlerts.confirmDownloadSize({ size: size, total: true }); } /** diff --git a/src/addons/mod/subsection/services/handlers/index-link.ts b/src/addons/mod/subsection/services/handlers/index-link.ts index 58f324f9b..f8fa01aa9 100644 --- a/src/addons/mod/subsection/services/handlers/index-link.ts +++ b/src/addons/mod/subsection/services/handlers/index-link.ts @@ -17,10 +17,10 @@ import { CoreContentLinksModuleIndexHandler } from '@features/contentlinks/class import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreCourse } from '@features/course/services/course'; import { CoreLoadings } from '@services/overlays/loadings'; -import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton } from '@singletons'; import { CoreSites } from '@services/sites'; import { CoreCourseHelper } from '@features/course/services/course-helper'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to treat links to subsection. @@ -77,7 +77,7 @@ export class AddonModSubsectionIndexLinkHandlerService extends CoreContentLinksM await this.openSubsection(module.section, module.course, siteId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error opening link.'); + CoreAlerts.showError(error, { default: 'Error opening link.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/survey/components/index/index.ts b/src/addons/mod/survey/components/index/index.ts index ad3c25cb8..c76765b19 100644 --- a/src/addons/mod/survey/components/index/index.ts +++ b/src/addons/mod/survey/components/index/index.ts @@ -19,7 +19,6 @@ import { CoreCourseModuleMainActivityComponent } from '@features/course/classes/ import { CoreCourseContentsPage } from '@features/course/pages/contents/contents'; import { IonContent } from '@ionic/angular'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; @@ -39,6 +38,7 @@ import { import { CorePromiseUtils } from '@singletons/promise-utils'; import { ADDON_MOD_SURVEY_AUTO_SYNCED, ADDON_MOD_SURVEY_COMPONENT } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a survey. @@ -195,7 +195,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo let modal: CoreIonLoadingElement | undefined; try { - await CoreDomUtils.showConfirm(Translate.instant('core.areyousure')); + await CoreAlerts.confirm(Translate.instant('core.areyousure')); const answers: AddonModSurveySubmitAnswerData[] = []; modal = await CoreLoadings.show('core.sending', true); @@ -233,7 +233,7 @@ export class AddonModSurveyIndexComponent extends CoreCourseModuleMainActivityCo this.showLoadingAndRefresh(false); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_survey.cannotsubmitsurvey', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_survey.cannotsubmitsurvey') }); } finally { modal?.dismiss(); } diff --git a/src/addons/mod/wiki/components/index/index.ts b/src/addons/mod/wiki/components/index/index.ts index bad6d8548..e39c2f652 100644 --- a/src/addons/mod/wiki/components/index/index.ts +++ b/src/addons/mod/wiki/components/index/index.ts @@ -25,7 +25,6 @@ import { CoreNetwork } from '@services/network'; import { CoreGroup, CoreGroups } from '@services/groups'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate, NgZone } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -60,6 +59,7 @@ import { } from '../../constants'; import { CoreModals } from '@services/overlays/modals'; import { CorePopovers } from '@services/overlays/popovers'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a wiki entry page. @@ -870,7 +870,7 @@ export class AddonModWikiIndexComponent extends CoreCourseModuleMainActivityComp if (this.isCurrentView && syncEventData.warnings && syncEventData.warnings.length) { // Show warnings. - CoreDomUtils.showAlert(undefined, syncEventData.warnings[0]); + CoreAlerts.show({ message: syncEventData.warnings[0] }); } // Check if current page was created or discarded. diff --git a/src/addons/mod/wiki/pages/edit/edit.ts b/src/addons/mod/wiki/pages/edit/edit.ts index 19f13cadf..ba130fc5d 100644 --- a/src/addons/mod/wiki/pages/edit/edit.ts +++ b/src/addons/mod/wiki/pages/edit/edit.ts @@ -20,7 +20,6 @@ import { CanLeave } from '@guards/can-leave'; import { CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSFile } from '@services/ws'; @@ -34,6 +33,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ADDON_MOD_WIKI_COMPONENT, ADDON_MOD_WIKI_PAGE_CREATED_EVENT, ADDON_MOD_WIKI_RENEW_LOCK_TIME } from '../../constants'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreFileHelper } from '@services/file-helper'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that allows adding or editing a wiki page. @@ -244,7 +244,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave { return true; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting wiki data.'); + CoreAlerts.showError(error, { default: 'Error getting wiki data.' }); fetchFailed = true; // Go back. @@ -254,7 +254,10 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave { } finally { if (!canEdit && !fetchFailed) { // Cannot edit, show alert and go back. - CoreDomUtils.showAlert(Translate.instant('core.notice'), Translate.instant('addon.mod_wiki.cannoteditpage')); + CoreAlerts.show({ + header: Translate.instant('core.notice'), + message: Translate.instant('addon.mod_wiki.cannoteditpage'), + }); this.forceLeavePage(); } } @@ -334,7 +337,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave { // Check if data has changed. if (this.hasDataChanged()) { - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId()); @@ -386,10 +389,10 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave { if (!title) { // Title is mandatory, stop. modal.dismiss(); - CoreDomUtils.showAlert( - Translate.instant('core.notice'), - Translate.instant('addon.mod_wiki.titleshouldnotbeempty'), - ); + CoreAlerts.show({ + header: Translate.instant('core.notice'), + message: Translate.instant('addon.mod_wiki.titleshouldnotbeempty'), + }); return; } @@ -453,7 +456,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave { this.goToPage(title); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error saving wiki data.'); + CoreAlerts.showError(error, { default: 'Error saving wiki data.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/wiki/services/handlers/create-link-lazy.ts b/src/addons/mod/wiki/services/handlers/create-link-lazy.ts index 8187226df..c22f2156f 100644 --- a/src/addons/mod/wiki/services/handlers/create-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/create-link-lazy.ts @@ -17,12 +17,12 @@ import { ActivatedRoute } from '@angular/router'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { makeSingleton } from '@singletons'; +import { makeSingleton, Translate } from '@singletons'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiCreateLinkHandlerService } from '@addons/mod/wiki/services/handlers/create-link'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to treat links to create a wiki page. @@ -132,7 +132,7 @@ export class AddonModWikiCreateLinkHandlerLazyService extends AddonModWikiCreate }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_wiki.errorloadingpage', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_wiki.errorloadingpage') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts b/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts index fcdda3e5f..b208b8ba5 100644 --- a/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/edit-link-lazy.ts @@ -16,12 +16,12 @@ import { Injectable } from '@angular/core'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { makeSingleton } from '@singletons'; +import { makeSingleton, Translate } from '@singletons'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiEditLinkHandlerService } from '@addons/mod/wiki/services/handlers/edit-link'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to treat links to edit a wiki page. @@ -62,7 +62,7 @@ export class AddonModWikiEditLinkHandlerLazyService extends AddonModWikiEditLink }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_wiki.errorloadingpage', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_wiki.errorloadingpage') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts b/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts index 7c2319b35..32b95a85c 100644 --- a/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts +++ b/src/addons/mod/wiki/services/handlers/page-or-map-link-lazy.ts @@ -16,13 +16,13 @@ import { Injectable } from '@angular/core'; import { CoreCourse } from '@features/course/services/course'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { makeSingleton } from '@singletons'; +import { makeSingleton, Translate } from '@singletons'; import { Md5 } from 'ts-md5'; import { AddonModWiki } from '../wiki'; import { ADDON_MOD_WIKI_PAGE_NAME } from '../../constants'; import { AddonModWikiPageOrMapLinkHandlerService } from '@addons/mod/wiki/services/handlers/page-or-map-link'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to treat links to a wiki page or the wiki map. @@ -70,7 +70,7 @@ export class AddonModWikiPageOrMapLinkHandlerLazyService extends AddonModWikiPag }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.mod_wiki.errorloadingpage', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_wiki.errorloadingpage') }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts index b7e016b05..5b7c68489 100644 --- a/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts +++ b/src/addons/mod/workshop/components/assessment-strategy/assessment-strategy.ts @@ -21,7 +21,6 @@ import { CoreFileEntry, CoreFileHelper } from '@services/file-helper'; import { CoreFileSession } from '@services/file-session'; import { CoreSites } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -46,6 +45,7 @@ import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreObject } from '@singletons/object'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays workshop assessment strategy form. @@ -148,7 +148,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe ); } catch (error) { this.componentClass = undefined; - CoreDomUtils.showErrorModalDefault(error, 'Error loading assessment.'); + CoreAlerts.showError(error, { default: 'Error loading assessment.' }); } finally { this.assessmentStrategyLoaded = true; } @@ -400,7 +400,7 @@ export class AddonModWorkshopAssessmentStrategyComponent implements OnInit, OnDe CoreFileUploader.clearTmpFiles(files); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error saving assessment.'); + CoreAlerts.showError(error, { default: 'Error saving assessment.' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/workshop/components/assessment/assessment.ts b/src/addons/mod/workshop/components/assessment/assessment.ts index ed8509410..6b7dc65e1 100644 --- a/src/addons/mod/workshop/components/assessment/assessment.ts +++ b/src/addons/mod/workshop/components/assessment/assessment.ts @@ -18,7 +18,6 @@ import { CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreUser, CoreUserProfile } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { AddonModWorkshopData, AddonModWorkshopGetWorkshopAccessInformationWSResponse } from '../../services/workshop'; import { AddonModWorkshopHelper, @@ -27,6 +26,7 @@ import { } from '../../services/workshop-helper'; import { AddonModWorkshopOffline } from '../../services/workshop-offline'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays workshop assessment. @@ -135,7 +135,7 @@ export class AddonModWorkshopAssessmentComponent implements OnInit { CoreNavigator.navigate(String(this.assessmentId), { params }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Cannot load submission'); + CoreAlerts.showError(error, { default: 'Cannot load submission' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/workshop/pages/assessment/assessment.ts b/src/addons/mod/workshop/pages/assessment/assessment.ts index 41b88263c..98f55d960 100644 --- a/src/addons/mod/workshop/pages/assessment/assessment.ts +++ b/src/addons/mod/workshop/pages/assessment/assessment.ts @@ -21,7 +21,6 @@ import { CanLeave } from '@guards/can-leave'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -45,6 +44,7 @@ import { AddonModWorkshopPhase, } from '@addons/mod/workshop/constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a workshop assessment. @@ -144,7 +144,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea this.profile = CoreNavigator.getRouteParam('profile'); this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -172,7 +172,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea } // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); CoreForms.triggerFormCancelledEvent(this.formElement, this.siteId); @@ -272,7 +272,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea this.evaluateByProfile = await CoreUser.getProfile(this.assessment.gradinggradeoverby, this.courseId, true); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { this.loaded = true; } @@ -403,7 +403,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea CoreEvents.trigger(ADDON_MOD_WORKSHOP_ASSESSMENT_SAVED, data, this.siteId); }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Cannot save assessment evaluation'); + CoreAlerts.showError(error, { default: 'Cannot save assessment evaluation' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts index efef8fbc0..0c88f0567 100644 --- a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts +++ b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts @@ -23,7 +23,6 @@ import { CoreFileEntry, CoreFileHelper } from '@services/file-helper'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreWSError } from '@classes/errors/wserror'; import { Translate } from '@singletons'; @@ -46,6 +45,7 @@ import { } from '@addons/mod/workshop/constants'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreDom } from '@singletons/dom'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the workshop edit submission. @@ -112,7 +112,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca this.access = CoreNavigator.getRequiredRouteParam('access'); this.submissionId = CoreNavigator.getRouteNumberParam('submissionId') || 0; } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -147,7 +147,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca // Check if data has changed. if (this.hasDataChanged()) { // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } if (this.submission?.attachmentfiles) { @@ -235,7 +235,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca } catch (error) { this.loaded = false; - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); this.forceLeavePage(); } @@ -339,7 +339,10 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca const inputData = this.getInputData(); if (!inputData.title) { - CoreDomUtils.showAlertTranslated('core.notice', 'addon.mod_workshop.submissionrequiredtitle'); + CoreAlerts.show({ + header: Translate.instant('core.notice'), + message: Translate.instant('addon.mod_workshop.submissionrequiredtitle'), + }); throw new CoreError(Translate.instant('addon.mod_workshop.submissionrequiredtitle')); } @@ -348,7 +351,10 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca const noFiles = !inputData.attachmentfiles.length; if ((this.textRequired && noText) || (this.fileRequired && noFiles) || (noText && noFiles)) { - CoreDomUtils.showAlertTranslated('core.notice', 'addon.mod_workshop.submissionrequiredcontent'); + CoreAlerts.show({ + header: Translate.instant('core.notice'), + message: Translate.instant('addon.mod_workshop.submissionrequiredcontent'), + }); throw new CoreError(Translate.instant('addon.mod_workshop.submissionrequiredcontent')); } @@ -483,7 +489,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca CoreFileUploader.clearTmpFiles(inputData.attachmentfiles); }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Cannot save submission'); + CoreAlerts.showError(error, { default: 'Cannot save submission' }); } finally { modal.dismiss(); } diff --git a/src/addons/mod/workshop/pages/submission/submission.ts b/src/addons/mod/workshop/pages/submission/submission.ts index 83d30b56f..6d36c33a3 100644 --- a/src/addons/mod/workshop/pages/submission/submission.ts +++ b/src/addons/mod/workshop/pages/submission/submission.ts @@ -24,7 +24,6 @@ import { IonContent } from '@ionic/angular'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; import { CoreSync } from '@services/sync'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -56,6 +55,7 @@ import { AddonModWorkshopPhase, } from '@addons/mod/workshop/constants'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a workshop submission. @@ -152,7 +152,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea this.submissionInfo = CoreNavigator.getRequiredRouteParam('submission'); this.assessment = CoreNavigator.getRouteParam('assessment'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -184,7 +184,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea } // Show confirmation if some data has been modified. - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); CoreForms.triggerFormCancelledEvent(this.formElement, this.siteId); @@ -326,7 +326,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea this.submission = await AddonModWorkshopHelper.applyOfflineData(this.submission, submissionsActions); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { this.loaded = true; } @@ -544,7 +544,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea CoreEvents.trigger(ADDON_MOD_WORKSHOP_SUBMISSION_CHANGED, data, this.siteId); }); } catch (message) { - CoreDomUtils.showErrorModalDefault(message, 'Cannot save submission evaluation'); + CoreAlerts.showError(message, { default: 'Cannot save submission evaluation' }); } finally { modal.dismiss(); } @@ -555,7 +555,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea */ async deleteSubmission(): Promise { try { - await CoreDomUtils.showDeleteConfirm('addon.mod_workshop.submissiondeleteconfirm'); + await CoreAlerts.confirmDelete(Translate.instant('addon.mod_workshop.submissiondeleteconfirm')); } catch { return; } @@ -569,7 +569,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea await AddonModWorkshop.invalidateSubmissionData(this.workshopId, this.submissionId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Cannot delete submission'); + CoreAlerts.showError(error, { default: 'Cannot delete submission' }); } finally { modal.dismiss(); if (success) { diff --git a/src/addons/notes/components/add/add-modal.ts b/src/addons/notes/components/add/add-modal.ts index bc4ee426b..a0911bd5a 100644 --- a/src/addons/notes/components/add/add-modal.ts +++ b/src/addons/notes/components/add/add-modal.ts @@ -15,13 +15,13 @@ import { AddonNotes, AddonNotesPublishState } from '@addons/notes/services/notes'; import { Component, ViewChild, ElementRef, Input } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreForms } from '@singletons/form'; import { ModalController } from '@singletons'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays a text area for composing a note. @@ -71,7 +71,7 @@ export class AddonNotesAddComponent { }); }); } catch (error){ - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); this.processing = false; } finally { loadingModal.dismiss(); diff --git a/src/addons/notes/pages/list/list.ts b/src/addons/notes/pages/list/list.ts index 43fffa8e0..a78518a93 100644 --- a/src/addons/notes/pages/list/list.ts +++ b/src/addons/notes/pages/list/list.ts @@ -24,7 +24,6 @@ import { IonContent } from '@ionic/angular'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreUrl } from '@singletons/url'; import { CorePromiseUtils } from '@singletons/promise-utils'; @@ -34,6 +33,7 @@ import { CoreTime } from '@singletons/time'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreModals } from '@services/overlays/modals'; import { ADDON_NOTES_AUTO_SYNCED } from '@addons/notes/services/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a list of notes. @@ -70,7 +70,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); this.userId = CoreNavigator.getRouteNumberParam('userId'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -139,7 +139,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { let canDelete = this.notes && this.notes.length > 0; if (canDelete && this.type == 'personal') { @@ -236,7 +236,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy { try { this.logViewDelete(note); - await CoreDomUtils.showDeleteConfirm('addon.notes.deleteconfirm'); + await CoreAlerts.confirmDelete(Translate.instant('addon.notes.deleteconfirm')); try { await AddonNotes.deleteNote(note, this.courseId); this.showDelete = false; @@ -250,7 +250,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy { }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Delete note failed.'); + CoreAlerts.showError(error, { default: 'Delete note failed.' }); } } catch { // User cancelled, nothing to do. @@ -291,7 +291,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy { this.showSyncWarnings(result.warnings); } catch (error) { if (showSyncErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') }); } } } @@ -305,7 +305,7 @@ export class AddonNotesListPage implements OnInit, OnDestroy { const message = CoreText.buildMessage(warnings); if (message) { - CoreDomUtils.showAlert(undefined, message); + CoreAlerts.show({ message }); } } diff --git a/src/addons/notifications/pages/list/list.ts b/src/addons/notifications/pages/list/list.ts index b78a98c65..727c691b9 100644 --- a/src/addons/notifications/pages/list/list.ts +++ b/src/addons/notifications/pages/list/list.ts @@ -14,8 +14,6 @@ import { AfterViewInit, Component, OnDestroy, ViewChild } from '@angular/core'; import { Subscription } from 'rxjs'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { @@ -35,6 +33,7 @@ import { CoreConfig } from '@services/config'; import { CoreConstants } from '@/core/constants'; import { CorePlatform } from '@services/platform'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of notifications. @@ -72,7 +71,7 @@ export class AddonNotificationsListPage implements AfterViewInit, OnDestroy { this.notifications = new CoreListItemsManager(source, AddonNotificationsListPage); } catch(error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -162,7 +161,7 @@ export class AddonNotificationsListPage implements AfterViewInit, OnDestroy { try { await this.fetchNotifications(true); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading notifications'); + CoreAlerts.showError(error, { default: 'Error loading notifications' }); this.notifications.reset(); } @@ -177,7 +176,7 @@ export class AddonNotificationsListPage implements AfterViewInit, OnDestroy { try { await this.fetchNotifications(false); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading more notifications'); + CoreAlerts.showError(error, { default: 'Error loading more notifications' }); this.fetchMoreNotificationsFailed = true; } diff --git a/src/addons/notifications/pages/notification/notification.ts b/src/addons/notifications/pages/notification/notification.ts index 1a8c9ddc2..9b3087400 100644 --- a/src/addons/notifications/pages/notification/notification.ts +++ b/src/addons/notifications/pages/notification/notification.ts @@ -26,8 +26,8 @@ import { CoreSwipeNavigationItemsManager } from '@classes/items-management/swipe import { CoreContentLinksAction, CoreContentLinksDelegate } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreNavigator } from '@services/navigator'; +import { CoreAlerts } from '@services/overlays/alerts'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; /** @@ -60,7 +60,7 @@ export class AddonNotificationsNotificationPage implements OnInit, OnDestroy { try { notification = this.getNotification(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; diff --git a/src/addons/notifications/pages/settings/settings.ts b/src/addons/notifications/pages/settings/settings.ts index 0484f0731..1654d54f1 100644 --- a/src/addons/notifications/pages/settings/settings.ts +++ b/src/addons/notifications/pages/settings/settings.ts @@ -17,7 +17,6 @@ import { Component, OnInit, OnDestroy, signal } from '@angular/core'; import { CoreConfig } from '@services/config'; import { CoreLocalNotifications } from '@services/local-notifications'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreUser } from '@features/user/services/user'; import { AddonMessageOutputDelegate, AddonMessageOutputHandlerData } from '@addons/messageoutput/services/messageoutput-delegate'; @@ -41,6 +40,7 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; import { CoreErrorHelper } from '@services/error-helper'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays notifications settings. @@ -127,7 +127,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { return; } - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { this.preferencesLoaded = true; } @@ -255,7 +255,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { this.updatePreferencesAfterDelay(); } catch (error) { // Show error and revert change. - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); processor[state].checked = !processor[state].checked; } finally { processorState.updating = false; @@ -294,7 +294,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { this.updatePreferencesAfterDelay(); } catch (error) { // Show error and revert change. - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); processor.enabled = !processor.enabled; } finally { processor.updating = false; @@ -321,7 +321,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy { this.updatePreferencesAfterDelay(); } catch (error) { // Show error and revert change. - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); this.preferences.enableall = !this.preferences.enableall; } finally { modal.dismiss(); diff --git a/src/addons/privatefiles/pages/index/index.ts b/src/addons/privatefiles/pages/index/index.ts index 9f201a8ec..98dad3dc0 100644 --- a/src/addons/privatefiles/pages/index/index.ts +++ b/src/addons/privatefiles/pages/index/index.ts @@ -17,7 +17,6 @@ import { Md5 } from 'ts-md5/dist/md5'; import { CoreNetwork } from '@services/network'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -38,6 +37,7 @@ import { CoreFilepool } from '@services/filepool'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; import { AddonPrivateFilesFileComponent } from '@addons/privatefiles/components/file/file'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of files. @@ -107,7 +107,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { }; } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -181,7 +181,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { */ async uploadFile(): Promise { if (!CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); + CoreAlerts.showError(Translate.instant('core.fileuploader.errormustbeonlinetoupload')); return; } @@ -196,7 +196,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { this.filesLoaded = true; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.fileuploader.errorwhileuploading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.fileuploader.errorwhileuploading') }); } } @@ -238,10 +238,10 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { this.logView(); } else { // Unknown root. - CoreDomUtils.showErrorModal('addon.privatefiles.couldnotloadfiles', true); + CoreAlerts.showError(Translate.instant('addon.privatefiles.couldnotloadfiles')); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'addon.privatefiles.couldnotloadfiles', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.privatefiles.couldnotloadfiles') }); } } @@ -304,12 +304,11 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { if (showConfirmation) { try { - this.selectedFiles.length === 1 - ? await CoreDomUtils.showDeleteConfirm( - 'core.confirmremoveselectedfile', - { filename: this.selectedFiles[0].filename }, - ) - : await CoreDomUtils.showDeleteConfirm('core.confirmremoveselectedfiles'); + const message = this.selectedFiles.length === 1 ? + Translate.instant('core.confirmremoveselectedfile', { filename: this.selectedFiles[0].filename }) : + Translate.instant('core.confirmremoveselectedfiles'); + + await CoreAlerts.confirmDelete(message); } catch { return; } @@ -322,7 +321,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { await AddonPrivateFiles.deleteFiles(this.selectedFiles); } catch (error) { loading.dismiss(); - await CoreDomUtils.showErrorModalDefault(error, 'An error occourred while file was being deleted.'); + await CoreAlerts.showError(error, { default: 'An error occourred while file was being deleted.' }); throw error; } @@ -396,7 +395,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { } if (status === 'deleteOnline') { - await CoreDomUtils.showDeleteConfirm('core.confirmremoveselectedfile', { filename: file.filename }); + await CoreAlerts.confirmDelete(Translate.instant('core.confirmremoveselectedfile', { filename: file.filename })); this.selectedFiles = [file]; return await this.deleteSelectedFiles(); @@ -450,7 +449,7 @@ export class AddonPrivateFilesIndexPage implements OnInit, OnDestroy { try { await CoreFilepool.removeFileByUrl(siteId, file.fileurl); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordeletefile', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordeletefile') }); } } diff --git a/src/addons/report/insights/services/handlers/action-link.ts b/src/addons/report/insights/services/handlers/action-link.ts index 9e1de6ae5..cbf1ff1c8 100644 --- a/src/addons/report/insights/services/handlers/action-link.ts +++ b/src/addons/report/insights/services/handlers/action-link.ts @@ -17,11 +17,11 @@ import { Injectable } from '@angular/core'; import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base-handler'; import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { makeSingleton, Translate } from '@singletons'; import { AddonReportInsights } from '../insights'; import { CoreToasts } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; // Bulk actions supported, along with the related lang string. const BULK_ACTIONS = { @@ -57,7 +57,7 @@ export class AddonReportInsightsActionLinkHandlerService extends CoreContentLink try { await AddonReportInsights.sendActionExecuted(params.action, [Number(params.predictionid)], siteId); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); return; } finally { diff --git a/src/addons/storagemanager/pages/course-storage/course-storage.ts b/src/addons/storagemanager/pages/course-storage/course-storage.ts index b01ecd45d..93b65a1b2 100644 --- a/src/addons/storagemanager/pages/course-storage/course-storage.ts +++ b/src/addons/storagemanager/pages/course-storage/course-storage.ts @@ -31,11 +31,12 @@ import { AccordionGroupChangeEventDetail } from '@ionic/angular'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { CoreDom } from '@singletons/dom'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { CoreErrorHelper } from '@services/error-helper'; /** * Page that displays the amount of file storage used by each activity on the course, and allows @@ -96,7 +97,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { try { this.courseId = CoreNavigator.getRequiredRouteParam('courseId'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -145,7 +146,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { this.initModulePrefetch(), ]); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } this.changeDetectorRef.markForCheck(); @@ -206,7 +207,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { // There is a download promise. Show an error if it fails. promise.catch((error) => { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errordownloadingcourse') }); } }); } else { @@ -380,12 +381,9 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { event.preventDefault(); try { - await CoreDomUtils.showDeleteConfirm( - 'addon.storagemanager.confirmdeletedatafrom', - { name: this.title }, - ); + await CoreAlerts.confirmDelete(Translate.instant('addon.storagemanager.confirmdeletedatafrom', { name: this.title })); } catch (error) { - if (!CoreDomUtils.isCanceledError(error)) { + if (!CoreErrorHelper.isCanceledError(error)) { throw error; } @@ -411,12 +409,9 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { event.preventDefault(); try { - await CoreDomUtils.showDeleteConfirm( - 'addon.storagemanager.confirmdeletedatafrom', - { name: section.name }, - ); + await CoreAlerts.confirmDelete(Translate.instant('addon.storagemanager.confirmdeletedatafrom', { name: section.name })); } catch (error) { - if (!CoreDomUtils.isCanceledError(error)) { + if (!CoreErrorHelper.isCanceledError(error)) { throw error; } @@ -446,12 +441,9 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { } try { - await CoreDomUtils.showDeleteConfirm( - 'addon.storagemanager.confirmdeletedatafrom', - { name: module.name }, - ); + await CoreAlerts.confirmDelete(Translate.instant('addon.storagemanager.confirmdeletedatafrom', { name: module.name })); } catch (error) { - if (!CoreDomUtils.isCanceledError(error)) { + if (!CoreErrorHelper.isCanceledError(error)) { throw error; } @@ -486,7 +478,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { try { await Promise.all(promises); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, Translate.instant('core.errordeletefile')); + CoreAlerts.showError(error, { default: Translate.instant('core.errordeletefile') }); } finally { modal.dismiss(); @@ -523,7 +515,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { } catch (error) { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingsection', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errordownloadingsection') }); } } finally { await this.updateSizes([section]); @@ -531,7 +523,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { } catch (error) { // User cancelled or there was an error calculating the size. if (!this.isDestroyed && error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); this.changeDetectorRef.markForCheck(); return; @@ -567,7 +559,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { await CoreCourseHelper.prefetchModule(module.prefetchHandler, module, size, module.course, refresh); } catch (error) { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } finally { module.spinner = false; @@ -655,7 +647,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { const course = await CoreCourseHelper.getCourseInfo(this.courseId); if (!course) { - CoreDomUtils.showErrorModal('core.course.errordownloadingcourse', true); + CoreAlerts.showError(Translate.instant('core.course.errordownloadingcourse')); return; } @@ -677,7 +669,7 @@ export class AddonStorageManagerCourseStoragePage implements OnInit, OnDestroy { return; } - CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errordownloadingcourse') }); } } diff --git a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts index ae52b8971..b3940a7ce 100644 --- a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts +++ b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts @@ -24,10 +24,11 @@ import { CoreSiteHome } from '@features/sitehome/services/sitehome'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { CoreArray } from '@singletons/array'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { CoreErrorHelper } from '@services/error-helper'; /** * Page that displays downloaded courses and allows the user to delete them. @@ -113,9 +114,9 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy event.stopPropagation(); try { - await CoreDomUtils.showDeleteConfirm('addon.storagemanager.confirmdeletecourses'); + await CoreAlerts.confirmDelete(Translate.instant('addon.storagemanager.confirmdeletecourses')); } catch (error) { - if (!CoreDomUtils.isCanceledError(error)) { + if (!CoreErrorHelper.isCanceledError(error)) { throw error; } @@ -132,7 +133,7 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy await this.setDownloadedCourses(this.downloadedCourses.filter((course) => !deletedCourseIds.includes(course.id))); }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, Translate.instant('core.errordeletefile')); + CoreAlerts.showError(error, { default: Translate.instant('core.errordeletefile') }); } finally { modal.dismiss(); } @@ -149,12 +150,9 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy event.stopPropagation(); try { - await CoreDomUtils.showDeleteConfirm( - 'addon.storagemanager.confirmdeletedatafrom', - { name: course.title }, - ); + await CoreAlerts.confirmDelete(Translate.instant('addon.storagemanager.confirmdeletedatafrom', { name: course.title })); } catch (error) { - if (!CoreDomUtils.isCanceledError(error)) { + if (!CoreErrorHelper.isCanceledError(error)) { throw error; } @@ -170,7 +168,7 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy await this.setDownloadedCourses(CoreArray.withoutItem(this.downloadedCourses, course)); }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, Translate.instant('core.errordeletefile')); + CoreAlerts.showError(error, { default: Translate.instant('core.errordeletefile') }); } finally { modal.dismiss(); } diff --git a/src/core/classes/sites/site.ts b/src/core/classes/sites/site.ts index 25aa422c7..587435c24 100644 --- a/src/core/classes/sites/site.ts +++ b/src/core/classes/sites/site.ts @@ -24,7 +24,6 @@ import { CoreWSExternalWarning, CoreWSUploadFileResult, } from '@services/ws'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreUrl } from '@singletons/url'; import { CoreOpener, CoreOpenerOpenInBrowserOptions } from '@singletons/opener'; @@ -56,6 +55,7 @@ import { firstValueFrom } from 'rxjs'; import { CorePlatform } from '@services/platform'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Class that represents a site (combination of site + user). @@ -509,12 +509,11 @@ export class CoreSite extends CoreAuthenticatedSite { if (alertMessage) { // Show an alert first. - const alert = await CoreDomUtils.showAlert( - Translate.instant('core.notice'), - alertMessage, - undefined, - 3000, - ); + const alert = await CoreAlerts.show({ + header: Translate.instant('core.notice'), + message: alertMessage, + autoCloseTime: 3000, + }); await alert.onDidDismiss(); options.showBrowserWarning = false; // A warning already shown, no need to show another. diff --git a/src/core/components/attachments/attachments.ts b/src/core/components/attachments/attachments.ts index 1996d62ec..d1627a287 100644 --- a/src/core/components/attachments/attachments.ts +++ b/src/core/components/attachments/attachments.ts @@ -20,12 +20,12 @@ import { CoreSites } from '@services/sites'; import { CoreText } from '@singletons/text'; import { Translate } from '@singletons'; import { CoreNetwork } from '@services/network'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreFileUploaderHelper } from '@features/fileuploader/services/fileuploader-helper'; import { CoreFileEntry } from '@services/file-helper'; import { CoreCourses } from '@features/courses/services/courses'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { toBoolean } from '@/core/transforms/boolean'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component to render attachments, allow adding more and delete the current ones. @@ -133,7 +133,7 @@ export class CoreAttachmentsComponent implements OnInit { */ async add(): Promise { if (!this.allowOffline && !CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); + CoreAlerts.showError(Translate.instant('core.fileuploader.errormustbeonlinetoupload')); return; } @@ -145,7 +145,7 @@ export class CoreAttachmentsComponent implements OnInit { this.files?.push(result); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error selecting file.'); + CoreAlerts.showError(error, { default: 'Error selecting file.' }); } } @@ -159,7 +159,7 @@ export class CoreAttachmentsComponent implements OnInit { if (askConfirm) { try { - await CoreDomUtils.showDeleteConfirm('core.confirmdeletefile'); + await CoreAlerts.confirmDelete(Translate.instant('core.confirmdeletefile')); } catch { // User cancelled. return; diff --git a/src/core/components/file/file.ts b/src/core/components/file/file.ts index 260fe3c88..949dc20d7 100644 --- a/src/core/components/file/file.ts +++ b/src/core/components/file/file.ts @@ -18,7 +18,6 @@ import { CoreFilepool } from '@services/filepool'; import { CoreFileHelper } from '@services/file-helper'; import { CorePluginFileDelegate } from '@services/plugin-file-delegate'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreUrl } from '@singletons/url'; import { CoreText } from '@singletons/text'; @@ -29,6 +28,8 @@ import { CorePlatform } from '@services/platform'; import { toBoolean } from '@/core/transforms/boolean'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener, CoreOpenerOpenFileOptions, OpenFileAction } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Component to handle a remote file. Shows the file name, icon (depending on mimetype) and a button @@ -169,7 +170,7 @@ export class CoreFileComponent implements OnInit, OnDestroy { } }, undefined, options); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } @@ -204,7 +205,7 @@ export class CoreFileComponent implements OnInit, OnDestroy { if (!CoreNetwork.isOnline() && (!openAfterDownload || (openAfterDownload && !CoreFileHelper.isStateDownloaded(this.state)))) { - CoreDomUtils.showErrorModal('core.networkerrormsg', true); + CoreAlerts.showError(Translate.instant('core.networkerrormsg')); return; } @@ -214,7 +215,7 @@ export class CoreFileComponent implements OnInit, OnDestroy { try { await this.openFile(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } else { try { @@ -222,7 +223,7 @@ export class CoreFileComponent implements OnInit, OnDestroy { const size = await CorePluginFileDelegate.getFileSize(this.file, this.siteId); if (size) { - await CoreDomUtils.confirmDownloadSize({ size: size, total: true }); + await CoreAlerts.confirmDownloadSize({ size: size, total: true }); } // User confirmed, add the file to queue. @@ -244,11 +245,11 @@ export class CoreFileComponent implements OnInit, OnDestroy { this.file, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); this.calculateState(); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } } diff --git a/src/core/components/iframe/iframe.ts b/src/core/components/iframe/iframe.ts index db236dba2..fdd472b85 100644 --- a/src/core/components/iframe/iframe.ts +++ b/src/core/components/iframe/iframe.ts @@ -18,10 +18,9 @@ import { import { SafeResourceUrl } from '@angular/platform-browser'; import { CoreFile } from '@services/file'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CoreIframeUtils } from '@services/utils/iframe'; -import { DomSanitizer, Router, StatusBar } from '@singletons'; +import { DomSanitizer, Router, StatusBar, Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreScreen, CoreScreenOrientation } from '@services/screen'; import { Subscription } from 'rxjs'; @@ -30,6 +29,7 @@ import { NavigationStart } from '@angular/router'; import { CoreSites } from '@services/sites'; import { toBoolean } from '@/core/transforms/boolean'; import { CoreDom } from '@singletons/dom'; +import { CoreAlerts } from '@services/overlays/alerts'; @Component({ selector: 'core-iframe', @@ -181,7 +181,7 @@ export class CoreIframeComponent implements OnChanges, OnDestroy { this.iframe.addEventListener('error', () => { this.loading = false; - CoreDomUtils.showErrorModal('core.errorloadingcontent', true); + CoreAlerts.showError(Translate.instant('core.errorloadingcontent')); }); } diff --git a/src/core/components/local-file/local-file.ts b/src/core/components/local-file/local-file.ts index 9ac652940..afce965af 100644 --- a/src/core/components/local-file/local-file.ts +++ b/src/core/components/local-file/local-file.ts @@ -19,7 +19,6 @@ import { CoreIonLoadingElement } from '@classes/ion-loading'; import { CoreFile } from '@services/file'; import { CoreFileHelper } from '@services/file-helper'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreText } from '@singletons/text'; import { CoreTimeUtils } from '@services/utils/time'; @@ -30,6 +29,8 @@ import { CorePlatform } from '@services/platform'; import { toBoolean } from '@/core/transforms/boolean'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreFileUtils } from '@singletons/file-utils'; +import { Translate } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component to handle a local file. Only files inside the app folder can be managed. @@ -191,7 +192,7 @@ export class CoreLocalFileComponent implements OnInit { await CoreFile.getFile(newPath); // There's a file with this name, show error and stop. - CoreDomUtils.showErrorModal('core.errorfileexistssamename', true); + CoreAlerts.showError(Translate.instant('core.errorfileexistssamename')); } catch { try { // File doesn't exist, move it. @@ -204,7 +205,7 @@ export class CoreLocalFileComponent implements OnInit { this.loadFileBasicData(this.file); this.onRename.emit({ file: this.file }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorrenamefile', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorrenamefile') }); } } finally { modal.dismiss(); @@ -224,7 +225,7 @@ export class CoreLocalFileComponent implements OnInit { try { // Ask confirmation. - await CoreDomUtils.showDeleteConfirm('core.confirmdeletefile'); + await CoreAlerts.confirmDelete(Translate.instant('core.confirmdeletefile')); modal = await CoreLoadings.show('core.deleting', true); @@ -232,7 +233,7 @@ export class CoreLocalFileComponent implements OnInit { this.onDelete.emit(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordeletefile', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordeletefile') }); } finally { modal?.dismiss(); } diff --git a/src/core/directives/download-file.ts b/src/core/directives/download-file.ts index 376b5c4c1..1a50c2fd3 100644 --- a/src/core/directives/download-file.ts +++ b/src/core/directives/download-file.ts @@ -14,9 +14,10 @@ import { Directive, Input, OnInit, ElementRef } from '@angular/core'; import { CoreFileHelper } from '@services/file-helper'; +import { CoreAlerts } from '@services/overlays/alerts'; import { CoreLoadings } from '@services/overlays/loadings'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreWSFile } from '@services/ws'; +import { Translate } from '@singletons'; /** * Directive to allow downloading and open a file. When the item with this directive is clicked, the file will be @@ -54,7 +55,7 @@ export class CoreDownloadFileDirective implements OnInit { try { await CoreFileHelper.downloadAndOpenFile(this.file, this.component, this.componentId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } finally { modal.dismiss(); } diff --git a/src/core/directives/format-text.ts b/src/core/directives/format-text.ts index 93379a63e..9ad3c2ed5 100644 --- a/src/core/directives/format-text.ts +++ b/src/core/directives/format-text.ts @@ -59,6 +59,7 @@ import { CoreWait } from '@singletons/wait'; import { toBoolean } from '../transforms/boolean'; import { CoreViewer } from '@features/viewer/services/viewer'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Directive to format text rendered. It renders the HTML and treats all links and media, using CoreLinkDirective @@ -671,7 +672,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec if (confirmMessage) { try { - await CoreDomUtils.showConfirm(Translate.instant(confirmMessage)); + await CoreAlerts.confirm(Translate.instant(confirmMessage)); } catch { return; } diff --git a/src/core/directives/link.ts b/src/core/directives/link.ts index fd31cd937..862bac631 100644 --- a/src/core/directives/link.ts +++ b/src/core/directives/link.ts @@ -17,7 +17,6 @@ import { SafeUrl } from '@angular/platform-browser'; import { CoreFileHelper } from '@services/file-helper'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CoreOpener } from '@singletons/opener'; import { CoreConstants } from '@/core/constants'; @@ -28,6 +27,7 @@ import { CoreFilepool } from '@services/filepool'; import { CoreDom } from '@singletons/dom'; import { toBoolean } from '../transforms/boolean'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Directive to open a link in external browser or in the app. @@ -169,7 +169,7 @@ export class CoreLinkDirective implements OnInit { try { await CoreOpener.openFile(path); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } } diff --git a/src/core/features/block/classes/base-block-component.ts b/src/core/features/block/classes/base-block-component.ts index 1d6aa2f35..9f1a61249 100644 --- a/src/core/features/block/classes/base-block-component.ts +++ b/src/core/features/block/classes/base-block-component.ts @@ -14,7 +14,6 @@ import { OnInit, Input, Component, Optional, Inject, OnChanges, SimpleChanges } from '@angular/core'; import { CoreLogger } from '@singletons/logger'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreArray } from '@singletons/array'; import { CoreText } from '@singletons/text'; import { CoreCourseBlock } from '../../course/services/course'; @@ -23,6 +22,8 @@ import { ContextLevel } from '@/core/constants'; import { CoreNavigationOptions } from '@services/navigator'; import { AsyncDirective } from '@classes/async-directive'; import { CorePromisedValue } from '@classes/promised-value'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Template class to easily create components for blocks. @@ -122,7 +123,7 @@ export abstract class CoreBlockBaseComponent implements OnInit, OnChanges, ICore this.logger.error(error); // Error getting data, fail. - CoreDomUtils.showErrorModalDefault(error, this.fetchContentDefaultError, true); + CoreAlerts.showError(error, { default: Translate.instant(this.fetchContentDefaultError) }); } this.loaded = true; diff --git a/src/core/features/block/components/side-blocks/side-blocks.ts b/src/core/features/block/components/side-blocks/side-blocks.ts index eabb1e33f..27687323e 100644 --- a/src/core/features/block/components/side-blocks/side-blocks.ts +++ b/src/core/features/block/components/side-blocks/side-blocks.ts @@ -14,7 +14,6 @@ import { Component, ViewChildren, Input, OnInit, QueryList, ElementRef } from '@angular/core'; import { ModalController } from '@singletons'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourse, CoreCourseBlock } from '@features/course/services/course'; import { CoreBlockHelper } from '../../services/block-helper'; import { CoreBlockComponent } from '../block/block'; @@ -25,6 +24,7 @@ import { ContextLevel } from '@/core/constants'; import { CoreWait } from '@singletons/wait'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreBlockComponentsModule } from '../components.module'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays the list of side blocks. @@ -103,8 +103,7 @@ export class CoreBlockSideBlocksComponent implements OnInit { this.blocks = blocks.sideBlocks; } } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); this.blocks = []; } diff --git a/src/core/features/comments/pages/viewer/viewer.ts b/src/core/features/comments/pages/viewer/viewer.ts index e4f4f2ec9..f1c02a174 100644 --- a/src/core/features/comments/pages/viewer/viewer.ts +++ b/src/core/features/comments/pages/viewer/viewer.ts @@ -30,7 +30,6 @@ import { ContextLevel, CoreConstants } from '@/core/constants'; import { CoreNavigator } from '@services/navigator'; import { NgZone, Translate } from '@singletons'; import { CorePromiseUtils } from '@singletons/promise-utils'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUser } from '@features/user/services/user'; import { CoreText } from '@singletons/text'; import { CoreError } from '@classes/errors/error'; @@ -45,6 +44,7 @@ import { CoreKeyboard } from '@singletons/keyboard'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; import { CORE_COMMENTS_AUTO_SYNCED } from '@features/comments/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays comments. @@ -134,7 +134,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { Translate.instant('core.comments.comments'); this.courseId = CoreNavigator.getRouteNumberParam('courseId'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); @@ -198,9 +198,12 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { } catch (error) { this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading. if (error && this.componentName == 'assignsubmission_comments') { - CoreDomUtils.showAlertTranslated('core.notice', 'core.comments.commentsnotworking'); + CoreAlerts.show({ + header: Translate.instant('core.notice'), + message: Translate.instant('core.comments.commentsnotworking'), + }); } else { - CoreDomUtils.showErrorModalDefault(error, Translate.instant('core.error') + ': get_comments'); + CoreAlerts.showError(error, { default: Translate.instant('core.error') + ': get_comments' }); } } finally { this.commentsLoaded = true; @@ -276,7 +279,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { private showSyncWarnings(warnings: string[]): void { const message = CoreText.buildMessage(warnings); if (message) { - CoreDomUtils.showAlert(undefined, message); + CoreAlerts.show({ message }); } } @@ -298,7 +301,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { this.showSyncWarnings(result?.warnings || []); } catch (error) { if (showErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') }); } throw new CoreError(error); @@ -359,7 +362,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { await this.loadOfflineData(); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { loadingModal.dismiss(); this.sending = false; @@ -394,10 +397,9 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { }; try { - await CoreDomUtils.showDeleteConfirm('core.comments.deletecommentbyon', { - $a: - { user: comment.fullname || '', time: time }, - }); + await CoreAlerts.confirmDelete(Translate.instant('core.comments.deletecommentbyon', { + $a: { user: comment.fullname || '', time: time }, + })); } catch { // User cancelled, nothing to do. return; @@ -436,7 +438,7 @@ export class CoreCommentsViewerPage implements OnInit, OnDestroy { duration: ToastDuration.LONG, }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Delete comment failed.'); + CoreAlerts.showError(error, { default: 'Delete comment failed.' }); } } diff --git a/src/core/features/compile/components/compile-html/compile-html.ts b/src/core/features/compile/components/compile-html/compile-html.ts index 9176d4990..7eff867c3 100644 --- a/src/core/features/compile/components/compile-html/compile-html.ts +++ b/src/core/features/compile/components/compile-html/compile-html.ts @@ -46,6 +46,7 @@ import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreWS } from '@services/ws'; import { CoreDom } from '@singletons/dom'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * This component has a behaviour similar to $compile for AngularJS. Given an HTML code, it will compile it so all its @@ -164,7 +165,7 @@ export class CoreCompileHtmlComponent implements OnChanges, OnDestroy, DoCheck { this.loaded = true; } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); this.loaded = true; } finally { diff --git a/src/core/features/contentlinks/components/choose-site-modal/choose-site-modal.ts b/src/core/features/contentlinks/components/choose-site-modal/choose-site-modal.ts index fa546b317..ced17c161 100644 --- a/src/core/features/contentlinks/components/choose-site-modal/choose-site-modal.ts +++ b/src/core/features/contentlinks/components/choose-site-modal/choose-site-modal.ts @@ -14,7 +14,6 @@ import { Component, Input, OnInit } from '@angular/core'; import { CoreSiteBasicInfo, CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { ModalController, Translate } from '@singletons'; import { CoreContentLinksAction } from '../../services/contentlinks-delegate'; import { CoreContentLinksHelper } from '../../services/contentlinks-helper'; @@ -22,6 +21,7 @@ import { CoreError } from '@classes/errors/error'; import { CoreNavigator } from '@services/navigator'; import { CoreSitesFactory } from '@services/sites-factory'; import { CoreSharedModule } from '@/core/shared.module'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to display the list of sites to choose one to perform a content link action. @@ -81,7 +81,7 @@ export class CoreContentLinksChooseSiteModalComponent implements OnInit { // All sites have the same URL, use the first one. this.displaySiteUrl = CoreSitesFactory.makeUnauthenticatedSite(this.sites[0].siteUrl).shouldDisplayInformativeLinks(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.contentlinks.errornosites', true); + CoreAlerts.showError(error, { default: Translate.instant('core.contentlinks.errornosites') }); this.closeModal(); } diff --git a/src/core/features/contentlinks/services/contentlinks-helper.ts b/src/core/features/contentlinks/services/contentlinks-helper.ts index a76c68d33..bb1892d5c 100644 --- a/src/core/features/contentlinks/services/contentlinks-helper.ts +++ b/src/core/features/contentlinks/services/contentlinks-helper.ts @@ -14,13 +14,13 @@ import { Injectable } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreContentLinksDelegate, CoreContentLinksAction } from './contentlinks-delegate'; import { CoreSite } from '@classes/sites/site'; import { makeSingleton, Translate } from '@singletons'; import { CoreNavigator } from '@services/navigator'; import { CoreCustomURLSchemes } from '@services/urlschemes'; import { CoreModals } from '@services/overlays/modals'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Service that provides some features regarding content links. @@ -160,7 +160,7 @@ export class CoreContentLinksHelperProvider { } else { try { // Not current site or more than one site. Ask for confirmation. - await CoreDomUtils.showConfirm(Translate.instant('core.contentlinks.confirmurlothersite')); + await CoreAlerts.confirm(Translate.instant('core.contentlinks.confirmurlothersite')); if (action.sites?.length == 1) { await action.action(action.sites[0]); } else { diff --git a/src/core/features/course/classes/main-activity-component.ts b/src/core/features/course/classes/main-activity-component.ts index e24f336a9..56dc3cd3f 100644 --- a/src/core/features/course/classes/main-activity-component.ts +++ b/src/core/features/course/classes/main-activity-component.ts @@ -19,10 +19,11 @@ import { CoreCourseModuleMainResourceComponent } from './main-resource-component import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreCourse } from '../services/course'; import { CorePromiseUtils } from '@singletons/promise-utils'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourseContentsPage } from '../pages/contents/contents'; import { CoreSites } from '@services/sites'; import { CoreSyncResult } from '@services/sync'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Template class to easily create CoreCourseModuleMainComponent of activities. @@ -177,7 +178,7 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR return await this.refreshContent(sync); } - CoreDomUtils.showErrorModalDefault(error, this.fetchContentDefaultError, true); + CoreAlerts.showError(error, { default: Translate.instant(this.fetchContentDefaultError) }); } finally { this.showLoading = false; } @@ -216,13 +217,13 @@ export class CoreCourseModuleMainActivityComponent extends CoreCourseModuleMainR const result = await this.sync(); if (result.warnings.length) { - CoreDomUtils.showAlert(undefined, result.warnings[0]); + CoreAlerts.show({ message: result.warnings[0] }); } return this.hasSyncSucceed(result); } catch (error) { if (showErrors) { - CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') }); } return false; diff --git a/src/core/features/course/classes/main-activity-page.ts b/src/core/features/course/classes/main-activity-page.ts index 50d2108ae..b3f24a093 100644 --- a/src/core/features/course/classes/main-activity-page.ts +++ b/src/core/features/course/classes/main-activity-page.ts @@ -14,9 +14,9 @@ import { Component, OnInit } from '@angular/core'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourseModuleData } from '../services/course-helper'; import { CoreCourseModuleMainResourceComponent } from './main-resource-component'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Template class to easily create CoreCourseModuleMainComponent of resources (or activities without syncing). @@ -40,8 +40,7 @@ export class CoreCourseModuleMainActivityPage('module'); this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; diff --git a/src/core/features/course/classes/main-resource-component.ts b/src/core/features/course/classes/main-resource-component.ts index a49f8a3e2..dc567092d 100644 --- a/src/core/features/course/classes/main-resource-component.ts +++ b/src/core/features/course/classes/main-resource-component.ts @@ -17,8 +17,6 @@ import { OnInit, OnDestroy, Input, Output, EventEmitter, Component, Optional, In import { CoreAnyError } from '@classes/errors/error'; import { CoreNetwork } from '@services/network'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; - import { CoreUtils } from '@singletons/utils'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -36,6 +34,7 @@ import { CoreText } from '@singletons/text'; import { CoreModals } from '@services/overlays/modals'; import { CoreErrorHelper, CoreErrorObject } from '@services/error-helper'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Result of a resource download. @@ -208,7 +207,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, return await this.refreshContent(); } - CoreDomUtils.showErrorModalDefault(error, this.fetchContentDefaultError, true); + CoreAlerts.showError(error, { default: Translate.instant(this.fetchContentDefaultError) }); } finally { this.showLoading = false; } @@ -275,7 +274,7 @@ export class CoreCourseModuleMainResourceComponent implements OnInit, OnDestroy, * @param error The specific error. */ protected showErrorDownloadingSomeFiles(error: string | CoreErrorObject): void { - CoreDomUtils.showErrorModal(this.getErrorDownloadingSomeFilesMessage(error, true)); + CoreAlerts.showError(Translate.instant(this.getErrorDownloadingSomeFilesMessage(error))); } /** diff --git a/src/core/features/course/components/course-format/course-format.ts b/src/core/features/course/components/course-format/course-format.ts index 6f45c0fd0..6638b9650 100644 --- a/src/core/features/course/components/course-format/course-format.ts +++ b/src/core/features/course/components/course-format/course-format.ts @@ -25,7 +25,6 @@ import { ChangeDetectorRef, ViewChild, } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreDynamicComponent } from '@components/dynamic-component/dynamic-component'; import { CoreCourseAnyCourseData } from '@features/courses/services/courses'; import { @@ -66,6 +65,7 @@ import { toBoolean } from '@/core/transforms/boolean'; import { CoreInfiniteLoadingComponent } from '@components/infinite-loading/infinite-loading'; import { CoreSite } from '@classes/sites/site'; import { CoreCourseSectionComponent, CoreCourseSectionToDisplay } from '../course-section/course-section'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component to display course contents using a certain format. If the format isn't found, use default one. @@ -161,8 +161,7 @@ export class CoreCourseFormatComponent implements OnInit, OnChanges, OnDestroy { */ ngOnInit(): void { if (this.course === undefined) { - CoreDomUtils.showErrorModal('Course not set'); - + CoreAlerts.showError('Course not set'); CoreNavigator.back(); return; diff --git a/src/core/features/course/components/module-navigation/module-navigation.ts b/src/core/features/course/components/module-navigation/module-navigation.ts index cf4f5f7f4..b9f10a5b5 100644 --- a/src/core/features/course/components/module-navigation/module-navigation.ts +++ b/src/core/features/course/components/module-navigation/module-navigation.ts @@ -20,9 +20,10 @@ import { IonContent } from '@ionic/angular'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Component to show a button to go to the next resource/activity. @@ -177,9 +178,8 @@ export class CoreCourseModuleNavigationComponent implements OnInit, OnDestroy { const module = next ? this.nextModule : this.previousModule; if (!module) { // It seems the module was hidden. Show a message. - CoreDomUtils.instance.showErrorModal( - next ? 'core.course.nextactivitynotfound' : 'core.course.previousactivitynotfound', - true, + CoreAlerts.showError( + Translate.instant(next ? 'core.course.nextactivitynotfound' : 'core.course.previousactivitynotfound'), ); return; diff --git a/src/core/features/course/components/module-summary/module-summary.ts b/src/core/features/course/components/module-summary/module-summary.ts index 5c0f53626..e7794c184 100644 --- a/src/core/features/course/components/module-summary/module-summary.ts +++ b/src/core/features/course/components/module-summary/module-summary.ts @@ -27,15 +27,15 @@ import { CoreNetwork } from '@services/network'; import { CoreFilepool } from '@services/filepool'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreUtils } from '@singletons/utils'; -import { ModalController, NgZone } from '@singletons'; +import { ModalController, NgZone, Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { Subscription } from 'rxjs'; import { CoreSharedModule } from '@/core/shared.module'; import { toBoolean } from '@/core/transforms/boolean'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component to display a module summary modal. @@ -191,7 +191,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { this.fetchCourse(), ]); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } this.loaded = true; @@ -314,7 +314,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { // We need to call getDownloadSize, the package might have been updated. const size = await CoreCourseModulePrefetchDelegate.getModuleDownloadSize(this.module, this.courseId, true); - await CoreDomUtils.confirmDownloadSize(size); + await CoreAlerts.confirmDownloadSize(size); await CoreCourseModulePrefetchDelegate.prefetchModule(this.module, this.courseId, true); @@ -323,7 +323,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { this.prefetchLoading = false; if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } } } @@ -337,13 +337,15 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { } if (this.prefetchLoading) { - CoreDomUtils.showAlertTranslated(undefined, 'core.course.cannotdeletewhiledownloading'); + CoreAlerts.show({ message: Translate.instant('core.course.cannotdeletewhiledownloading') }); return; } try { - await CoreDomUtils.showDeleteConfirm('addon.storagemanager.confirmdeletedatafrom', { name: this.module.name }); + await CoreAlerts.confirmDelete( + Translate.instant('addon.storagemanager.confirmdeletedatafrom', { name: this.module.name }), + ); this.removeFilesLoading = true; @@ -351,7 +353,7 @@ export class CoreCourseModuleSummaryComponent implements OnInit, OnDestroy { } catch (error) { if (!this.isDestroyed &&error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } } finally { this.removeFilesLoading = false; diff --git a/src/core/features/course/directives/download-module-main-file.ts b/src/core/features/course/directives/download-module-main-file.ts index 0f8df12b8..9f2412069 100644 --- a/src/core/features/course/directives/download-module-main-file.ts +++ b/src/core/features/course/directives/download-module-main-file.ts @@ -13,12 +13,12 @@ // limitations under the License. import { Directive, Input, OnInit, ElementRef } from '@angular/core'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourse, CoreCourseModuleContentFile } from '@features/course/services/course'; import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/services/course-helper'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreOpenerOpenFileOptions } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Directive to allow downloading and open the main file of a module. @@ -83,7 +83,7 @@ export class CoreCourseDownloadModuleMainFileDirective implements OnInit { this.options, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); } finally { modal.dismiss(); } diff --git a/src/core/features/course/pages/contents/contents.ts b/src/core/features/course/pages/contents/contents.ts index 958ecd0f1..df96634a4 100644 --- a/src/core/features/course/pages/contents/contents.ts +++ b/src/core/features/course/pages/contents/contents.ts @@ -15,7 +15,6 @@ import { Component, ViewChild, OnInit, OnDestroy, forwardRef, ChangeDetectorRef } from '@angular/core'; import { IonContent } from '@ionic/angular'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { CoreCourses, CoreCourseAnyCourseData } from '@features/courses/services/courses'; import { @@ -48,6 +47,8 @@ import { } from '@features/course/constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreObject } from '@singletons/object'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays the contents of a course. @@ -96,7 +97,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon try { this.course = CoreNavigator.getRequiredRouteParam('course'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -167,7 +168,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon this.showLoadingAndRefresh(false, false); if (data.warnings && data.warnings[0]) { - CoreDomUtils.showAlert(undefined, data.warnings[0].message); + CoreAlerts.show({ message: data.warnings[0].message }); } }); } @@ -198,7 +199,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon this.course.displayname || this.course.fullname, )); if (result?.warnings?.length) { - CoreDomUtils.showAlert(undefined, result.warnings[0].message); + CoreAlerts.show({ message: result.warnings[0].message }); } } @@ -208,7 +209,7 @@ export class CoreCourseContentsPage implements OnInit, OnDestroy, CoreRefreshCon this.loadCourseFormatOptions(), ]); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.couldnotloadsectioncontent', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.couldnotloadsectioncontent') }); } } diff --git a/src/core/features/course/pages/course-summary/course-summary.page.ts b/src/core/features/course/pages/course-summary/course-summary.page.ts index 4585d7cb6..f6e9ad9cb 100644 --- a/src/core/features/course/pages/course-summary/course-summary.page.ts +++ b/src/core/features/course/pages/course-summary/course-summary.page.ts @@ -16,7 +16,6 @@ import { Component, OnDestroy, OnInit, Input, ViewChild, ElementRef } from '@ang import { ActionSheetButton } from '@ionic/angular'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourseCustomField, CoreCourses, @@ -42,6 +41,7 @@ import { CoreEnrolHelper } from '@features/enrol/services/enrol-helper'; import { CoreEnrolDelegate } from '@features/enrol/services/enrol-delegate'; import { CoreEnrol, CoreEnrolEnrolmentMethod } from '@features/enrol/services/enrol'; import { CORE_COURSES_MY_COURSES_UPDATED_EVENT, CoreCoursesMyCoursesUpdatedEventAction } from '@features/courses/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that shows the summary of a course including buttons to enrol and other available options. @@ -123,7 +123,7 @@ export class CoreCourseSummaryPage implements OnInit, OnDestroy { try { this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); this.closeModal(); // Just in case. @@ -155,7 +155,7 @@ export class CoreCourseSummaryPage implements OnInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting enrolment data'); + CoreAlerts.showError(error, { default: 'Error getting enrolment data' }); } await this.setCourseColor(); @@ -342,11 +342,10 @@ export class CoreCourseSummaryPage implements OnInit, OnDestroy { async browserEnrol(): Promise { // Send user to browser to enrol. Warn the user first. try { - await CoreDomUtils.showConfirm( - Translate.instant('core.courses.browserenrolinstructions'), - Translate.instant('core.courses.completeenrolmentbrowser'), - Translate.instant('core.openinbrowser'), - ); + await CoreAlerts.confirm(Translate.instant('core.courses.browserenrolinstructions'), { + header: Translate.instant('core.courses.completeenrolmentbrowser'), + okText: Translate.instant('core.openinbrowser'), + }); } catch { // User canceled. return; diff --git a/src/core/features/course/pages/index/index.ts b/src/core/features/course/pages/index/index.ts index 99a3a1c62..6756f0ddc 100644 --- a/src/core/features/course/pages/index/index.ts +++ b/src/core/features/course/pages/index/index.ts @@ -25,12 +25,12 @@ import { CoreCourseHelper, CoreCourseModuleData } from '@features/course/service import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CORE_COURSE_CONTENTS_PAGE_NAME, CORE_COURSE_PROGRESS_UPDATED_EVENT } from '@features/course/constants'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCoursesHelper, CoreCourseWithImageAndColor } from '@features/courses/services/courses-helper'; import { CoreColors } from '@singletons/colors'; import { CorePath } from '@singletons/path'; import { CoreSites } from '@services/sites'; import { CoreWait } from '@singletons/wait'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of courses the user is enrolled in. @@ -119,7 +119,7 @@ export class CoreCourseIndexPage implements OnInit, OnDestroy { try { this.course = CoreNavigator.getRequiredRouteParam('course'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); this.loaded = true; diff --git a/src/core/features/course/pages/list-mod-type/list-mod-type.ts b/src/core/features/course/pages/list-mod-type/list-mod-type.ts index 5cdad52e0..5423ca810 100644 --- a/src/core/features/course/pages/list-mod-type/list-mod-type.ts +++ b/src/core/features/course/pages/list-mod-type/list-mod-type.ts @@ -14,7 +14,6 @@ import { Component, OnInit } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourse, CoreCourseWSSection, sectionContentIsModule } from '@features/course/services/course'; import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; import { CoreCourseHelper, CoreCourseSection } from '@features/course/services/course-helper'; @@ -23,6 +22,7 @@ import { CoreConstants } from '@/core/constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays all modules of a certain type in a course. @@ -77,7 +77,7 @@ export class CoreCourseListModTypePage implements OnInit { this.courseId = CoreNavigator.getRequiredRouteParam('courseId'); this.modName = CoreNavigator.getRequiredRouteParam('modName'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -111,7 +111,7 @@ export class CoreCourseListModTypePage implements OnInit { this.lastShownSectionIndex = -1; this.showMoreActivities(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting data'); + CoreAlerts.showError(error, { default: 'Error getting data' }); } } diff --git a/src/core/features/course/pages/module-preview/module-preview.ts b/src/core/features/course/pages/module-preview/module-preview.ts index fec9c3a88..a1dd9cd04 100644 --- a/src/core/features/course/pages/module-preview/module-preview.ts +++ b/src/core/features/course/pages/module-preview/module-preview.ts @@ -20,8 +20,8 @@ import { CoreCourseModuleDelegate } from '@features/course/services/module-deleg import { CoreModals } from '@services/overlays/modals'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a module preview. @@ -52,8 +52,7 @@ export class CoreCourseModulePreviewPage implements OnInit { this.module = CoreNavigator.getRequiredRouteParam('module'); this.courseId = CoreNavigator.getRequiredRouteNumberParam('courseId'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; diff --git a/src/core/features/course/services/course-helper.ts b/src/core/features/course/services/course-helper.ts index 56ab342e8..ef654c88c 100644 --- a/src/core/features/course/services/course-helper.ts +++ b/src/core/features/course/services/course-helper.ts @@ -31,7 +31,6 @@ import { CoreConstants, DownloadStatus, ContextLevel } from '@/core/constants'; import { CoreLogger } from '@singletons/logger'; import { ApplicationInit, makeSingleton, Translate } from '@singletons'; import { CoreFilepool } from '@services/filepool'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreArray } from '@singletons/array'; import { CoreCourseAnyCourseData, @@ -84,6 +83,7 @@ import { } from '../constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener, CoreOpenerOpenFileOptions } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Prefetch info of a module. @@ -410,7 +410,9 @@ export class CoreCourseHelperProvider { const siteId = CoreSites.getCurrentSiteId(); // Confirm the download without checking size because it could take a while. - await CoreDomUtils.showConfirm(Translate.instant('core.areyousure'), Translate.instant('core.courses.downloadcourses')); + await CoreAlerts.confirm(Translate.instant('core.areyousure'), { + header: Translate.instant('core.courses.downloadcourses'), + }); const total = courses.length; let count = 0; @@ -499,7 +501,7 @@ export class CoreCourseHelperProvider { } // Show confirm modal if needed. - await CoreDomUtils.confirmDownloadSize(sizeSum, undefined, undefined, undefined, undefined, alwaysConfirm); + await CoreAlerts.confirmDownloadSize(sizeSum, { alwaysConfirm }); } /** @@ -1426,7 +1428,7 @@ export class CoreCourseHelperProvider { }, ); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { // Just in case. In fact we need to dismiss the modal before showing a toast or error message. modal.dismiss(); @@ -1506,7 +1508,7 @@ export class CoreCourseHelperProvider { await this.getAndOpenCourse(courseId, params, siteId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errorgetmodule', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errorgetmodule') }); } finally { modal.dismiss(); } @@ -1637,7 +1639,7 @@ export class CoreCourseHelperProvider { refresh?: boolean, ): Promise { // Show confirmation if needed. - await CoreDomUtils.confirmDownloadSize(size); + await CoreAlerts.confirmDownloadSize(size); // Invalidate content if refreshing and download the data. if (refresh) { @@ -1957,7 +1959,7 @@ export class CoreCourseHelperProvider { : CoreCourseModuleCompletionStatus.COMPLETION_COMPLETE; completion.isoverallcomplete = !completion.isoverallcomplete; - CoreDomUtils.showErrorModalDefault(error, 'core.errorchangecompletion', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorchangecompletion') }); } finally { modal.dismiss(); } diff --git a/src/core/features/course/services/course.ts b/src/core/features/course/services/course.ts index 6311590fc..ff2f03398 100644 --- a/src/core/features/course/services/course.ts +++ b/src/core/features/course/services/course.ts @@ -75,6 +75,7 @@ import { } from '../constants'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreObject } from '@singletons/object'; +import { CoreAlerts } from '@services/overlays/alerts'; export type CoreCourseProgressUpdated = { progress: number; courseId: number }; @@ -1470,11 +1471,11 @@ export class CoreCourseProvider { return; } catch { // The site plugin failed to load. The user needs to restart the app to try loading it again. - const message = Translate.instant('core.courses.errorloadplugins'); - const reload = Translate.instant('core.courses.reload'); - const ignore = Translate.instant('core.courses.ignore'); + await CoreAlerts.confirm(Translate.instant('core.courses.errorloadplugins'), { + okText: Translate.instant('core.courses.reload'), + cancelText: Translate.instant('core.courses.ignore'), + }); - await CoreDomUtils.showConfirm(message, '', reload, ignore); window.location.reload(); } finally { loading.dismiss(); diff --git a/src/core/features/courses/components/course-list-item/course-list-item.ts b/src/core/features/courses/components/course-list-item/course-list-item.ts index 962146b88..587bc30c2 100644 --- a/src/core/features/courses/components/course-list-item/course-list-item.ts +++ b/src/core/features/courses/components/course-list-item/course-list-item.ts @@ -19,7 +19,6 @@ import { CoreCourseHelper, CorePrefetchStatusInfo } from '@features/course/servi import { CoreUser } from '@features/user/services/user'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { Translate } from '@singletons'; import { CoreColors } from '@singletons/colors'; import { CoreEventCourseStatusChanged, CoreEventObserver, CoreEvents } from '@singletons/events'; @@ -37,6 +36,8 @@ import { CORE_COURSES_STATE_FAVOURITE, } from '@features/courses/constants'; import { CORE_COURSE_ALL_COURSES_CLEARED, CORE_COURSE_PROGRESS_UPDATED_EVENT } from '@features/course/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { CoreErrorHelper } from '@services/error-helper'; /** * This directive is meant to display an item for a list of courses. @@ -225,7 +226,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On // There is a download promise. If it fails, show an error. promise.catch((error) => { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errordownloadingcourse') }); } }); } else { @@ -265,7 +266,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On await CoreCourseHelper.confirmAndPrefetchCourse(this.prefetchCourseData, this.course); } catch (error) { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.errordownloadingcourse', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.errordownloadingcourse') }); } } } @@ -275,12 +276,11 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On */ async deleteCourseStoredData(): Promise { try { - await CoreDomUtils.showDeleteConfirm( - 'addon.storagemanager.confirmdeletedatafrom', - { name: this.course.displayname || this.course.fullname }, - ); + await CoreAlerts.confirmDelete(Translate.instant('addon.storagemanager.confirmdeletedatafrom', { + name: this.course.displayname || this.course.fullname, + })); } catch (error) { - if (!CoreDomUtils.isCanceledError(error)) { + if (!CoreErrorHelper.isCanceledError(error)) { throw error; } @@ -292,7 +292,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On try { await CoreCourseHelper.deleteCourseFiles(this.course.id); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, Translate.instant('core.errordeletefile')); + CoreAlerts.showError(error, { default: Translate.instant('core.errordeletefile') }); } finally { modal.dismiss(); } @@ -377,7 +377,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On } catch (error) { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'Error changing course visibility.'); + CoreAlerts.showError(error, { default: 'Error changing course visibility.' }); } } finally { this.showSpinner = false; @@ -406,7 +406,7 @@ export class CoreCoursesCourseListItemComponent implements OnInit, OnDestroy, On } catch (error) { if (!this.isDestroyed) { - CoreDomUtils.showErrorModalDefault(error, 'Error changing course favourite attribute.'); + CoreAlerts.showError(error, { default: 'Error changing course favourite attribute.' }); } } finally { this.showSpinner = false; diff --git a/src/core/features/courses/pages/categories/categories.ts b/src/core/features/courses/pages/categories/categories.ts index c52e7bd2f..225077261 100644 --- a/src/core/features/courses/pages/categories/categories.ts +++ b/src/core/features/courses/pages/categories/categories.ts @@ -14,7 +14,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { CoreCategoryData, CoreCourseListItem, CoreCourses } from '../../services/courses'; import { Translate } from '@singletons'; @@ -27,6 +26,7 @@ import { CoreCoursesMyCoursesUpdatedEventAction, CORE_COURSES_DASHBOARD_DOWNLOAD_ENABLED_CHANGED_EVENT, } from '@features/courses/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a list of categories and the courses in the current category if any. @@ -152,13 +152,15 @@ export class CoreCoursesCategoriesPage implements OnInit, OnDestroy { this.categoryCourses = await CoreCourses.getCoursesByField('category', this.categoryId); await this.filterEnrolled(); } catch (error) { - !this.isDestroyed && CoreDomUtils.showErrorModalDefault(error, 'core.courses.errorloadcourses', true); + !this.isDestroyed && CoreAlerts.showError(error, { + default: Translate.instant('core.courses.errorloadcourses'), + }); } } this.logView(); } catch (error) { - !this.isDestroyed && CoreDomUtils.showErrorModalDefault(error, 'core.courses.errorloadcategories', true); + !this.isDestroyed && CoreAlerts.showError(error, { default: Translate.instant('core.courses.errorloadcategories') }); } } diff --git a/src/core/features/courses/pages/dashboard/dashboard.ts b/src/core/features/courses/pages/dashboard/dashboard.ts index 50789a2c9..9d93e2d61 100644 --- a/src/core/features/courses/pages/dashboard/dashboard.ts +++ b/src/core/features/courses/pages/dashboard/dashboard.ts @@ -18,7 +18,6 @@ import { CoreCourses } from '../../services/courses'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; import { CoreCoursesDashboard } from '@features/courses/services/dashboard'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourseBlock } from '@features/course/services/course'; import { CoreBlockComponent } from '@features/block/components/block/block'; import { CoreNavigator } from '@services/navigator'; @@ -27,6 +26,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the dashboard page. @@ -104,7 +104,7 @@ export class CoreCoursesDashboardPage implements OnInit, OnDestroy { this.hasMainBlocks = CoreBlockDelegate.hasSupportedBlock(blocks.mainBlocks); this.hasSideBlocks = CoreBlockDelegate.hasSupportedBlock(blocks.sideBlocks); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); // Cannot get the blocks, just show dashboard if needed. this.loadFallbackBlocks(); diff --git a/src/core/features/courses/pages/list/list.ts b/src/core/features/courses/pages/list/list.ts index 519b44603..b4bd5ea08 100644 --- a/src/core/features/courses/pages/list/list.ts +++ b/src/core/features/courses/pages/list/list.ts @@ -16,7 +16,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CoreCoursesHelper, CoreEnrolledCourseDataWithExtraInfo } from '@features/courses/services/courses-helper'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreCourseBasicSearchedData, CoreCourses } from '../../services/courses'; import { CoreTime } from '@singletons/time'; @@ -27,6 +26,7 @@ import { CoreCoursesMyCoursesUpdatedEventAction, CORE_COURSES_DASHBOARD_DOWNLOAD_ENABLED_CHANGED_EVENT, } from '@features/courses/constants'; +import { CoreAlerts } from '@services/overlays/alerts'; type CoreCoursesListMode = 'search' | 'all' | 'my'; @@ -212,7 +212,7 @@ export class CoreCoursesListPage implements OnInit, OnDestroy { this.logView(); } catch (error) { this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading. - !this.isDestroyed && CoreDomUtils.showErrorModalDefault(error, 'core.courses.errorloadcourses', true); + !this.isDestroyed && CoreAlerts.showError(error, { default: Translate.instant('core.courses.errorloadcourses') }); } } @@ -337,7 +337,7 @@ export class CoreCoursesListPage implements OnInit, OnDestroy { this.logSearch?.(); } catch (error) { this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading. - !this.isDestroyed && CoreDomUtils.showErrorModalDefault(error, 'core.courses.errorsearching', true); + !this.isDestroyed && CoreAlerts.showError(error, { default: Translate.instant('core.courses.errorsearching') }); } } diff --git a/src/core/features/courses/pages/my/my.ts b/src/core/features/courses/pages/my/my.ts index cd9092777..928206429 100644 --- a/src/core/features/courses/pages/my/my.ts +++ b/src/core/features/courses/pages/my/my.ts @@ -22,7 +22,6 @@ import { CoreBlockDelegate } from '@features/block/services/block-delegate'; import { CoreCourseBlock } from '@features/course/services/course'; import { CoreCoursesDashboard, CoreCoursesDashboardProvider } from '@features/courses/services/dashboard'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { Subscription } from 'rxjs'; @@ -31,6 +30,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; import { CoreWait } from '@singletons/wait'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that shows a my courses. @@ -133,7 +133,7 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { this.loadFallbackBlock(); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); // Cannot get the blocks, just show the block if needed. this.loadFallbackBlock(); diff --git a/src/core/features/courses/services/handlers/enrol-push-click.ts b/src/core/features/courses/services/handlers/enrol-push-click.ts index 20000128b..cc7d10a1f 100644 --- a/src/core/features/courses/services/handlers/enrol-push-click.ts +++ b/src/core/features/courses/services/handlers/enrol-push-click.ts @@ -19,9 +19,9 @@ import { CorePushNotificationsClickHandler } from '@features/pushnotifications/s import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { makeSingleton } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler for enrol push notifications clicks. @@ -72,7 +72,7 @@ export class CoreCoursesEnrolPushClickHandlerService implements CorePushNotifica await CoreNavigator.navigateToSitePath(page, { params, siteId: notification.site }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting course.'); + CoreAlerts.showError(error, { default: 'Error getting course.' }); } finally { modal.dismiss(); } diff --git a/src/core/features/courses/services/handlers/request-push-click.ts b/src/core/features/courses/services/handlers/request-push-click.ts index 2fcc33066..42d62f86d 100644 --- a/src/core/features/courses/services/handlers/request-push-click.ts +++ b/src/core/features/courses/services/handlers/request-push-click.ts @@ -19,13 +19,13 @@ import { CorePushNotificationsClickHandler } from '@features/pushnotifications/s import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUtils } from '@singletons/utils'; import { makeSingleton } from '@singletons'; import { CorePath } from '@singletons/path'; import { CoreCourses } from '../courses'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler for course request push notifications clicks. @@ -86,7 +86,7 @@ export class CoreCoursesRequestPushClickHandlerService implements CorePushNotifi await CoreNavigator.navigateToSitePath(page, { params, siteId: notification.site }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting course.'); + CoreAlerts.showError(error, { default: 'Error getting course.' }); } finally { modal.dismiss(); } diff --git a/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts b/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts index b98805def..dde83dfe7 100644 --- a/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts +++ b/src/core/features/dataprivacy/components/contactdpo/contactdpo.ts @@ -18,12 +18,12 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms'; import { CoreDataPrivacy } from '@features/dataprivacy/services/dataprivacy'; import { CoreUser } from '@features/user/services/user'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { ModalController } from '@singletons'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays the contact DPO page. @@ -90,7 +90,7 @@ export class CoreDataPrivacyContactDPOComponent implements OnInit { ModalController.dismiss(true); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error sending data privacy request'); + CoreAlerts.showError(error, { default: 'Error sending data privacy request' }); } finally { modal.dismiss(); } diff --git a/src/core/features/dataprivacy/components/newrequest/newrequest.ts b/src/core/features/dataprivacy/components/newrequest/newrequest.ts index 5d0cfe975..68df6e202 100644 --- a/src/core/features/dataprivacy/components/newrequest/newrequest.ts +++ b/src/core/features/dataprivacy/components/newrequest/newrequest.ts @@ -20,11 +20,11 @@ import { CoreDataPrivacyDataRequestType, CoreDataPrivacyGetAccessInformationWSResponse, } from '@features/dataprivacy/services/dataprivacy'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { ModalController } from '@singletons'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays the new request page. @@ -115,7 +115,7 @@ export class CoreDataPrivacyNewRequestComponent implements OnInit { ModalController.dismiss(true); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error sending data privacy request'); + CoreAlerts.showError(error, { default: 'Error sending data privacy request' }); } finally { modal.dismiss(); } diff --git a/src/core/features/dataprivacy/pages/main/main.ts b/src/core/features/dataprivacy/pages/main/main.ts index d28541033..cc45d4b77 100644 --- a/src/core/features/dataprivacy/pages/main/main.ts +++ b/src/core/features/dataprivacy/pages/main/main.ts @@ -23,10 +23,10 @@ import { CoreLoadings } from '@services/overlays/loadings'; import { CoreModals } from '@services/overlays/modals'; import { CoreNavigator } from '@services/navigator'; import { CoreScreen } from '@services/screen'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; import { Subscription } from 'rxjs'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to display the main data privacy page. @@ -90,7 +90,7 @@ export class CoreDataPrivacyMainPage implements OnInit { request.canCancel = CoreDataPrivacy.canCancelRequest(request); }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error fetching data privacy information', true); + CoreAlerts.showError(error, { default: 'Error fetching data privacy information' }); } finally { this.loaded = true; } @@ -167,11 +167,10 @@ export class CoreDataPrivacyMainPage implements OnInit { async cancelRequest(requestId: number): Promise { try { - await CoreDomUtils.showConfirm( - Translate.instant('core.dataprivacy.cancelrequestconfirmation'), - Translate.instant('core.dataprivacy.cancelrequest'), - Translate.instant('core.dataprivacy.cancelrequest'), - ); + await CoreAlerts.confirm(Translate.instant('core.dataprivacy.cancelrequestconfirmation'), { + header: Translate.instant('core.dataprivacy.cancelrequest'), + okText: Translate.instant('core.dataprivacy.cancelrequest'), + }); } catch { return; } @@ -183,7 +182,7 @@ export class CoreDataPrivacyMainPage implements OnInit { await this.refreshContent(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error cancelling data privacy request'); + CoreAlerts.showError(error, { default: 'Error cancelling data privacy request' }); } finally { modal.dismiss(); } diff --git a/src/core/features/emulator/components/capture-media/capture-media.ts b/src/core/features/emulator/components/capture-media/capture-media.ts index 15a9e0a42..d16c4f24c 100644 --- a/src/core/features/emulator/components/capture-media/capture-media.ts +++ b/src/core/features/emulator/components/capture-media/capture-media.ts @@ -16,7 +16,6 @@ import { Component, OnInit, OnDestroy, ViewChild, ElementRef, ChangeDetectorRef, import { MediaFile } from '@awesome-cordova-plugins/media-capture/ngx'; import { CoreFile, CoreFileProvider } from '@services/file'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreTimeUtils } from '@services/utils/time'; import { ModalController, Translate } from '@singletons'; @@ -26,6 +25,7 @@ import { CoreCanceledError } from '@classes/errors/cancelederror'; import { CorePath } from '@singletons/path'; import { toBoolean } from '@/core/transforms/boolean'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to capture media in browser. @@ -235,7 +235,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy { async cancel(): Promise { if (this.hasCaptured) { try { - await CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); } catch { // Canceled. return; @@ -309,7 +309,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy { if (!this.mediaBlob) { // Shouldn't happen. - CoreDomUtils.showErrorModal('Please capture the media first.'); + CoreAlerts.showError('Please capture the media first.'); return; } @@ -350,7 +350,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy { this.dismissWithData([mediaFile]); } } catch (err) { - CoreDomUtils.showErrorModal(err); + CoreAlerts.showError(err); } finally { loadingModal.dismiss(); } diff --git a/src/core/features/fileuploader/components/audio-recorder/audio-recorder.component.ts b/src/core/features/fileuploader/components/audio-recorder/audio-recorder.component.ts index 85f37c6c2..197091936 100644 --- a/src/core/features/fileuploader/components/audio-recorder/audio-recorder.component.ts +++ b/src/core/features/fileuploader/components/audio-recorder/audio-recorder.component.ts @@ -21,7 +21,6 @@ import { Mp3MediaRecorder } from 'mp3-mediarecorder'; import { map, shareReplay, tap } from 'rxjs/operators'; import { initAudioEncoderMessage } from '@features/fileuploader/utils/worker-messages'; import { SafeUrl } from '@angular/platform-browser'; -import { CoreDomUtils } from '@services/utils/dom'; import { CAPTURE_ERROR_NO_MEDIA_FILES, CoreCaptureError } from '@classes/errors/captureerror'; import { CoreFileUploaderAudioRecording } from '@features/fileuploader/services/fileuploader'; import { CoreFile, CoreFileProvider } from '@services/file'; @@ -29,6 +28,7 @@ import { CorePath } from '@singletons/path'; import { CoreNative } from '@features/native/services/native'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreFileUploaderAudioHistogramComponent } from '../audio-histogram/audio-histogram'; +import { CoreAlerts } from '@services/overlays/alerts'; @Component({ selector: 'core-fileuploader-audio-recorder', @@ -112,7 +112,7 @@ export class CoreFileUploaderAudioRecorderComponent extends CoreModalComponent audioChunks.push(event.data); - const onError = event => CoreDomUtils.showErrorModal(event.error); + const onError = event => CoreAlerts.showError(event.error); const onStop = () => { const blob = new Blob(audioChunks, { type: 'audio/mpeg' }); diff --git a/src/core/features/fileuploader/services/fileuploader-helper.ts b/src/core/features/fileuploader/services/fileuploader-helper.ts index 2cf257130..c94abea8b 100644 --- a/src/core/features/fileuploader/services/fileuploader-helper.ts +++ b/src/core/features/fileuploader/services/fileuploader-helper.ts @@ -21,7 +21,6 @@ import { MediaFile } from '@awesome-cordova-plugins/media-capture/ngx'; import { CoreNetwork } from '@services/network'; import { CoreFile, CoreFileProvider, CoreFileProgressEvent } from '@services/file'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreText } from '@singletons/text'; import { CoreArray } from '@singletons/array'; @@ -47,6 +46,7 @@ import { Chooser } from '@features/native/plugins'; import { CoreToasts } from '@services/overlays/toasts'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreFileUtils } from '@singletons/file-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Helper service to upload files. @@ -139,15 +139,13 @@ export class CoreFileUploaderHelperProvider { CoreFileUploaderProvider.LIMITED_SIZE_WARNING : limitedThreshold; if (size < 0) { - return CoreDomUtils.showConfirm(Translate.instant('core.fileuploader.confirmuploadunknownsize')); + return CoreAlerts.confirm(Translate.instant('core.fileuploader.confirmuploadunknownsize')); } else if (size >= wifiThreshold || (CoreNetwork.isNetworkAccessLimited() && size >= limitedThreshold)) { const readableSize = CoreText.bytesToSize(size, 2); - return CoreDomUtils.showConfirm( - Translate.instant('core.fileuploader.confirmuploadfile', { size: readableSize }), - ); + return CoreAlerts.confirm(Translate.instant('core.fileuploader.confirmuploadfile', { size: readableSize })); } else if (alwaysConfirm) { - return CoreDomUtils.showConfirm(Translate.instant('core.areyousure')); + return CoreAlerts.confirm(Translate.instant('core.areyousure')); } } @@ -375,7 +373,7 @@ export class CoreFileUploaderHelperProvider { if (!allowOffline && !CoreNetwork.isOnline()) { // Not allowed, show error. - CoreDomUtils.showErrorModal('core.fileuploader.errormustbeonlinetoupload', true); + CoreAlerts.showError(Translate.instant('core.fileuploader.errormustbeonlinetoupload')); return false; } @@ -415,10 +413,7 @@ export class CoreFileUploaderHelperProvider { return true; } catch (error) { - CoreDomUtils.showErrorModalDefault( - error, - Translate.instant('core.fileuploader.errorreadingfile'), - ); + CoreAlerts.showError(error, { default: Translate.instant('core.fileuploader.errorreadingfile') }); return false; } @@ -466,7 +461,7 @@ export class CoreFileUploaderHelperProvider { cssClass: 'core-toast-success', }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.fileuploader.errorreadingfile', true); + CoreAlerts.showError(error, { default: Translate.instant('core.fileuploader.errorreadingfile') }); throw error; } @@ -774,13 +769,14 @@ export class CoreFileUploaderHelperProvider { options: CoreFileUploaderOptions, siteId?: string, ): Promise { - const errorStr = Translate.instant('core.error'); - const retryStr = Translate.instant('core.retry'); const uploadingStr = Translate.instant('core.fileuploader.uploading'); const errorUploading = async (error): Promise => { // Allow the user to retry. try { - await CoreDomUtils.showConfirm(error, errorStr, retryStr); + await CoreAlerts.confirm(error, { + header: Translate.instant('core.error'), + okText: Translate.instant('core.retry'), + }); } catch (error) { // User cancelled. Delete the file if needed. if (options.deleteAfterUpload) { diff --git a/src/core/features/fileuploader/services/handlers/file.ts b/src/core/features/fileuploader/services/handlers/file.ts index 4e63a0aa8..118c6d787 100644 --- a/src/core/features/fileuploader/services/handlers/file.ts +++ b/src/core/features/fileuploader/services/handlers/file.ts @@ -13,13 +13,12 @@ // limitations under the License. import { Injectable } from '@angular/core'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CoreFileUploaderHandler, CoreFileUploaderHandlerData, CoreFileUploaderHandlerResult } from '../fileuploader-delegate'; import { CoreFileUploaderHelper } from '../fileuploader-helper'; import { CoreFileUploader } from '../fileuploader'; import { makeSingleton, Translate } from '@singletons'; import { CorePlatform } from '@services/platform'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handler to upload any type of file. @@ -102,7 +101,7 @@ export class CoreFileUploaderFileHandlerService implements CoreFileUploaderHandl // Verify that the mimetype of the file is supported, in case the accept attribute isn't supported. const error = CoreFileUploader.isInvalidMimetype(mimetypes, file.name, file.type); if (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); return; } @@ -119,10 +118,7 @@ export class CoreFileUploaderFileHandlerService implements CoreFileUploaderHandl CoreFileUploaderHelper.fileUploaded(result); } catch (error) { - CoreDomUtils.showErrorModalDefault( - error, - Translate.instant('core.fileuploader.errorreadingfile'), - ); + CoreAlerts.showError(error, { default: Translate.instant('core.fileuploader.errorreadingfile') }); } }); diff --git a/src/core/features/grades/pages/course/course.page.ts b/src/core/features/grades/pages/course/course.page.ts index 085f36489..4ce53a137 100644 --- a/src/core/features/grades/pages/course/course.page.ts +++ b/src/core/features/grades/pages/course/course.page.ts @@ -14,8 +14,6 @@ import { ActivatedRoute, ActivatedRouteSnapshot } from '@angular/router'; import { AfterViewInit, Component, ElementRef, OnDestroy } from '@angular/core'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CoreGrades } from '@features/grades/services/grades'; import { CoreGradesFormattedTableColumn, @@ -36,6 +34,7 @@ import { CoreGradesCoursesSource } from '@features/grades/classes/grades-courses import { CoreDom } from '@singletons/dom'; import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays a course grades. @@ -95,8 +94,7 @@ export class CoreGradesCoursePage implements AfterViewInit, OnDestroy { break; } } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -212,7 +210,7 @@ export class CoreGradesCoursePage implements AfterViewInit, OnDestroy { } } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading course'); + CoreAlerts.showError(error, { default: 'Error loading course' }); this.columns = []; this.rows = []; diff --git a/src/core/features/grades/pages/courses/courses.ts b/src/core/features/grades/pages/courses/courses.ts index 140bc18af..93fca1cd8 100644 --- a/src/core/features/grades/pages/courses/courses.ts +++ b/src/core/features/grades/pages/courses/courses.ts @@ -21,9 +21,9 @@ import { CoreGradesCoursesSource } from '@features/grades/classes/grades-courses import { CoreGrades } from '@features/grades/services/grades'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays courses grades (main menu option). @@ -79,7 +79,7 @@ export class CoreGradesCoursesPage implements OnDestroy, AfterViewInit { try { await this.courses.load(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading courses'); + CoreAlerts.showError(error, { default: 'Error loading courses' }); } } diff --git a/src/core/features/h5p/components/h5p-iframe/h5p-iframe.ts b/src/core/features/h5p/components/h5p-iframe/h5p-iframe.ts index 389472e77..f97283bb2 100644 --- a/src/core/features/h5p/components/h5p-iframe/h5p-iframe.ts +++ b/src/core/features/h5p/components/h5p-iframe/h5p-iframe.ts @@ -21,7 +21,6 @@ import { CoreFile } from '@services/file'; import { CoreFilepool } from '@services/filepool'; import { CoreFileHelper } from '@services/file-helper'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CoreH5P } from '@features/h5p/services/h5p'; import { DownloadStatus } from '@/core/constants'; @@ -31,6 +30,7 @@ import { CoreH5PCore, CoreH5PDisplayOptions } from '../../classes/core'; import { CoreH5PHelper } from '../../classes/helper'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { toBoolean } from '@/core/transforms/boolean'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component to render an iframe with an H5P package. @@ -147,8 +147,7 @@ export class CoreH5PIframeComponent implements OnChanges, OnDestroy { this.iframeSrc = CoreUrl.addParamsToUrl(src, { preventredirect: false }); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading H5P package.', true); - + CoreAlerts.showError(error, { default: 'Error loading H5P package.' }); } finally { CoreH5PHelper.addResizerScript(); this.onIframeUrlSet.emit({ src: this.iframeSrc!, online: !!localUrl }); diff --git a/src/core/features/h5p/components/h5p-player/h5p-player.ts b/src/core/features/h5p/components/h5p-player/h5p-player.ts index 95853d05c..3f9115820 100644 --- a/src/core/features/h5p/components/h5p-player/h5p-player.ts +++ b/src/core/features/h5p/components/h5p-player/h5p-player.ts @@ -17,7 +17,6 @@ import { Component, Input, ElementRef, OnInit, OnDestroy, OnChanges, SimpleChang import { CoreNetwork } from '@services/network'; import { CoreFilepool } from '@services/filepool'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CorePluginFileDelegate } from '@services/plugin-file-delegate'; import { DownloadStatus } from '@/core/constants'; @@ -27,6 +26,9 @@ import { CoreLogger } from '@singletons/logger'; import { CoreH5P } from '@features/h5p/services/h5p'; import { CoreH5PDisplayOptions } from '../../classes/core'; import { BehaviorSubject } from 'rxjs'; +import { CoreErrorHelper } from '@services/error-helper'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Component to render an H5P package. @@ -117,7 +119,7 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { */ async download(): Promise { if (!CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal('core.networkerrormsg', true); + CoreAlerts.showError(Translate.instant('core.networkerrormsg')); return; } @@ -132,18 +134,18 @@ export class CoreH5PPlayerComponent implements OnInit, OnChanges, OnDestroy { // Get the file size and ask the user to confirm. const size = await CorePluginFileDelegate.getFileSize({ fileurl: this.urlParams.url }, this.siteId); - await CoreDomUtils.confirmDownloadSize({ size: size, total: true }); + await CoreAlerts.confirmDownloadSize({ size: size, total: true }); // User confirmed, add to the queue. await CoreFilepool.addToQueueByUrl(this.siteId, this.urlParams.url, this.component, this.componentId); } catch (error) { - if (CoreDomUtils.isCanceledError(error)) { + if (CoreErrorHelper.isCanceledError(error)) { // User cancelled, stop. return; } - CoreDomUtils.showErrorModalDefault(error, 'core.errordownloading', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errordownloading') }); this.calculateState(); } } diff --git a/src/core/features/login/components/identity-provider/identity-provider.ts b/src/core/features/login/components/identity-provider/identity-provider.ts index 350ef4c72..e1761eadc 100644 --- a/src/core/features/login/components/identity-provider/identity-provider.ts +++ b/src/core/features/login/components/identity-provider/identity-provider.ts @@ -15,9 +15,9 @@ import { Component, Input } from '@angular/core'; import { CoreSiteIdentityProvider } from '@classes/sites/unauthenticated-site'; import { CoreLoginHelper } from '@features/login/services/login-helper'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSharedModule } from '@/core/shared.module'; import { CoreRedirectPayload } from '@services/navigator'; +import { CoreAlerts } from '@services/overlays/alerts'; @Component({ selector: 'core-identity-provider', @@ -46,7 +46,7 @@ export class CoreLoginIdentityProviderComponent { ); if (!result) { - CoreDomUtils.showErrorModal('Invalid data.'); + CoreAlerts.showError('Invalid data.'); } } diff --git a/src/core/features/login/components/sites-modal/sites-modal.ts b/src/core/features/login/components/sites-modal/sites-modal.ts index 897f27487..122aa0eac 100644 --- a/src/core/features/login/components/sites-modal/sites-modal.ts +++ b/src/core/features/login/components/sites-modal/sites-modal.ts @@ -12,16 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CoreDomUtils } from '@services/utils/dom'; import { Component, OnInit } from '@angular/core'; - import { CoreSiteBasicInfo, CoreSites } from '@services/sites'; import { CoreAccountsList, CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreNavigator } from '@services/navigator'; import { CoreFilter } from '@features/filter/services/filter'; import { CoreAnimations } from '@components/animations'; -import { ModalController } from '@singletons'; +import { ModalController, Translate } from '@singletons'; import { CoreSharedModule } from '@/core/shared.module'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Modal that displays a list of sites to be able to enter or delete a site. @@ -85,7 +84,7 @@ export class CoreLoginSitesModalComponent implements OnInit { siteName = await CoreFilter.formatText(siteName, { clean: true, singleLine: true, filter: false }, [], site.id); try { - await CoreDomUtils.showDeleteConfirm('core.login.confirmdeletesite', { sitename: siteName }); + await CoreAlerts.confirmDelete(Translate.instant('core.login.confirmdeletesite', { sitename: siteName })); } catch { // User cancelled, stop. return; @@ -96,7 +95,7 @@ export class CoreLoginSitesModalComponent implements OnInit { this.showDelete = false; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.login.errordeletesite', true); + CoreAlerts.showError(error, { default: Translate.instant('core.login.errordeletesite') }); } } diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index a1909859c..d31a4b71e 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -20,7 +20,6 @@ import { debounceTime } from 'rxjs/operators'; import { CoreSSO } from '@singletons/sso'; import { CoreNetwork } from '@services/network'; import { CoreSiteCheckResponse, CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { Translate } from '@singletons'; import { CoreSitePublicConfigResponse, CoreUnauthenticatedSite } from '@classes/sites/unauthenticated-site'; @@ -42,6 +41,7 @@ import { CoreCustomURLSchemes } from '@services/urlschemes'; import { CoreSiteError } from '@classes/errors/siteerror'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to enter the user credentials. @@ -105,7 +105,7 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { this.supportConfig = this.siteConfig && new CoreUserGuestSupportConfig(this.site, this.siteConfig); this.displaySiteUrl = this.site.shouldDisplayInformativeLinks(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); return CoreNavigator.back(); } @@ -191,9 +191,10 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { // Check if user needs to authenticate in a browser. this.isBrowserSSO = CoreLoginHelper.isSSOLoginNeeded(this.siteCheck.code); } catch (error) { - this.siteCheckError = CoreDomUtils.getErrorMessage(error) || 'Error loading site'; + const alert = await CoreAlerts.showError(error); - CoreDomUtils.showErrorModal(error); + this.siteCheckError = + (typeof alert?.message === 'object' ? alert.message.value : alert?.message) || 'Error loading site'; } finally { this.pageLoaded = true; } @@ -268,18 +269,18 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { const password = this.credForm.value.password; if (!username) { - CoreDomUtils.showErrorModal('core.login.usernamerequired', true); + CoreAlerts.showError(Translate.instant('core.login.usernamerequired')); return; } if (!password) { - CoreDomUtils.showErrorModal('core.login.passwordrequired', true); + CoreAlerts.showError(Translate.instant('core.login.passwordrequired')); return; } if (!CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal('core.networkerrormsg', true); + CoreAlerts.showError(Translate.instant('core.networkerrormsg')); return; } diff --git a/src/core/features/login/pages/email-signup/email-signup.ts b/src/core/features/login/pages/email-signup/email-signup.ts index bdc00321e..2d10e6c68 100644 --- a/src/core/features/login/pages/email-signup/email-signup.ts +++ b/src/core/features/login/pages/email-signup/email-signup.ts @@ -14,8 +14,6 @@ import { Component, ViewChild, ElementRef, OnInit, ChangeDetectorRef } from '@angular/core'; import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreCountries, CoreCountry } from '@singletons/countries'; import { CoreWS, CoreWSExternalWarning } from '@services/ws'; @@ -40,6 +38,7 @@ import { CoreViewer } from '@features/viewer/services/viewer'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to signup using email. @@ -135,7 +134,7 @@ export class CoreLoginEmailSignupPage implements OnInit { ngOnInit(): void { const siteUrl = CoreNavigator.getRouteParam('siteUrl'); if (!siteUrl) { - CoreDomUtils.showErrorModal('Site URL not supplied.'); + CoreAlerts.showError('Site URL not supplied.'); CoreNavigator.back(); return; @@ -208,7 +207,7 @@ export class CoreLoginEmailSignupPage implements OnInit { this.completeFormGroup(); } catch (error) { if (this.allRequiredSupported) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } } } @@ -265,7 +264,7 @@ export class CoreLoginEmailSignupPage implements OnInit { return true; } else { - CoreDomUtils.showErrorModal( + CoreAlerts.showError( Translate.instant( 'core.login.signupplugindisabled', { $a: Translate.instant('core.login.auth_email') }, @@ -303,7 +302,7 @@ export class CoreLoginEmailSignupPage implements OnInit { if (!errorFound) { // Input not found, show an error modal. - CoreDomUtils.showErrorModal('core.errorinvalidform', true); + CoreAlerts.showError(Translate.instant('core.errorinvalidform')); } return; @@ -351,7 +350,7 @@ export class CoreLoginEmailSignupPage implements OnInit { // Show alert and ho back. const message = Translate.instant('core.login.emailconfirmsent', { $a: params.email }); - CoreDomUtils.showAlert(Translate.instant('core.success'), message); + CoreAlerts.show({ header: Translate.instant('core.success'), message }); CoreNavigator.back(); } else { this.recaptchaComponent?.expireRecaptchaAnswer(); @@ -363,13 +362,13 @@ export class CoreLoginEmailSignupPage implements OnInit { error = Translate.instant('core.login.recaptchaincorrect'); } - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } else { - CoreDomUtils.showErrorModal('core.login.usernotaddederror', true); + CoreAlerts.showError(Translate.instant('core.login.usernotaddederror')); } } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.login.usernotaddederror', true); + CoreAlerts.showError(error, { default: Translate.instant('core.login.usernotaddederror') }); } finally { modal.dismiss(); } @@ -413,7 +412,7 @@ export class CoreLoginEmailSignupPage implements OnInit { e.stopPropagation(); if (!this.ageVerificationForm.valid) { - CoreDomUtils.showErrorModal('core.errorinvalidform', true); + CoreAlerts.showError(Translate.instant('core.errorinvalidform')); return; } @@ -442,7 +441,7 @@ export class CoreLoginEmailSignupPage implements OnInit { } } catch { // Something wrong, redirect to the site. - CoreDomUtils.showErrorModal('There was an error verifying your age, please try again using the browser.'); + CoreAlerts.showError('There was an error verifying your age, please try again using the browser.'); } finally { modal.dismiss(); } diff --git a/src/core/features/login/pages/forgotten-password/forgotten-password.ts b/src/core/features/login/pages/forgotten-password/forgotten-password.ts index 54f35172a..bf8cfb231 100644 --- a/src/core/features/login/pages/forgotten-password/forgotten-password.ts +++ b/src/core/features/login/pages/forgotten-password/forgotten-password.ts @@ -14,8 +14,6 @@ import { Component, ViewChild, ElementRef, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { Translate } from '@singletons'; import { CoreNavigator } from '@services/navigator'; @@ -26,6 +24,7 @@ import { CoreUserSupportConfig } from '@features/user/classes/support/support-co import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config'; import { CoreSitesFactory } from '@services/sites-factory'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to recover a forgotten password. @@ -53,7 +52,7 @@ export class CoreLoginForgottenPasswordPage implements OnInit { async ngOnInit(): Promise { const siteUrl = CoreNavigator.getRouteParam('siteUrl'); if (!siteUrl) { - CoreDomUtils.showErrorModal('Site URL not supplied.'); + CoreAlerts.showError('Site URL not supplied.'); CoreNavigator.back(); return; @@ -86,7 +85,7 @@ export class CoreLoginForgottenPasswordPage implements OnInit { const value = this.myForm.value.value; if (!value) { - CoreDomUtils.showErrorModal('core.login.usernameoremail', true); + CoreAlerts.showError(Translate.instant('core.login.usernameoremail')); return; } @@ -106,21 +105,21 @@ export class CoreLoginForgottenPasswordPage implements OnInit { const warning = response.warnings?.find((warning) => (warning.item === 'email' && isMail) || (warning.item === 'username' && !isMail)); if (warning) { - CoreDomUtils.showErrorModal(warning.message); + CoreAlerts.showError(warning.message); } } else if (response.status === 'emailpasswordconfirmnotsent' || response.status === 'emailpasswordconfirmnoemail') { // Error, not found. - CoreDomUtils.showErrorModal(response.notice); + CoreAlerts.showError(response.notice); } else { // Success. CoreForms.triggerFormSubmittedEvent(this.formElement, true); - await CoreDomUtils.showAlert(Translate.instant('core.success'), response.notice); + await CoreAlerts.show({ header: Translate.instant('core.success'), message: response.notice }); await CoreNavigator.back(); await CoreLoginHelper.passwordResetRequested(this.site.getURL()); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index b2e365ac4..a1c813902 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -17,7 +17,6 @@ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { CoreNetwork } from '@services/network'; import { CoreSiteBasicInfo, CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreSite } from '@classes/sites/site'; @@ -35,6 +34,7 @@ import { ALWAYS_SHOW_LOGIN_FORM_CHANGED, FORGOTTEN_PASSWORD_FEATURE_NAME } from import { CoreKeyboard } from '@singletons/keyboard'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreLoginMethodsComponent, CoreLoginMethodsCurrentLogin } from '@features/login/components/login-methods/login-methods'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to enter the user password to reconnect to a site. @@ -152,7 +152,7 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { this.showLoading = false; } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); return this.cancel(); } @@ -251,13 +251,13 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { const password = this.credForm.value.password; if (!password) { - CoreDomUtils.showErrorModal('core.login.passwordrequired', true); + CoreAlerts.showError(Translate.instant('core.login.passwordrequired')); return; } if (!CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal('core.networkerrormsg', true); + CoreAlerts.showError(Translate.instant('core.networkerrormsg')); return; } diff --git a/src/core/features/login/pages/site/site.ts b/src/core/features/login/pages/site/site.ts index f6e1c8432..c2f813b26 100644 --- a/src/core/features/login/pages/site/site.ts +++ b/src/core/features/login/pages/site/site.ts @@ -19,7 +19,6 @@ import { CoreNetwork } from '@services/network'; import { CoreConfig } from '@services/config'; import { CoreSites, CoreSiteCheckResponse, CoreLoginSiteInfo, CoreSitesDemoSiteData } from '@services/sites'; import { CoreUtils } from '@singletons/utils'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreLoginHelper, CoreLoginSiteFinderSettings, @@ -51,6 +50,7 @@ import { CoreQRScan } from '@services/qrscan'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreCountries } from '@singletons/countries'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Site (url) chooser when adding a new site. @@ -301,13 +301,13 @@ export class CoreLoginSitePage implements OnInit { CoreKeyboard.close(); if (!url) { - CoreDomUtils.showErrorModal('core.login.siteurlrequired', true); + CoreAlerts.showError(Translate.instant('core.login.siteurlrequired')); return; } if (!CoreNetwork.isOnline()) { - CoreDomUtils.showErrorModal('core.networkerrormsg', true); + CoreAlerts.showError(Translate.instant('core.networkerrormsg')); return; } @@ -418,7 +418,7 @@ export class CoreLoginSitePage implements OnInit { * @param error Error to display. */ protected async showLoginIssue(url: string, error: CoreError): Promise { - let errorMessage = CoreDomUtils.getErrorMessage(error); + let errorMessage = CoreAlerts.getErrorMessage(error); let debug: CoreErrorDebug | undefined; let errorTitle: string | undefined; let site: CoreUnauthenticatedSite | undefined; @@ -470,7 +470,7 @@ export class CoreLoginSitePage implements OnInit { ), ].filter(button => !!button); - const alertElement = await CoreDomUtils.showAlertWithOptions({ + const alertElement = await CoreAlerts.show({ header: errorTitle ?? Translate.instant('core.cannotconnect'), message: errorMessage ?? Translate.instant('core.sitenotfoundhelp'), buttons: buttons as AlertButton[], @@ -575,7 +575,7 @@ export class CoreLoginSitePage implements OnInit { const scheme = CoreUrl.getUrlProtocol(text); if (scheme && scheme != 'http' && scheme != 'https') { - CoreDomUtils.showErrorModal(Translate.instant('core.errorurlschemeinvalidscheme', { $a: text })); + CoreAlerts.showError(Translate.instant('core.errorurlschemeinvalidscheme', { $a: text })); return; } @@ -587,7 +587,7 @@ export class CoreLoginSitePage implements OnInit { this.connect(text); } else { - CoreDomUtils.showErrorModal('core.errorurlschemeinvalidsite', true); + CoreAlerts.showError(Translate.instant('core.errorurlschemeinvalidsite')); } } diff --git a/src/core/features/login/pages/sites/sites.ts b/src/core/features/login/pages/sites/sites.ts index f69cfbd18..98ff6c306 100644 --- a/src/core/features/login/pages/sites/sites.ts +++ b/src/core/features/login/pages/sites/sites.ts @@ -12,15 +12,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CoreDomUtils } from '@services/utils/dom'; import { Component, OnInit } from '@angular/core'; - import { CoreSiteBasicInfo, CoreSites } from '@services/sites'; import { CoreAccountsList, CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreNavigator } from '@services/navigator'; import { CoreFilter } from '@features/filter/services/filter'; import { CoreAnimations } from '@components/animations'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays the list of sites stored in the device. @@ -79,7 +79,7 @@ export class CoreLoginSitesPage implements OnInit { siteName = await CoreFilter.formatText(siteName, { clean: true, singleLine: true, filter: false }, [], site.id); try { - await CoreDomUtils.showDeleteConfirm('core.login.confirmdeletesite', { sitename: siteName }); + await CoreAlerts.confirmDelete(Translate.instant('core.login.confirmdeletesite', { sitename: siteName })); } catch (error) { // User cancelled, stop. return; @@ -95,7 +95,7 @@ export class CoreLoginSitesPage implements OnInit { CoreLoginHelper.goToAddSite(true, true); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.login.errordeletesite', true); + CoreAlerts.showError(error, { default: Translate.instant('core.login.errordeletesite') }); } } @@ -117,7 +117,7 @@ export class CoreLoginSitesPage implements OnInit { return; } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading site.'); + CoreAlerts.showError(error, { default: 'Error loading site.' }); } finally { modal.dismiss(); } diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts index c61fb6c09..663e34b69 100644 --- a/src/core/features/login/services/login-helper.ts +++ b/src/core/features/login/services/login-helper.ts @@ -21,7 +21,6 @@ import { CoreConfig } from '@services/config'; import { CoreEvents, CoreEventSessionExpiredData, CoreEventSiteData } from '@singletons/events'; import { CoreSites, CoreLoginSiteInfo, CoreSiteBasicInfo } from '@services/sites'; import { CoreWS, CoreWSExternalWarning } from '@services/ws'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreText } from '@singletons/text'; import { CoreObject } from '@singletons/object'; import { CoreConstants } from '@/core/constants'; @@ -64,6 +63,8 @@ import { CoreErrorHelper } from '@services/error-helper'; import { CoreSSO } from '@singletons/sso'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { CorePrompts } from '@services/overlays/prompts'; /** * Helper provider that provides some common features regarding authentication. @@ -644,7 +645,7 @@ export class CoreLoginHelperProvider { return true; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error opening browser'); + CoreAlerts.showError(error, { default: 'Error opening browser' }); } finally { modal.dismiss(); } @@ -685,7 +686,7 @@ export class CoreLoginHelperProvider { CoreApp.closeApp(); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error opening browser'); + CoreAlerts.showError(error, { default: 'Error opening browser' }); } finally { modal.dismiss(); } @@ -698,7 +699,11 @@ export class CoreLoginHelperProvider { * @param error Error message. */ async openChangePassword(siteUrl: string, error: string): Promise { - const alert = await CoreDomUtils.showAlert(Translate.instant('core.notice'), error, undefined, 3000); + const alert = await CoreAlerts.show({ + header: Translate.instant('core.notice'), + message: error, + autoCloseTime: 3000, + }); await alert.onDidDismiss(); @@ -897,7 +902,7 @@ export class CoreLoginHelperProvider { // Error checking site. if (currentSite.isLoggedOut()) { // Site is logged out, show error and logout the user. - CoreDomUtils.showErrorModalDefault(error, 'core.networkerrormsg', true); + CoreAlerts.showError(error, { default: Translate.instant('core.networkerrormsg') }); CoreSites.logout(); } } finally { @@ -960,7 +965,7 @@ export class CoreLoginHelperProvider { async showAppUnsupportedModal(siteUrl: string, site?: CoreUnauthenticatedSite, debug?: CoreErrorDebug): Promise { const siteName = await site?.getSiteName() ?? siteUrl; - await CoreDomUtils.showAlertWithOptions({ + await CoreAlerts.show({ header: Translate.instant('core.login.unsupportedsite'), message: Translate.instant('core.login.unsupportedsitemessage', { site: siteName }), buttons: [ @@ -994,7 +999,7 @@ export class CoreLoginHelperProvider { protected showInvalidLoginModal(error: CoreError): void { const errorDetails = error instanceof CoreSiteError ? error.debug?.details : null; - CoreDomUtils.showErrorModal(errorDetails ?? error.message); + CoreAlerts.showError(errorDetails ?? error.message); } /** @@ -1005,7 +1010,7 @@ export class CoreLoginHelperProvider { protected showWorkplaceNoticeModal(message: string): void { const link = CoreApp.getAppStoreUrl({ android: 'com.moodle.workplace', ios: 'id1470929705' }); - CoreDomUtils.showDownloadAppNoticeModal(message, link); + CoreAlerts.showDownloadAppNotice(message, link); } /** @@ -1020,7 +1025,7 @@ export class CoreLoginHelperProvider { const link = CoreApp.getAppStoreUrl(storesConfig); - CoreDomUtils.showDownloadAppNoticeModal(message, link); + CoreAlerts.showDownloadAppNotice(message, link); } /** @@ -1032,7 +1037,7 @@ export class CoreLoginHelperProvider { * @param password User password. If not set the button to resend email will not be shown. */ protected async showNotConfirmedModal(siteUrl: string, email?: string, username?: string, password?: string): Promise { - const title = Translate.instant('core.login.mustconfirm'); + const header = Translate.instant('core.login.mustconfirm'); let message: string; let canResend = false; if (email) { @@ -1048,17 +1053,18 @@ export class CoreLoginHelperProvider { if (!canResend) { // Just display an informative alert. - await CoreDomUtils.showAlert(title, message); + await CoreAlerts.show({ header, message }); return; } - const okText = Translate.instant('core.login.resendemail'); - const cancelText = Translate.instant('core.close'); - try { // Ask the user if he wants to resend the email. - await CoreDomUtils.showConfirm(message, title, okText, cancelText); + await CoreAlerts.confirm(message, { + header, + okText: Translate.instant('core.login.resendemail'), + cancelText: Translate.instant('core.close'), + }); // Call the WS to resend the confirmation email. const modal = await CoreLoadings.show('core.sending', true); @@ -1081,12 +1087,12 @@ export class CoreLoginHelperProvider { } const message = Translate.instant('core.login.emailconfirmsentsuccess'); - CoreDomUtils.showAlert(Translate.instant('core.success'), message); + CoreAlerts.show({ header: Translate.instant('core.success'), message }); } finally { modal.dismiss(); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } } @@ -1154,7 +1160,7 @@ export class CoreLoginHelperProvider { this.showInvalidLoginModal(error); break; default: - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); break; } } @@ -1291,13 +1297,11 @@ export class CoreLoginHelperProvider { const header = Translate.instant('core.login.faqwhereisqrcode'); try { - const dontShowAgain = await CoreDomUtils.showPrompt( - message, + const dontShowAgain = await CorePrompts.show(message, 'checkbox', { header, - Translate.instant('core.dontshowagain'), - 'checkbox', - { okText: Translate.instant('core.next'), cancelText: Translate.instant('core.cancel') }, - ); + placeholderOrLabel: Translate.instant('core.dontshowagain'), + buttons: { okText: Translate.instant('core.next'), cancelText: Translate.instant('core.cancel') }, + }); if (dontShowAgain) { CoreConfig.set(FAQ_QRCODE_INFO_DONE, 1); @@ -1323,9 +1327,9 @@ export class CoreLoginHelperProvider { const scheme = CoreUrl.getUrlProtocol(text); if (scheme && scheme != 'http' && scheme != 'https') { - CoreDomUtils.showErrorModal(Translate.instant('core.errorurlschemeinvalidscheme', { $a: text })); + CoreAlerts.showError(Translate.instant('core.errorurlschemeinvalidscheme', { $a: text })); } else { - CoreDomUtils.showErrorModal('core.login.errorqrnoscheme', true); + CoreAlerts.showError(Translate.instant('core.login.errorqrnoscheme')); } } diff --git a/src/core/features/mainmenu/components/user-menu/user-menu.ts b/src/core/features/mainmenu/components/user-menu/user-menu.ts index 0b9b5a5ea..6e40a288e 100644 --- a/src/core/features/mainmenu/components/user-menu/user-menu.ts +++ b/src/core/features/mainmenu/components/user-menu/user-menu.ts @@ -29,11 +29,11 @@ import { import { CoreModals } from '@services/overlays/modals'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; -import { ModalController } from '@singletons'; +import { ModalController, Translate } from '@singletons'; import { Subscription } from 'rxjs'; import { CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreSiteLogoComponent } from '@/core/components/site-logo/site-logo'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component to display a user menu. @@ -192,7 +192,7 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy { ''; try { - await CoreDomUtils.showDeleteConfirm('core.login.confirmdeletesite', { sitename: siteName }); + await CoreAlerts.confirmDelete(Translate.instant('core.login.confirmdeletesite', { sitename: siteName })); } catch (error) { // User cancelled, stop. return; diff --git a/src/core/features/policy/pages/acceptances/acceptances.ts b/src/core/features/policy/pages/acceptances/acceptances.ts index 4f145ff83..fce4e55b1 100644 --- a/src/core/features/policy/pages/acceptances/acceptances.ts +++ b/src/core/features/policy/pages/acceptances/acceptances.ts @@ -15,7 +15,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; @@ -28,6 +27,7 @@ import { CoreNavigator } from '@services/navigator'; import { CoreDataPrivacy } from '@features/dataprivacy/services/dataprivacy'; import { CoreModals } from '@services/overlays/modals'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to view user acceptances. @@ -132,7 +132,7 @@ export class CorePolicyAcceptancesPage implements OnInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting policies.'); + CoreAlerts.showError(error, { default: 'Error getting policies.' }); } } @@ -220,7 +220,7 @@ export class CorePolicyAcceptancesPage implements OnInit, OnDestroy { await this.updatePolicyAcceptance(policy, accept); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error changing policy status.'); + CoreAlerts.showError(error, { default: 'Error changing policy status.' }); } finally { modal.dismiss(); } diff --git a/src/core/features/policy/pages/site-policy/site-policy.ts b/src/core/features/policy/pages/site-policy/site-policy.ts index 026b3314c..e4a0afd43 100644 --- a/src/core/features/policy/pages/site-policy/site-policy.ts +++ b/src/core/features/policy/pages/site-policy/site-policy.ts @@ -15,7 +15,6 @@ import { ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreSite } from '@classes/sites/site'; import { CoreNavigator } from '@services/navigator'; @@ -33,6 +32,7 @@ import { CoreWait } from '@singletons/wait'; import { CoreModals } from '@services/overlays/modals'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to accept a site policy. @@ -132,7 +132,7 @@ export class CorePolicySitePolicyPage implements OnInit, OnDestroy { try { this.sitePoliciesURL = await CorePolicy.getSitePoliciesURL(this.siteId); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting site policy.'); + CoreAlerts.showError(error, { default: 'Error getting site policy.' }); this.cancel(); return; @@ -199,7 +199,7 @@ export class CorePolicySitePolicyPage implements OnInit, OnDestroy { this.setCurrentPolicy(policy); this.policyLoaded = true; } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error getting site policy.'); + CoreAlerts.showError(error, { default: 'Error getting site policy.' }); this.cancel(); } } @@ -368,7 +368,7 @@ export class CorePolicySitePolicyPage implements OnInit, OnDestroy { if (!errorFound) { // Input not found, show an error modal. - CoreDomUtils.showErrorModal('core.policy.mustagreetocontinue', true); + CoreAlerts.showError(Translate.instant('core.policy.mustagreetocontinue')); } return; @@ -387,7 +387,7 @@ export class CorePolicySitePolicyPage implements OnInit, OnDestroy { await this.finishAcceptingPolicies(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error accepting site policies.'); + CoreAlerts.showError(error, { default: 'Error accepting site policies.' }); } finally { modal.dismiss(); } @@ -412,7 +412,7 @@ export class CorePolicySitePolicyPage implements OnInit, OnDestroy { if (policy.optional) { if (control.value === null || control.value === undefined) { // Not answered, this code shouldn't be reached. Display error. - CoreDomUtils.showErrorModal('core.policy.mustagreetocontinue', true); + CoreAlerts.showError(Translate.instant('core.policy.mustagreetocontinue')); return; } @@ -421,7 +421,7 @@ export class CorePolicySitePolicyPage implements OnInit, OnDestroy { } else { if (!control.value) { // Not answered, this code shouldn't be reached. Display error. - CoreDomUtils.showErrorModal('core.policy.mustagreetocontinue', true); + CoreAlerts.showError(Translate.instant('core.policy.mustagreetocontinue')); return; } diff --git a/src/core/features/question/services/question-helper.ts b/src/core/features/question/services/question-helper.ts index 0ed8aeffa..1bc6e0cd9 100644 --- a/src/core/features/question/services/question-helper.ts +++ b/src/core/features/question/services/question-helper.ts @@ -34,6 +34,7 @@ import { CoreViewer } from '@features/viewer/services/viewer'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { AddonModQuizNavigationQuestion } from '@addons/mod/quiz/components/navigation-modal/navigation-modal'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Service with some common functions to handle questions. @@ -794,7 +795,7 @@ export class CoreQuestionHelperProvider { const now = Date.now(); if (now - this.lastErrorShown > 500) { this.lastErrorShown = now; - CoreDomUtils.showErrorModalDefault(error || '', 'addon.mod_quiz.errorparsequestions', true); + CoreAlerts.showError(error, { default: Translate.instant('addon.mod_quiz.errorparsequestions') }); } onAbort?.emit(); diff --git a/src/core/features/rating/components/rate/rate.ts b/src/core/features/rating/components/rate/rate.ts index 71f836c0a..19a4a9aa6 100644 --- a/src/core/features/rating/components/rate/rate.ts +++ b/src/core/features/rating/components/rate/rate.ts @@ -23,11 +23,11 @@ import { } from '@features/rating/services/rating'; import { CoreRatingOffline } from '@features/rating/services/rating-offline'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { Translate } from '@singletons'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Component that displays the user rating select. @@ -158,7 +158,7 @@ export class CoreRatingRateComponent implements OnChanges, OnDestroy { this.onUpdate.emit(); } } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal.dismiss(); } diff --git a/src/core/features/rating/components/ratings/ratings.ts b/src/core/features/rating/components/ratings/ratings.ts index 005476c11..f9c8d6e1e 100644 --- a/src/core/features/rating/components/ratings/ratings.ts +++ b/src/core/features/rating/components/ratings/ratings.ts @@ -16,7 +16,7 @@ import { ContextLevel } from '@/core/constants'; import { CoreSharedModule } from '@/core/shared.module'; import { Component, Input, OnInit } from '@angular/core'; import { CoreRating, CoreRatingItemRating } from '@features/rating/services/rating'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreAlerts } from '@services/overlays/alerts'; import { ModalController } from '@singletons'; /** @@ -59,7 +59,7 @@ export class CoreRatingRatingsComponent implements OnInit { this.courseId, ); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { this.loaded = true; } diff --git a/src/core/features/reportbuilder/components/report-detail/report-detail.ts b/src/core/features/reportbuilder/components/report-detail/report-detail.ts index 8fe12e1e0..c97147f66 100644 --- a/src/core/features/reportbuilder/components/report-detail/report-detail.ts +++ b/src/core/features/reportbuilder/components/report-detail/report-detail.ts @@ -25,7 +25,6 @@ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreNavigator } from '@services/navigator'; import { CoreScreen } from '@services/screen'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreErrorObject } from '@services/error-helper'; import { CoreOpener } from '@singletons/opener'; import { Translate } from '@singletons'; @@ -33,6 +32,7 @@ import { CoreTime } from '@singletons/time'; import { BehaviorSubject, Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; @Component({ selector: 'core-report-builder-report-detail', @@ -105,7 +105,7 @@ export class CoreReportBuilderReportDetailComponent implements OnInit { async getReport(): Promise { try { if (!this.reportId) { - CoreDomUtils.showErrorModal(new CoreError('No report found')); + CoreAlerts.showError(new CoreError('No report found')); CoreNavigator.back(); return; @@ -116,7 +116,7 @@ export class CoreReportBuilderReportDetailComponent implements OnInit { const report = await CoreReportBuilder.loadReport(parseInt(this.reportId), page,this.perPage ?? REPORT_ROWS_LIMIT); if (!report) { - CoreDomUtils.showErrorModal(new CoreError('No report found')); + CoreAlerts.showError(new CoreError('No report found')); CoreNavigator.back(); return; @@ -157,7 +157,7 @@ export class CoreReportBuilderReportDetailComponent implements OnInit { ], }; - await CoreDomUtils.showErrorModal(errorConfig); + await CoreAlerts.showError(errorConfig); } } @@ -228,7 +228,7 @@ export class CoreReportBuilderReportDetailComponent implements OnInit { canLoadMoreRows: newReport.data.totalrowcount > report.data.rows.length + newReport.data.rows.length, }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading more reports'); + CoreAlerts.showError(error, { default: 'Error loading more reports' }); this.updateState({ canLoadMoreRows: false, errorLoadingRows: true }); } diff --git a/src/core/features/reportbuilder/pages/list/list.ts b/src/core/features/reportbuilder/pages/list/list.ts index d0d91aa74..54c68939f 100644 --- a/src/core/features/reportbuilder/pages/list/list.ts +++ b/src/core/features/reportbuilder/pages/list/list.ts @@ -19,11 +19,11 @@ import { CoreReportBuilderReportsSource } from '@features/reportbuilder/classes/ import { CoreReportBuilder, CoreReportBuilderReport, REPORTS_LIST_LIMIT } from '@features/reportbuilder/services/reportbuilder'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { Translate } from '@singletons'; import { CoreTime } from '@singletons/time'; import { BehaviorSubject } from 'rxjs'; +import { CoreAlerts } from '@services/overlays/alerts'; @Component({ selector: 'core-report-builder-list', @@ -50,7 +50,7 @@ export class CoreReportBuilderListPage implements AfterViewInit, OnDestroy { const source = CoreRoutedItemsManagerSourcesTracker.getOrCreateSource(CoreReportBuilderReportsSource, []); this.reports = new CoreListItemsManager(source, CoreReportBuilderListPage); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); } } @@ -63,7 +63,7 @@ export class CoreReportBuilderListPage implements AfterViewInit, OnDestroy { await this.fetchReports(true); this.updateState({ loaded: true }); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading reports'); + CoreAlerts.showError(error, { default: 'Error loading reports' }); this.reports.reset(); } @@ -100,7 +100,7 @@ export class CoreReportBuilderListPage implements AfterViewInit, OnDestroy { try { await this.fetchReports(false); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading more reports'); + CoreAlerts.showError(error, { default: 'Error loading more reports' }); this.updateState({ loadMoreError: true }); } diff --git a/src/core/features/settings/pages/dev/dev.ts b/src/core/features/settings/pages/dev/dev.ts index 138c1083b..bf8a017e2 100644 --- a/src/core/features/settings/pages/dev/dev.ts +++ b/src/core/features/settings/pages/dev/dev.ts @@ -32,6 +32,7 @@ import { CoreSites } from '@services/sites'; import { CoreDomUtils } from '@services/utils/dom'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreText } from '@singletons/text'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the developer options. @@ -261,7 +262,7 @@ export class CoreSettingsDevPage implements OnInit { this.previousEnableStagingSites = enabled; } catch (error) { this.enableStagingSites = !enabled; - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } } diff --git a/src/core/features/settings/pages/general/general.ts b/src/core/features/settings/pages/general/general.ts index 471d6821e..886dc204c 100644 --- a/src/core/features/settings/pages/general/general.ts +++ b/src/core/features/settings/pages/general/general.ts @@ -17,7 +17,6 @@ import { CoreConstants } from '@/core/constants'; import { CoreConfig } from '@services/config'; import { CoreEvents } from '@singletons/events'; import { CoreLang } from '@services/lang'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSettingsHelper, CoreColorScheme, CoreZoomLevel } from '../../services/settings-helper'; import { CoreIframeUtils } from '@services/utils/iframe'; import { Translate } from '@singletons'; @@ -28,6 +27,7 @@ import { CoreNavigator } from '@services/navigator'; import { CorePlatform } from '@services/platform'; import { CoreAnalytics } from '@services/analytics'; import { CoreNative } from '@features/native/services/native'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the general settings. @@ -153,7 +153,7 @@ export class CoreSettingsGeneralPage { }, ]; - const alert = await CoreDomUtils.showAlertWithOptions( + const alert = await CoreAlerts.show( { message: Translate.instant('core.settings.changelanguagealert'), buttons, @@ -241,7 +241,7 @@ export class CoreSettingsGeneralPage { ev.preventDefault(); CoreConfig.set(CoreConstants.SETTINGS_DEBUG_DISPLAY, this.debugDisplay ? 1 : 0); - CoreDomUtils.setDebugDisplay(this.debugDisplay); + CoreAlerts.setDebugDisplay(this.debugDisplay); } /** diff --git a/src/core/features/settings/pages/site/site.ts b/src/core/features/settings/pages/site/site.ts index 8037d28ba..c61e8b8ba 100644 --- a/src/core/features/settings/pages/site/site.ts +++ b/src/core/features/settings/pages/site/site.ts @@ -22,14 +22,14 @@ import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreListItemsManager } from '@classes/items-management/list-items-manager'; import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/routed-items-manager-sources-tracker'; import { CoreSettingsHelper } from '@features/settings/services/settings-helper'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreNetwork } from '@services/network'; import { Subscription } from 'rxjs'; -import { NgZone } from '@singletons'; +import { NgZone, Translate } from '@singletons'; import { CoreConstants } from '@/core/constants'; import { CoreConfig } from '@services/config'; import { CoreSettingsHandlersSource } from '@features/settings/classes/settings-handlers-source'; import { CoreToasts } from '@services/overlays/toasts'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of site settings pages. @@ -126,7 +126,7 @@ export class CoreSitePreferencesPage implements AfterViewInit, OnDestroy { if (this.isDestroyed) { return; } - CoreDomUtils.showErrorModalDefault(error, 'core.settings.sitesyncfailed', true); + CoreAlerts.showError(error, { default: Translate.instant('core.settings.sitesyncfailed') }); } } diff --git a/src/core/features/settings/pages/synchronization/synchronization.ts b/src/core/features/settings/pages/synchronization/synchronization.ts index 90ec7b52d..cb22f2995 100644 --- a/src/core/features/settings/pages/synchronization/synchronization.ts +++ b/src/core/features/settings/pages/synchronization/synchronization.ts @@ -17,7 +17,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CoreConstants } from '@/core/constants'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreConfig } from '@services/config'; import { CoreSettingsHelper } from '@features/settings/services/settings-helper'; import { NgZone, Translate } from '@singletons'; @@ -26,6 +25,7 @@ import { CoreNetwork } from '@services/network'; import { Subscription } from 'rxjs'; import { CoreNavigator } from '@services/navigator'; import { CoreToasts } from '@services/overlays/toasts'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the synchronization settings. @@ -142,7 +142,7 @@ export class CoreSettingsSynchronizationPage implements OnInit, OnDestroy { return; } - CoreDomUtils.showErrorModalDefault(error, 'core.settings.sitesyncfailed', true); + CoreAlerts.showError(error, { default: Translate.instant('core.settings.sitesyncfailed') }); } } @@ -170,10 +170,10 @@ export class CoreSettingsSynchronizationPage implements OnInit, OnDestroy { * Show information about sync actions. */ showInfo(): void { - CoreDomUtils.showAlert( - Translate.instant('core.help'), - Translate.instant('core.settings.synchronizenowhelp'), - ); + CoreAlerts.show({ + header: Translate.instant('core.help'), + message: Translate.instant('core.settings.synchronizenowhelp'), + }); } /** diff --git a/src/core/features/settings/services/settings-helper.ts b/src/core/features/settings/services/settings-helper.ts index 558c2dead..2ff118c6d 100644 --- a/src/core/features/settings/services/settings-helper.ts +++ b/src/core/features/settings/services/settings-helper.ts @@ -24,7 +24,6 @@ import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreConstants } from '@/core/constants'; import { CoreConfig } from '@services/config'; import { CoreFilter } from '@features/filter/services/filter'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreCourse } from '@features/course/services/course'; import { makeSingleton, Translate } from '@singletons'; import { CoreError } from '@classes/errors/error'; @@ -32,6 +31,7 @@ import { Observable, Subject } from 'rxjs'; import { CoreErrorHelper } from '@services/error-helper'; import { CoreNavigator } from '@services/navigator'; import { CoreHTMLClasses } from '@singletons/html-classes'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Object with space usage and cache entries that can be erased. @@ -126,11 +126,9 @@ export class CoreSettingsHelperProvider { const title = Translate.instant('addon.storagemanager.confirmdeleteallsitedata'); - await CoreDomUtils.showDeleteConfirm( - 'addon.storagemanager.deleteallsitedatainfo', - { name: siteName }, - { header: title }, - ); + await CoreAlerts.confirmDelete(Translate.instant('addon.storagemanager.deleteallsitedatainfo', { name: siteName }), { + header: title, + }); const site = await CoreSites.getSite(siteId); @@ -153,7 +151,7 @@ export class CoreSettingsHelperProvider { siteInfo.spaceUsage = 0; } else { // Error, recalculate the site usage. - CoreDomUtils.showErrorModal('addon.storagemanager.errordeletedownloadeddata', true); + CoreAlerts.showError(Translate.instant('addon.storagemanager.errordeletedownloadeddata')); siteInfo.spaceUsage = await site.getSpaceUsage(); } @@ -473,7 +471,7 @@ export class CoreSettingsHelperProvider { const reloadApp = !CoreSites.isLoggedIn(); if (reloadApp) { - await CoreDomUtils.showConfirm('Are you sure that you want to enable/disable staging sites?'); + await CoreAlerts.confirm('Are you sure that you want to enable/disable staging sites?'); } await CoreConfig.set('stagingSites', enabled ? 1 : 0); diff --git a/src/core/features/sharedfiles/pages/choose-site/choose-site.ts b/src/core/features/sharedfiles/pages/choose-site/choose-site.ts index 02ff14e50..fd1051760 100644 --- a/src/core/features/sharedfiles/pages/choose-site/choose-site.ts +++ b/src/core/features/sharedfiles/pages/choose-site/choose-site.ts @@ -19,8 +19,8 @@ import { FileEntry } from '@awesome-cordova-plugins/file/ngx'; import { CoreFile } from '@services/file'; import { CoreNavigator } from '@services/navigator'; import { CoreSiteBasicInfo } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreFileUtils } from '@singletons/file-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to display the list of sites to choose one to store a shared file. @@ -51,7 +51,7 @@ export class CoreSharedFilesChooseSitePage implements OnInit { this.filePath = CoreNavigator.getRequiredRouteParam('filePath'); this.isInbox = !!CoreNavigator.getRouteBooleanParam('isInbox'); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error reading file.'); + CoreAlerts.showError(error, { default: 'Error reading file.' }); CoreNavigator.back(); return; @@ -68,7 +68,7 @@ export class CoreSharedFilesChooseSitePage implements OnInit { this.loadSites(), ]); } catch { - CoreDomUtils.showErrorModal('Error reading file.'); + CoreAlerts.showError('Error reading file.'); CoreNavigator.back(); } finally { this.loaded = true; diff --git a/src/core/features/sharedfiles/services/sharedfiles-helper.ts b/src/core/features/sharedfiles/services/sharedfiles-helper.ts index ded3dad88..44e0ee0d4 100644 --- a/src/core/features/sharedfiles/services/sharedfiles-helper.ts +++ b/src/core/features/sharedfiles/services/sharedfiles-helper.ts @@ -21,7 +21,6 @@ import { CoreFileUploaderHandlerResult } from '@features/fileuploader/services/f import { CoreFile } from '@services/file'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { AlertController, ApplicationInit, makeSingleton, Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { CoreLogger } from '@singletons/logger'; @@ -31,6 +30,7 @@ import { CoreSharedFilesChooseSitePage } from '../pages/choose-site/choose-site' import { CoreError } from '@classes/errors/error'; import { CorePlatform } from '@services/platform'; import { CoreModals } from '@services/overlays/modals'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Helper service to share files with the app. @@ -224,7 +224,7 @@ export class CoreSharedFilesHelperProvider { if (!siteIds.length) { // No sites stored, show error and delete the file. - CoreDomUtils.showErrorModal('core.sharedfiles.errorreceivefilenosites', true); + CoreAlerts.showError(Translate.instant('core.sharedfiles.errorreceivefilenosites')); return this.removeSharedFile(fileEntry, !path); } else if (siteIds.length == 1) { @@ -263,10 +263,13 @@ export class CoreSharedFilesHelperProvider { try { await CoreSharedFiles.storeFileInSite(fileEntry, newName, siteId); } catch (error) { - CoreDomUtils.showErrorModal(error || 'Error moving file.'); + CoreAlerts.showError(error || 'Error moving file.'); } finally { this.removeSharedFile(fileEntry, isInbox); - CoreDomUtils.showAlertTranslated('core.success', 'core.sharedfiles.successstorefile'); + CoreAlerts.show({ + header: Translate.instant('core.success'), + message: Translate.instant('core.sharedfiles.successstorefile'), + }); } } diff --git a/src/core/features/sitehome/pages/index/index.ts b/src/core/features/sitehome/pages/index/index.ts index 3de7c9f64..73b1cc46e 100644 --- a/src/core/features/sitehome/pages/index/index.ts +++ b/src/core/features/sitehome/pages/index/index.ts @@ -17,7 +17,6 @@ import { ActivatedRoute } from '@angular/router'; import { CoreSite, CoreSiteConfig } from '@classes/sites/site'; import { CoreCourse, CoreCourseWSSection, sectionContentIsModule } from '@features/course/services/course'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSites } from '@services/sites'; import { CoreSiteHome } from '@features/sitehome/services/sitehome'; import { CoreCourses } from '@features//courses/services/courses'; @@ -32,6 +31,8 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { ContextLevel } from '@/core/constants'; import { CoreModals } from '@services/overlays/modals'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Page that displays site home index. @@ -153,7 +154,7 @@ export class CoreSiteHomeIndexPage implements OnInit, OnDestroy { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.course.couldnotloadsectioncontent', true); + CoreAlerts.showError(error, { default: Translate.instant('core.course.couldnotloadsectioncontent') }); } this.hasBlocks = await CoreBlockHelper.hasCourseBlocks(this.siteHomeId); diff --git a/src/core/features/siteplugins/classes/call-ws-click-directive.ts b/src/core/features/siteplugins/classes/call-ws-click-directive.ts index 0dca4e0b1..b80f28611 100644 --- a/src/core/features/siteplugins/classes/call-ws-click-directive.ts +++ b/src/core/features/siteplugins/classes/call-ws-click-directive.ts @@ -14,13 +14,13 @@ import { Input, OnInit, ElementRef, Directive } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreErrorHelper } from '@services/error-helper'; import { Translate } from '@singletons'; import { CoreSitePluginsPluginContentComponent } from '../components/plugin-content/plugin-content'; import { CoreSitePluginsCallWSBaseDirective } from './call-ws-directive'; import { toBoolean } from '@/core/transforms/boolean'; import { CoreLoadings } from '@services/overlays/loadings'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Base class for directives to call a WS when the element is clicked. @@ -53,7 +53,7 @@ export class CoreSitePluginsCallWSOnClickBaseDirective extends CoreSitePluginsCa if (this.confirmMessage !== undefined) { // Ask for confirm. try { - await CoreDomUtils.showConfirm(this.confirmMessage || Translate.instant('core.areyousure')); + await CoreAlerts.confirm(this.confirmMessage || Translate.instant('core.areyousure')); } catch { // User cancelled, stop. return; @@ -74,12 +74,11 @@ export class CoreSitePluginsCallWSOnClickBaseDirective extends CoreSitePluginsCa await super.callWS(); } catch (error) { if (this.showError) { - CoreDomUtils.showErrorModalDefault( - error, - Translate.instant('core.serverconnection', { + CoreAlerts.showError(error, { + default: Translate.instant('core.serverconnection', { details: CoreErrorHelper.getErrorMessageFromError(error) ?? 'Unknown error', }), - ); + }); } } finally { modal.dismiss(); diff --git a/src/core/features/siteplugins/components/plugin-content/plugin-content.ts b/src/core/features/siteplugins/components/plugin-content/plugin-content.ts index 3081f82e8..b13d63dfa 100644 --- a/src/core/features/siteplugins/components/plugin-content/plugin-content.ts +++ b/src/core/features/siteplugins/components/plugin-content/plugin-content.ts @@ -31,12 +31,13 @@ import { CoreSiteWSPreSets } from '@classes/sites/authenticated-site'; import { CoreCompileHtmlComponent } from '@features/compile/components/compile-html/compile-html'; import { CoreSitePlugins, CoreSitePluginsContent } from '@features/siteplugins/services/siteplugins'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreEvents } from '@singletons/events'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CORE_SITE_PLUGINS_UPDATE_COURSE_CONTENT } from '@features/siteplugins/constants'; import { CoreCompileHtmlComponentModule } from '@features/compile/components/compile-html/compile-html.module'; import { CoreSharedModule } from '@/core/shared.module'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { Translate } from '@singletons'; /** * Component to render a site plugin content. @@ -160,7 +161,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit, DoCheck { this.content = '
'; this.onContentLoaded.emit({ refresh: !!refresh, success: false, content: this.content }); - CoreDomUtils.showErrorModalDefault(error, 'core.errorloadingcontent', true); + CoreAlerts.showError(error, { default: Translate.instant('core.errorloadingcontent') }); } finally { this.dataLoaded = true; } diff --git a/src/core/features/tag/pages/index-area/index-area.ts b/src/core/features/tag/pages/index-area/index-area.ts index 567baa48b..e5b5d58cc 100644 --- a/src/core/features/tag/pages/index-area/index-area.ts +++ b/src/core/features/tag/pages/index-area/index-area.ts @@ -13,12 +13,12 @@ // limitations under the License. import { Component, OnInit, Type } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTag } from '@features/tag/services/tag'; import { ActivatedRoute } from '@angular/router'; import { CoreTagAreaDelegate } from '../../services/tag-area-delegate'; import { Translate } from '@singletons'; import { CoreNavigator } from '@services/navigator'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the tag index area. @@ -129,7 +129,7 @@ export class CoreTagIndexAreaPage implements OnInit { this.nextPage = page + 1; } catch (error) { this.loadMoreError = true; // Set to prevent infinite calls with infinite-loading. - CoreDomUtils.showErrorModalDefault(error, 'Error loading tag index'); + CoreAlerts.showError(error, { default: 'Error loading tag index' }); } } diff --git a/src/core/features/tag/pages/index/index.ts b/src/core/features/tag/pages/index/index.ts index bc944e34a..6b9635e77 100644 --- a/src/core/features/tag/pages/index/index.ts +++ b/src/core/features/tag/pages/index/index.ts @@ -13,7 +13,6 @@ // limitations under the License. import { Component, OnInit } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreTag } from '@features/tag/services/tag'; import { CoreTagAreaDelegate } from '@features/tag/services/tag-area-delegate'; import { CoreScreen } from '@services/screen'; @@ -22,6 +21,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; import { CoreUrl } from '@singletons/url'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the tag index. @@ -139,7 +139,7 @@ export class CoreTagIndexPage implements OnInit { this.logView(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading tag index'); + CoreAlerts.showError(error, { default: 'Error loading tag index' }); } } diff --git a/src/core/features/tag/pages/search/search.ts b/src/core/features/tag/pages/search/search.ts index 878ca174b..e0eb924b4 100644 --- a/src/core/features/tag/pages/search/search.ts +++ b/src/core/features/tag/pages/search/search.ts @@ -13,8 +13,6 @@ // limitations under the License. import { Component, OnInit } from '@angular/core'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreUrl } from '@singletons/url'; import { CoreTagCloud, CoreTagCollection, CoreTagCloudTag, CoreTag } from '@features/tag/services/tag'; @@ -25,6 +23,7 @@ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreSites } from '@services/sites'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays most used tags and allows searching. @@ -83,7 +82,7 @@ export class CoreTagSearchPage implements OnInit { this.logView(); } } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading tags.'); + CoreAlerts.showError(error, { default: 'Error loading tags.' }); } } @@ -155,7 +154,7 @@ export class CoreTagSearchPage implements OnInit { CoreKeyboard.close(); return this.fetchTags().catch((error) => { - CoreDomUtils.showErrorModalDefault(error, 'Error loading tags.'); + CoreAlerts.showError(error, { default: 'Error loading tags.' }); }).finally(() => { this.searching = false; }); diff --git a/src/core/features/user/pages/about/about.ts b/src/core/features/user/pages/about/about.ts index 37860bd11..65d048c99 100644 --- a/src/core/features/user/pages/about/about.ts +++ b/src/core/features/user/pages/about/about.ts @@ -15,7 +15,6 @@ import { Component, OnDestroy, OnInit } from '@angular/core'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { @@ -34,6 +33,7 @@ import { Translate } from '@singletons'; import { CoreUrl } from '@singletons/url'; import { CoreLoadings } from '@services/overlays/loadings'; import { CoreTime } from '@singletons/time'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays info about a user. @@ -64,7 +64,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { try { this.site = CoreSites.getRequiredCurrentSite(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -122,7 +122,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { await this.checkUserImageUpdated(); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'core.user.errorloaduser', true); + CoreAlerts.showError(error, { default: Translate.instant('core.user.errorloaduser') }); } } @@ -190,7 +190,7 @@ export class CoreUserAboutPage implements OnInit, OnDestroy { this.refreshUser(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } finally { modal?.dismiss(); } diff --git a/src/core/features/user/pages/participants/participants.page.ts b/src/core/features/user/pages/participants/participants.page.ts index 0ec5c1b3a..5233d32ac 100644 --- a/src/core/features/user/pages/participants/participants.page.ts +++ b/src/core/features/user/pages/participants/participants.page.ts @@ -13,8 +13,6 @@ // limitations under the License. import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core'; - -import { CoreDomUtils } from '@services/utils/dom'; import { CoreNavigator } from '@services/navigator'; import { CoreListItemsManager } from '@classes/items-management/list-items-manager'; import { CoreSplitViewComponent } from '@components/split-view/split-view'; @@ -25,6 +23,7 @@ import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/ import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; import { CoreKeyboard } from '@singletons/keyboard'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page that displays the list of course participants. @@ -52,8 +51,7 @@ export class CoreUserParticipantsPage implements OnInit, AfterViewInit, OnDestro CoreUserParticipantsPage, ); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -151,7 +149,7 @@ export class CoreUserParticipantsPage implements OnInit, AfterViewInit, OnDestro try { await this.fetchParticipants(false); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading more participants'); + CoreAlerts.showError(error, { default: 'Error loading more participants' }); this.fetchMoreParticipantsFailed = true; } @@ -166,7 +164,7 @@ export class CoreUserParticipantsPage implements OnInit, AfterViewInit, OnDestro try { await this.fetchParticipants(true); } catch (error) { - CoreDomUtils.showErrorModalDefault(error, 'Error loading participants'); + CoreAlerts.showError(error, { default: 'Error loading participants' }); this.participants.reset(); } diff --git a/src/core/features/user/pages/profile/profile.ts b/src/core/features/user/pages/profile/profile.ts index 5d623b98d..dcef301a9 100644 --- a/src/core/features/user/pages/profile/profile.ts +++ b/src/core/features/user/pages/profile/profile.ts @@ -18,7 +18,6 @@ import { Subscription } from 'rxjs'; import { CoreSite } from '@classes/sites/site'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreEventObserver, CoreEvents } from '@singletons/events'; import { CoreUser, CoreUserProfile, USER_PROFILE_REFRESHED } from '@features/user/services/user'; import { CoreUserHelper } from '@features/user/services/user-helper'; @@ -37,6 +36,7 @@ import { CoreRoutedItemsManagerSourcesTracker } from '@classes/items-management/ import { CoreTime } from '@singletons/time'; import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { Translate } from '@singletons'; +import { CoreAlerts } from '@services/overlays/alerts'; @Component({ selector: 'page-core-user-profile', @@ -106,7 +106,7 @@ export class CoreUserProfilePage implements OnInit, OnDestroy { this.courseId = CoreNavigator.getRouteNumberParam('courseId'); this.userId = CoreNavigator.getRequiredRouteNumberParam('userId'); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); CoreNavigator.back(); return; @@ -175,7 +175,7 @@ export class CoreUserProfilePage implements OnInit, OnDestroy { this.logView(user); } catch (error) { // Error is null for deleted users, do not show the modal. - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } } diff --git a/src/core/features/user/services/support.ts b/src/core/features/user/services/support.ts index f76c4a2de..bcf2d0ec7 100644 --- a/src/core/features/user/services/support.ts +++ b/src/core/features/user/services/support.ts @@ -22,10 +22,10 @@ import { makeSingleton, Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { CoreSubscriptions } from '@singletons/subscriptions'; import { AlertButton } from '@ionic/angular'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreLang } from '@services/lang'; import { CoreUserNullSupportConfig } from '@features/user/classes/support/null-support-config'; import { CoreOpener } from '@singletons/opener'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Handle site support. @@ -79,7 +79,7 @@ export class CoreUserSupportService { buttons.push(Translate.instant('core.close')); - CoreDomUtils.showAlertWithOptions({ + CoreAlerts.show({ header: Translate.instant('core.help'), message, buttons, @@ -139,7 +139,7 @@ export class CoreUserSupportService { } browser.close(); - CoreDomUtils.showAlert(undefined, appSuccessMessage); + CoreAlerts.show({ message: appSuccessMessage }); }); CoreEvents.once(CoreEvents.IAB_EXIT, () => subscription.unsubscribe()); diff --git a/src/core/features/viewer/components/qr-scanner/qr-scanner.ts b/src/core/features/viewer/components/qr-scanner/qr-scanner.ts index 61a0cfc2e..6180449a3 100644 --- a/src/core/features/viewer/components/qr-scanner/qr-scanner.ts +++ b/src/core/features/viewer/components/qr-scanner/qr-scanner.ts @@ -14,8 +14,9 @@ import { CoreSharedModule } from '@/core/shared.module'; import { Component, Input, OnDestroy, OnInit } from '@angular/core'; +import { CoreErrorHelper } from '@services/error-helper'; +import { CoreAlerts } from '@services/overlays/alerts'; import { CoreQRScan } from '@services/qrscan'; -import { CoreDomUtils } from '@services/utils/dom'; import { ModalController, Translate } from '@singletons'; /** @@ -48,9 +49,9 @@ export class CoreViewerQRScannerComponent implements OnInit, OnDestroy { this.closeModal(text); } catch (error) { - if (!CoreDomUtils.isCanceledError(error)) { + if (!CoreErrorHelper.isCanceledError(error)) { // Show error and stop scanning. - CoreDomUtils.showErrorModalDefault(error, 'An error occurred.'); + CoreAlerts.showError(error, { default: 'An error occurred.' }); CoreQRScan.stopScanQR(); } diff --git a/src/core/features/viewer/pages/iframe/iframe.ts b/src/core/features/viewer/pages/iframe/iframe.ts index 85487da0f..c3cfeb8ae 100644 --- a/src/core/features/viewer/pages/iframe/iframe.ts +++ b/src/core/features/viewer/pages/iframe/iframe.ts @@ -14,7 +14,7 @@ import { Component, OnInit } from '@angular/core'; import { CoreNavigator } from '@services/navigator'; -import { CoreDomUtils } from '@services/utils/dom'; +import { CoreAlerts } from '@services/overlays/alerts'; /** * Page to display a URL in an iframe. @@ -37,8 +37,7 @@ export class CoreViewerIframePage implements OnInit { this.title = CoreNavigator.getRequiredRouteParam('title'); this.url = CoreNavigator.getRequiredRouteParam('url'); } catch (error) { - CoreDomUtils.showErrorModal(error); - + CoreAlerts.showError(error); CoreNavigator.back(); return; diff --git a/src/core/initializers/prepare-inapp-browser.ts b/src/core/initializers/prepare-inapp-browser.ts index 720daaf46..42956cfab 100644 --- a/src/core/initializers/prepare-inapp-browser.ts +++ b/src/core/initializers/prepare-inapp-browser.ts @@ -18,11 +18,11 @@ import { CoreUserAuthenticatedSupportConfig } from '@features/user/classes/suppo import { CoreUserNullSupportConfig } from '@features/user/classes/support/null-support-config'; import { CoreSites } from '@services/sites'; import { CoreCustomURLSchemes } from '@services/urlschemes'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CoreOpener } from '@singletons/opener'; import { Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; +import { CoreAlerts } from '@services/overlays/alerts'; let lastInAppUrl: string | null = null; @@ -51,7 +51,7 @@ export default function(): void { if (isExternalApp && url.includes('://token=')) { // It's an SSO token for another app. Close the IAB and show an error. CoreOpener.closeInAppBrowser(); - CoreDomUtils.showErrorModal(new CoreSiteError({ + CoreAlerts.showError(new CoreSiteError({ supportConfig: CoreSites.getCurrentSite() ? CoreUserAuthenticatedSupportConfig.forCurrentSite() : new CoreUserNullSupportConfig(), diff --git a/src/core/services/error-helper.ts b/src/core/services/error-helper.ts index 8de5307b3..6a3a23da3 100644 --- a/src/core/services/error-helper.ts +++ b/src/core/services/error-helper.ts @@ -18,6 +18,9 @@ import { makeSingleton, Translate } from '@singletons'; import { AlertButton } from '@ionic/angular'; import { CoreWSError } from '@classes/errors/wserror'; import { CoreText } from '@singletons/text'; +import { CoreCanceledError } from '@classes/errors/cancelederror'; +import { CoreSilentError } from '@classes/errors/silenterror'; +import { CoreNetworkError } from '@classes/errors/network-error'; /** * Provider to provide some helper functions regarding files and packages. @@ -211,6 +214,57 @@ export class CoreErrorHelperService { return element?.innerText.trim() ?? ''; } + /** + * Check whether an error is an error caused because the user canceled an action. + * + * @param error Error to check. + * @returns Whether it's a canceled error. + */ + isCanceledError(error: CoreAnyError): boolean { + return error instanceof CoreCanceledError; + } + + /** + * Check whether an error is a network error. + * + * @param error Error to check. + * @returns Whether it's a network error. + */ + isNetworkError(error: CoreAnyError): boolean { + if (error instanceof CoreNetworkError) { + return true; + } + + const errorMessage = this.getErrorMessageFromError(error); + + return errorMessage === Translate.instant('core.networkerrormsg') || + errorMessage === Translate.instant('core.fileuploader.errormustbeonlinetoupload'); + } + + /** + * Check whether an error is a silent error that shouldn't be displayed to the user. + * + * @param error Error to check. + * @returns Whether it's a silent error. + */ + isSilentError(error: CoreAnyError): boolean { + return error instanceof CoreSilentError; + } + + /** + * Given a message, check if it's a site unavailable error. + * + * @param message Message text. + * @returns Whether the message is a site unavailable error. + */ + isSiteUnavailableErrorMessage(message: string): boolean { + let siteUnavailableMessage = Translate.instant('core.siteunavailablehelp', { site: 'SITEURLPLACEHOLDER' }); + siteUnavailableMessage = CoreText.escapeForRegex(siteUnavailableMessage); + siteUnavailableMessage = siteUnavailableMessage.replace('SITEURLPLACEHOLDER', '.*'); + + return new RegExp(siteUnavailableMessage).test(message); + } + /** * Log an unhandled error. * diff --git a/src/core/services/file-helper.ts b/src/core/services/file-helper.ts index 9dd331ad7..525257e4e 100644 --- a/src/core/services/file-helper.ts +++ b/src/core/services/file-helper.ts @@ -21,7 +21,6 @@ import { CoreFileUtils } from '@singletons/file-utils'; import { CoreFilepool } from '@services/filepool'; import { CoreSites } from '@services/sites'; import { CoreWS, CoreWSFile } from '@services/ws'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CoreOpener, CoreOpenerOpenFileOptions, OpenFileAction } from '@singletons/opener'; import { CoreConstants, DownloadStatus } from '@/core/constants'; @@ -34,6 +33,7 @@ import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CorePlatform } from './platform'; import { CorePath } from '@singletons/path'; import { CoreText } from '@singletons/text'; +import { CorePrompts } from './overlays/prompts'; /** * Provider to provide some helper functions regarding files and packages. @@ -446,14 +446,11 @@ export class CoreFileHelperProvider { const okButton = Translate.instant(onlyDownload ? 'core.downloadfile' : 'core.openfile'); try { - const dontShowAgain = await CoreDomUtils.showPrompt( - message, - undefined, - Translate.instant('core.dontshowagain'), - 'checkbox', - { okText: okButton }, - { cssClass: 'core-alert-force-on-top' }, - ); + const dontShowAgain = await CorePrompts.show(message, 'checkbox', { + placeholderOrLabel: Translate.instant('core.dontshowagain'), + buttons: { okText: okButton }, + cssClass: 'core-alert-force-on-top', + }); if (dontShowAgain) { CoreConfig.set(configKey, 1); diff --git a/src/core/services/local-notifications.ts b/src/core/services/local-notifications.ts index f566855a8..af5543226 100644 --- a/src/core/services/local-notifications.ts +++ b/src/core/services/local-notifications.ts @@ -41,10 +41,10 @@ import { Push } from '@features/native/plugins'; import { AsyncInstance, asyncInstance } from '@/core/utils/async-instance'; import { CoreDatabaseTable } from '@classes/database/database-table'; import { CoreDatabaseCachingStrategy, CoreDatabaseTableProxy } from '@classes/database/database-table-proxy'; -import { CoreDomUtils } from './utils/dom'; import { CoreSites } from './sites'; import { CoreNavigator } from './navigator'; import { CoreWait } from '@singletons/wait'; +import { CoreAlerts } from './overlays/alerts'; /** * Service to handle local notifications. @@ -160,7 +160,7 @@ export class CoreLocalNotificationsProvider { return; } - CoreDomUtils.showAlertWithOptions({ + CoreAlerts.show({ header: Translate.instant('core.turnonexactalarms'), message: Translate.instant('core.exactalarmsturnedoffmessage'), buttons: [ diff --git a/src/core/services/overlays/alerts.ts b/src/core/services/overlays/alerts.ts new file mode 100644 index 000000000..338388b8a --- /dev/null +++ b/src/core/services/overlays/alerts.ts @@ -0,0 +1,535 @@ +// (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 { Injectable } from '@angular/core'; +import { AlertButton, AlertOptions } from '@ionic/angular'; +import { CoreLang } from '@services/lang'; +import { CoreSites } from '@services/sites'; +import { AlertController, makeSingleton, Translate } from '@singletons'; +import { CoreText } from '@singletons/text'; +import { Md5 } from 'ts-md5'; +import { CoreLoadings } from './loadings'; +import { fixOverlayAriaHidden } from '@/core/utils/fix-aria-hidden'; +import { CoreOpener } from '@singletons/opener'; +import { CoreAnyError, CoreError } from '@classes/errors/error'; +import { CoreErrorHelper } from '@services/error-helper'; +import { CoreLogger } from '@singletons/logger'; +import { CoreConfig } from '@services/config'; +import { CoreConstants } from '@/core/constants'; +import { CoreErrorLogs } from '@singletons/error-logs'; +import { CoreSiteError } from '@classes/errors/siteerror'; +import { CoreUserSupport } from '@features/user/services/support'; +import { CoreErrorAccordion } from '@services/error-accordion'; +import { CorePlatform } from '@services/platform'; +import { CoreCanceledError } from '@classes/errors/cancelederror'; +import { CoreFileSizeSum } from '@services/plugin-file-delegate'; +import { CoreFile } from '@services/file'; +import { CoreNetwork } from '@services/network'; + +/** + * Helper service to display alerts. + */ +@Injectable({ providedIn: 'root' }) +export class CoreAlertsService { + + protected displayedAlerts: Record = {}; // To prevent duplicated alerts. + protected debugDisplay = false; // Whether to display debug messages. Store it in a variable to make it synchronous. + protected logger = CoreLogger.getInstance('CoreAlerts'); + + constructor() { + this.init(); + } + + /** + * Init some properties. + */ + protected async init(): Promise { + // Check if debug messages should be displayed. + const debugDisplay = await CoreConfig.get(CoreConstants.SETTINGS_DEBUG_DISPLAY, 0); + + this.debugDisplay = debugDisplay !== 0; + } + + /** + * Show a confirm alert. + * + * @param message Message to display. + * @param options Options of the confirm alert. + * @returns Promise resolved if the user confirms and rejected with a canceled error if he cancels. + */ + confirm(message: string, options: CoreAlertsConfirmOptions = {}): Promise { + return new Promise((resolve, reject): void => { + const { okText, cancelText, ...alertOptions } = options; + + ( alertOptions).buttons = [ + { + text: cancelText || Translate.instant('core.cancel'), + role: 'cancel', + handler: () => { + reject(new CoreCanceledError()); + }, + }, + { + text: okText || Translate.instant('core.ok'), + handler: (data: T) => { + resolve(data); + }, + }, + ]; + + if (!alertOptions.header) { + options.cssClass = (options.cssClass || '') + ' core-nohead'; + } + + this.show(options); + }); + } + + /** + * Show a delete confirmation modal. + * + * @param message Message to show. + * @param options Alert options. + * @returns Promise resolved if the user confirms and rejected with a canceled error if he cancels. + */ + async confirmDelete(message: string, options: Omit = {}): Promise { + message = await CoreLang.filterMultilang(message); + + const alertOptions: AlertOptions = { + ...options, + message, + }; + + return new Promise((resolve, reject): void => { + alertOptions.buttons = [ + { + text: Translate.instant('core.cancel'), + role: 'cancel', + handler: () => { + reject(new CoreCanceledError()); + }, + }, + { + text: Translate.instant('core.delete'), + role: 'destructive', + handler: () => { + resolve(); + }, + }, + ]; + + if (!options.header) { + options.cssClass = (options.cssClass || '') + ' core-nohead'; + } + + this.show(options); + }); + } + + /** + * If the download size is higher than a certain threshold shows a confirm dialog. + * + * @param size Object containing size to download and a boolean to indicate if its totally or partialy calculated. + * @param options Other options. + * @returns Promise resolved when the user confirms or if no confirm needed. + */ + async confirmDownloadSize( + size: CoreFileSizeSum, + options: CoreAlertsConfirmDownloadSizeOptions = {}, + ): Promise { + const readableSize = CoreText.bytesToSize(size.size, 2); + + const getAvailableBytes = async (): Promise => { + const availableBytes = await CoreFile.calculateFreeSpace(); + + if (CorePlatform.isAndroid()) { + return availableBytes; + } else { + // Space calculation is not accurate on iOS, but it gets more accurate when space is lower. + // We'll only use it when space is <500MB, or we're downloading more than twice the reported space. + if (availableBytes < CoreConstants.IOS_FREE_SPACE_THRESHOLD || size.size > availableBytes / 2) { + return availableBytes; + } else { + return null; + } + } + }; + + const getAvailableSpace = (availableBytes: number | null): string => { + if (availableBytes === null) { + return ''; + } else { + const availableSize = CoreText.bytesToSize(availableBytes, 2); + + if (CorePlatform.isAndroid() && size.size > availableBytes - CoreConstants.MINIMUM_FREE_SPACE) { + throw new CoreError( + Translate.instant( + 'core.course.insufficientavailablespace', + { size: readableSize }, + ), + ); + } + + return Translate.instant('core.course.availablespace', { available: availableSize }); + } + }; + + const availableBytes = await getAvailableBytes(); + + const availableSpace = getAvailableSpace(availableBytes); + const wifiThreshold = options.wifiThreshold ?? CoreConstants.WIFI_DOWNLOAD_THRESHOLD; + const limitedThreshold = options.limitedThreshold ?? CoreConstants.DOWNLOAD_THRESHOLD; + + let wifiPrefix = ''; + if (CoreNetwork.isNetworkAccessLimited()) { + wifiPrefix = Translate.instant('core.course.confirmlimiteddownload'); + } + + if (size.size < 0 || (size.size == 0 && !size.total)) { + // Seems size was unable to be calculated. Show a warning. + return this.confirm(wifiPrefix + Translate.instant( + options.unknownMessage ?? 'core.course.confirmdownloadunknownsize', + { availableSpace: availableSpace }, + )); + } else if (!size.total) { + // Filesize is only partial. + return this.confirm(wifiPrefix + Translate.instant( + 'core.course.confirmpartialdownloadsize', + { size: readableSize, availableSpace: availableSpace }, + )); + } else if (options.alwaysConfirm || size.size >= wifiThreshold || + (CoreNetwork.isNetworkAccessLimited() && size.size >= limitedThreshold)) { + + return this.confirm(wifiPrefix + Translate.instant( + options.message ?? (size.size === 0 ? 'core.course.confirmdownloadzerosize' : 'core.course.confirmdownload'), + { size: readableSize, availableSpace: availableSpace }, + )); + } + } + + /** + * Get the error message from an error to be displayed in an alert, including debug data if needed. + * + * @param error Message to show. + * @param options Other options. + * @returns Error message, null if no error should be displayed. + */ + getErrorMessage(error: CoreAnyError, options: CoreAlertsGetErrorMessageOptions = {}): string | null { + let errorMessage: string | undefined; + + if (typeof error !== 'string' && !error) { + errorMessage = options.default; + } else if (typeof error === 'object') { + if (this.debugDisplay) { + // eslint-disable-next-line no-console + console.error(error); + } + + // We received an object instead of a string. Search for common properties. + errorMessage = CoreErrorHelper.getErrorMessageFromError(error) || options.default; + CoreErrorLogs.addErrorLog({ message: JSON.stringify(error), type: errorMessage || '', time: new Date().getTime() }); + if (!errorMessage) { + // No common properties found, just stringify it. + errorMessage = JSON.stringify(error); + } + + // Try to remove tokens from the contents. + const matches = errorMessage.match(/token"?[=|:]"?(\w*)/); + if (matches?.[1]) { + errorMessage = errorMessage.replace(new RegExp(matches[1], 'g'), 'secret'); + } + } else { + errorMessage = error || options.default || ''; + } + + if (!errorMessage) { + return null; + } + + return CoreText.decodeHTML(errorMessage); + } + + /** + * Set whether debug messages should be displayed. + * + * @param value Whether to display or not. + */ + setDebugDisplay(value: boolean): void { + this.debugDisplay = value; + } + + /** + * Show an alert modal. + * + * @param options Alert options. + * @returns Alert modal. + */ + async show(options: CoreAlertsShowOptions = {}): Promise { + let message = typeof options.message == 'string' + ? options.message + : options.message?.value || ''; + const buttons = options.buttons || [Translate.instant('core.ok')]; + + const hasHTMLTags = CoreText.hasHTMLTags(message); + + if (hasHTMLTags && !CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.7')) { + // Treat multilang. + message = await CoreLang.filterMultilang(message); + } + + const alertId = Md5.hashAsciiStr((options.header || '') + '#' + (message|| '')); + + if (this.displayedAlerts[alertId]) { + // There's already an alert with the same message and title. Return it. + return this.displayedAlerts[alertId]; + } + + const { autoCloseTime, ...alertOptions } = options; + const alert = await AlertController.create({ + ...alertOptions, + message, + buttons, + }); + + if (Object.keys(this.displayedAlerts).length === 0) { + await CoreLoadings.pauseActiveModals(); + } + + // eslint-disable-next-line promise/catch-or-return + alert.present().then(() => { + if (hasHTMLTags) { + // Treat all anchors so they don't override the app. + const alertMessageEl: HTMLElement | null = alert.querySelector('.alert-message'); + alertMessageEl && this.treatAnchors(alertMessageEl); + } + + fixOverlayAriaHidden(alert); + + return; + }); + + // Store the alert and remove it when dismissed. + this.displayedAlerts[alertId] = alert; + + // Set the callbacks to trigger an observable event. + // eslint-disable-next-line promise/catch-or-return + alert.onDidDismiss().then(async () => { + delete this.displayedAlerts[alertId]; + + // eslint-disable-next-line promise/always-return + if (Object.keys(this.displayedAlerts).length === 0) { + await CoreLoadings.resumeActiveModals(); + } + }); + + if (autoCloseTime && autoCloseTime > 0) { + setTimeout(async () => { + await alert.dismiss(); + + if (buttons) { + // Execute dismiss function if any. + const cancelButton = buttons.find( + (button) => typeof button != 'string' && button.handler !== undefined && button.role == 'cancel', + ); + cancelButton?.handler?.(null); + } + }, autoCloseTime); + } + + return alert; + } + + /** + * Show a modal warning the user that he should use a different app. + * + * @param message The warning message. + * @param link Link to the app to download if any. + * @returns Promise resolved when done. + */ + async showDownloadAppNotice(message: string, link?: string): Promise { + const buttons: AlertButton[] = [{ + text: Translate.instant('core.ok'), + role: 'cancel', + }]; + + if (link) { + buttons.push({ + text: Translate.instant('core.download'), + handler: (): void => { + CoreOpener.openInBrowser(link, { showBrowserWarning: false }); + }, + }); + } + + const alert = await this.show({ + message: message, + buttons: buttons, + }); + + const isDevice = CorePlatform.isAndroid() || CorePlatform.isIOS(); + if (!isDevice) { + // Treat all anchors so they don't override the app. + const alertMessageEl: HTMLElement | null = alert.querySelector('.alert-message'); + alertMessageEl && this.treatAnchors(alertMessageEl); + } + + await alert.onDidDismiss(); + } + + /** + * Show an alert modal with an error message. + * + * @param error Error to show. + * @param options Other options. + * @returns Alert modal. + */ + async showError( + error: CoreAnyError, + options: CoreAlertsShowErrorOptions = {}, + ): Promise { + if (CoreErrorHelper.isCanceledError(error) || CoreErrorHelper.isSilentError(error)) { + // It's a canceled or a silent error, don't display an error. + return null; + } + + const message = this.getErrorMessage(error, { default: options.default }); + if (message === null) { + return null; + } + + const alertOptions: CoreAlertsShowOptions = { message, autoCloseTime: options.autoCloseTime }; + + if (CoreErrorHelper.isNetworkError(error)) { + alertOptions.cssClass = 'core-alert-network-error'; + } + + if (typeof error !== 'string' && error && 'title' in error && error.title) { + alertOptions.header = error.title || undefined; + } else if (message === Translate.instant('core.sitenotfoundhelp')) { + alertOptions.header = Translate.instant('core.cannotconnect'); + } else if (CoreErrorHelper.isSiteUnavailableErrorMessage(message)) { + alertOptions.header = CoreSites.isLoggedIn() + ? Translate.instant('core.connectionlost') + : Translate.instant('core.cannotconnect'); + } else { + alertOptions.header = Translate.instant('core.error'); + } + + if (typeof error !== 'string' && error && 'buttons' in error && typeof error.buttons !== 'undefined') { + alertOptions.buttons = error.buttons; + } else { + alertOptions.buttons = [Translate.instant('core.ok')]; + } + + // For site errors, always show debug info. + const showDebugInfo = this.debugDisplay || error instanceof CoreSiteError; + const debugInfo = showDebugInfo && CoreErrorHelper.getDebugInfoFromError(error); + if (debugInfo) { + alertOptions.message = `

${message}

`; + } + + if (error instanceof CoreSiteError && error.supportConfig?.canContactSupport()) { + alertOptions.buttons.push({ + text: Translate.instant('core.contactsupport'), + handler: () => CoreUserSupport.contact({ + supportConfig: error.supportConfig, + subject: alertOptions.header, + message: `${error.debug?.code}\n\n${error.debug?.details}`, + }), + }); + } + + const alertElement = await this.show(alertOptions); + + if (debugInfo) { + const containerElement = alertElement.querySelector('.core-error-accordion-container'); + + if (containerElement) { + await CoreErrorAccordion.render(containerElement, debugInfo.details, debugInfo.code); + } + } + + return alertElement; + } + + /** + * Treat anchors inside an alert. + * + * @param container The HTMLElement that can contain anchors. + */ + protected treatAnchors(container: HTMLElement): void { + const anchors = Array.from(container.querySelectorAll('a')); + + anchors.forEach((anchor) => { + anchor.addEventListener('click', (event) => { + if (event.defaultPrevented) { + // Stop. + return; + } + + const href = anchor.getAttribute('href'); + if (href) { + event.preventDefault(); + event.stopPropagation(); + + CoreOpener.openInBrowser(href); + } + }); + }); + } + +} + +export const CoreAlerts = makeSingleton(CoreAlertsService); + +/** + * Options to pass to CoreAlerts.confirm. + */ +export type CoreAlertsConfirmOptions = Omit & { + okText?: string; // Text of the OK button. By default, 'OK'. + cancelText?: string; // Text of the Cancel button. By default, 'Cancel'. +}; + +/** + * Options to pass to CoreAlerts.confirmDownloadSize. + */ +export type CoreAlertsConfirmDownloadSizeOptions = { + message?: string; // Message to show. If not set, uses a default message. + unknownMessage?: string; // Message to show if size is unknown. + wifiThreshold?: number; // Threshold to show confirm in WiFi connection. Default: CoreWifiDownloadThreshold. + limitedThreshold?: number; // Threshold to show confirm in limited connection. Default: CoreDownloadThreshold. + alwaysConfirm?: boolean; // True to show a confirm even if the size isn't high, false otherwise. +}; + +/** + * Options to pass to CoreAlerts.getErrorMessage. + */ +export type CoreAlertsGetErrorMessageOptions = { + default?: string; // Default error message to show if the error is empty. +}; + +/** + * Options to pass to CoreAlerts.show. + */ +export type CoreAlertsShowOptions = AlertOptions & { + autoCloseTime?: number; // Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. +}; + +/** + * Options to pass to CoreAlerts.showError. + */ +export type CoreAlertsShowErrorOptions = { + autoCloseTime?: number; // Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. + default?: string; // Default error message to show if the error is empty. +}; diff --git a/src/core/services/overlays/modals.ts b/src/core/services/overlays/modals.ts index 0f68b2aa3..7a330b813 100644 --- a/src/core/services/overlays/modals.ts +++ b/src/core/services/overlays/modals.ts @@ -24,8 +24,6 @@ import { Subscription, filter } from 'rxjs'; import { Md5 } from 'ts-md5'; import { fixOverlayAriaHidden } from '../../utils/fix-aria-hidden'; import { ModalOptions } from '@ionic/angular'; -import { CoreCanceledError } from '@classes/errors/cancelederror'; -import { CoreWSError } from '@classes/errors/wserror'; import { CorePasswordModalResponse, CorePasswordModalParams } from '@components/password-modal/password-modal'; /** @@ -188,28 +186,12 @@ export class CoreModalsService { * * @param passwordParams Params to show the modal. * @returns Entered password, error and validation. + * @deprecated since 5.0. Use CorePrompts.promptPassword instead. */ async promptPassword(passwordParams?: CorePasswordModalParams): Promise { - const { CorePasswordModalComponent } = - await import('@/core/components/password-modal/password-modal.module'); + const { CorePrompts } = await import('./prompts'); - const modalData = await CoreModals.openModal( - { - cssClass: 'core-password-modal', - showBackdrop: true, - backdropDismiss: true, - component: CorePasswordModalComponent, - componentProps: passwordParams, - }, - ); - - if (modalData === undefined) { - throw new CoreCanceledError(); - } else if (modalData instanceof CoreWSError) { - throw modalData; - } - - return modalData; + return CorePrompts.promptPassword(passwordParams); } } diff --git a/src/core/services/overlays/prompts.ts b/src/core/services/overlays/prompts.ts new file mode 100644 index 000000000..d62cd5df5 --- /dev/null +++ b/src/core/services/overlays/prompts.ts @@ -0,0 +1,165 @@ +// (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 { Injectable } from '@angular/core'; +import { AlertButton, AlertOptions } from '@ionic/angular'; +import { TextFieldTypes } from '@ionic/core'; +import { CoreAlerts } from './alerts'; +import { makeSingleton, Translate } from '@singletons'; +import { CorePasswordModalParams, CorePasswordModalResponse } from '@components/password-modal/password-modal'; +import { CoreModals } from './modals'; +import { CoreCanceledError } from '@classes/errors/cancelederror'; +import { CoreWSError } from '@classes/errors/wserror'; + +/** + * Helper service to display prompts (modals where the user enters data). + */ +@Injectable({ providedIn: 'root' }) +export class CorePromptsService { + + /** + * Show a prompt modal to input some data. + * + * @param message Modal message. + * @param type Type of prompt. + * @param options Other alert options. + * @returns Promise resolved with the input data (true for checkbox/radio) if the user clicks OK, rejected if cancels. + */ + show(message: string, type: 'checkbox'|'radio', options?: CoreAlertsShowPromptOptions): Promise; + show(message: string, type: CoreAlertsPromptType, options?: CoreAlertsShowPromptOptions): Promise; + show(message: string, type: CoreAlertsPromptType, options: CoreAlertsShowPromptOptions = {}): Promise { + return new Promise((resolve, reject) => { + const { placeholderOrLabel, buttons, ...alertOptions } = options; + + const isCheckbox = type === 'checkbox'; + const isRadio = type === 'radio'; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const resolvePromise = (data: any) => { + if (isCheckbox) { + resolve(data[0]); + } else if (isRadio) { + resolve(data); + } else { + resolve(data.promptinput); + } + }; + + ( alertOptions).message = message; + alertOptions.inputs = [ + { + name: 'promptinput', + placeholder: placeholderOrLabel ?? Translate.instant('core.login.password'), + label: placeholderOrLabel ?? Translate.instant('core.login.password'), + type, + value: (isCheckbox || isRadio) ? true : undefined, + }, + ]; + + if (Array.isArray(buttons) && buttons.length) { + ( alertOptions).buttons = buttons.map((button) => ({ + ...button, + handler: (data) => { + if (!button.handler) { + if (button.role === 'cancel') { + reject(new CoreCanceledError()); + } else { + resolvePromise(data); + } + + return; + } + + button.handler(data, resolve, reject); + }, + })); + } else { + // Default buttons. + ( alertOptions).buttons = [ + { + text: buttons && 'cancelText' in buttons + ? buttons.cancelText as string + : Translate.instant('core.cancel'), + role: 'cancel', + handler: () => { + reject(new CoreCanceledError()); + }, + }, + { + text: buttons && 'okText' in buttons + ? buttons.okText as string + : Translate.instant('core.ok'), + handler: resolvePromise, + }, + ]; + } + + CoreAlerts.show(alertOptions); + }); + } + + /** + * Prompts password to the user and returns the entered text. + * + * @param passwordParams Params to show the modal. + * @returns Entered password, error and validation. + */ + async promptPassword(passwordParams?: CorePasswordModalParams): Promise { + const { CorePasswordModalComponent } = + await import('@/core/components/password-modal/password-modal.module'); + + const modalData = await CoreModals.openModal( + { + cssClass: 'core-password-modal', + showBackdrop: true, + backdropDismiss: true, + component: CorePasswordModalComponent, + componentProps: passwordParams, + }, + ); + + if (modalData === undefined) { + throw new CoreCanceledError(); + } else if (modalData instanceof CoreWSError) { + throw modalData; + } + + return modalData; + } + +} + +export const CorePrompts = makeSingleton(CorePromptsService); + +/** + * Buttons for prompt alert. + */ +export type PromptButton = Omit & { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + handler?: (value: any, resolve: (value: any) => void, reject: (reason: any) => void) => void; +}; + +/** + * Types of prompts. + */ +export type CoreAlertsPromptType = TextFieldTypes | 'checkbox' | 'radio' | 'textarea'; + +/** + * Options to pass to CoreAlerts.showPrompt. + */ +export type CoreAlertsShowPromptOptions = Omit & { + placeholderOrLabel?: string; // Placeholder (for textual/numeric inputs) or label (for radio/checkbox). By default, "Password". + buttons?: PromptButton[] | { okText?: string; cancelText?: string }; // Buttons. If not provided or it's an object with texts, + // OK and Cancel buttons will be displayed. +}; diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 5706f4d30..e0e379d9c 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -19,7 +19,6 @@ import { timeout } from 'rxjs/operators'; import { CoreApp, CoreStoreConfig } from '@services/app'; import { CoreEvents } from '@singletons/events'; import { CoreWS } from '@services/ws'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl, CoreUrlPartNames } from '@singletons/url'; import { CoreConstants, MINIMUM_MOODLE_VERSION, MOODLE_RELEASES } from '@/core/constants'; import { @@ -70,6 +69,7 @@ import { CoreAppDB } from './app-db'; import { CoreRedirects } from '@singletons/redirects'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreOpener } from '@singletons/opener'; +import { CoreAlerts } from './overlays/alerts'; export const CORE_SITE_SCHEMAS = new InjectionToken('CORE_SITE_SCHEMAS'); export const CORE_SITE_CURRENT_SITE_ID_CONFIG = 'current_site_id'; @@ -939,20 +939,22 @@ export class CoreSitesProvider { if (downloadUrl != null) { // Do not block interface. - promise = CoreDomUtils.showConfirm( + promise = CoreAlerts.confirm( Translate.instant('core.updaterequireddesc', { $a: config.tool_mobile_minimumversion }), - Translate.instant('core.updaterequired'), - Translate.instant('core.download'), - Translate.instant(siteId ? 'core.mainmenu.logout' : 'core.cancel'), + { + header: Translate.instant('core.updaterequired'), + okText: Translate.instant('core.download'), + cancelText: Translate.instant(siteId ? 'core.mainmenu.logout' : 'core.cancel'), + }, ).then(() => CoreOpener.openInBrowser(downloadUrl, { showBrowserWarning: false })).catch(() => { // Do nothing. }); } else { // Do not block interface. - promise = CoreDomUtils.showAlert( - Translate.instant('core.updaterequired'), - Translate.instant('core.updaterequireddesc', { $a: config.tool_mobile_minimumversion }), - ).then((alert) => alert.onWillDismiss()); + promise = CoreAlerts.show({ + header: Translate.instant('core.updaterequired'), + message: Translate.instant('core.updaterequireddesc', { $a: config.tool_mobile_minimumversion }), + }).then((alert) => alert.onWillDismiss()); } promise.finally(() => { diff --git a/src/core/services/tests/utils/dom.test.ts b/src/core/services/tests/overlays/alerts.test.ts similarity index 61% rename from src/core/services/tests/utils/dom.test.ts rename to src/core/services/tests/overlays/alerts.test.ts index 45e8499d9..c3aa4054c 100644 --- a/src/core/services/tests/utils/dom.test.ts +++ b/src/core/services/tests/overlays/alerts.test.ts @@ -12,20 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CoreDomUtilsProvider } from '@services/utils/dom'; import { AlertController, Translate } from '@singletons'; - import { mock, mockSingleton, mockTranslate } from '@/testing/utils'; import { CoreSiteError } from '@classes/errors/siteerror'; import { CoreSites } from '@services/sites'; -import { OverlayEventDetail } from '@ionic/core'; +import { CoreAlertsService } from '@services/overlays/alerts'; -describe('CoreDomUtilsProvider', () => { +describe('CoreAlertsService', () => { - let domUtils: CoreDomUtilsProvider; + let alertsService: CoreAlertsService; beforeEach(() => { - domUtils = new CoreDomUtilsProvider(); + alertsService = new CoreAlertsService(); }); it('shows site unavailable errors', async () => { @@ -46,7 +44,7 @@ describe('CoreDomUtilsProvider', () => { mockSingleton(CoreSites, mock({ isLoggedIn: () => true })); // Act. - await domUtils.showErrorModal(new CoreSiteError({ message })); + await alertsService.showError(new CoreSiteError({ message })); // Assert. expect(mockAlert.present).toHaveBeenCalled(); @@ -57,30 +55,4 @@ describe('CoreDomUtilsProvider', () => { }); }); - it('ignores alert inputs on cancel', async () => { - // Arrange. - const mockAlert = mock({ - present: () => Promise.resolve(), - onWillDismiss: () => Promise.resolve({ - data: { - values: { - 'textarea-prompt': 'Not empty!', - }, - }, - role: 'cancel', - } as OverlayEventDetail), // eslint-disable-line @typescript-eslint/no-explicit-any - }); - - mockSingleton(AlertController, mock({ create: () => Promise.resolve(mockAlert) })); - - // Act. - const result = await domUtils.showTextareaPrompt('Age', 'How old are you?', [ - { text: 'Cancel', role: 'cancel' }, - { text: 'Save' }, - ]); - - // Assert. - expect(result).toBeUndefined(); - }); - }); diff --git a/src/core/services/urlschemes.ts b/src/core/services/urlschemes.ts index a6a9d351d..715cb8513 100644 --- a/src/core/services/urlschemes.ts +++ b/src/core/services/urlschemes.ts @@ -26,10 +26,10 @@ import { CoreConstants } from '../constants'; import { CoreSSO } from '@singletons/sso'; import { CoreNavigator, CoreRedirectPayload } from './navigator'; import { CoreSiteCheckResponse, CoreSites } from './sites'; -import { CoreDomUtils } from './utils/dom'; import { CoreErrorHelper, CoreErrorObject } from './error-helper'; import { CoreUrl } from '@singletons/url'; import { CoreLoadings } from './overlays/loadings'; +import { CoreAlerts } from './overlays/alerts'; /* * Provider to handle custom URL schemes. @@ -218,7 +218,7 @@ export class CoreCustomURLSchemesProvider { const treated = await CoreContentLinksHelper.handleLink(data.redirect, username); if (!treated) { - CoreDomUtils.showErrorModal('core.contentlinks.errornoactions', true); + CoreAlerts.showError(Translate.instant('core.contentlinks.errornoactions')); } } @@ -430,7 +430,7 @@ export class CoreCustomURLSchemesProvider { if (CoreSites.isLoggedIn()) { // Ask the user before changing site. - await CoreDomUtils.showConfirm(Translate.instant('core.contentlinks.confirmurlothersite')); + await CoreAlerts.confirm(Translate.instant('core.contentlinks.confirmurlothersite')); await CoreSites.logout({ siteId: CoreConstants.NO_SITE_ID, @@ -531,7 +531,7 @@ export class CoreCustomURLSchemesProvider { CoreLoginHelper.treatUserTokenError(error.data.siteUrl, error.error); CoreSites.logout(); } else { - CoreDomUtils.showErrorModal(error.error ?? new CoreError(Translate.instant('core.login.invalidsite'), { debug: { + CoreAlerts.showError(error.error ?? new CoreError(Translate.instant('core.login.invalidsite'), { debug: { code: 'unknownerror', details: `Unknown error when treating a URL scheme.

Origin: ${origin}.

URL: ${url}.`, } })); diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index 5b4f403f6..2b2149717 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -15,41 +15,22 @@ import { Injectable, SimpleChange, KeyValueChanges } from '@angular/core'; import { IonContent } from '@ionic/angular'; import { PopoverOptions, AlertOptions, AlertButton, TextFieldTypes } from '@ionic/core'; -import { Md5 } from 'ts-md5'; import { CoreConfig } from '@services/config'; -import { CoreFile } from '@services/file'; import { CoreWSExternalWarning } from '@services/ws'; -import { CoreText } from '@singletons/text'; import { CoreUrl, CoreUrlPartNames } from '@singletons/url'; -import { CoreOpener } from '@singletons/opener'; import { CoreConstants } from '@/core/constants'; import { CoreIonLoadingElement } from '@classes/ion-loading'; -import { CoreCanceledError } from '@classes/errors/cancelederror'; import { CoreAnyError, CoreError } from '@classes/errors/error'; -import { CoreSilentError } from '@classes/errors/silenterror'; -import { - makeSingleton, - Translate, - AlertController, -} from '@singletons'; +import { AlertController, makeSingleton, Translate } from '@singletons'; import { CoreLogger } from '@singletons/logger'; import { CoreFileSizeSum } from '@services/plugin-file-delegate'; -import { CoreNetworkError } from '@classes/errors/network-error'; -import { CoreSites } from '@services/sites'; -import { CoreNetwork } from '@services/network'; -import { CoreSiteError } from '@classes/errors/siteerror'; -import { CoreUserSupport } from '@features/user/services/support'; -import { CoreErrorAccordion } from '@services/error-accordion'; import { CorePlatform } from '@services/platform'; import { CoreCancellablePromise } from '@classes/cancellable-promise'; -import { CoreLang } from '@services/lang'; import { CorePasswordModalParams, CorePasswordModalResponse } from '@components/password-modal/password-modal'; -import { CoreErrorLogs } from '@singletons/error-logs'; import { CoreKeyboard } from '@singletons/keyboard'; import { CoreWait } from '@singletons/wait'; import { CoreToasts, ToastDuration, ShowToastOptions } from '../overlays/toasts'; -import { fixOverlayAriaHidden } from '@/core/utils/fix-aria-hidden'; import { CoreModals, OpenModalOptions } from '@services/overlays/modals'; import { CorePopovers, OpenPopoverOptions } from '@services/overlays/popovers'; import { CoreViewer } from '@features/viewer/services/viewer'; @@ -58,6 +39,8 @@ import { CoreErrorHelper, CoreErrorObject } from '@services/error-helper'; import { convertTextToHTMLElement } from '@/core/utils/create-html-element'; import { CoreHTMLClasses } from '@singletons/html-classes'; import { CoreDom } from '@singletons/dom'; +import { CoreAlerts } from '@services/overlays/alerts'; +import { PromptButton } from '@services/overlays/prompts'; /* * "Utils" service with helper functions for UI, DOM elements and HTML code. @@ -72,24 +55,10 @@ export class CoreDomUtilsProvider { 'password', 'search', 'tel', 'text', 'time', 'url', 'week']; protected matchesFunctionName?: string; // Name of the "matches" function to use when simulating a closest call. - protected debugDisplay = false; // Whether to display debug messages. Store it in a variable to make it synchronous. - protected displayedAlerts: Record = {}; // To prevent duplicated alerts. protected logger: CoreLogger; constructor() { this.logger = CoreLogger.getInstance('CoreDomUtilsProvider'); - - this.init(); - } - - /** - * Init some properties. - */ - protected async init(): Promise { - // Check if debug messages should be displayed. - const debugDisplay = await CoreConfig.get(CoreConstants.SETTINGS_DEBUG_DISPLAY, 0); - - this.debugDisplay = debugDisplay != 0; } /** @@ -102,6 +71,7 @@ export class CoreDomUtilsProvider { * @param limitedThreshold Threshold to show confirm in limited connection. Default: CoreDownloadThreshold. * @param alwaysConfirm True to show a confirm even if the size isn't high, false otherwise. * @returns Promise resolved when the user confirms or if no confirm needed. + * @deprecated since 5.0. Use CoreAlerts.confirmDownloadSize instead. */ async confirmDownloadSize( size: CoreFileSizeSum, @@ -111,85 +81,7 @@ export class CoreDomUtilsProvider { limitedThreshold?: number, alwaysConfirm?: boolean, ): Promise { - const readableSize = CoreText.bytesToSize(size.size, 2); - - const getAvailableBytes = async (): Promise => { - const availableBytes = await CoreFile.calculateFreeSpace(); - - if (CorePlatform.isAndroid()) { - return availableBytes; - } else { - // Space calculation is not accurate on iOS, but it gets more accurate when space is lower. - // We'll only use it when space is <500MB, or we're downloading more than twice the reported space. - if (availableBytes < CoreConstants.IOS_FREE_SPACE_THRESHOLD || size.size > availableBytes / 2) { - return availableBytes; - } else { - return null; - } - } - }; - - const getAvailableSpace = (availableBytes: number | null): string => { - if (availableBytes === null) { - return ''; - } else { - const availableSize = CoreText.bytesToSize(availableBytes, 2); - - if (CorePlatform.isAndroid() && size.size > availableBytes - CoreConstants.MINIMUM_FREE_SPACE) { - throw new CoreError( - Translate.instant( - 'core.course.insufficientavailablespace', - { size: readableSize }, - ), - ); - } - - return Translate.instant('core.course.availablespace', { available: availableSize }); - } - }; - - const availableBytes = await getAvailableBytes(); - - const availableSpace = getAvailableSpace(availableBytes); - - wifiThreshold = wifiThreshold === undefined ? CoreConstants.WIFI_DOWNLOAD_THRESHOLD : wifiThreshold; - limitedThreshold = limitedThreshold === undefined ? CoreConstants.DOWNLOAD_THRESHOLD : limitedThreshold; - - let wifiPrefix = ''; - if (CoreNetwork.isNetworkAccessLimited()) { - wifiPrefix = Translate.instant('core.course.confirmlimiteddownload'); - } - - if (size.size < 0 || (size.size == 0 && !size.total)) { - // Seems size was unable to be calculated. Show a warning. - unknownMessage = unknownMessage || 'core.course.confirmdownloadunknownsize'; - - return this.showConfirm( - wifiPrefix + Translate.instant( - unknownMessage, - { availableSpace: availableSpace }, - ), - ); - } else if (!size.total) { - // Filesize is only partial. - - return this.showConfirm( - wifiPrefix + Translate.instant( - 'core.course.confirmpartialdownloadsize', - { size: readableSize, availableSpace: availableSpace }, - ), - ); - } else if (alwaysConfirm || size.size >= wifiThreshold || - (CoreNetwork.isNetworkAccessLimited() && size.size >= limitedThreshold)) { - message = message || (size.size === 0 ? 'core.course.confirmdownloadzerosize' : 'core.course.confirmdownload'); - - return this.showConfirm( - wifiPrefix + Translate.instant( - message, - { size: readableSize, availableSpace: availableSpace }, - ), - ); - } + return CoreAlerts.confirmDownloadSize(size, { message, unknownMessage, wifiThreshold, limitedThreshold, alwaysConfirm }); } /** @@ -393,84 +285,18 @@ export class CoreDomUtilsProvider { return parseInt(style[measure], 10) || 0; } - /** - * Given a message, it deduce if it's a network error. - * - * @param message Message text. - * @param error Error object. - * @returns True if the message error is a network error, false otherwise. - */ - protected isNetworkError(message: string, error?: CoreError | CoreErrorObject | string): boolean { - return message == Translate.instant('core.networkerrormsg') || - message == Translate.instant('core.fileuploader.errormustbeonlinetoupload') || - error instanceof CoreNetworkError; - } - - /** - * Given a message, check if it's a site unavailable error. - * - * @param message Message text. - * @returns Whether the message is a site unavailable error. - */ - protected isSiteUnavailableError(message: string): boolean { - let siteUnavailableMessage = Translate.instant('core.siteunavailablehelp', { site: 'SITEURLPLACEHOLDER' }); - siteUnavailableMessage = CoreText.escapeForRegex(siteUnavailableMessage); - siteUnavailableMessage = siteUnavailableMessage.replace('SITEURLPLACEHOLDER', '.*'); - - return new RegExp(siteUnavailableMessage).test(message); - } - /** * Get the error message from an error, including debug data if needed. * * @param error Message to show. * @param needsTranslate Whether the error needs to be translated. * @returns Error message, null if no error should be displayed. + * @deprecated since 5.0. Use CoreAlerts.getErrorMessage instead. */ getErrorMessage(error: CoreError | CoreErrorObject | string, needsTranslate?: boolean): string | null { - if (typeof error != 'string' && !error) { - return null; - } + const message = CoreAlerts.getErrorMessage(error); - let extraInfo = ''; - let errorMessage: string | undefined; - - if (typeof error === 'object') { - if (this.debugDisplay) { - // eslint-disable-next-line no-console - console.error(error); - } - - if (this.isSilentError(error)) { - // It's a silent error, don't display an error. - return null; - } - - // We received an object instead of a string. Search for common properties. - errorMessage = CoreErrorHelper.getErrorMessageFromError(error); - CoreErrorLogs.addErrorLog({ message: JSON.stringify(error), type: errorMessage || '', time: new Date().getTime() }); - if (!errorMessage) { - // No common properties found, just stringify it. - errorMessage = JSON.stringify(error); - extraInfo = ''; // No need to add extra info because it's already in the error. - } - - // Try to remove tokens from the contents. - const matches = errorMessage.match(/token"?[=|:]"?(\w*)/); - if (matches?.[1]) { - errorMessage = errorMessage.replace(new RegExp(matches[1], 'g'), 'secret'); - } - } else { - errorMessage = error; - } - - let message = CoreText.decodeHTML(needsTranslate ? Translate.instant(errorMessage) : errorMessage); - - if (extraInfo) { - message += extraInfo; - } - - return message; + return needsTranslate && message ? Translate.instant(message) : message; } /** @@ -478,19 +304,21 @@ export class CoreDomUtilsProvider { * * @param error Error to check. * @returns Whether it's a canceled error. + * @deprecated since 5.0. Use CoreErrorHelper.isCanceledError instead. */ isCanceledError(error: CoreAnyError): boolean { - return error instanceof CoreCanceledError; + return CoreErrorHelper.isCanceledError(error); } /** - * Check whether an error is an error caused because the user canceled a showConfirm. + * Check whether an error is a silent error that shouldn't be displayed to the user. * * @param error Error to check. * @returns Whether it's a canceled error. + * @deprecated since 5.0. Use CoreErrorHelper.isSilentError instead. */ isSilentError(error: CoreAnyError): boolean { - return error instanceof CoreSilentError; + return CoreErrorHelper.isSilentError(error); } /** @@ -775,15 +603,6 @@ export class CoreDomUtilsProvider { } } - /** - * Set whether debug messages should be displayed. - * - * @param value Whether to display or not. - */ - setDebugDisplay(value: boolean): void { - this.debugDisplay = value; - } - /** * Show an alert modal with a button to close it. * @@ -792,6 +611,7 @@ export class CoreDomUtilsProvider { * @param buttonText Text of the button. * @param autocloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. * @returns Promise resolved with the alert modal. + * @deprecated since 5.0. Use CoreAlerts.show instead. */ async showAlert( header: string | undefined, @@ -799,11 +619,12 @@ export class CoreDomUtilsProvider { buttonText?: string, autocloseTime?: number, ): Promise { - return this.showAlertWithOptions({ + return CoreAlerts.show({ header, message, buttons: [buttonText || Translate.instant('core.ok')], - }, autocloseTime); + autoCloseTime: autocloseTime, + }); } /** @@ -812,76 +633,13 @@ export class CoreDomUtilsProvider { * @param options Alert options to pass to the alert. * @param autocloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. * @returns Promise resolved with the alert modal. + * @deprecated since 5.0. Use CoreAlerts.show instead. */ async showAlertWithOptions(options: AlertOptions = {}, autocloseTime?: number): Promise { - let message = typeof options.message == 'string' - ? options.message - : options.message?.value || ''; - - const hasHTMLTags = CoreText.hasHTMLTags(message); - - if (hasHTMLTags && !CoreSites.getCurrentSite()?.isVersionGreaterEqualThan('3.7')) { - // Treat multilang. - message = await CoreLang.filterMultilang(message); - } - - options.message = message; - - const alertId = Md5.hashAsciiStr((options.header || '') + '#' + (message|| '')); - - if (this.displayedAlerts[alertId]) { - // There's already an alert with the same message and title. Return it. - return this.displayedAlerts[alertId]; - } - - const alert = await AlertController.create(options); - - if (Object.keys(this.displayedAlerts).length === 0) { - await CoreLoadings.pauseActiveModals(); - } - - // eslint-disable-next-line promise/catch-or-return - alert.present().then(() => { - if (hasHTMLTags) { - // Treat all anchors so they don't override the app. - const alertMessageEl: HTMLElement | null = alert.querySelector('.alert-message'); - alertMessageEl && this.treatAnchors(alertMessageEl); - } - - fixOverlayAriaHidden(alert); - - return; + return CoreAlerts.show({ + ...options, + autoCloseTime: autocloseTime, }); - - // Store the alert and remove it when dismissed. - this.displayedAlerts[alertId] = alert; - - // Set the callbacks to trigger an observable event. - // eslint-disable-next-line promise/catch-or-return - alert.onDidDismiss().then(async () => { - delete this.displayedAlerts[alertId]; - - // eslint-disable-next-line promise/always-return - if (Object.keys(this.displayedAlerts).length === 0) { - await CoreLoadings.resumeActiveModals(); - } - }); - - if (autocloseTime && autocloseTime > 0) { - setTimeout(async () => { - await alert.dismiss(); - - if (options.buttons) { - // Execute dismiss function if any. - const cancelButton = options.buttons.find( - (button) => typeof button != 'string' && button.handler !== undefined && button.role == 'cancel', - ); - cancelButton?.handler?.(null); - } - }, autocloseTime); - } - - return alert; } /** @@ -892,6 +650,7 @@ export class CoreDomUtilsProvider { * @param buttonText Text of the button. * @param autocloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. * @returns Promise resolved with the alert modal. + * @deprecated since 5.0. Use CoreAlerts.show instead, and pass the strings already translated. */ showAlertTranslated( header: string | undefined, @@ -903,7 +662,12 @@ export class CoreDomUtilsProvider { message = message ? Translate.instant(message) : message; buttonText = buttonText ? Translate.instant(buttonText) : buttonText; - return this.showAlert(header, message, buttonText, autocloseTime); + return CoreAlerts.show({ + header, + message, + buttons: [buttonText || Translate.instant('core.ok')], + autoCloseTime: autocloseTime, + }); } /** @@ -913,39 +677,14 @@ export class CoreDomUtilsProvider { * @param translateArgs Arguments to pass to translate if necessary. * @param options More options. See https://ionicframework.com/docs/v3/api/components/alert/AlertController/ * @returns Promise resolved if the user confirms and rejected with a canceled error if he cancels. + * @deprecated since 5.0. Use CoreAlerts.confirmDelete instead. */ async showDeleteConfirm( translateMessage: string = 'core.areyousure', translateArgs: Record = {}, options: AlertOptions = {}, ): Promise { - options.message = Translate.instant(translateMessage, translateArgs); - options.message = await CoreLang.filterMultilang(options.message); - - return new Promise((resolve, reject): void => { - options.buttons = [ - { - text: Translate.instant('core.cancel'), - role: 'cancel', - handler: () => { - reject(new CoreCanceledError('')); - }, - }, - { - text: Translate.instant('core.delete'), - role: 'destructive', - handler: () => { - resolve(); - }, - }, - ]; - - if (!options.header) { - options.cssClass = (options.cssClass || '') + ' core-nohead'; - } - - this.showAlertWithOptions(options, 0); - }); + return CoreAlerts.confirmDelete(Translate.instant(translateMessage, translateArgs), { ...options }); } /** @@ -957,6 +696,7 @@ export class CoreDomUtilsProvider { * @param cancelText Text of the Cancel button. * @param options More options. * @returns Promise resolved if the user confirms and rejected with a canceled error if he cancels. + * @deprecated since 5.0. Use CoreAlerts.confirm instead. */ showConfirm( message: string, @@ -965,32 +705,7 @@ export class CoreDomUtilsProvider { cancelText?: string, options: AlertOptions = {}, ): Promise { - return new Promise((resolve, reject): void => { - options.header = header; - options.message = message; - - options.buttons = [ - { - text: cancelText || Translate.instant('core.cancel'), - role: 'cancel', - handler: () => { - reject(new CoreCanceledError('')); - }, - }, - { - text: okText || Translate.instant('core.ok'), - handler: (data: T) => { - resolve(data); - }, - }, - ]; - - if (!header) { - options.cssClass = (options.cssClass || '') + ' core-nohead'; - } - - this.showAlertWithOptions(options, 0); - }); + return CoreAlerts.confirm(message, { header, okText, cancelText, ...options }); } /** @@ -998,79 +713,20 @@ export class CoreDomUtilsProvider { * * @param error Message to show. * @param needsTranslate Whether the error needs to be translated. - * @param autocloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. + * @param autoCloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. * @returns Promise resolved with the alert modal. + * @deprecated since 5.0. Use CoreAlerts.showError instead. */ async showErrorModal( error: CoreError | CoreErrorObject | string, needsTranslate?: boolean, - autocloseTime?: number, + autoCloseTime?: number, ): Promise { - if (this.isCanceledError(error)) { - // It's a canceled error, don't display an error. - return null; + if (needsTranslate && typeof error === 'string') { + error = Translate.instant(error); } - const message = this.getErrorMessage(error, needsTranslate); - - if (message === null) { - // Message doesn't need to be displayed, stop. - return null; - } - - const alertOptions: AlertOptions = { message }; - - if (this.isNetworkError(message, error)) { - alertOptions.cssClass = 'core-alert-network-error'; - } - - if (typeof error !== 'string' && 'title' in error && error.title) { - alertOptions.header = error.title || undefined; - } else if (message === Translate.instant('core.sitenotfoundhelp')) { - alertOptions.header = Translate.instant('core.cannotconnect'); - } else if (this.isSiteUnavailableError(message)) { - alertOptions.header = CoreSites.isLoggedIn() - ? Translate.instant('core.connectionlost') - : Translate.instant('core.cannotconnect'); - } else { - alertOptions.header = Translate.instant('core.error'); - } - - if (typeof error !== 'string' && 'buttons' in error && typeof error.buttons !== 'undefined') { - alertOptions.buttons = error.buttons; - } else { - alertOptions.buttons = [Translate.instant('core.ok')]; - } - - // For site errors, always show debug info. - const showDebugInfo = this.debugDisplay || error instanceof CoreSiteError; - const debugInfo = showDebugInfo && CoreErrorHelper.getDebugInfoFromError(error); - if (debugInfo) { - alertOptions.message = `

${message}

`; - } - - if (error instanceof CoreSiteError && error.supportConfig?.canContactSupport()) { - alertOptions.buttons.push({ - text: Translate.instant('core.contactsupport'), - handler: () => CoreUserSupport.contact({ - supportConfig: error.supportConfig, - subject: alertOptions.header, - message: `${error.debug?.code}\n\n${error.debug?.details}`, - }), - }); - } - - const alertElement = await this.showAlertWithOptions(alertOptions, autocloseTime); - - if (debugInfo) { - const containerElement = alertElement.querySelector('.core-error-accordion-container'); - - if (containerElement) { - await CoreErrorAccordion.render(containerElement, debugInfo.details, debugInfo.code); - } - } - - return alertElement; + return CoreAlerts.showError(error, { autoCloseTime }); } /** @@ -1079,31 +735,24 @@ export class CoreDomUtilsProvider { * @param error Message to show. * @param defaultError Message to show if the error is not a string. * @param needsTranslate Whether the error needs to be translated. - * @param autocloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. + * @param autoCloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. * @returns Promise resolved with the alert modal. + * @deprecated since 5.0. Use CoreAlerts.showError instead. */ async showErrorModalDefault( error: CoreAnyError, defaultError: string, needsTranslate = false, - autocloseTime?: number, + autoCloseTime?: number, ): Promise { - if (this.isCanceledError(error) || this.isSilentError(error)) { - // It's a canceled or a silent error, don't display an error. - return null; + if (needsTranslate && typeof error === 'string') { + error = Translate.instant(error); } - let errorMessage = error || undefined; - - if (error && typeof error != 'string') { - errorMessage = CoreErrorHelper.getErrorMessageFromError(error); - } - - return this.showErrorModal( - typeof errorMessage == 'string' && errorMessage && error ? error : defaultError, - needsTranslate, - autocloseTime, - ); + return CoreAlerts.showError(error, { + autoCloseTime, + default: needsTranslate ? Translate.instant(defaultError) : defaultError, + }); } /** @@ -1112,16 +761,18 @@ export class CoreDomUtilsProvider { * @param warnings Warnings returned. * @param defaultError Message to show if the error is not a string. * @param needsTranslate Whether the error needs to be translated. - * @param autocloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. + * @param autoCloseTime Number of milliseconds to wait to close the modal. If not defined, modal won't be closed. * @returns Promise resolved with the alert modal. + * @deprecated since 5.0. Use CoreAlerts.showError instead. */ showErrorModalFirstWarning( warnings: CoreWSExternalWarning[], defaultError: string, needsTranslate?: boolean, - autocloseTime?: number, + autoCloseTime?: number, ): Promise { - return this.showErrorModalDefault(warnings?.[0], defaultError, needsTranslate, autocloseTime); + // eslint-disable-next-line deprecation/deprecation + return this.showErrorModalDefault(warnings?.[0], defaultError, needsTranslate, autoCloseTime); } /** @@ -1150,7 +801,7 @@ export class CoreDomUtilsProvider { try { return await operation(); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); return null; } finally { @@ -1164,35 +815,10 @@ export class CoreDomUtilsProvider { * @param message The warning message. * @param link Link to the app to download if any. * @returns Promise resolved when done. + * @deprecated since 5.0. Use CoreAlerts.showDownloadAppNotice instead. */ async showDownloadAppNoticeModal(message: string, link?: string): Promise { - const buttons: AlertButton[] = [{ - text: Translate.instant('core.ok'), - role: 'cancel', - }]; - - if (link) { - buttons.push({ - text: Translate.instant('core.download'), - handler: (): void => { - CoreOpener.openInBrowser(link, { showBrowserWarning: false }); - }, - }); - } - - const alert = await this.showAlertWithOptions({ - message: message, - buttons: buttons, - }); - - const isDevice = CorePlatform.isAndroid() || CorePlatform.isIOS(); - if (!isDevice) { - // Treat all anchors so they don't override the app. - const alertMessageEl: HTMLElement | null = alert.querySelector('.alert-message'); - alertMessageEl && this.treatAnchors(alertMessageEl); - } - - await alert.onDidDismiss(); + await CoreAlerts.showDownloadAppNotice(message, link); } /** @@ -1206,7 +832,7 @@ export class CoreDomUtilsProvider { * @param options Other alert options. * @returns Promise resolved with the input data (true for checkbox/radio) if the user clicks OK, rejected if cancels. */ - showPrompt( + async showPrompt( message: string, header?: string, placeholderOrLabel?: string, @@ -1214,72 +840,9 @@ export class CoreDomUtilsProvider { buttons?: PromptButton[] | { okText?: string; cancelText?: string }, options: AlertOptions = {}, ): Promise { // eslint-disable-line @typescript-eslint/no-explicit-any - return new Promise((resolve, reject) => { - placeholderOrLabel = placeholderOrLabel ?? Translate.instant('core.login.password'); + const { CorePrompts } = await import('../overlays/prompts'); - const isCheckbox = type === 'checkbox'; - const isRadio = type === 'radio'; - - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const resolvePromise = (data: any) => { - if (isCheckbox) { - resolve(data[0]); - } else if (isRadio) { - resolve(data); - } else { - resolve(data.promptinput); - } - }; - - options.header = header; - options.message = message; - options.inputs = [ - { - name: 'promptinput', - placeholder: placeholderOrLabel, - label: placeholderOrLabel, - type, - value: (isCheckbox || isRadio) ? true : undefined, - }, - ]; - - if (Array.isArray(buttons) && buttons.length) { - options.buttons = buttons.map((button) => ({ - ...button, - handler: (data) => { - if (!button.handler) { - // Just resolve the promise. - resolvePromise(data); - - return; - } - - button.handler(data, resolve, reject); - }, - })); - } else { - // Default buttons. - options.buttons = [ - { - text: buttons && 'cancelText' in buttons - ? buttons.cancelText as string - : Translate.instant('core.cancel'), - role: 'cancel', - handler: () => { - reject(); - }, - }, - { - text: buttons && 'okText' in buttons - ? buttons.okText as string - : Translate.instant('core.ok'), - handler: resolvePromise, - }, - ]; - } - - this.showAlertWithOptions(options); - }); + return CorePrompts.show(message, type, { ...options, header, placeholderOrLabel, buttons }); } /** @@ -1290,6 +853,7 @@ export class CoreDomUtilsProvider { * @param buttons Buttons to pass to the modal. * @param placeholder Placeholder of the input element if any. * @returns Promise resolved with the entered text if any. + * @deprecated since 5.0. Use CorePrompts.show instead. */ async showTextareaPrompt( title: string, @@ -1384,32 +948,6 @@ export class CoreDomUtilsProvider { return element.children; } - /** - * Treat anchors inside alert/modals. - * - * @param container The HTMLElement that can contain anchors. - */ - treatAnchors(container: HTMLElement): void { - const anchors = Array.from(container.querySelectorAll('a')); - - anchors.forEach((anchor) => { - anchor.addEventListener('click', (event) => { - if (event.defaultPrevented) { - // Stop. - return; - } - - const href = anchor.getAttribute('href'); - if (href) { - event.preventDefault(); - event.stopPropagation(); - - CoreOpener.openInBrowser(href); - } - }); - }); - } - /** * Opens a Modal. * @@ -1468,10 +1006,12 @@ export class CoreDomUtilsProvider { * @param passwordParams Params to show the modal. * @returns Entered password, error and validation. * - * @deprecated since 4.5. Use CoreModals.promptPassword instead. + * @deprecated since 4.5. Use CorePrompts.promptPassword instead. */ async promptPassword(passwordParams?: CorePasswordModalParams): Promise { - return CoreModals.promptPassword(passwordParams); + const { CorePrompts } = await import('../overlays/prompts'); + + return CorePrompts.promptPassword(passwordParams); } /** @@ -1627,14 +1167,6 @@ export class CoreDomUtilsProvider { export const CoreDomUtils = makeSingleton(CoreDomUtilsProvider); -/** - * Buttons for prompt alert. - */ -export type PromptButton = Omit & { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - handler?: (value: any, resolve: (value: any) => void, reject: (reason: any) => void) => void; -}; - /** * Vertical points for an element. */ diff --git a/src/core/services/utils/iframe.ts b/src/core/services/utils/iframe.ts index 2cdaeace1..852b16a95 100644 --- a/src/core/services/utils/iframe.ts +++ b/src/core/services/utils/iframe.ts @@ -38,6 +38,7 @@ import { CoreNative } from '@features/native/services/native'; import { CoreLoadings } from '@services/overlays/loadings'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreFileUtils } from '@singletons/file-utils'; +import { CoreAlerts } from '@services/overlays/alerts'; type CoreFrameElement = FrameElement & { window?: Window; @@ -456,7 +457,7 @@ export class CoreIframeUtilsProvider { // It's an external link or a local file, check if it can be opened in the app. await CoreWindow.open(url, name); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } } @@ -493,7 +494,7 @@ export class CoreIframeUtilsProvider { event?.preventDefault(); await CoreWindow.open(link.href, link.target); } catch (error) { - CoreDomUtils.showErrorModal(error); + CoreAlerts.showError(error); } } @@ -565,7 +566,7 @@ export class CoreIframeUtilsProvider { * Open help modal for iframes. */ openIframeHelpModal(): void { - CoreDomUtils.showAlertWithOptions({ + CoreAlerts.show({ header: Translate.instant('core.settings.ioscookies'), message: Translate.instant('core.ioscookieshelp'), buttons: [ @@ -632,7 +633,7 @@ export class CoreIframeUtilsProvider { if (localUrl) { CoreOpener.openFile(localUrl); } else { - CoreDomUtils.showErrorModal('core.networkerrormsg', true); + CoreAlerts.showError(Translate.instant('core.networkerrormsg')); } return; diff --git a/src/core/singletons/opener.ts b/src/core/singletons/opener.ts index a7f037b56..c8fbc59ac 100644 --- a/src/core/singletons/opener.ts +++ b/src/core/singletons/opener.ts @@ -27,9 +27,9 @@ import { CorePromiseUtils } from './promise-utils'; import { CoreUrl } from './url'; import { CoreLogger } from './logger'; import { CoreConfig } from '@services/config'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreEvents } from '@singletons/events'; import { CoreColors } from './colors'; +import { CorePrompts } from '@services/overlays/prompts'; /** * Singleton with helper functions to handler open files and urls. @@ -65,12 +65,9 @@ export class CoreOpener { .replace(/token=[^&#]+/gi, 'token=secret') .replace(/tokenpluginfile\.php\/[^/]+/gi, 'tokenpluginfile.php/secret'); - const dontShowAgain = await CoreDomUtils.showPrompt( - Translate.instant('core.warnopeninbrowser', { url }), - undefined, - Translate.instant('core.dontshowagain'), - 'checkbox', - ); + const dontShowAgain = await CorePrompts.show(Translate.instant('core.warnopeninbrowser', { url }), 'checkbox', { + placeholderOrLabel: Translate.instant('core.dontshowagain'), + }); if (dontShowAgain) { CoreConfig.set(CoreConstants.SETTINGS_DONT_SHOW_EXTERNAL_LINK_WARN, 1); From 9e006424f6e4c0705e4af2ef866c95aab7cd40c5 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 13 Jan 2025 08:32:20 +0100 Subject: [PATCH 3/5] MOBILE-4724 core: Move showOperationModals to CoreLoadings --- .github/workflows/testing.yml | 2 +- src/addons/mod/forum/pages/search/search.ts | 4 ++-- .../pages/global-search/global-search.ts | 6 ++--- src/core/features/settings/pages/dev/dev.ts | 4 ++-- src/core/services/overlays/alerts.ts | 19 +++++++++------ src/core/services/overlays/loadings.ts | 23 +++++++++++++++++++ src/core/services/utils/dom.ts | 13 ++--------- 7 files changed, 45 insertions(+), 26 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 546d1db53..d51c2f17f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -69,7 +69,7 @@ jobs: cat circular-dependencies lines=$(cat circular-dependencies | wc -l) echo "Total circular dependencies: $lines" - test $lines -eq 90 + test $lines -eq 93 - name: JavaScript code compatibility run: | npx check-es-compat www/*.js --polyfills="\{Array,String,TypedArray\}.prototype.at,Object.hasOwn" diff --git a/src/addons/mod/forum/pages/search/search.ts b/src/addons/mod/forum/pages/search/search.ts index 24abb8c17..a79612d0b 100644 --- a/src/addons/mod/forum/pages/search/search.ts +++ b/src/addons/mod/forum/pages/search/search.ts @@ -26,12 +26,12 @@ import { import { CoreAnalytics, CoreAnalyticsEventType } from '@services/analytics'; import { CoreNavigator } from '@services/navigator'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreUrl } from '@singletons/url'; import { CoreUtils } from '@singletons/utils'; import { Translate } from '@singletons'; import { CorePromiseUtils } from '@singletons/promise-utils'; import { CoreAlerts } from '@services/overlays/alerts'; +import { CoreLoadings } from '@services/overlays/loadings'; @Component({ selector: 'page-addon-mod-forum-search', @@ -104,7 +104,7 @@ export class AddonModForumSearchPage implements OnInit { return; } - await CoreDomUtils.showOperationModals('core.searching', true, async () => { + await CoreLoadings.showOperationModals('core.searching', true, async () => { await this.resultsSource.reload(); await CorePromiseUtils.ignoreErrors( CoreSearchGlobalSearch.logViewResults(this.resultsSource.getQuery(), this.resultsSource.getFilters()), diff --git a/src/core/features/search/pages/global-search/global-search.ts b/src/core/features/search/pages/global-search/global-search.ts index 2e05b430f..b00dfb355 100644 --- a/src/core/features/search/pages/global-search/global-search.ts +++ b/src/core/features/search/pages/global-search/global-search.ts @@ -13,7 +13,6 @@ // limitations under the License. import { Component, OnInit, OnDestroy, AfterViewInit, ViewChild } from '@angular/core'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreSearchGlobalSearchResultsSource } from '@features/search/classes/global-search-results-source'; import { CoreSites } from '@services/sites'; import { CoreUtils } from '@singletons/utils'; @@ -31,6 +30,7 @@ import { CoreNavigator } from '@services/navigator'; import { CoreSearchBoxComponent } from '@features/search/components/search-box/search-box'; import { CoreModals } from '@services/overlays/modals'; import { CorePromiseUtils } from '@singletons/promise-utils'; +import { CoreLoadings } from '@services/overlays/loadings'; @Component({ selector: 'page-core-search-global-search', @@ -103,7 +103,7 @@ export class CoreSearchGlobalSearchPage implements OnInit, OnDestroy, AfterViewI return; } - await CoreDomUtils.showOperationModals('core.searching', true, async () => { + await CoreLoadings.showOperationModals('core.searching', true, async () => { await this.resultsSource.reload(); await CorePromiseUtils.ignoreErrors( CoreSearchGlobalSearch.logViewResults(this.resultsSource.getQuery(), this.resultsSource.getFilters()), @@ -150,7 +150,7 @@ export class CoreSearchGlobalSearchPage implements OnInit, OnDestroy, AfterViewI }); if (!this.resultsSource.hasEmptyQuery() && this.resultsSource.isDirty()) { - await CoreDomUtils.showOperationModals('core.searching', true, () => this.resultsSource.reload()); + await CoreLoadings.showOperationModals('core.searching', true, () => this.resultsSource.reload()); } } diff --git a/src/core/features/settings/pages/dev/dev.ts b/src/core/features/settings/pages/dev/dev.ts index bf8a017e2..ecc05f8e9 100644 --- a/src/core/features/settings/pages/dev/dev.ts +++ b/src/core/features/settings/pages/dev/dev.ts @@ -29,10 +29,10 @@ import { CoreFile } from '@services/file'; import { CoreNavigator } from '@services/navigator'; import { CorePlatform } from '@services/platform'; import { CoreSites } from '@services/sites'; -import { CoreDomUtils } from '@services/utils/dom'; import { CoreToasts, ToastDuration } from '@services/overlays/toasts'; import { CoreText } from '@singletons/text'; import { CoreAlerts } from '@services/overlays/alerts'; +import { CoreLoadings } from '@services/overlays/loadings'; /** * Page that displays the developer options. @@ -225,7 +225,7 @@ export class CoreSettingsDevPage implements OnInit { * Invalidate app caches. */ async invalidateCaches(): Promise { - const success = await CoreDomUtils.showOperationModals('Invalidating caches', false, async () => { + const success = await CoreLoadings.showOperationModals('Invalidating caches', false, async () => { await CoreCacheManager.invalidate(); return true; diff --git a/src/core/services/overlays/alerts.ts b/src/core/services/overlays/alerts.ts index 338388b8a..9223a357a 100644 --- a/src/core/services/overlays/alerts.ts +++ b/src/core/services/overlays/alerts.ts @@ -71,8 +71,7 @@ export class CoreAlertsService { confirm(message: string, options: CoreAlertsConfirmOptions = {}): Promise { return new Promise((resolve, reject): void => { const { okText, cancelText, ...alertOptions } = options; - - ( alertOptions).buttons = [ + const buttons = [ { text: cancelText || Translate.instant('core.cancel'), role: 'cancel', @@ -88,11 +87,17 @@ export class CoreAlertsService { }, ]; + let cssClass = alertOptions.cssClass || ''; if (!alertOptions.header) { - options.cssClass = (options.cssClass || '') + ' core-nohead'; + cssClass = cssClass + ' core-nohead'; } - this.show(options); + this.show({ + ...alertOptions, + message, + buttons, + cssClass, + }); }); } @@ -129,11 +134,11 @@ export class CoreAlertsService { }, ]; - if (!options.header) { - options.cssClass = (options.cssClass || '') + ' core-nohead'; + if (!alertOptions.header) { + alertOptions.cssClass = (alertOptions.cssClass || '') + ' core-nohead'; } - this.show(options); + this.show(alertOptions); }); } diff --git a/src/core/services/overlays/loadings.ts b/src/core/services/overlays/loadings.ts index a5d3c8007..ea3bdae4b 100644 --- a/src/core/services/overlays/loadings.ts +++ b/src/core/services/overlays/loadings.ts @@ -15,6 +15,7 @@ import { Injectable } from '@angular/core'; import { CoreIonLoadingElement } from '@classes/ion-loading'; import { Translate, makeSingleton } from '@singletons'; +import { CoreAlerts } from './alerts'; /** * Handles application loading. @@ -60,6 +61,28 @@ export class CoreLoadingsService { return loading; } + /** + * Show a loading modal whilst an operation is running, and an error modal if it fails. + * + * @param text Loading dialog text. + * @param needsTranslate Whether the 'text' needs to be translated. + * @param operation Operation. + * @returns Operation result. + */ + async showOperationModals(text: string, needsTranslate: boolean, operation: () => Promise): Promise { + const modal = await this.show(text, needsTranslate); + + try { + return await operation(); + } catch (error) { + CoreAlerts.showError(error); + + return null; + } finally { + modal.dismiss(); + } + } + /** * Pauses the active loading modal. */ diff --git a/src/core/services/utils/dom.ts b/src/core/services/utils/dom.ts index 2b2149717..51e55a30e 100644 --- a/src/core/services/utils/dom.ts +++ b/src/core/services/utils/dom.ts @@ -794,19 +794,10 @@ export class CoreDomUtilsProvider { * @param needsTranslate Whether the 'text' needs to be translated. * @param operation Operation. * @returns Operation result. + * @deprecated since 5.0. Use CoreLoadings.showOperationModals instead. */ async showOperationModals(text: string, needsTranslate: boolean, operation: () => Promise): Promise { - const modal = await CoreLoadings.show(text, needsTranslate); - - try { - return await operation(); - } catch (error) { - CoreAlerts.showError(error); - - return null; - } finally { - modal.dismiss(); - } + return CoreLoadings.showOperationModals(text, needsTranslate, operation); } /** From c51cca9fd3b1476db21e3878f8cc4b01166851af Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 13 Jan 2025 10:05:00 +0100 Subject: [PATCH 4/5] MOBILE-4724 ux: Change confirm message when leaving page --- scripts/langindex.json | 5 ++- .../blog/pages/edit-entry/edit-entry.ts | 3 +- .../calendar/pages/edit-event/edit-event.ts | 2 +- .../edit-feedback-modal.ts | 4 +- .../components/submission/submission.ts | 2 +- src/addons/mod/assign/pages/edit/edit.ts | 2 +- src/addons/mod/data/pages/edit/edit.ts | 2 +- src/addons/mod/feedback/pages/form/form.ts | 2 +- .../mod/forum/pages/discussion/discussion.ts | 2 +- .../pages/new-discussion/new-discussion.ts | 2 +- src/addons/mod/glossary/pages/edit/edit.ts | 2 +- .../mod/h5pactivity/pages/index/index.ts | 3 +- src/addons/mod/lesson/pages/player/player.ts | 2 +- src/addons/mod/wiki/pages/edit/edit.ts | 2 +- .../workshop/pages/assessment/assessment.ts | 2 +- .../pages/edit-submission/edit-submission.ts | 2 +- .../workshop/pages/submission/submission.ts | 2 +- .../components/capture-media/capture-media.ts | 4 +- .../features/login/tests/behat/logout.feature | 14 +++--- src/core/lang.json | 5 ++- src/core/services/overlays/alerts.ts | 44 +++++++------------ .../tests/behat/navigation_deeplinks.feature | 5 ++- 22 files changed, 53 insertions(+), 60 deletions(-) diff --git a/scripts/langindex.json b/scripts/langindex.json index 9e6a56dc5..66eb70568 100644 --- a/scripts/langindex.json +++ b/scripts/langindex.json @@ -1561,9 +1561,9 @@ "core.completion-alt-manual-n-override": "completion", "core.completion-alt-manual-y": "completion", "core.completion-alt-manual-y-override": "completion", - "core.confirmcanceledit": "local_moodlemobileapp", "core.confirmdeletefile": "repository", - "core.confirmleaveunknownchanges": "local_moodlemobileapp", + "core.confirmleavepagedescription": "local_moodlemobileapp", + "core.confirmleavepagetitle": "local_moodlemobileapp", "core.confirmloss": "local_moodlemobileapp", "core.confirmopeninbrowser": "local_moodlemobileapp", "core.confirmremoveselectedfile": "local_moodlemobileapp", @@ -2091,6 +2091,7 @@ "core.lastmodified": "moodle", "core.lastsync": "local_moodlemobileapp", "core.layoutgrid": "workshopform_rubric", + "core.leave": "local_moodlemobileapp", "core.list": "moodle", "core.listsep": "langconfig", "core.loading": "moodle", diff --git a/src/addons/blog/pages/edit-entry/edit-entry.ts b/src/addons/blog/pages/edit-entry/edit-entry.ts index 778667479..c1018222a 100644 --- a/src/addons/blog/pages/edit-entry/edit-entry.ts +++ b/src/addons/blog/pages/edit-entry/edit-entry.ts @@ -41,7 +41,6 @@ import { CoreNetwork } from '@services/network'; import { CoreSites, CoreSitesReadingStrategy } from '@services/sites'; import { CoreSync } from '@services/sync'; import { CoreWSError } from '@classes/errors/wserror'; -import { Translate } from '@singletons'; import { CoreEvents } from '@singletons/events'; import { CoreForms } from '@singletons/form'; import { CoreFileEntry } from '@services/file-helper'; @@ -412,7 +411,7 @@ export default class AddonBlogEditEntryPage implements CanLeave, OnInit, OnDestr if ((!this.entry && this.hasDataChangedForNewEntry) || (this.entry && this.hasDataChangedForEdit)) { // Modified, confirm user wants to go back. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId()); diff --git a/src/addons/calendar/pages/edit-event/edit-event.ts b/src/addons/calendar/pages/edit-event/edit-event.ts index 4aeee891f..f1a5d3bbb 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.ts +++ b/src/addons/calendar/pages/edit-event/edit-event.ts @@ -593,7 +593,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { async canLeave(): Promise { if (AddonCalendarHelper.hasEventDataChanged(this.form.value, this.originalData)) { // Show confirmation if some data has been modified. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } CoreForms.triggerFormCancelledEvent(this.formElement, this.currentSite.getId()); diff --git a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts index 361259fc7..5bc1dc7de 100644 --- a/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts +++ b/src/addons/mod/assign/components/edit-feedback-modal/edit-feedback-modal.ts @@ -16,7 +16,7 @@ import { Component, Input, ViewChild, ElementRef } from '@angular/core'; import { CoreSites } from '@services/sites'; import { CoreFormFields, CoreForms } from '@singletons/form'; import { CorePromiseUtils } from '@singletons/promise-utils'; -import { ModalController, Translate } from '@singletons'; +import { ModalController } from '@singletons'; import { AddonModAssignAssign, AddonModAssignPlugin, AddonModAssignSubmission } from '../../services/assign'; import { AddonModAssignFeedbackDelegate } from '../../services/feedback-delegate'; import { CoreSharedModule } from '@/core/shared.module'; @@ -50,7 +50,7 @@ export class AddonModAssignEditFeedbackModalComponent { async closeModal(): Promise { const changed = await this.hasDataChanged(); if (changed) { - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId()); diff --git a/src/addons/mod/assign/components/submission/submission.ts b/src/addons/mod/assign/components/submission/submission.ts index ba0d03cf4..d0d7c9a96 100644 --- a/src/addons/mod/assign/components/submission/submission.ts +++ b/src/addons/mod/assign/components/submission/submission.ts @@ -296,7 +296,7 @@ export class AddonModAssignSubmissionComponent implements OnInit, OnDestroy, Can if (modified) { // Modified, confirm user wants to go back. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); await this.discardDrafts(); } diff --git a/src/addons/mod/assign/pages/edit/edit.ts b/src/addons/mod/assign/pages/edit/edit.ts index 645d2c4ff..c2b917f99 100644 --- a/src/addons/mod/assign/pages/edit/edit.ts +++ b/src/addons/mod/assign/pages/edit/edit.ts @@ -125,7 +125,7 @@ export class AddonModAssignEditPage implements OnInit, OnDestroy, CanLeave { // Check if data has changed. const changed = await this.hasDataChanged(); if (changed) { - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } // Nothing has changed or user confirmed to leave. Clear temporary data from plugins. diff --git a/src/addons/mod/data/pages/edit/edit.ts b/src/addons/mod/data/pages/edit/edit.ts index dea968bde..d03763942 100644 --- a/src/addons/mod/data/pages/edit/edit.ts +++ b/src/addons/mod/data/pages/edit/edit.ts @@ -156,7 +156,7 @@ export class AddonModDataEditPage implements OnInit { if (changed) { // Show confirmation if some data has been modified. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } // Delete the local files from the tmp folder. diff --git a/src/addons/mod/feedback/pages/form/form.ts b/src/addons/mod/feedback/pages/form/form.ts index 935a1b3ae..e176ee5d1 100644 --- a/src/addons/mod/feedback/pages/form/form.ts +++ b/src/addons/mod/feedback/pages/form/form.ts @@ -160,7 +160,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave { if (this.items && !this.completed && this.originalData) { // Form submitted. Check if there is any change. if (!CoreObject.basicLeftCompare(responses, this.originalData, 3)) { - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } } } diff --git a/src/addons/mod/forum/pages/discussion/discussion.ts b/src/addons/mod/forum/pages/discussion/discussion.ts index 9ba5e03ae..3e89ed320 100644 --- a/src/addons/mod/forum/pages/discussion/discussion.ts +++ b/src/addons/mod/forum/pages/discussion/discussion.ts @@ -303,7 +303,7 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes async canLeave(): Promise { if (AddonModForumHelper.hasPostDataChanged(this.formData, this.originalData)) { // Show confirmation if some data has been modified. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } // Delete the local files from the tmp folder. diff --git a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts index 6a53b218e..20e5bbbaf 100644 --- a/src/addons/mod/forum/pages/new-discussion/new-discussion.ts +++ b/src/addons/mod/forum/pages/new-discussion/new-discussion.ts @@ -662,7 +662,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea if (AddonModForumHelper.hasPostDataChanged(this.newDiscussion, this.originalData)) { // Show confirmation if some data has been modified. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } // Delete the local files from the tmp folder. diff --git a/src/addons/mod/glossary/pages/edit/edit.ts b/src/addons/mod/glossary/pages/edit/edit.ts index 0c4800d8c..65be7888b 100644 --- a/src/addons/mod/glossary/pages/edit/edit.ts +++ b/src/addons/mod/glossary/pages/edit/edit.ts @@ -187,7 +187,7 @@ export class AddonModGlossaryEditPage implements OnInit, CanLeave { if (this.hasDataChanged()) { // Show confirmation if some data has been modified. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } // Delete the local files from the tmp folder. diff --git a/src/addons/mod/h5pactivity/pages/index/index.ts b/src/addons/mod/h5pactivity/pages/index/index.ts index b6a100c89..9a3c16934 100644 --- a/src/addons/mod/h5pactivity/pages/index/index.ts +++ b/src/addons/mod/h5pactivity/pages/index/index.ts @@ -16,7 +16,6 @@ import { Component, OnDestroy, ViewChild } from '@angular/core'; import { CoreCourseModuleMainActivityPage } from '@features/course/classes/main-activity-page'; import { CanLeave } from '@guards/can-leave'; -import { Translate } from '@singletons'; import { AddonModH5PActivityIndexComponent } from '../../components/index'; import { CoreAlerts } from '@services/overlays/alerts'; @@ -45,7 +44,7 @@ export class AddonModH5PActivityIndexPage extends CoreCourseModuleMainActivityPa if (!this.canLeaveSafely) { try { - await CoreAlerts.confirm(Translate.instant('core.confirmleaveunknownchanges')); + await CoreAlerts.confirmLeaveWithChanges(); return true; } catch { diff --git a/src/addons/mod/lesson/pages/player/player.ts b/src/addons/mod/lesson/pages/player/player.ts index 6ed71931e..7d64ce768 100644 --- a/src/addons/mod/lesson/pages/player/player.ts +++ b/src/addons/mod/lesson/pages/player/player.ts @@ -173,7 +173,7 @@ export class AddonModLessonPlayerPage implements OnInit, OnDestroy, CanLeave { if (this.question && !this.eolData && !this.processData && this.originalData) { // Question shown. Check if there is any change. if (!CoreObject.basicLeftCompare(this.questionForm.getRawValue(), this.originalData, 3)) { - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } } diff --git a/src/addons/mod/wiki/pages/edit/edit.ts b/src/addons/mod/wiki/pages/edit/edit.ts index ba130fc5d..481b42484 100644 --- a/src/addons/mod/wiki/pages/edit/edit.ts +++ b/src/addons/mod/wiki/pages/edit/edit.ts @@ -337,7 +337,7 @@ export class AddonModWikiEditPage implements OnInit, OnDestroy, CanLeave { // Check if data has changed. if (this.hasDataChanged()) { - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId()); diff --git a/src/addons/mod/workshop/pages/assessment/assessment.ts b/src/addons/mod/workshop/pages/assessment/assessment.ts index 98f55d960..4e7fe8954 100644 --- a/src/addons/mod/workshop/pages/assessment/assessment.ts +++ b/src/addons/mod/workshop/pages/assessment/assessment.ts @@ -172,7 +172,7 @@ export class AddonModWorkshopAssessmentPage implements OnInit, OnDestroy, CanLea } // Show confirmation if some data has been modified. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); CoreForms.triggerFormCancelledEvent(this.formElement, this.siteId); diff --git a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts index 0c88f0567..ec851b200 100644 --- a/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts +++ b/src/addons/mod/workshop/pages/edit-submission/edit-submission.ts @@ -147,7 +147,7 @@ export class AddonModWorkshopEditSubmissionPage implements OnInit, OnDestroy, Ca // Check if data has changed. if (this.hasDataChanged()) { // Show confirmation if some data has been modified. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } if (this.submission?.attachmentfiles) { diff --git a/src/addons/mod/workshop/pages/submission/submission.ts b/src/addons/mod/workshop/pages/submission/submission.ts index 6d36c33a3..36c334c89 100644 --- a/src/addons/mod/workshop/pages/submission/submission.ts +++ b/src/addons/mod/workshop/pages/submission/submission.ts @@ -184,7 +184,7 @@ export class AddonModWorkshopSubmissionPage implements OnInit, OnDestroy, CanLea } // Show confirmation if some data has been modified. - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); CoreForms.triggerFormCancelledEvent(this.formElement, this.siteId); diff --git a/src/core/features/emulator/components/capture-media/capture-media.ts b/src/core/features/emulator/components/capture-media/capture-media.ts index d16c4f24c..fdc9c7cc5 100644 --- a/src/core/features/emulator/components/capture-media/capture-media.ts +++ b/src/core/features/emulator/components/capture-media/capture-media.ts @@ -18,7 +18,7 @@ import { MediaFile } from '@awesome-cordova-plugins/media-capture/ngx'; import { CoreFile, CoreFileProvider } from '@services/file'; import { CoreMimetypeUtils } from '@services/utils/mimetype'; import { CoreTimeUtils } from '@services/utils/time'; -import { ModalController, Translate } from '@singletons'; +import { ModalController } from '@singletons'; import { CoreError } from '@classes/errors/error'; import { CoreCaptureError } from '@classes/errors/captureerror'; import { CoreCanceledError } from '@classes/errors/cancelederror'; @@ -235,7 +235,7 @@ export class CoreEmulatorCaptureMediaComponent implements OnInit, OnDestroy { async cancel(): Promise { if (this.hasCaptured) { try { - await CoreAlerts.confirm(Translate.instant('core.confirmcanceledit')); + await CoreAlerts.confirmLeaveWithChanges(); } catch { // Canceled. return; diff --git a/src/core/features/login/tests/behat/logout.feature b/src/core/features/login/tests/behat/logout.feature index 15b1ebb73..07aaa06c2 100755 --- a/src/core/features/login/tests/behat/logout.feature +++ b/src/core/features/login/tests/behat/logout.feature @@ -87,12 +87,13 @@ Feature: Test different cases of logout and switch account | Message | An awesome message | And I press the user menu button in the app And I press "Log out" in the app - Then I should find "Are you sure you want to leave this page?" in the app + Then I should find "Leave page?" in the app + And I should find "Unsaved changes will be lost." in the app # Check that the app continues working fine if the user cancels the logout. When I press "Cancel" in the app And I press "Forum topic 1" in the app - And I press "OK" in the app + And I press "Leave" in the app Then I should find "Forum message 1" in the app When I press "Forum topic 2" in the app @@ -105,7 +106,7 @@ Feature: Test different cases of logout and switch account | Message | An awesome message | And I press the user menu button in the app And I press "Log out" in the app - And I press "OK" in the app + And I press "Leave" in the app And I wait the app to restart Then the header should be "Accounts" in the app @@ -135,12 +136,13 @@ Feature: Test different cases of logout and switch account And I press the user menu button in the app And I press "Switch account" in the app And I press "pau student2" in the app - Then I should find "Are you sure you want to leave this page?" in the app + Then I should find "Leave page?" in the app + And I should find "Unsaved changes will be lost." in the app # Check that the app continues working fine if the user cancels the switch account. When I press "Cancel" in the app And I press "Forum topic 1" in the app - And I press "OK" in the app + And I press "Leave" in the app Then I should find "Forum message 1" in the app When I press "Forum topic 2" in the app @@ -154,7 +156,7 @@ Feature: Test different cases of logout and switch account And I press the user menu button in the app And I press "Switch account" in the app And I press "pau student2" in the app - And I press "OK" in the app + And I press "Leave" in the app And I wait the app to restart And I press the user menu button in the app Then I should find "pau student2" in the app diff --git a/src/core/lang.json b/src/core/lang.json index a4a3981d3..c0857841d 100644 --- a/src/core/lang.json +++ b/src/core/lang.json @@ -48,9 +48,9 @@ "completion-alt-manual-n-override": "Not completed: {{$a.modname}} (set by {{$a.overrideuser}}). Select to mark as complete.", "completion-alt-manual-y": "Completed: {{$a}}. Select to mark as not complete.", "completion-alt-manual-y-override": "Completed: {{$a.modname}} (set by {{$a.overrideuser}}). Select to mark as not complete.", - "confirmcanceledit": "Are you sure you want to leave this page? All changes will be lost.", "confirmdeletefile": "Are you sure you want to delete this file?", - "confirmleaveunknownchanges": "Are you sure you want to leave this page? If you have unsaved changes they will be lost.", + "confirmleavepagedescription": "Unsaved changes will be lost.", + "confirmleavepagetitle": "Leave page?", "confirmloss": "Are you sure? All changes will be lost.", "confirmopeninbrowser": "Do you want to open it in a web browser?", "confirmremoveselectedfile": "This will permanently delete '{{filename}}'. You can't undo this.", @@ -168,6 +168,7 @@ "lastmodified": "Last modified", "lastsync": "Last synchronisation", "layoutgrid": "Grid", + "leave": "Leave", "list": "List", "listsep": ",", "loading": "Loading", diff --git a/src/core/services/overlays/alerts.ts b/src/core/services/overlays/alerts.ts index 9223a357a..4407cc342 100644 --- a/src/core/services/overlays/alerts.ts +++ b/src/core/services/overlays/alerts.ts @@ -70,7 +70,7 @@ export class CoreAlertsService { */ confirm(message: string, options: CoreAlertsConfirmOptions = {}): Promise { return new Promise((resolve, reject): void => { - const { okText, cancelText, ...alertOptions } = options; + const { okText, cancelText, isDestructive, ...alertOptions } = options; const buttons = [ { text: cancelText || Translate.instant('core.cancel'), @@ -81,6 +81,7 @@ export class CoreAlertsService { }, { text: okText || Translate.instant('core.ok'), + role: isDestructive ? 'destructive' : undefined, handler: (data: T) => { resolve(data); }, @@ -111,34 +112,22 @@ export class CoreAlertsService { async confirmDelete(message: string, options: Omit = {}): Promise { message = await CoreLang.filterMultilang(message); - const alertOptions: AlertOptions = { + await this.confirm(message, { ...options, - message, - }; + okText: Translate.instant('core.delete'), + isDestructive: true, + }); + } - return new Promise((resolve, reject): void => { - alertOptions.buttons = [ - { - text: Translate.instant('core.cancel'), - role: 'cancel', - handler: () => { - reject(new CoreCanceledError()); - }, - }, - { - text: Translate.instant('core.delete'), - role: 'destructive', - handler: () => { - resolve(); - }, - }, - ]; - - if (!alertOptions.header) { - alertOptions.cssClass = (alertOptions.cssClass || '') + ' core-nohead'; - } - - this.show(alertOptions); + /** + * Show a confirmation modal to confirm leaving a page with unsaves changes. + * + * @returns Promise resolved if the user confirms and rejected with a canceled error if he cancels. + */ + async confirmLeaveWithChanges(): Promise { + await this.confirm(Translate.instant('core.confirmleavepagedescription'), { + header: Translate.instant('core.confirmleavepagetitle'), + okText: Translate.instant('core.leave'), }); } @@ -504,6 +493,7 @@ export const CoreAlerts = makeSingleton(CoreAlertsService); export type CoreAlertsConfirmOptions = Omit & { okText?: string; // Text of the OK button. By default, 'OK'. cancelText?: string; // Text of the Cancel button. By default, 'Cancel'. + isDestructive?: boolean; // Whether confirming is destructive (will remove data), so the button will have a danger color. }; /** diff --git a/src/core/tests/behat/navigation_deeplinks.feature b/src/core/tests/behat/navigation_deeplinks.feature index 7f858d53b..ed387b757 100644 --- a/src/core/tests/behat/navigation_deeplinks.feature +++ b/src/core/tests/behat/navigation_deeplinks.feature @@ -155,7 +155,8 @@ Feature: It navigates properly using deep links. Then I should find "This link belongs to another site" in the app When I press "OK" in the app - Then I should find "Are you sure you want to leave this page?" in the app + Then I should find "Leave page?" in the app + And I should find "Unsaved changes will be lost." in the app When I press "Cancel" in the app Then I should not find "Forum message" in the app @@ -164,7 +165,7 @@ Feature: It navigates properly using deep links. | discussion | user | | Forum topic | student2 | And I press "OK" in the app - And I press "OK" in the app + And I press "Leave" in the app And I wait the app to restart Then I should find "Forum topic" in the app And I should find "Forum message" in the app From 239ed82697d0a9ff0219473598220fee4fcda8d2 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 13 Jan 2025 10:28:50 +0100 Subject: [PATCH 5/5] MOBILE-4724 calendar: Fix confirm not shown when leaving --- src/addons/calendar/calendar-lazy.module.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/addons/calendar/calendar-lazy.module.ts b/src/addons/calendar/calendar-lazy.module.ts index 538c6c366..c8dd05fe1 100644 --- a/src/addons/calendar/calendar-lazy.module.ts +++ b/src/addons/calendar/calendar-lazy.module.ts @@ -26,6 +26,7 @@ import { CoreMainMenuComponentsModule } from '@features/mainmenu/components/comp import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { ADDON_CALENDAR_PAGE_NAME } from './constants'; +import { canLeaveGuard } from '@guards/can-leave'; /** * Build module routes. @@ -55,6 +56,7 @@ function buildRoutes(injector: Injector): Routes { { path: 'edit/:eventId', component: AddonCalendarEditEventPage, + canDeactivate: [canLeaveGuard], }, ...buildTabMainRoutes(injector, { redirectTo: 'index',