MOBILE-3833 calendar: Remove unused splitview on calendar

main
Pau Ferrer Ocaña 2021-09-10 12:31:54 +02:00
parent d63e750580
commit d8bab320d7
4 changed files with 31 additions and 76 deletions

View File

@ -13,22 +13,11 @@
// limitations under the License. // limitations under the License.
import { Injector, NgModule } from '@angular/core'; 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 { buildTabMainRoutes } from '@features/mainmenu/mainmenu-tab-routing.module';
import { AddonCalendarMainMenuHandlerService } from './services/handlers/mainmenu'; 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 { function buildRoutes(injector: Injector): Routes {
return [ return [
{ {
@ -48,8 +37,15 @@ function buildRoutes(injector: Injector): Routes {
loadChildren: () => loadChildren: () =>
import('@/addons/calendar/pages/day/day.module').then(m => m.AddonCalendarDayPageModule), 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, { ...buildTabMainRoutes(injector, {
redirectTo: 'index', redirectTo: 'index',
pathMatch: 'full', pathMatch: 'full',

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // 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 { FormControl, FormGroup, FormBuilder, Validators } from '@angular/forms';
import { IonRefresher } from '@ionic/angular'; import { IonRefresher } from '@ionic/angular';
import { CoreEvents } from '@singletons/events'; import { CoreEvents } from '@singletons/events';
@ -23,7 +23,6 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreTimeUtils } from '@services/utils/time'; import { CoreTimeUtils } from '@services/utils/time';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreCategoryData, CoreCourses, CoreCourseSearchedData, CoreEnrolledCourseData } from '@features/courses/services/courses'; 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 { CoreEditorRichTextEditorComponent } from '@features/editor/components/rich-text-editor/rich-text-editor';
import { import {
AddonCalendarProvider, AddonCalendarProvider,
@ -94,7 +93,6 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
constructor( constructor(
protected fb: FormBuilder, protected fb: FormBuilder,
@Optional() protected svComponent: CoreSplitViewComponent,
) { ) {
this.currentSite = CoreSites.getRequiredCurrentSite(); this.currentSite = CoreSites.getRequiredCurrentSite();
this.errors = { this.errors = {
@ -572,16 +570,9 @@ 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. this.originalData = undefined; // Avoid asking for confirmation.
CoreNavigator.back(); CoreNavigator.back();
} }
}
/** /**
* Discard an offline saved discussion. * Discard an offline saved discussion.

View File

@ -15,13 +15,8 @@
[contextInstanceId]="event.contextInstanceId"></core-format-text> [contextInstanceId]="event.contextInstanceId"></core-format-text>
</h1> </h1>
<ion-buttons slot="end"> <ion-buttons slot="end">
<!-- The context menu will be added in here. -->
</ion-buttons>
</ion-toolbar>
</ion-header>
<core-navbar-buttons slot="end">
<core-context-menu> <core-context-menu>
<core-context-menu-item [hidden]="isSplitViewOn || !eventLoaded || (!hasOffline && event && !event.deleted) || !isOnline" <core-context-menu-item [hidden]="!eventLoaded || (!hasOffline && event && !event.deleted) || !isOnline"
[priority]="400" [content]="'core.settings.synchronizenow' | translate" (action)="doRefresh(undefined, $event, true)" [priority]="400" [content]="'core.settings.synchronizenow' | translate" (action)="doRefresh(undefined, $event, true)"
[iconAction]="syncIcon" [closeOnClick]="false"> [iconAction]="syncIcon" [closeOnClick]="false">
</core-context-menu-item> </core-context-menu-item>
@ -34,7 +29,9 @@
<core-context-menu-item [hidden]="!event || !event.deleted" [priority]="200" [content]="'core.restore' | translate" <core-context-menu-item [hidden]="!event || !event.deleted" [priority]="200" [content]="'core.restore' | translate"
(action)="undoDelete()" iconAction="fas-undo-alt"></core-context-menu-item> (action)="undoDelete()" iconAction="fas-undo-alt"></core-context-menu-item>
</core-context-menu> </core-context-menu>
</core-navbar-buttons> </ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content> <ion-content>
<ion-refresher slot="fixed" [disabled]="!eventLoaded" (ionRefresh)="doRefresh($event.target)"> <ion-refresher slot="fixed" [disabled]="!eventLoaded" (ionRefresh)="doRefresh($event.target)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content> <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
@ -50,33 +47,13 @@
<ion-card> <ion-card>
<ion-card-content *ngIf="event"> <ion-card-content *ngIf="event">
<ion-item class="ion-text-wrap" *ngIf="isSplitViewOn">
<img *ngIf="event.moduleIcon" src="{{event.moduleIcon}}" slot="start" alt="" role="presentation"
class="core-module-icon">
<ion-icon *ngIf="event.eventIcon && !event.moduleIcon" [name]="event.eventIcon" slot="start" aria-hidden="true">
</ion-icon>
<ion-label>
<span class="sr-only">
{{ 'addon.calendar.type' + event.formattedType | translate }}
<span class="sr-only" *ngIf="event.moduleIcon && event.iconTitle">{{ event.iconTitle }}</span>
</span>
<h2>{{ 'addon.calendar.eventname' | translate }}</h2>
<p>
<core-format-text [text]="event.name" [contextLevel]="event.contextLevel"
[contextInstanceId]="event.contextInstanceId"></core-format-text>
</p>
</ion-label>
<ion-note slot="end" *ngIf="event.deleted">
<ion-icon name="fas-trash" aria-hidden="true"></ion-icon> {{ 'core.deletedoffline' | translate }}
</ion-note>
</ion-item>
<ion-item> <ion-item>
<ion-label> <ion-label>
<h2>{{ 'addon.calendar.when' | translate }}</h2> <h2>{{ 'addon.calendar.when' | translate }}</h2>
<core-format-text [text]="event.formattedtime" [contextLevel]="event.contextLevel" <core-format-text [text]="event.formattedtime" [contextLevel]="event.contextLevel"
[contextInstanceId]="event.contextInstanceId"></core-format-text> [contextInstanceId]="event.contextInstanceId"></core-format-text>
</ion-label> </ion-label>
<ion-note slot="end" *ngIf="!isSplitViewOn && event.deleted"> <ion-note slot="end" *ngIf="event.deleted">
<ion-icon name="fas-trash" aria-hidden="true"></ion-icon> {{ 'core.deletedoffline' | translate }} <ion-icon name="fas-trash" aria-hidden="true"></ion-icon> {{ 'core.deletedoffline' | translate }}
</ion-note> </ion-note>
</ion-item> </ion-item>

View File

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