Skip to content

Commit

Permalink
Merge pull request moodlehq#4282 from dpalou/MOBILE-4724
Browse files Browse the repository at this point in the history
Mobile 4724
  • Loading branch information
crazyserver authored Jan 14, 2025
2 parents 11753a4 + 239ed82 commit 070fbc5
Show file tree
Hide file tree
Showing 264 changed files with 2,068 additions and 1,842 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions scripts/langindex.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/addons/badges/pages/badge-class/badge-class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.' });
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/addons/badges/pages/issued-badge/issued-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.
Expand Down Expand Up @@ -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.' });
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/addons/badges/pages/user-badges/user-badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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'];
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/addons/block/timeline/components/events/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 2 additions & 4 deletions src/addons/block/timeline/components/timeline/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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.
Expand Down Expand Up @@ -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[]);
}),
Expand Down
15 changes: 7 additions & 8 deletions src/addons/blog/pages/edit-entry/edit-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@ 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';
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';
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',
Expand Down Expand Up @@ -164,7 +163,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;
Expand Down Expand Up @@ -204,7 +203,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();

Expand Down Expand Up @@ -338,7 +337,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;
}
Expand All @@ -363,7 +362,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;
}
Expand Down Expand Up @@ -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 CoreDomUtils.showConfirm(Translate.instant('core.confirmcanceledit'));
await CoreAlerts.confirmLeaveWithChanges();
}

CoreForms.triggerFormCancelledEvent(this.formElement, CoreSites.getCurrentSiteId());
Expand Down
19 changes: 10 additions & 9 deletions src/addons/blog/pages/index/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ 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';
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';
import { CoreAlerts } from '@services/overlays/alerts';
import { Translate } from '@singletons';

/**
* Page that displays the list of blog entries.
Expand Down Expand Up @@ -236,15 +237,15 @@ 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) {
CoreEvents.trigger(ADDON_BLOG_MANUAL_SYNCED, { ...result, source: this });
}
} catch (error) {
if (showSyncErrors) {
CoreDomUtils.showErrorModalDefault(error, 'core.errorsync', true);
CoreAlerts.showError(error, { default: Translate.instant('core.errorsync') });
}
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -418,7 +419,7 @@ export class AddonBlogIndexPage implements OnInit, OnDestroy {
*/
async deleteEntry(entryToRemove: AddonBlogOfflinePostFormatted | AddonBlogPostFormatted): Promise<void> {
try {
await CoreDomUtils.showDeleteConfirm('addon.blog.blogdeleteconfirm', { $a: entryToRemove.subject });
await CoreAlerts.confirmDelete(Translate.instant('addon.blog.blogdeleteconfirm', { $a: entryToRemove.subject }));
} catch {
return;
}
Expand All @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions src/addons/calendar/calendar-lazy.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -55,6 +56,7 @@ function buildRoutes(injector: Injector): Routes {
{
path: 'edit/:eventId',
component: AddonCalendarEditEventPage,
canDeactivate: [canLeaveGuard],
},
...buildTabMainRoutes(injector, {
redirectTo: 'index',
Expand Down
6 changes: 3 additions & 3 deletions src/addons/calendar/components/calendar/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
Loading

0 comments on commit 070fbc5

Please sign in to comment.