@@ -64,9 +64,8 @@ export class PostTranslateComponent implements OnInit {
64
64
saveTranslation ( ) {
65
65
this . translateForm . disable ( ) ;
66
66
this . post . post_content . forEach ( ( task : any ) => {
67
- task . fields
68
- . filter ( ( field : any ) => field . key in this . translateForm . controls )
69
- . forEach ( ( field : any ) => {
67
+ task . fields . forEach ( ( field : any ) => {
68
+ if ( field . key in this . translateForm . controls ) {
70
69
const translatedValue = this . translateForm . controls [ field . key ] . value ;
71
70
field . value = field . value || { } ;
72
71
field . value . translations = field . value . translations || { } ;
@@ -86,16 +85,21 @@ export class PostTranslateComponent implements OnInit {
86
85
this . post . translations [ this . activeLanguage . code ] || { } ;
87
86
this . post . translations [ this . activeLanguage . code ] [ field . type ] = translatedValue ;
88
87
}
89
- } ) ;
88
+ } else if ( field . input === 'upload' || field . type === 'media' ) {
89
+ if ( field . value ) {
90
+ field . value = { value : field . value . map ( ( v : any ) => v . value ) } ;
91
+ }
92
+ }
93
+ } ) ;
90
94
} ) ;
95
+
91
96
this . post . enabled_languages = { default : 'en' , available : this . enabledLanguages } ;
92
97
delete this . post . completed_stages ;
93
98
94
99
this . postsService . updateTranslations ( this . post . id , this . post ) . subscribe ( {
95
100
next : ( { result } ) => {
96
101
this . postsService . unlockPost ( this . post . id ) . subscribe ( ) ;
97
102
this . showMessage ( 'Translation saved successfully' , 'success' ) ;
98
- this . postsService . unlockPost ( this . post . id ) . subscribe ( ) ;
99
103
this . closeModal ( { displayLanguage : this . activeLanguage , post : result } ) ;
100
104
} ,
101
105
error : ( { error } ) => {
0 commit comments