@@ -825,7 +825,11 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
825825 }
826826 }
827827 const primaryKeyColumn = this . resourceConfig . columns . find ( ( col ) => col . primaryKey ) ;
828+
828829 const decimalFieldsArray = this . resourceConfig . columns . filter ( c => c . type === 'decimal' ) . map ( c => c . name ) ;
830+ const integerFieldsArray = this . resourceConfig . columns . filter ( c => c . type === 'integer' ) . map ( c => c . name ) ;
831+ const floatFieldsArray = this . resourceConfig . columns . filter ( c => c . type === 'float' ) . map ( c => c . name ) ;
832+
829833 const updates = selectedIds . map ( async ( ID , idx ) => {
830834 const oldRecord = await this . adminforth . resource ( this . resourceConfig . resourceId ) . get ( [ Filters . EQ ( primaryKeyColumn . name , ID ) ] ) ;
831835 for ( const [ key , value ] of Object . entries ( outputImageFields ) ) {
@@ -869,6 +873,21 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
869873 }
870874 }
871875 }
876+ if ( integerFieldsArray . length > 0 ) {
877+ for ( const fieldName of integerFieldsArray ) {
878+ if ( fieldsToUpdate [ idx ] . hasOwnProperty ( fieldName ) ) {
879+ fieldsToUpdate [ idx ] [ fieldName ] = parseInt ( fieldsToUpdate [ idx ] [ fieldName ] , 10 ) ;
880+ }
881+ }
882+ }
883+ if ( floatFieldsArray . length > 0 ) {
884+ for ( const fieldName of floatFieldsArray ) {
885+ if ( fieldsToUpdate [ idx ] . hasOwnProperty ( fieldName ) ) {
886+ fieldsToUpdate [ idx ] [ fieldName ] = parseFloat ( fieldsToUpdate [ idx ] [ fieldName ] ) ;
887+ }
888+ }
889+ }
890+
872891 const newRecord = {
873892 ...oldRecord ,
874893 ...fieldsToUpdate [ idx ]
@@ -881,7 +900,11 @@ export default class BulkAiFlowPlugin extends AdminForthPlugin {
881900 adminUser : adminUser ,
882901 } )
883902 } ) ;
884- await Promise . all ( updates ) ;
903+ try {
904+ await Promise . all ( updates ) ;
905+ } catch ( error ) {
906+ return { ok : false , error : `Error updating records, because of unprocesseble data for record ID ${ selectedIds } ` } ;
907+ }
885908 return { ok : true } ;
886909 } else {
887910 return { ok : false , error : isAllowedToSave . error } ;
0 commit comments