Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: smoother feedback (fixes #7892)(fixes #7963)(fixes #7965) #7907

Merged
merged 15 commits into from
Jan 22, 2025
Merged
2 changes: 1 addition & 1 deletion src/app/courses/courses.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ <h3 class="header">
<mat-icon>clear</mat-icon>
<span i18n>Leave</span>
</a>
<a mat-menu-item planetFeedback [feedbackOf]="{'state': 'courses', 'item': element._id}" i18n-title title="Feedback">
<a mat-menu-item planetFeedback [feedbackOf]="{'state': 'courses', 'item': element._id, name: element.doc.courseTitle}" i18n-title title="Feedback">
<mat-icon>feedback</mat-icon>
<span i18n>Feedback</span>
</a>
Expand Down
57 changes: 33 additions & 24 deletions src/app/feedback/feedback.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,30 +79,39 @@ export class FeedbackDirective {

addFeedback(post: any) {
const date = this.couchService.datePlaceholder;
const user = this.userService.get().name,
{ message, ...feedbackInfo } = post,
startingMessage: Message = { message, time: date, user },
newFeedback: Feedback = {
owner: user,
...feedbackInfo,
openTime: date,
status: 'Open',
messages: [ startingMessage ],
url: this.router.url,
source: this.stateService.configuration.code,
parentCode: this.stateService.configuration.parentCode,
...this.feedbackOf
};
const feedbackUrl = newFeedback.url.substring(0, newFeedback.url.indexOf(';')) || newFeedback.url;
this.couchService.updateDocument('feedback', {
...newFeedback, title: $localize`${newFeedback.type} regarding ${feedbackUrl}` })
.subscribe((data) => {
this.feedbackService.setFeedback();
this.planetMessageService.showMessage($localize`Thank you, your feedback is submitted!`);
},
(error) => {
this.planetMessageService.showAlert($localize`Error, your feedback cannot be submitted`);
});
const user = this.userService.get().name;
const feedbackUrl = this.router.url && this.router.url !== '/' ? this.router.url.split(';')[0] : '';
let itemName = this.feedbackOf.name || '';
if (itemName.length > 40) {
itemName = `${itemName.slice(0, 40)}...`;
}
const feedbackTitle = itemName
? $localize`${post.type} regarding ${feedbackUrl}/${itemName}`
: feedbackUrl
? $localize`${post.type} regarding ${feedbackUrl}`
: $localize`General ${post.type}`;
const startingMessage: Message = { message: post.message, time: date, user };
const newFeedback: Feedback = {
owner: user,
...post,
openTime: date,
status: 'Open',
messages: [ startingMessage ],
url: feedbackUrl,
source: this.stateService.configuration.code,
parentCode: this.stateService.configuration.parentCode,
...this.feedbackOf,
title: feedbackTitle,
};
this.couchService.updateDocument('feedback', newFeedback).subscribe(
() => {
this.feedbackService.setFeedback();
this.planetMessageService.showMessage($localize`Thank you, your feedback is submitted!`);
},
() => {
this.planetMessageService.showAlert($localize`Error, your feedback cannot be submitted`);
}
);
}

@HostListener('click')
Expand Down
2 changes: 1 addition & 1 deletion src/app/meetups/meetups.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h3 class="header">
<span *ngIf="element.participate; else joinMeetup"><mat-icon>clear</mat-icon><span i18n>Leave</span></span>
<ng-template #joinMeetup><mat-icon>done</mat-icon><span i18n>Join</span></ng-template>
</a>
<a mat-menu-item planetFeedback [feedbackOf]="{'state': 'meetups', 'item': element._id}" i18n-title title="Feedback">
<a mat-menu-item planetFeedback [feedbackOf]="{'state': 'meetups', 'item': element._id, name: element.doc.title}" i18n-title title="Feedback">
<mat-icon>feedback</mat-icon>
<span i18n>Feedback</span>
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/app/resources/resources.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ <h3 class="header">
<a mat-menu-item *ngIf="element.libraryInfo" (click)="libraryToggle([ element._id ], 'remove')">
<mat-icon>clear</mat-icon><span i18n>Remove from myLibrary</span>
</a>
<a mat-menu-item planetFeedback [feedbackOf]="{'state': 'resources', 'item': element._id}" i18n-title title="Feedback">
<a mat-menu-item planetFeedback [feedbackOf]="{'state': 'resources', 'item': element._id, name: element.doc.title}" i18n-title title="Feedback">
<mat-icon>feedback</mat-icon>
<span i18n>Feedback</span>
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/app/teams/teams.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ <h3>
<label *ngIf="!isMobile" i18n> Request pending </label>
</button>
</ng-container>
<button mat-raised-button color="primary" planetFeedback [feedbackOf]="{'state': mode + 's', 'item': element.doc._id}" (click)="$event.stopPropagation()">
<button mat-raised-button color="primary" planetFeedback [feedbackOf]="{'state': mode + 's', 'item': element.doc._id, name: element.doc.name}" (click)="$event.stopPropagation()">
<mat-icon>feedback</mat-icon>
<label *ngIf="!isMobile" i18n> Feedback </label>
</button>
Expand Down
Loading