@@ -7,7 +7,8 @@ export function useTableEdits(
77 collection : Ref < string > ,
88 primaryKeyField : Ref < Field | undefined > ,
99 items : Ref < any [ ] > ,
10- getItems : ( ) => Promise < void >
10+ getItems : ( ) => Promise < void > ,
11+ languageCodeField = 'languages_code'
1112) {
1213 const tableApi = useTableApi ( ) ;
1314 const edits = ref < Edits > ( { } ) ;
@@ -55,13 +56,13 @@ export function useTableEdits(
5556 // Build translation update structure
5657 const existingTranslations = item . translations || [ ] ;
5758 const translationForLang = existingTranslations . find (
58- ( t : any ) => t . languages_code === value . language
59+ ( t : any ) => t [ languageCodeField ] === value . language
5960 ) ;
6061
6162 if ( translationForLang ) {
6263 // Update existing translation
6364 updatePayload . translations = existingTranslations . map ( ( t : any ) => {
64- if ( t . languages_code === value . language ) {
65+ if ( t [ languageCodeField ] === value . language ) {
6566 return {
6667 ...t ,
6768 [ value . translationField ] : value . value ,
@@ -74,7 +75,7 @@ export function useTableEdits(
7475 updatePayload . translations = [
7576 ...existingTranslations ,
7677 {
77- languages_code : value . language ,
78+ [ languageCodeField ] : value . language ,
7879 [ value . translationField ] : value . value ,
7980 } ,
8081 ] ;
@@ -90,12 +91,18 @@ export function useTableEdits(
9091 for ( const [ field , value ] of Object . entries ( updatePayload ) ) {
9192 if ( field === 'translations' ) {
9293 // For full translations update
93- await tableApi . updateItem ( collection . value , itemId , 'translations' , {
94- isFullTranslations : true ,
95- translations : value ,
96- } ) ;
94+ await tableApi . updateItem (
95+ collection . value ,
96+ itemId ,
97+ 'translations' ,
98+ {
99+ isFullTranslations : true ,
100+ translations : value ,
101+ } ,
102+ languageCodeField
103+ ) ;
97104 } else {
98- await tableApi . updateItem ( collection . value , itemId , field , value ) ;
105+ await tableApi . updateItem ( collection . value , itemId , field , value , languageCodeField ) ;
99106 }
100107 }
101108
0 commit comments