diff --git a/src/addons/calendar/calendar-lazy.module.ts b/src/addons/calendar/calendar-lazy.module.ts index 5ead2dbca..20af6f9a7 100644 --- a/src/addons/calendar/calendar-lazy.module.ts +++ b/src/addons/calendar/calendar-lazy.module.ts @@ -13,22 +13,11 @@ // limitations under the License. import { Injector, NgModule } from '@angular/core'; -import { Route, RouterModule, ROUTES, Routes } from '@angular/router'; +import { RouterModule, ROUTES, Routes } from '@angular/router'; import { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module'; import { AddonCalendarMainMenuHandlerService } from './services/handlers/mainmenu'; -export const AddonCalendarEditRoute: Route = { - path: 'edit/:eventId', - loadChildren: () => - import('@/addons/calendar/pages/edit-event/edit-event.module').then(m => m.AddonCalendarEditEventPageModule), -}; - -export const AddonCalendarEventRoute: Route ={ - path: 'event/:id', - loadChildren: () => import('@/addons/calendar/pages/event/event.module').then(m => m.AddonCalendarEventPageModule), -}; - function buildRoutes(injector: Injector): Routes { return [ { @@ -48,8 +37,15 @@ function buildRoutes(injector: Injector): Routes { loadChildren: () => import('@/addons/calendar/pages/day/day.module').then(m => m.AddonCalendarDayPageModule), }, - AddonCalendarEventRoute, - AddonCalendarEditRoute, + { + path: 'event/:id', + loadChildren: () => import('@/addons/calendar/pages/event/event.module').then(m => m.AddonCalendarEventPageModule), + }, + { + path: 'edit/:eventId', + loadChildren: () => + import('@/addons/calendar/pages/edit-event/edit-event.module').then(m => m.AddonCalendarEditEventPageModule), + }, ...buildTabMainRoutes(injector, { redirectTo: 'index', pathMatch: 'full', diff --git a/src/addons/calendar/pages/edit-event/edit-event.page.ts b/src/addons/calendar/pages/edit-event/edit-event.page.ts index fee73d0aa..366e07fa9 100644 --- a/src/addons/calendar/pages/edit-event/edit-event.page.ts +++ b/src/addons/calendar/pages/edit-event/edit-event.page.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Component, OnInit, OnDestroy, ViewChild, ElementRef, Optional } from '@angular/core'; +import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core'; import { FormControl, FormGroup, FormBuilder, Validators } from '@angular/forms'; import { IonRefresher } from '@ionic/angular'; import { CoreEvents } from '@singletons/events'; @@ -23,7 +23,6 @@ import { CoreDomUtils } from '@services/utils/dom'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreUtils } from '@services/utils/utils'; import { CoreCategoryData, CoreCourses, CoreCourseSearchedData, CoreEnrolledCourseData } from '@features/courses/services/courses'; -import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { CoreEditorRichTextEditorComponent } from '@features/editor/components/rich-text-editor/rich-text-editor'; import { AddonCalendarProvider, @@ -94,7 +93,6 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { constructor( protected fb: FormBuilder, - @Optional() protected svComponent: CoreSplitViewComponent, ) { this.currentSite = CoreSites.getRequiredCurrentSite(); this.errors = { @@ -572,15 +570,8 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave { } } - if (this.svComponent?.outletActivated) { - // Empty form. - this.hasOffline = false; - this.form.reset(this.originalData); - this.originalData = CoreUtils.clone(this.form.value); - } else { - this.originalData = undefined; // Avoid asking for confirmation. - CoreNavigator.back(); - } + this.originalData = undefined; // Avoid asking for confirmation. + CoreNavigator.back(); } /** diff --git a/src/addons/calendar/pages/event/event.html b/src/addons/calendar/pages/event/event.html index 445329e5c..6244bc546 100644 --- a/src/addons/calendar/pages/event/event.html +++ b/src/addons/calendar/pages/event/event.html @@ -15,26 +15,23 @@ [contextInstanceId]="event.contextInstanceId"> - + + + + + + + + - - - - - - - - - - @@ -50,33 +47,13 @@ - - - - - - {{ 'addon.calendar.type' + event.formattedType | translate }} - {{ event.iconTitle }} - -

{{ 'addon.calendar.eventname' | translate }}

-

- -

-
- - {{ 'core.deletedoffline' | translate }} - -

{{ 'addon.calendar.when' | translate }}

- + {{ 'core.deletedoffline' | translate }}
diff --git a/src/addons/calendar/pages/event/event.page.ts b/src/addons/calendar/pages/event/event.page.ts index c449856b4..88d4597f9 100644 --- a/src/addons/calendar/pages/event/event.page.ts +++ b/src/addons/calendar/pages/event/event.page.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Component, OnDestroy, OnInit, Optional } from '@angular/core'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { IonRefresher } from '@ionic/angular'; import { AlertOptions } from '@ionic/core'; import { @@ -32,14 +32,12 @@ import { CoreLocalNotifications } from '@services/local-notifications'; import { CoreCourse } from '@features/course/services/course'; import { CoreTimeUtils } from '@services/utils/time'; import { CoreGroups } from '@services/groups'; -import { CoreSplitViewComponent } from '@components/split-view/split-view'; import { Network, NgZone, Translate } from '@singletons'; import { Subscription } from 'rxjs'; import { CoreNavigator } from '@services/navigator'; import { CoreUtils } from '@services/utils/utils'; import { AddonCalendarReminderDBRecord } from '../../services/database/calendar'; import { ActivatedRoute } from '@angular/router'; -import { CoreScreen } from '@services/screen'; import { CoreConstants } from '@/core/constants'; import { CoreLang } from '@services/lang'; @@ -81,18 +79,15 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { hasOffline = false; isOnline = false; syncIcon = CoreConstants.ICON_LOADING; // Sync icon. - isSplitViewOn = false; monthNames?: string[]; constructor( - @Optional() protected svComponent: CoreSplitViewComponent, protected route: ActivatedRoute, ) { this.notificationsEnabled = CoreLocalNotifications.isAvailable(); this.siteHomeId = CoreSites.getCurrentSiteHomeId(); this.currentSiteId = CoreSites.getCurrentSiteId(); - this.isSplitViewOn = this.svComponent?.outletActivated; // Check if site supports editing. No need to check allowed types, event.canedit already does it. this.canEdit = AddonCalendar.canEditEventsInSite(); @@ -480,9 +475,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { CoreDomUtils.showToast('addon.calendar.eventcalendareventdeleted', true, 3000); // Event deleted, close the view. - if (CoreScreen.isMobile) { - CoreNavigator.back(); - } + CoreNavigator.back(); } else { // Event deleted in offline, just mark it as deleted. this.event.deleted = true; @@ -537,9 +530,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy { CoreDomUtils.showToast('addon.calendar.eventcalendareventdeleted', true, 3000); // Event was deleted, close the view. - if (CoreScreen.isMobile) { - CoreNavigator.back(); - } + CoreNavigator.back(); } else if (data.events && (!isManual || data.source != 'event')) { const event = data.events.find((ev) => ev.id == this.eventId);