@processmaker/screen-builder 3.7.0 → 3.8.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -1382,14 +1382,7 @@ export default {
1382
1382
  return index > this.pageDelete ? index - 1 : index;
1383
1383
  },
1384
1384
  // This function is used to calculate the new index of the references FormRecordList
1385
- calcNewIndexForFormRecordList(index, referencedBy, config) {
1386
- if (config[this.pageDelete].items.length > 0) {
1387
- throw new Error(
1388
- `${this.$t(
1389
- "Can not delete this page, it is referenced by"
1390
- )}: ${referencedBy}`
1391
- );
1392
- }
1385
+ calcNewIndexForFormRecordList(index, referencedBy) {
1393
1386
  return index > this.pageDelete ? index - 1 : index;
1394
1387
  },
1395
1388
  // Update Record list references
@@ -1398,11 +1391,12 @@ export default {
1398
1391
  page.items.forEach((item) => {
1399
1392
  if (item.component === "FormRecordList") {
1400
1393
  // eslint-disable-next-line no-param-reassign
1401
- item.config.form = this.calcNewIndexForFormRecordList(
1402
- item.config.form * 1,
1403
- item.config.label,
1404
- this.config,
1405
- );
1394
+ if (this.isValidInteger(item.config.form)) {
1395
+ item.config.form = this.calcNewIndexForFormRecordList(
1396
+ item.config.form * 1,
1397
+ item.config.label,
1398
+ );
1399
+ }
1406
1400
  }
1407
1401
  });
1408
1402
  });
@@ -1426,6 +1420,9 @@ export default {
1426
1420
  },
1427
1421
  async deletePage() {
1428
1422
  const back = _.cloneDeep(this.config);
1423
+ if(!this.isNotReferenceToRecordForm()) {
1424
+ return;
1425
+ }
1429
1426
  try {
1430
1427
  this.updateRecordListReferences();
1431
1428
  this.updateNavigationButtonsReferences();
@@ -1446,6 +1443,32 @@ export default {
1446
1443
  });
1447
1444
  this.$store.dispatch("clipboardModule/pushState", this.clipboardPage.items);
1448
1445
  },
1446
+ isNotReferenceToRecordForm() {
1447
+ for (let page of this.config) {
1448
+ for (let item of page.items) {
1449
+ if (item.component === "FormRecordList") {
1450
+ if (this.isValidInteger(item.config.form) && Number(item.config.form) === this.pageDelete) {
1451
+ const referencedBy = item.config.label;
1452
+ const message = `${this.$t("Can not delete this page, it is referenced by")}: ${referencedBy}`;
1453
+ globalObject.ProcessMaker.alert(message, "danger");
1454
+ return false;
1455
+ }
1456
+ }
1457
+ }
1458
+ }
1459
+ return true;
1460
+ },
1461
+ isValidInteger(value) {
1462
+ if (typeof value === 'boolean' || value === null || value === undefined) {
1463
+ return false;
1464
+ }
1465
+ const str = String(value).trim();
1466
+ if (str === '') {
1467
+ return false;
1468
+ }
1469
+ const num = Number(str);
1470
+ return Number.isInteger(num);
1471
+ },
1449
1472
  inspect(element = {}) {
1450
1473
  this.closeTemplatesPanel();
1451
1474
  this.inspection = element;