@@ -106,6 +106,7 @@ const openGenerationCarousel = ref([]);
106106const isLoading = ref (false );
107107const isError = ref (false );
108108const isCriticalError = ref (false );
109+ const isImageGenerationError = ref (false );
109110const errorMessage = ref (' ' );
110111const checkedCount = ref (0 );
111112
@@ -289,20 +290,21 @@ async function prepareDataForSave() {
289290 .filter (item => item .isChecked === true )
290291 .map (item => item [primaryKey ]);
291292
292- const promises = [];
293- for (const item of checkedItems ) {
294- for (const [key, value] of Object .entries (item )) {
295- if (props .meta .outputImageFields ?.includes (key )) {
296- const p = convertImages (key , value ).then (result => {
297- item [key ] = result ;
298- });
299-
300- promises .push (p );
293+ if (isImageGenerationError .value !== true ) {
294+ const promises = [];
295+ for (const item of checkedItems ) {
296+ for (const [key, value] of Object .entries (item )) {
297+ if (props .meta .outputImageFields ?.includes (key )) {
298+ const p = convertImages (key , value ).then (result => {
299+ item [key ] = result ;
300+ });
301+
302+ promises .push (p );
303+ }
301304 }
302305 }
306+ await Promise .all (promises );
303307 }
304- await Promise .all (promises );
305-
306308 return [checkedItemsIDs , checkedItems ];
307309}
308310
@@ -350,7 +352,7 @@ async function analyzeFields() {
350352
351353 console .error (' Failed to analyze image(s):' , res .error );
352354 isError .value = true ;
353- isCriticalError .value = true ;
355+ // isCriticalError.value = true;
354356 errorMessage .value = ` Failed to fetch analyze image(s). Please, try to re-run the action. ` ;
355357 } else {
356358 res .result .forEach ((item , idx ) => {
@@ -375,7 +377,7 @@ async function analyzeFields() {
375377
376378 console .error (' Failed to analyze image(s):' , error );
377379 isError .value = true ;
378- isCriticalError .value = true ;
380+ // isCriticalError.value = true;
379381 errorMessage .value = res .error ;
380382 }
381383}
@@ -403,7 +405,7 @@ async function analyzeFieldsNoImages() {
403405 });
404406 console .error (' Failed to analyze fields:' , res .error );
405407 isError .value = true ;
406- isCriticalError .value = true ;
408+ // isCriticalError.value = true;
407409 errorMessage .value = res .error ;
408410 } else {
409411 res .result .forEach ((item , idx ) => {
@@ -427,7 +429,7 @@ async function analyzeFieldsNoImages() {
427429 });
428430 console .error (' Failed to analyze fields:' , error );
429431 isError .value = true ;
430- isCriticalError .value = true ;
432+ // isCriticalError.value = true;
431433 errorMessage .value = ` Failed to analyze fields. Please, try to re-run the action. ` ;
432434 }
433435}
@@ -443,26 +445,28 @@ async function saveData() {
443445 try {
444446 isLoading .value = true ;
445447 const [checkedItemsIDs, reqData] = await prepareDataForSave ();
446-
447- const imagesToUpload = [];
448- for (const item of reqData ) {
449- for (const [key, value] of Object .entries (item )) {
450- if (props .meta .outputImageFields ?.includes (key )) {
451- const p = uploadImage (value , item [primaryKey ], key ).then (result => {
452- item [key ] = result ;
453- });
454- imagesToUpload .push (p );
448+ if (isImageGenerationError .value === false ) {
449+ const imagesToUpload = [];
450+ for (const item of reqData ) {
451+ for (const [key, value] of Object .entries (item )) {
452+ if (props .meta .outputImageFields ?.includes (key )) {
453+ const p = uploadImage (value , item [primaryKey ], key ).then (result => {
454+ item [key ] = result ;
455+ });
456+ imagesToUpload .push (p );
457+ }
455458 }
456459 }
460+ await Promise .all (imagesToUpload );
457461 }
458- await Promise .all (imagesToUpload );
459462
460463 const res = await callAdminForthApi ({
461464 path: ` /plugin/${props .meta .pluginInstanceId }/update_fields ` ,
462465 method: ' POST' ,
463466 body: {
464467 selectedIds: checkedItemsIDs ,
465468 fields: reqData ,
469+ saveImages: ! isImageGenerationError .value
466470 },
467471 });
468472
@@ -508,7 +512,7 @@ async function generateImages() {
508512 } catch (e ) {
509513 console .error (' Error generating images:' , e );
510514 isError .value = true ;
511- isCriticalError .value = true ;
515+ isImageGenerationError .value = true ;
512516 errorMessage .value = ` Failed to generate images. Please, try to re-run the action. ` ;
513517 }
514518 isAiResponseReceivedImage .value = props .checkboxes .map (() => true );
@@ -519,7 +523,7 @@ async function generateImages() {
519523 if (! res ) {
520524 error = ' Error generating images, something went wrong' ;
521525 isError .value = true ;
522- isCriticalError .value = true ;
526+ isImageGenerationError .value = true ;
523527 errorMessage .value = ` Failed to generate images. Please, try to re-run the action. ` ;
524528 }
525529
@@ -528,9 +532,9 @@ async function generateImages() {
528532 message: error ,
529533 variant: ' danger' ,
530534 timeout: ' unlimited' ,
531- });;
535+ });
532536 isError .value = true ;
533- isCriticalError .value = true ;
537+ isImageGenerationError .value = true ;
534538 errorMessage .value = error ;
535539 } else {
536540 res .result .forEach ((item , idx ) => {
0 commit comments