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 { useService } from 'bpmn-js-properties-panel';
import {SpiffExtensionTextInput} from '../../extensions/propertiesPanel/SpiffExtensionTextInput';
import { import {
isTextFieldEntryEdited, isTextFieldEntryEdited,
TextFieldEntry, TextFieldEntry,
@ -42,6 +43,8 @@ export function DataObjectArray(props) {
idPrefix: id, idPrefix: id,
element, element,
dataObject, dataObject,
commandStack,
moddle,
}), }),
autoFocusEntry: `${id}-dataObject`, autoFocusEntry: `${id}-dataObject`,
remove: removeFactory({ remove: removeFactory({
@ -95,7 +98,7 @@ function removeFactory(props) {
} }
function DataObjectGroup(props) { function DataObjectGroup(props) {
const { idPrefix, dataObject } = props; const { idPrefix, dataObject, element, moddle, commandStack } = props;
return [ return [
{ {
@ -111,7 +114,16 @@ function DataObjectGroup(props) {
isEdited: isTextFieldEntryEdited, isEdited: isTextFieldEntryEdited,
idPrefix, idPrefix,
dataObject, 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, setValue,
debounce, debounce,
}); });
} }

View File

@ -168,10 +168,10 @@ function createDataStateTextField(props) {
element, element,
id: `${id}-textField`, id: `${id}-textField`,
name: 'spiffworkflow:DataStateLabel', 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.', description: 'Enter the Data State for this reference.',
getValue, getValue,
setValue, setValue,
debounce, debounce,
}); });
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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