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.
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',

View File

@ -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();
}
/**

View File

@ -15,26 +15,23 @@
[contextInstanceId]="event.contextInstanceId"></core-format-text>
</h1>
<ion-buttons slot="end">
<!-- The context menu will be added in here. -->
<core-context-menu>
<core-context-menu-item [hidden]="!eventLoaded || (!hasOffline && event && !event.deleted) || !isOnline"
[priority]="400" [content]="'core.settings.synchronizenow' | translate" (action)="doRefresh(undefined, $event, true)"
[iconAction]="syncIcon" [closeOnClick]="false">
</core-context-menu-item>
<core-context-menu-item [hidden]="!canEdit || !event || !event.canedit || event.deleted" [priority]="300"
[content]="'core.edit' | translate" (action)="openEdit()" iconAction="fas-edit">
</core-context-menu-item>
<core-context-menu-item [hidden]="!event || !event.candelete || event.deleted" [priority]="200"
[content]="'core.delete' | translate" (action)="deleteEvent()"
iconAction="fas-trash"></core-context-menu-item>
<core-context-menu-item [hidden]="!event || !event.deleted" [priority]="200" [content]="'core.restore' | translate"
(action)="undoDelete()" iconAction="fas-undo-alt"></core-context-menu-item>
</core-context-menu>
</ion-buttons>
</ion-toolbar>
</ion-header>
<core-navbar-buttons slot="end">
<core-context-menu>
<core-context-menu-item [hidden]="isSplitViewOn || !eventLoaded || (!hasOffline && event && !event.deleted) || !isOnline"
[priority]="400" [content]="'core.settings.synchronizenow' | translate" (action)="doRefresh(undefined, $event, true)"
[iconAction]="syncIcon" [closeOnClick]="false">
</core-context-menu-item>
<core-context-menu-item [hidden]="!canEdit || !event || !event.canedit || event.deleted" [priority]="300"
[content]="'core.edit' | translate" (action)="openEdit()" iconAction="fas-edit">
</core-context-menu-item>
<core-context-menu-item [hidden]="!event || !event.candelete || event.deleted" [priority]="200"
[content]="'core.delete' | translate" (action)="deleteEvent()"
iconAction="fas-trash"></core-context-menu-item>
<core-context-menu-item [hidden]="!event || !event.deleted" [priority]="200" [content]="'core.restore' | translate"
(action)="undoDelete()" iconAction="fas-undo-alt"></core-context-menu-item>
</core-context-menu>
</core-navbar-buttons>
<ion-content>
<ion-refresher slot="fixed" [disabled]="!eventLoaded" (ionRefresh)="doRefresh($event.target)">
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
@ -50,33 +47,13 @@
<ion-card>
<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-label>
<h2>{{ 'addon.calendar.when' | translate }}</h2>
<core-format-text [text]="event.formattedtime" [contextLevel]="event.contextLevel"
[contextInstanceId]="event.contextInstanceId"></core-format-text>
</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-note>
</ion-item>

View File

@ -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);