Hi!
First off, i tip my hat to the community support, engagement, and lots of usable and clear to follow examples. This makes it very easy to get very far by just having a look at the available material.
Thus far i have found two examples, one which details how to extend the properties panel with a provider and custom “parts” or input fields, and another detailing how to add a custom meta-model.
I am trying to add fields to the properties panel that would make it possible to create and update custom elements. (elements that do not pertain to the bpmn namespace).
To make it easier to troubleshoot i have employed an already available descriptor: bpmn-js-example-model-extension/qa.json at master · bpmn-io/bpmn-js-example-model-extension · GitHub
Here we have an example of a valid bpmn document containing the extensions described in the descriptor: bpmn-js-example-model-extension/diagram.bpmn at master · bpmn-io/bpmn-js-example-model-extension · GitHub
I have also borrowed parts from the bpmn-js-properties-panel module:bpmn-js-properties-panel/DocumentationProps.js at master · bpmn-io/bpmn-js-properties-panel · GitHub
The latter have been altered to fit the descriptor, and also trimmed, but the mechanism and logic remains the same.
Here are the specifics of this part
import entryFactory from "bpmn-js-properties-panel/lib/factory/EntryFactory";
import cmdHelper from "bpmn-js-properties-panel/lib/helper/CmdHelper"
import { getBusinessObject } from 'bpmn-js/lib/util/ModelUtil';
export default function (group, element, bpmnFactory, translate) {
console.log("trigggggered")
var getValue = function (businessObject) {
return function (element) {
// what exactly does the businessObject getter do
// what is a *businessObject*
var documentations = businessObject && businessObject.get('comment'),
text = (documentations && documentations.length > 0) ? documentations[0].text : '';
return { comment: text };
};
};
var setValue = function (businessObject) {
return function (element, values) {
var newObjectList = [];
// breaks here --> Error: unknown type <qa:comment>
// does not manage to create the qa:comment element
if (typeof values.comment !== 'undefined' && values.comment !== '') {
newObjectList.push(bpmnFactory.create('qa:comment', {
text: values.comment
}));
}
console.log(newObjectList)
return cmdHelper.setList(element, businessObject, 'comment', newObjectList);
};
};
// Element Documentation
var elementDocuEntry = entryFactory.textBox(translate, {
id: 'scenario',
label: translate('scenario documentation'),
modelProperty: 'comment'
});
elementDocuEntry.set = setValue(getBusinessObject(element));
elementDocuEntry.get = getValue(getBusinessObject(element));
group.entries.push(elementDocuEntry);
}
My issue being:
The bpmnFactory.create function throws an error because if fails to create the qa:comment element, even though it is described in the descriptor.
Why is this so, and what exactly is the businessObject (not a very intuitive name?)
Hope you could help steer me in the right direction.
Thanks
Herman
Edit: make the title a bit more descriptive