@processmaker/screen-builder 3.6.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.6.0",
3
+ "version": "3.8.0",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -247,7 +247,11 @@ export default {
247
247
  return json;
248
248
  },
249
249
  showSimpleErrorMessage() {
250
- this.renderComponent = 'simpleErrorMessage';
250
+ // This triggers a re-render if it has already been displayed.
251
+ this.renderComponent = null;
252
+ setTimeout(() => {
253
+ this.renderComponent = 'simpleErrorMessage';
254
+ }, 0);
251
255
  },
252
256
  loadScreen(id) {
253
257
  this.disabled = true;
@@ -1381,16 +1381,22 @@ export default {
1381
1381
  }
1382
1382
  return index > this.pageDelete ? index - 1 : index;
1383
1383
  },
1384
+ // This function is used to calculate the new index of the references FormRecordList
1385
+ calcNewIndexForFormRecordList(index, referencedBy) {
1386
+ return index > this.pageDelete ? index - 1 : index;
1387
+ },
1384
1388
  // Update Record list references
1385
1389
  updateRecordListReferences() {
1386
1390
  this.config.forEach((page) => {
1387
1391
  page.items.forEach((item) => {
1388
1392
  if (item.component === "FormRecordList") {
1389
1393
  // eslint-disable-next-line no-param-reassign
1390
- item.config.form = this.calcNewIndexFor(
1391
- item.config.form * 1,
1392
- item.config.label
1393
- );
1394
+ if (this.isValidInteger(item.config.form)) {
1395
+ item.config.form = this.calcNewIndexForFormRecordList(
1396
+ item.config.form * 1,
1397
+ item.config.label,
1398
+ );
1399
+ }
1394
1400
  }
1395
1401
  });
1396
1402
  });
@@ -1414,6 +1420,9 @@ export default {
1414
1420
  },
1415
1421
  async deletePage() {
1416
1422
  const back = _.cloneDeep(this.config);
1423
+ if(!this.isNotReferenceToRecordForm()) {
1424
+ return;
1425
+ }
1417
1426
  try {
1418
1427
  this.updateRecordListReferences();
1419
1428
  this.updateNavigationButtonsReferences();
@@ -1434,6 +1443,32 @@ export default {
1434
1443
  });
1435
1444
  this.$store.dispatch("clipboardModule/pushState", this.clipboardPage.items);
1436
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
+ },
1437
1472
  inspect(element = {}) {
1438
1473
  this.closeTemplatesPanel();
1439
1474
  this.inspection = element;
@@ -222,6 +222,7 @@ export default [
222
222
  allowMultiSelect: false,
223
223
  selectedOptions: [],
224
224
  optionsList: [],
225
+ optionsListExtra: [],
225
226
  key:'value',
226
227
  value:'content',
227
228
  ariaLabel: 'ariaLabel',