Skip to content

Commit

Permalink
Trim and remove spaces from ID with user alert (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
theaubmov authored Jun 25, 2024
1 parent bf7ea0c commit 91aa2f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -146,7 +147,7 @@ function DataObjectTextField(props) {
element,
moddleElement: dataObject,
properties: {
id: value,
id: processId(value),
// name: doName
},
});
Expand Down
4 changes: 2 additions & 2 deletions app/spiffworkflow/eventList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -142,7 +142,7 @@ function ItemTextField(props) {
element,
moddleElement: item,
properties: {
id: value,
id: processId(value),
name: value,
},
});
Expand Down
10 changes: 10 additions & 0 deletions app/spiffworkflow/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 91aa2f5

Please sign in to comment.