added support to add categories to data objects in extensions w/ burnettk

This commit is contained in:
jasquat 2023-12-06 14:57:55 -05:00
parent b00abf00c1
commit d888c37b07
No known key found for this signature in database
9 changed files with 54 additions and 30 deletions

View File

@ -1,4 +1,5 @@
import { useService } from 'bpmn-js-properties-panel';
import {SpiffExtensionTextInput} from '../../extensions/propertiesPanel/SpiffExtensionTextInput';
import {
isTextFieldEntryEdited,
TextFieldEntry,
@ -42,6 +43,8 @@ export function DataObjectArray(props) {
idPrefix: id,
element,
dataObject,
commandStack,
moddle,
}),
autoFocusEntry: `${id}-dataObject`,
remove: removeFactory({
@ -95,7 +98,7 @@ function removeFactory(props) {
}
function DataObjectGroup(props) {
const { idPrefix, dataObject } = props;
const { idPrefix, dataObject, element, moddle, commandStack } = props;
return [
{
@ -111,7 +114,16 @@ function DataObjectGroup(props) {
isEdited: isTextFieldEntryEdited,
idPrefix,
dataObject,
}
},
{
businessObject: dataObject,
commandStack: commandStack,
moddle: moddle,
component: SpiffExtensionTextInput,
name: 'spiffworkflow:DataObjectCategory',
label: 'Data Object Category',
description: 'Useful for setting permissions on groups of data objects.',
},
];
}
@ -192,4 +204,4 @@ function DataObjectNameTextField(props) {
setValue,
debounce,
});
}
}

View File

@ -168,10 +168,10 @@ function createDataStateTextField(props) {
element,
id: `${id}-textField`,
name: 'spiffworkflow:DataStateLabel',
label: 'Enter Data State of this reference?',
label: 'What is the state of this reference?',
description: 'Enter the Data State for this reference.',
getValue,
setValue,
debounce,
});
}
}

View File

@ -33,14 +33,14 @@ const PREFIX = 'spiffworkflow:';
* @param element
* @param name
*/
export function getExtensionValue(element, name) {
export function getExtensionValue(businessObject, name) {
const useProperties = !name.startsWith(PREFIX);
let extension;
if (useProperties) {
extension = getExtensionProperty(element, name);
extension = getExtensionProperty(businessObject, name);
} else {
extension = getExtension(element, name);
extension = getExtension(businessObject, name);
}
if (extension) {
return extension.value;
@ -48,20 +48,24 @@ export function getExtensionValue(element, name) {
return '';
}
export function setExtensionValue(element, name, value, moddle, commandStack) {
export function setExtensionValue(element, name, value, moddle, commandStack, businessObject) {
const useProperties = !name.startsWith(PREFIX)
const { businessObject } = element;
let businessObjectToUse = businessObject
if (!businessObjectToUse) {
businessObjectToUse = element.businessObject;
}
// Assure we have extensions
let extensions = businessObject.extensionElements;
let extensions = businessObjectToUse.extensionElements;
if (!extensions) {
extensions = moddle.create('bpmn:ExtensionElements');
}
if (useProperties) {
let properties = getExtension(element, SPIFF_PARENT_PROP);
let property = getExtensionProperty(element, name);
let properties = getExtension(businessObjectToUse, SPIFF_PARENT_PROP);
let property = getExtensionProperty(businessObjectToUse, name);
if (!properties) {
properties = moddle.create(SPIFF_PARENT_PROP);
extensions.get('values').push(properties);
@ -73,7 +77,7 @@ export function setExtensionValue(element, name, value, moddle, commandStack) {
property.value = value;
property.name = name;
} else {
let extension = getExtension(element, name);
let extension = getExtension(businessObjectToUse, name);
if (!extension) {
extension = moddle.create(name);
extensions.get('values').push(extension)
@ -83,19 +87,18 @@ export function setExtensionValue(element, name, value, moddle, commandStack) {
commandStack.execute('element.updateModdleProperties', {
element,
moddleElement: businessObject,
moddleElement: businessObjectToUse,
properties: {
extensionElements: extensions,
},
});
}
function getExtension(element, name) {
const bizObj = element.businessObject;
if (!bizObj.extensionElements) {
function getExtension(businessObject, name) {
if (!businessObject.extensionElements) {
return null;
}
const extensionElements = bizObj.extensionElements.get('values');
const extensionElements = businessObject.extensionElements.get('values');
return extensionElements.filter(function (extensionElement) {
if (extensionElement.$instanceOf(name)) {
return true;
@ -104,8 +107,8 @@ function getExtension(element, name) {
}
function getExtensionProperty(element, name) {
const parentElement = getExtension(element, SPIFF_PARENT_PROP);
function getExtensionProperty(businessObject, name) {
const parentElement = getExtension(businessObject, SPIFF_PARENT_PROP);
if (parentElement) {
return parentElement.get('properties').filter(function (propertyElement) {
return (

View File

@ -15,7 +15,7 @@ export function SpiffExtensionCheckboxEntry(props) {
const debounce = useService('debounceInput');
const getValue = () => {
return getExtensionValue(element, name)
return getExtensionValue(element.businessObject, name)
}
const setValue = value => {

View File

@ -14,7 +14,7 @@ export function SpiffExtensionLaunchButton(props) {
className: 'spiffworkflow-properties-panel-button',
id: `launch_editor_button_${name}`,
onClick: () => {
const value = getExtensionValue(element, name);
const value = getExtensionValue(element.businessObject, name);
eventBus.fire(event, {
value,
eventBus,

View File

@ -36,7 +36,7 @@ export function SpiffExtensionSelect(props) {
const eventBus = useService('eventBus');
const getValue = () => {
return getExtensionValue(element, name);
return getExtensionValue(element.businessObject, name);
};
const setValue = (value) => {

View File

@ -15,7 +15,7 @@ export function SpiffExtensionTextArea(props) {
const debounce = useService('debounceInput');
const getValue = () => {
return getExtensionValue(element, name)
return getExtensionValue(element.businessObject, name)
}
const setValue = value => {

View File

@ -21,17 +21,15 @@ import {
* @returns {string|null|*}
*/
export function SpiffExtensionTextInput(props) {
const element = props.element;
const commandStack = props.commandStack, moddle = props.moddle;
const name = props.name, label = props.label, description = props.description;
const { element, commandStack, moddle, name, label, description, businessObject } = props;
const debounce = useService('debounceInput');
const getValue = () => {
return getExtensionValue(element, name)
return getExtensionValue(businessObject, name)
}
const setValue = value => {
setExtensionValue(element, name, value, moddle, commandStack)
setExtensionValue(element, name, value, moddle, commandStack, businessObject)
};
return <TextFieldEntry

View File

@ -93,6 +93,17 @@
}
]
},
{
"name": "DataObjectCategory",
"superClass": [ "Element" ],
"properties": [
{
"name": "value",
"isBody": true,
"type": "String"
}
]
},
{
"name": "SignalButtonLabel",
"superClass": [ "Element" ],