MOBILE-3643 core: Rename splitview property

main
Noel De Martin 2021-03-02 09:35:41 +01:00
parent 05ae8ada14
commit da14b7dac3
6 changed files with 33 additions and 31 deletions

View File

@ -570,7 +570,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy {
}
}
if (this.svComponent?.isOn()) {
if (this.svComponent?.outletActivated) {
// Empty form.
this.hasOffline = false;
this.form.reset(this.originalData);

View File

@ -96,7 +96,7 @@ export class AddonCalendarEventPage implements OnInit, OnDestroy {
this.notificationsEnabled = CoreLocalNotifications.instance.isAvailable();
this.siteHomeId = CoreSites.instance.getCurrentSiteHomeId();
this.currentSiteId = CoreSites.instance.getCurrentSiteId();
this.isSplitViewOn = this.svComponent?.isOn();
this.isSplitViewOn = this.svComponent?.outletActivated;
// Check if site supports editing and deleting. No need to check allowed types, event.canedit already does it.
this.canEdit = AddonCalendar.instance.canEditEventsInSite();

View File

@ -121,9 +121,9 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
this.refreshEvents(true, false).finally(() => {
// In tablet mode try to open the event (only if it's an online event).
if (this.splitviewCtrl?.isOn() && data.eventId > 0) {
if (this.splitviewCtrl?.outletActivated && data.eventId > 0) {
this.gotoEvent(data.eventId);
} else if (this.splitviewCtrl?.isOn()) {
} else if (this.splitviewCtrl?.outletActivated) {
// Discussion added, clear details page.
this.emptySplitView();
}
@ -133,7 +133,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
// Listen for new event discarded event. When it does, reload the data.
this.discardedObserver = CoreEvents.on(AddonCalendarProvider.NEW_EVENT_DISCARDED_EVENT, () => {
if (this.splitviewCtrl?.isOn()) {
if (this.splitviewCtrl?.outletActivated) {
// Discussion added, clear details page.
this.emptySplitView();
}
@ -155,7 +155,8 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
this.eventsLoaded = false;
this.refreshEvents();
if (this.splitviewCtrl?.isOn() && this.eventId && data && data.deleted && data.deleted.indexOf(this.eventId) != -1) {
if (this.splitviewCtrl?.outletActivated &&
this.eventId && data && data.deleted && data.deleted.indexOf(this.eventId) != -1) {
// Current selected event was deleted. Clear details.
this.emptySplitView();
}
@ -168,7 +169,8 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
this.refreshEvents();
}
if (this.splitviewCtrl?.isOn() && this.eventId && data && data.deleted && data.deleted.indexOf(this.eventId) != -1) {
if (this.splitviewCtrl?.outletActivated &&
this.eventId && data && data.deleted && data.deleted.indexOf(this.eventId) != -1) {
// Current selected event was deleted. Clear details.
this.emptySplitView();
}
@ -185,7 +187,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
this.hasOffline = true;
} else {
// Event deleted, clear the details if needed and refresh the view.
if (this.splitviewCtrl?.isOn()) {
if (this.splitviewCtrl?.outletActivated) {
this.emptySplitView();
}
@ -255,7 +257,7 @@ export class AddonCalendarListPage implements OnInit, OnDestroy {
await this.fetchData(false, true, false);
if (!this.eventId && this.splitviewCtrl?.isOn() && this.events.length > 0) {
if (!this.eventId && this.splitviewCtrl?.outletActivated && this.events.length > 0) {
// Take first online event and load it. If no online event, load the first offline.
if (this.onlineEvents[0]) {
this.gotoEvent(this.onlineEvents[0].id);

View File

@ -12,7 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnDestroy, ViewChild, OnInit, AfterViewInit, ElementRef } from '@angular/core';
import { Component, OnDestroy, ViewChild, OnInit, AfterViewInit, ElementRef, Optional } from '@angular/core';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { CoreUser } from '@features/user/services/user';
import { CanLeave } from '@guards/can-leave';
@ -106,7 +107,10 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
protected ratingSyncObserver?: CoreEventObserver;
protected changeDiscObserver?: CoreEventObserver;
constructor(protected elementRef: ElementRef) {}
constructor(
@Optional() protected splitView: CoreSplitViewComponent,
protected elementRef: ElementRef,
) {}
get isMobile(): boolean {
return CoreScreen.instance.isMobile;
@ -216,12 +220,11 @@ export class AddonModForumDiscussionPage implements OnInit, AfterViewInit, OnDes
if (typeof data.deleted != 'undefined' && data.deleted) {
if (!data.post?.parentid) {
// @todo
// if (this.svComponent && this.svComponent.isOn()) {
// this.svComponent.emptyDetails();
// } else {
// this.navCtrl.pop();
// }
if (this.splitView?.outletActivated) {
CoreNavigator.instance.navigate('../');
} else {
CoreNavigator.instance.back();
}
} else {
this.discussionLoaded = false;
this.refreshPosts();

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnDestroy, ViewChild, ElementRef, OnInit } from '@angular/core';
import { Component, OnDestroy, ViewChild, ElementRef, OnInit, Optional } from '@angular/core';
import { FileEntry } from '@ionic-native/file/ngx';
import { FormControl } from '@angular/forms';
import { CoreEvents, CoreEventObserver } from '@singletons/events';
@ -38,7 +38,7 @@ import { IonRefresher } from '@ionic/angular';
import { CoreFileUploader } from '@features/fileuploader/services/fileuploader';
import { CoreTextUtils } from '@services/utils/text';
import { CanLeave } from '@guards/can-leave';
import { CoreScreen } from '@services/screen';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
type NewDiscussionData = {
subject: string;
@ -96,6 +96,8 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
protected originalData?: Partial<NewDiscussionData>;
protected forceLeave = false;
constructor(@Optional() protected splitView: CoreSplitViewComponent) {}
/**
* Component being initialized.
*/
@ -433,9 +435,7 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
CoreSites.instance.getCurrentSiteId(),
);
if (CoreScreen.instance.isMobile) {
CoreNavigator.instance.back();
} else {
if (this.splitView?.outletActivated) {
// Empty form.
this.hasOffline = false;
this.newDiscussion.subject = '';
@ -444,6 +444,8 @@ export class AddonModForumNewDiscussionPage implements OnInit, OnDestroy, CanLea
this.newDiscussion.postToAllGroups = false;
this.messageEditor.clearText();
this.originalData = CoreUtils.instance.clone(this.newDiscussion);
} else {
CoreNavigator.instance.back();
}
}

View File

@ -46,6 +46,10 @@ export class CoreSplitViewComponent implements AfterViewInit, OnDestroy {
return this.outletRouteSubject.value;
}
get outletActivated(): boolean {
return this.contentOutlet.isActivated;
}
get outletRouteObservable(): Observable<ActivatedRouteSnapshot | null> {
return this.outletRouteSubject.asObservable();
}
@ -118,13 +122,4 @@ export class CoreSplitViewComponent implements AfterViewInit, OnDestroy {
return CoreSplitViewMode.MenuAndContent;
}
/**
* Check if both panels are shown. It depends on screen width.
*
* @return If split view is enabled.
*/
isOn(): boolean {
return this.contentOutlet.isActivated;
}
}