Trim and remove spaces from ID with user alert (#94)

This commit is contained in:
Ayoub Ait Lachgar 2024-06-25 21:21:46 +01:00 committed by GitHub
parent bf7ea0c0b5
commit 91aa2f5933
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View File

@ -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
},
});

View File

@ -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,
},
});

View File

@ -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;
}