Skip to content

Ush 1779 to release #1531

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

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ export class PostDetailsComponent extends BaseComponent implements OnChanges, On
dialogRef.afterClosed().subscribe((response) => {
if (response) {
this.post = response.post;
this.getData(this.post);
this.displayLanguage = response.displayLanguage.code;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ export class PostTranslateComponent implements OnInit {
saveTranslation() {
this.translateForm.disable();
this.post.post_content.forEach((task: any) => {
task.fields
.filter((field: any) => field.key in this.translateForm.controls)
.forEach((field: any) => {
task.fields.forEach((field: any) => {
if (field.key in this.translateForm.controls) {
const translatedValue = this.translateForm.controls[field.key].value;
field.value = field.value || {};
field.value.translations = field.value.translations || {};
Expand All @@ -86,16 +85,21 @@ export class PostTranslateComponent implements OnInit {
this.post.translations[this.activeLanguage.code] || {};
this.post.translations[this.activeLanguage.code][field.type] = translatedValue;
}
});
} else if (field.input === 'upload' || field.type === 'media') {
if (field.value) {
field.value = { value: field.value.map((v: any) => v.value) };
}
}
});
});

this.post.enabled_languages = { default: 'en', available: this.enabledLanguages };
delete this.post.completed_stages;

this.postsService.updateTranslations(this.post.id, this.post).subscribe({
next: ({ result }) => {
this.postsService.unlockPost(this.post.id).subscribe();
this.showMessage('Translation saved successfully', 'success');
this.postsService.unlockPost(this.post.id).subscribe();
this.closeModal({ displayLanguage: this.activeLanguage, post: result });
},
error: ({ error }) => {
Expand Down
Loading