From 13694fbfbfafcc20dabe1540d22d433ac8bd8537 Mon Sep 17 00:00:00 2001 From: theaubmov Date: Fri, 10 May 2024 11:55:37 +0100 Subject: [PATCH] Trim and remove spaces from ID with user alert --- .../DataObject/propertiesPanel/DataObjectArray.js | 3 ++- app/spiffworkflow/eventList.js | 4 ++-- app/spiffworkflow/helpers.js | 10 ++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/spiffworkflow/DataObject/propertiesPanel/DataObjectArray.js b/app/spiffworkflow/DataObject/propertiesPanel/DataObjectArray.js index cdaa704..e4941be 100644 --- a/app/spiffworkflow/DataObject/propertiesPanel/DataObjectArray.js +++ b/app/spiffworkflow/DataObject/propertiesPanel/DataObjectArray.js @@ -13,6 +13,7 @@ import { idToHumanReadableName, findDataObject, } from '../DataObjectHelpers'; +import { processId } from '../../helpers'; /** * Provides a list of data objects, and allows you to add / remove data objects, and change their ids. @@ -146,7 +147,7 @@ function DataObjectTextField(props) { element, moddleElement: dataObject, properties: { - id: value, + id: processId(value), // name: doName }, }); diff --git a/app/spiffworkflow/eventList.js b/app/spiffworkflow/eventList.js index a1604cb..d81415e 100644 --- a/app/spiffworkflow/eventList.js +++ b/app/spiffworkflow/eventList.js @@ -5,7 +5,7 @@ import { TextFieldEntry, isTextFieldEntryEdited } from '@bpmn-io/properties-panel'; -import { getRoot } from './helpers'; +import { getRoot, processId } from './helpers'; /* This function creates a list of a particular event type at the process level using the item list * and add function provided by `getArray`. @@ -142,7 +142,7 @@ function ItemTextField(props) { element, moddleElement: item, properties: { - id: value, + id: processId(value), name: value, }, }); diff --git a/app/spiffworkflow/helpers.js b/app/spiffworkflow/helpers.js index e576eaa..ad4115d 100644 --- a/app/spiffworkflow/helpers.js +++ b/app/spiffworkflow/helpers.js @@ -36,3 +36,13 @@ export function getRoot(businessObject, moddle) { } return businessObject; } + + +export function processId(id) { + let trimmedId = id.trim(); + let processedId = trimmedId.replace(/\s+/g, ''); + if (id !== processedId) { + alert('ID should not contain spaces. It has been adjusted.'); + } + return processedId; +} \ No newline at end of file