commit
989c3f199d
|
@ -48,13 +48,14 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
||||||
@Input() trackPosts: boolean; // True if post is being tracked.
|
@Input() trackPosts: boolean; // True if post is being tracked.
|
||||||
@Input() forum: any; // The forum the post belongs to. Required for attachments and offline posts.
|
@Input() forum: any; // The forum the post belongs to. Required for attachments and offline posts.
|
||||||
@Input() accessInfo: any; // Forum access information.
|
@Input() accessInfo: any; // Forum access information.
|
||||||
@Input() defaultSubject: string; // Default subject to set to new posts.
|
@Input() parentSubject?: string; // Subject of parent post.
|
||||||
@Input() ratingInfo?: CoreRatingInfo; // Rating info item.
|
@Input() ratingInfo?: CoreRatingInfo; // Rating info item.
|
||||||
@Output() onPostChange: EventEmitter<void>; // Event emitted when a reply is posted or modified.
|
@Output() onPostChange: EventEmitter<void>; // Event emitted when a reply is posted or modified.
|
||||||
|
|
||||||
messageControl = new FormControl();
|
messageControl = new FormControl();
|
||||||
|
|
||||||
uniqueId: string;
|
uniqueId: string;
|
||||||
|
defaultReplySubject: string;
|
||||||
advanced = false; // Display all form fields.
|
advanced = false; // Display all form fields.
|
||||||
tagsEnabled: boolean;
|
tagsEnabled: boolean;
|
||||||
displaySubject = true;
|
displaySubject = true;
|
||||||
|
@ -89,9 +90,11 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
||||||
this.uniqueId = this.post.id ? 'reply' + this.post.id : 'edit' + this.post.parent;
|
this.uniqueId = this.post.id ? 'reply' + this.post.id : 'edit' + this.post.parent;
|
||||||
|
|
||||||
const reTranslated = this.translate.instant('addon.mod_forum.re');
|
const reTranslated = this.translate.instant('addon.mod_forum.re');
|
||||||
this.displaySubject = this.post.parent == 0 ||
|
this.displaySubject = !this.parentSubject ||
|
||||||
(this.post.subject != this.defaultSubject && this.post.subject != 'Re: ' + this.defaultSubject &&
|
(this.post.subject != this.parentSubject && this.post.subject != `Re: ${this.parentSubject}` &&
|
||||||
this.post.subject != reTranslated + this.defaultSubject);
|
this.post.subject != `${reTranslated} ${this.parentSubject}`);
|
||||||
|
this.defaultReplySubject = (this.post.subject.startsWith('Re: ') || this.post.subject.startsWith(reTranslated))
|
||||||
|
? this.post.subject : `${reTranslated} ${this.post.subject}`;
|
||||||
|
|
||||||
this.optionsMenuEnabled = !this.post.id || (this.forumProvider.isGetDiscussionPostAvailable() &&
|
this.optionsMenuEnabled = !this.post.id || (this.forumProvider.isGetDiscussionPostAvailable() &&
|
||||||
(this.forumProvider.isDeletePostAvailable() || this.forumProvider.isUpdatePostAvailable()));
|
(this.forumProvider.isDeletePostAvailable() || this.forumProvider.isUpdatePostAvailable()));
|
||||||
|
@ -145,7 +148,7 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
this.replyData.replyingTo = replyingTo || 0;
|
this.replyData.replyingTo = replyingTo || 0;
|
||||||
this.replyData.isEditing = !!isEditing;
|
this.replyData.isEditing = !!isEditing;
|
||||||
this.replyData.subject = subject || this.defaultSubject || '';
|
this.replyData.subject = subject || this.defaultReplySubject || '';
|
||||||
this.replyData.message = message || null;
|
this.replyData.message = message || null;
|
||||||
this.replyData.files = files || [];
|
this.replyData.files = files || [];
|
||||||
this.replyData.isprivatereply = !!isPrivate;
|
this.replyData.isprivatereply = !!isPrivate;
|
||||||
|
@ -282,6 +285,13 @@ export class AddonModForumPostComponent implements OnInit, OnDestroy {
|
||||||
} else {
|
} else {
|
||||||
// The post being replied has changed but the data will be kept.
|
// The post being replied has changed but the data will be kept.
|
||||||
this.replyData.replyingTo = this.post.id;
|
this.replyData.replyingTo = this.post.id;
|
||||||
|
|
||||||
|
if (this.replyData.subject == this.originalData.subject) {
|
||||||
|
// Update subject only if it hadn't been modified
|
||||||
|
this.replyData.subject = this.defaultReplySubject;
|
||||||
|
this.originalData.subject = this.defaultReplySubject;
|
||||||
|
}
|
||||||
|
|
||||||
this.messageControl.setValue(this.replyData.message);
|
this.messageControl.setValue(this.replyData.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,13 @@
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|
||||||
<div *ngIf="discussion" margin-bottom class="highlight">
|
<div *ngIf="discussion" margin-bottom class="highlight">
|
||||||
<addon-mod-forum-post [post]="discussion" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [defaultSubject]="defaultSubject" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
<addon-mod-forum-post [post]="discussion" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ion-card *ngIf="sort != 'nested'">
|
<ion-card *ngIf="sort != 'nested'">
|
||||||
<ng-container *ngFor="let post of posts; first as first">
|
<ng-container *ngFor="let post of posts; first as first">
|
||||||
<ion-item-divider *ngIf="!first"></ion-item-divider>
|
<ion-item-divider *ngIf="!first"></ion-item-divider>
|
||||||
<addon-mod-forum-post [post]="post" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [defaultSubject]="defaultSubject" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
<addon-mod-forum-post [post]="post" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [parentSubject]="postSubjects[post.parent]" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</ion-card>
|
</ion-card>
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
|
|
||||||
<ng-template #nestedPosts let-post="post">
|
<ng-template #nestedPosts let-post="post">
|
||||||
<ion-card>
|
<ion-card>
|
||||||
<addon-mod-forum-post [post]="post" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [defaultSubject]="defaultSubject" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
<addon-mod-forum-post [post]="post" [courseId]="courseId" [discussionId]="discussionId" [component]="component" [componentId]="cmId" [replyData]="replyData" [originalData]="originalData" [parentSubject]="postSubjects[post.parent]" [forum]="forum" [accessInfo]="accessInfo" [trackPosts]="trackPosts" [ratingInfo]="ratingInfo" (onPostChange)="postListChanged()"></addon-mod-forum-post>
|
||||||
</ion-card>
|
</ion-card>
|
||||||
<div padding-left *ngIf="post.children.length && post.children[0].subject">
|
<div padding-left *ngIf="post.children.length && post.children[0].subject">
|
||||||
<ng-container *ngFor="let child of post.children">
|
<ng-container *ngFor="let child of post.children">
|
||||||
|
|
|
@ -51,7 +51,7 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
discussion: any;
|
discussion: any;
|
||||||
posts: any[];
|
posts: any[];
|
||||||
discussionLoaded = false;
|
discussionLoaded = false;
|
||||||
defaultSubject: string;
|
postSubjects: { [id: string]: string };
|
||||||
isOnline: boolean;
|
isOnline: boolean;
|
||||||
isSplitViewOn: boolean;
|
isSplitViewOn: boolean;
|
||||||
postHasOffline: boolean;
|
postHasOffline: boolean;
|
||||||
|
@ -375,10 +375,6 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
// Ignore errors.
|
// Ignore errors.
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.defaultSubject = this.translate.instant('addon.mod_forum.re') + ' ' +
|
|
||||||
(this.discussion ? this.discussion.subject : '');
|
|
||||||
this.replyData.subject = this.defaultSubject;
|
|
||||||
|
|
||||||
const startingPost = this.forumProvider.extractStartingPost(posts);
|
const startingPost = this.forumProvider.extractStartingPost(posts);
|
||||||
if (startingPost) {
|
if (startingPost) {
|
||||||
// Update discussion data from first post.
|
// Update discussion data from first post.
|
||||||
|
@ -388,9 +384,6 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
return Promise.reject('Invalid forum discussion.');
|
return Promise.reject('Invalid forum discussion.');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.defaultSubject = this.translate.instant('addon.mod_forum.re') + ' ' + this.discussion.subject;
|
|
||||||
this.replyData.subject = this.defaultSubject;
|
|
||||||
|
|
||||||
if (this.discussion.userfullname && this.discussion.parent == 0 && this.forum.type == 'single') {
|
if (this.discussion.userfullname && this.discussion.parent == 0 && this.forum.type == 'single') {
|
||||||
// Hide author for first post and type single.
|
// Hide author for first post and type single.
|
||||||
this.discussion.userfullname = null;
|
this.discussion.userfullname = null;
|
||||||
|
@ -398,6 +391,11 @@ export class AddonModForumDiscussionPage implements OnDestroy {
|
||||||
|
|
||||||
this.posts = posts;
|
this.posts = posts;
|
||||||
this.ratingInfo = ratingInfo;
|
this.ratingInfo = ratingInfo;
|
||||||
|
this.postSubjects = this.posts.reduce((postSubjects, post) => {
|
||||||
|
postSubjects[post.id] = post.subject;
|
||||||
|
|
||||||
|
return postSubjects;
|
||||||
|
}, { [this.discussion.id]: this.discussion.subject });
|
||||||
});
|
});
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (this.forumProvider.isSetPinStateAvailableForSite()) {
|
if (this.forumProvider.isSetPinStateAvailableForSite()) {
|
||||||
|
|
Loading…
Reference in New Issue