12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import { getBusinessObject, is } from 'bpmn-js/lib/util/ModelUtil';
- import { TextFieldEntry, isTextFieldEntryEdited } from '@bpmn-io/properties-panel';
- import { useService } from 'bpmn-js-properties-panel';
- import { isIdValid } from '../utils/ValidationUtil';
- /**
- * @typedef { import('@bpmn-io/properties-panel').EntryDefinition } Entry
- */
- /**
- * @returns {Array<Entry>} entries
- */
- export function IdProps() {
- return [
- {
- id: 'id',
- component: Id,
- isEdited: isTextFieldEntryEdited,
- },
- ];
- }
- function Id(props) {
- const { element } = props;
- const modeling = useService('modeling');
- const debounce = useService('debounceInput');
- const translate = useService('translate');
- const setValue = (value) => {
- modeling.updateProperties(element, {
- id: value,
- });
- };
- const getValue = (element) => {
- return element.businessObject.id;
- };
- const validate = (value) => {
- const businessObject = getBusinessObject(element);
- return isIdValid(businessObject, value, translate);
- };
- return TextFieldEntry({
- element,
- id: 'id',
- label: translate(is(element, 'bpmn:Participant') ? 'Participant ID' : 'ID'),
- getValue,
- setValue,
- debounce,
- validate,
- });
- }
|