From 43d6839a8d78d7570e9c84044f86c780a583f5ec Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 28 Aug 2019 11:20:07 +0200 Subject: [PATCH] MOBILE-3068 comments: Open comments in new page if split view --- .../addon-mod-assign-submission-comments.html | 2 +- .../submission/comments/component/comments.ts | 4 ++-- .../comments/components/comments/comments.ts | 18 ++++++++++++++---- .../components/comments/core-comments.html | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/addon/mod/assign/submission/comments/component/addon-mod-assign-submission-comments.html b/src/addon/mod/assign/submission/comments/component/addon-mod-assign-submission-comments.html index be2ba466f..8040cdfeb 100644 --- a/src/addon/mod/assign/submission/comments/component/addon-mod-assign-submission-comments.html +++ b/src/addon/mod/assign/submission/comments/component/addon-mod-assign-submission-comments.html @@ -1,4 +1,4 @@ - +

{{plugin.name}}

diff --git a/src/addon/mod/assign/submission/comments/component/comments.ts b/src/addon/mod/assign/submission/comments/component/comments.ts index 98c8be9e0..bd6bb57c2 100644 --- a/src/addon/mod/assign/submission/comments/component/comments.ts +++ b/src/addon/mod/assign/submission/comments/component/comments.ts @@ -48,7 +48,7 @@ export class AddonModAssignSubmissionCommentsComponent extends AddonModAssignSub /** * Show the comments. */ - showComments(): void { - this.commentsComponent && this.commentsComponent.openComments(); + showComments(e?: Event): void { + this.commentsComponent && this.commentsComponent.openComments(e); } } diff --git a/src/core/comments/components/comments/comments.ts b/src/core/comments/components/comments/comments.ts index 6e32bc710..6bbe34fc4 100644 --- a/src/core/comments/components/comments/comments.ts +++ b/src/core/comments/components/comments/comments.ts @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Component, EventEmitter, Input, OnChanges, OnDestroy, Output, SimpleChange } from '@angular/core'; +import { Component, EventEmitter, Input, OnChanges, OnDestroy, Output, SimpleChange, Optional } from '@angular/core'; import { NavController } from 'ionic-angular'; import { CoreCommentsProvider } from '../../providers/comments'; import { CoreEventsProvider } from '@providers/events'; import { CoreSitesProvider } from '@providers/sites'; +import { CoreSplitViewComponent } from '@components/split-view/split-view'; /** * Component that displays the count of comments. @@ -44,7 +45,9 @@ export class CoreCommentsCommentsComponent implements OnChanges, OnDestroy { protected refreshCommentsObserver; constructor(private navCtrl: NavController, private commentsProvider: CoreCommentsProvider, - sitesProvider: CoreSitesProvider, eventsProvider: CoreEventsProvider) { + sitesProvider: CoreSitesProvider, eventsProvider: CoreEventsProvider, + @Optional() private svComponent: CoreSplitViewComponent) { + this.onLoading = new EventEmitter(); this.disabled = this.commentsProvider.areCommentsDisabledInSite(); @@ -135,10 +138,17 @@ export class CoreCommentsCommentsComponent implements OnChanges, OnDestroy { /** * Opens the comments page. */ - openComments(): void { + openComments(e?: Event): void { + if (e) { + e.preventDefault(); + e.stopPropagation(); + } + if (!this.disabled && !this.countError) { // Open a new state with the interpolated contents. - this.navCtrl.push('CoreCommentsViewerPage', { + const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl; + + navCtrl.push('CoreCommentsViewerPage', { contextLevel: this.contextLevel, instanceId: this.instanceId, componentName: this.component, diff --git a/src/core/comments/components/comments/core-comments.html b/src/core/comments/components/comments/core-comments.html index 2c2c8efeb..4375edc5a 100644 --- a/src/core/comments/components/comments/core-comments.html +++ b/src/core/comments/components/comments/core-comments.html @@ -1,5 +1,5 @@ -
+
{{ 'core.comments.commentscount' | translate : {'$a': commentsCount} }}