MOBILE-3068 comments: Open comments in new page if split view

main
Dani Palou 2019-08-28 11:20:07 +02:00
parent 5794bade90
commit 43d6839a8d
4 changed files with 18 additions and 8 deletions

View File

@ -1,4 +1,4 @@
<a *ngIf="commentsEnabled" ion-item text-wrap (click)="showComments()" detail-none>
<a *ngIf="commentsEnabled" ion-item text-wrap (click)="showComments($event)" detail-none>
<h2>{{plugin.name}}</h2>
<core-comments contextLevel="module" [instanceId]="assign.cmid" component="assignsubmission_comments" [itemId]="submission.id" area="submission_comments" [title]="plugin.name"></core-comments>
</a>

View File

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

View File

@ -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<boolean>();
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,

View File

@ -1,5 +1,5 @@
<core-loading *ngIf="!disabled" [hideUntil]="commentsLoaded || !displaySpinner">
<div (click)="openComments()" *ngIf="!countError" [class.core-comments-clickable]="!disabled">
<div (click)="openComments($event)" *ngIf="!countError" [class.core-comments-clickable]="!disabled">
{{ 'core.comments.commentscount' | translate : {'$a': commentsCount} }}
</div>
<div *ngIf="countError">