Skip to content

Commit

Permalink
Cleaned up unneccessary tilt-meta functions
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousjaki committed Jan 5, 2023
1 parent 3c61dcd commit 0db587c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 135 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This plug-in for the Camunda Modeler provides a TILT elements properties panel e

![alt image](./images/properties_panel_extension.png)

The information will automatically appended to the xml representation of the model in the following format:
The information will automatically append to the xml representation of the model in the following format:

```xml
<bpmn:extensionElements>
Expand Down
22 changes: 5 additions & 17 deletions client/tilt-properties/extensions-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,14 @@ export function findExtensions(element, types) {
}
}

export function getXMLTiltMetaProperties(element){
const bo = getBusinessObject(element);
const properties = findExtensions(bo,'tilt:Meta');
if (properties.length) {
return properties[0];
}
return null;
}

export function createExtensionElements(element, bpmnFactory) {
const bo = getBusinessObject(element);
return createElement('bpmn:ExtensionElements', { values: []}, bo, bpmnFactory);
}
export function createTiltMetaProperty(extensionElements, bpmnFactory, properties) {
return createElement('tilt:Meta', properties, extensionElements, bpmnFactory);
}

export function createElement(elementType, properties, parent, factory) {
const element = factory.create(elementType, properties);
element.$parent = parent;

return element;
}

export function createExtensionElements(element, bpmnFactory) {
const bo = getBusinessObject(element);
return createElement('bpmn:ExtensionElements', { values: []}, bo, bpmnFactory);
}
110 changes: 8 additions & 102 deletions client/tilt-properties/props/tilt-property-groups.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { is } from 'bpmn-js/lib/util/ModelUtil';
import { ListGroup} from '@bpmn-io/properties-panel';
import { getBusinessObject } from 'bpmn-js/lib/util/ModelUtil';
import { useService } from 'bpmn-js-properties-panel';
import { TextFieldEntry } from '@bpmn-io/properties-panel';
import {
getXMLTiltMetaProperties,
findExtensions,
createExtensionElements,
createTiltMetaProperty
createElement
} from '../extensions-helper';
import { updateTiltProperty } from '../tilt-io-helper';

import { createMetaPropertyGroup } from './meta-property-group';
import { createControllerPropertyGroup } from './controller-property-group';
import {
updateTiltProperty
} from '../tilt-io-helper';
import { createElement } from '../extensions-helper';

function addFactory(tilt_type, element, injector){
const bpmnFactory = injector.get('bpmnFactory'),
Expand All @@ -27,8 +23,6 @@ function addFactory(tilt_type, element, injector){

const extensionElements = getBusinessObject(element).get('extensionElements'),
tiltProperties = findExtensions(businessObject, tilt_type);

debugger;

let updatedBusinessObject, update;

Expand All @@ -53,48 +47,10 @@ function addFactory(tilt_type, element, injector){
return add;
}

function addMetaFactory(element, injector) {
const bpmnFactory = injector.get('bpmnFactory'),
modeling = injector.get('modeling');

function add(event) {
event.stopPropagation();

const businessObject = getBusinessObject(element);

const extensionElements = getBusinessObject(element).get('extensionElements'),
tiltMetaProperties = getXMLTiltMetaProperties(businessObject);

let updatedBusinessObject, update;

if (!extensionElements) {
updatedBusinessObject = businessObject;

const extensionElements = createExtensionElements(businessObject, bpmnFactory),
tiltMetaProperties = createElement("tilt:Meta",{},extensionElements, bpmnFactory);
extensionElements.values.push(tiltMetaProperties);

update = { extensionElements };
} else if (!tiltMetaProperties) {
updatedBusinessObject = extensionElements;

const tiltMetaProperties = createTiltMetaProperty(extensionElements, bpmnFactory, {});

update = { values: extensionElements.get('values').concat(tiltMetaProperties) };
}
modeling.updateModdleProperties(element, updatedBusinessObject, update);
}

return add;
}

export function removeFactory(element, property, modeling) {

return function(event) {
event.stopPropagation();
//console.log(property)
//debugger;
//const businessObject = getBusinessObject(element);
const extensionElements = getBusinessObject(element).get('extensionElements');

modeling.updateModdleProperties(element, extensionElements, {
Expand Down Expand Up @@ -130,49 +86,6 @@ export function createTiltPropertiesGroup(element,injector,extension_type="tilt:
return tiltGroup
}

export function createTiltMetaGroup(element, injector){
const processBo = getProcessBo(element);
const properties = getTiltMetaProperties(processBo);
var addButton = null;
if(properties.length==0){
addButton = addMetaFactory(element, injector)
};

const tiltGroup = {
id: "tilt-specification-group",
label: "TILT elements",
add:addButton,
component: ListGroup,
items: [
createMetaPropertyGroup(properties,element,injector)
]
}
return tiltGroup
}

export function createTiltControllerGroup(element, injector){
const processBo = getProcessBo(element);
const properties = findExtensions(processBo,"tilt:Controller");
debugger;


var addButton = null;
if(properties.length==0){
addButton = addFactory("tilt:Controller",element, injector)
};

const tiltGroup = {
id: "tilt-specification-group",
label: "TILT elements",
add:addButton,
component: ListGroup,
items: [
createControllerPropertyGroup(properties,element,injector)
]
}
return tiltGroup
}

export function createTextField(props){
const {
id,
Expand Down Expand Up @@ -224,21 +137,14 @@ export function createTextField(props){

/**
* Get process business object from process element or participant.
*/
function getProcessBo(element) {
const bo = getBusinessObject(element);

*
//function getProcessBo(element) {
// const bo = getBusinessObject(element);
//
if (is(element, 'bpmn:Participant')) {
bo = bo.processRef;
}
return bo;
}

function getTiltMetaProperties(processBo){
const tiltMetaProperties = getXMLTiltMetaProperties(processBo);
if (!tiltMetaProperties) {
return [];
}
return tiltMetaProperties;
}
*/
13 changes: 6 additions & 7 deletions client/tilt-properties/tilt-extension-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
} from 'bpmn-js/lib/util/ModelUtil';

import {
createTiltMetaGroup,
createTiltPropertiesGroup
} from './props/tilt-property-groups';

Expand All @@ -27,7 +26,7 @@ export default class TiltPropertiesExtensionProvider {

groups = groups.slice();
if(is(element, 'bpmn:Process')) {
groups.push(createTiltMetaGroup(element,this._injector));
groups.push(createTiltPropertiesGroup(element,this._injector));
}
//if(is(element, 'bpmn:StartEvent')) {
// groups.push(createTiltMetaGroup(element,this._injector));
Expand All @@ -46,8 +45,8 @@ TiltPropertiesExtensionProvider.$inject = [
];


function getProcessRef(element) {
const bo = getBusinessObject(element);

return bo.processRef;
}
//function getProcessRef(element) {
// const bo = getBusinessObject(element);
//
// return bo.processRef;
//}
8 changes: 0 additions & 8 deletions client/tilt-properties/tilt-io-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export function composeTiltControllerPropertyProps(options){
return {name,division,address,country};
}

/**
* Craft the UPDATE command to set a property value.
*/

export function updateTiltProperty(element, property, newProps, modeling, tilt_type) {
const currentProps = property;
var props = {}
Expand All @@ -48,7 +44,3 @@ export function updateTiltProperty(element, property, newProps, modeling, tilt_t

return modeling.updateModdleProperties(element, property, props);
}

//export function createMetaProperty(factory, options) {
// return factory.create('tilt:Meta', composeTiltMetaPropertyProps(options));
//}

0 comments on commit 0db587c

Please sign in to comment.