Trim and remove spaces from ID with user alert (#94)
This commit is contained in:
parent
bf7ea0c0b5
commit
91aa2f5933
|
@ -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
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue