Merge pull request #58 from sartography/feature/data-object-category

feature/data-object-category
This commit is contained in:
jasquat 2023-12-06 15:19:23 -05:00 committed by GitHub
commit 2169b54d39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 57 additions and 33 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" ],

View File

@ -131,8 +131,8 @@ describe('Properties Panel for User Tasks', function () {
eventBus.fire('spiff.jsonSchema.update', {
value: 'new-schema.json',
});
const jsonFile = getExtensionValue(userElement, 'formJsonSchemaFilename');
const uiFile = getExtensionValue(userElement, 'formUiSchemaFilename');
const jsonFile = getExtensionValue(userElement.businessObject, 'formJsonSchemaFilename');
const uiFile = getExtensionValue(userElement.businessObject, 'formUiSchemaFilename');
expect(jsonFile).to.equal('new-schema.json');
expect(uiFile).to.equal('new-uischema.json');
@ -155,7 +155,7 @@ describe('Properties Panel for User Tasks', function () {
const businessObject = getBusinessObject(userElement);
// The change is reflected in the business object
let instructions = getExtensionValue(
userElement,
businessObject,
'spiffworkflow:InstructionsForEndUser'
);
expect(instructions).to.equal('#Hello!');