Merge pull request #58 from sartography/feature/data-object-category
feature/data-object-category
This commit is contained in:
commit
2169b54d39
|
@ -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.',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ 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,
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -93,6 +93,17 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "DataObjectCategory",
|
||||
"superClass": [ "Element" ],
|
||||
"properties": [
|
||||
{
|
||||
"name": "value",
|
||||
"isBody": true,
|
||||
"type": "String"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignalButtonLabel",
|
||||
"superClass": [ "Element" ],
|
||||
|
|
|
@ -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!');
|
||||
|
|
Loading…
Reference in New Issue