@adminforth/bulk-ai-flow 1.16.1 → 1.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build.log CHANGED
@@ -13,5 +13,5 @@ custom/package-lock.json
13
13
  custom/package.json
14
14
  custom/tsconfig.json
15
15
 
16
- sent 88,106 bytes received 172 bytes 176,556.00 bytes/sec
17
- total size is 87,461 speedup is 0.99
16
+ sent 88,181 bytes received 172 bytes 176,706.00 bytes/sec
17
+ total size is 87,536 speedup is 0.99
@@ -200,10 +200,12 @@ const imageGenerationErrorMessage = ref<string[]>([]);
200
200
  const isImageHasPreviewUrl = ref<Record<string, boolean>>({});
201
201
  const popupMode = ref<'generation' | 'confirmation' | 'settings'>('confirmation');
202
202
  const generationPrompts = ref<any>({});
203
+ const isDataSaved = ref(false);
203
204
 
204
205
  const regeneratingFieldsStatus = ref<Record<string, Record<string, boolean>>>({});
205
206
 
206
207
  const openDialog = async () => {
208
+ window.addEventListener('beforeunload', beforeUnloadHandler);
207
209
  if (props.meta.askConfirmationBeforeGenerating) {
208
210
  popupMode.value = 'confirmation';
209
211
  } else {
@@ -277,6 +279,7 @@ function runAiActions() {
277
279
  }
278
280
 
279
281
  const closeDialog = () => {
282
+ window.removeEventListener('beforeunload', beforeUnloadHandler);
280
283
  isAiResponseReceivedAnalizeImage.value = [];
281
284
  isAiResponseReceivedAnalizeNoImage.value = [];
282
285
  isAiResponseReceivedImage.value = [];
@@ -292,6 +295,7 @@ const closeDialog = () => {
292
295
  errorMessage.value = '';
293
296
  isDialogOpen.value = false;
294
297
  popupMode.value = 'confirmation';
298
+ isDataSaved.value = false;
295
299
  }
296
300
 
297
301
  watch(selected, (val) => {
@@ -537,6 +541,8 @@ async function saveData() {
537
541
  errorMessage.value = t(`Failed to save data. Please, try to re-run the action.`);
538
542
  } finally {
539
543
  isLoading.value = false;
544
+ isDataSaved.value = true;
545
+ window.removeEventListener('beforeunload', beforeUnloadHandler);
540
546
  }
541
547
  }
542
548
 
@@ -944,7 +950,6 @@ function checkAndAddNewFieldsToPrompts(savedPrompts, defaultPrompts) {
944
950
  }
945
951
 
946
952
  async function regenerateCell(recordInfo: any) {
947
- console.log('Regenerating cell for record:', recordInfo.recordId, 'field:', recordInfo.fieldName);
948
953
  if (!regeneratingFieldsStatus.value[recordInfo.recordId]) {
949
954
  regeneratingFieldsStatus.value[recordInfo.recordId] = {};
950
955
  }
@@ -965,7 +970,6 @@ async function regenerateCell(recordInfo: any) {
965
970
  } else if (actionType === 'analyze_no_images') {
966
971
  generationPromptsForField = generationPrompts.value.plainFieldsPrompts || {};
967
972
  }
968
- console.log('Using generation prompts for field regeneration:', generationPromptsForField);
969
973
 
970
974
  let res;
971
975
  try {
@@ -991,12 +995,9 @@ async function regenerateCell(recordInfo: any) {
991
995
  errorMessage.value = t(`Failed to regenerate field. You are not allowed to regenerate.`);
992
996
  return;
993
997
  }
994
- console.log('Regeneration response:', res);
995
998
  const index = selected.value.findIndex(item => String(item[primaryKey]) === String(recordInfo.recordId));
996
- console.log('Found index in selected array:', index);
997
999
 
998
1000
  const pk = selected.value[index]?.[primaryKey];
999
- console.log('Primary key for the record:', pk);
1000
1001
  if (pk) {
1001
1002
  selected.value[index] = {
1002
1003
  ...selected.value[index],
@@ -1007,4 +1008,11 @@ async function regenerateCell(recordInfo: any) {
1007
1008
  }
1008
1009
  regeneratingFieldsStatus.value[recordInfo.recordId][recordInfo.fieldName] = false;
1009
1010
  }
1011
+
1012
+ const beforeUnloadHandler = (event) => {
1013
+ if (isDataSaved.value) return;
1014
+ event.preventDefault();
1015
+ event.returnValue = '';
1016
+ };
1017
+
1010
1018
  </script>
@@ -200,10 +200,12 @@ const imageGenerationErrorMessage = ref<string[]>([]);
200
200
  const isImageHasPreviewUrl = ref<Record<string, boolean>>({});
201
201
  const popupMode = ref<'generation' | 'confirmation' | 'settings'>('confirmation');
202
202
  const generationPrompts = ref<any>({});
203
+ const isDataSaved = ref(false);
203
204
 
204
205
  const regeneratingFieldsStatus = ref<Record<string, Record<string, boolean>>>({});
205
206
 
206
207
  const openDialog = async () => {
208
+ window.addEventListener('beforeunload', beforeUnloadHandler);
207
209
  if (props.meta.askConfirmationBeforeGenerating) {
208
210
  popupMode.value = 'confirmation';
209
211
  } else {
@@ -277,6 +279,7 @@ function runAiActions() {
277
279
  }
278
280
 
279
281
  const closeDialog = () => {
282
+ window.removeEventListener('beforeunload', beforeUnloadHandler);
280
283
  isAiResponseReceivedAnalizeImage.value = [];
281
284
  isAiResponseReceivedAnalizeNoImage.value = [];
282
285
  isAiResponseReceivedImage.value = [];
@@ -292,6 +295,7 @@ const closeDialog = () => {
292
295
  errorMessage.value = '';
293
296
  isDialogOpen.value = false;
294
297
  popupMode.value = 'confirmation';
298
+ isDataSaved.value = false;
295
299
  }
296
300
 
297
301
  watch(selected, (val) => {
@@ -537,6 +541,8 @@ async function saveData() {
537
541
  errorMessage.value = t(`Failed to save data. Please, try to re-run the action.`);
538
542
  } finally {
539
543
  isLoading.value = false;
544
+ isDataSaved.value = true;
545
+ window.removeEventListener('beforeunload', beforeUnloadHandler);
540
546
  }
541
547
  }
542
548
 
@@ -944,7 +950,6 @@ function checkAndAddNewFieldsToPrompts(savedPrompts, defaultPrompts) {
944
950
  }
945
951
 
946
952
  async function regenerateCell(recordInfo: any) {
947
- console.log('Regenerating cell for record:', recordInfo.recordId, 'field:', recordInfo.fieldName);
948
953
  if (!regeneratingFieldsStatus.value[recordInfo.recordId]) {
949
954
  regeneratingFieldsStatus.value[recordInfo.recordId] = {};
950
955
  }
@@ -965,7 +970,6 @@ async function regenerateCell(recordInfo: any) {
965
970
  } else if (actionType === 'analyze_no_images') {
966
971
  generationPromptsForField = generationPrompts.value.plainFieldsPrompts || {};
967
972
  }
968
- console.log('Using generation prompts for field regeneration:', generationPromptsForField);
969
973
 
970
974
  let res;
971
975
  try {
@@ -991,12 +995,9 @@ async function regenerateCell(recordInfo: any) {
991
995
  errorMessage.value = t(`Failed to regenerate field. You are not allowed to regenerate.`);
992
996
  return;
993
997
  }
994
- console.log('Regeneration response:', res);
995
998
  const index = selected.value.findIndex(item => String(item[primaryKey]) === String(recordInfo.recordId));
996
- console.log('Found index in selected array:', index);
997
999
 
998
1000
  const pk = selected.value[index]?.[primaryKey];
999
- console.log('Primary key for the record:', pk);
1000
1001
  if (pk) {
1001
1002
  selected.value[index] = {
1002
1003
  ...selected.value[index],
@@ -1007,4 +1008,11 @@ async function regenerateCell(recordInfo: any) {
1007
1008
  }
1008
1009
  regeneratingFieldsStatus.value[recordInfo.recordId][recordInfo.fieldName] = false;
1009
1010
  }
1011
+
1012
+ const beforeUnloadHandler = (event) => {
1013
+ if (isDataSaved.value) return;
1014
+ event.preventDefault();
1015
+ event.returnValue = '';
1016
+ };
1017
+
1010
1018
  </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/bulk-ai-flow",
3
- "version": "1.16.1",
3
+ "version": "1.17.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },