diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 1a3a631..adf0e31 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -15,6 +15,7 @@ jobs: - run: | npm install npm run all + sed -i "s/TILT Extension (Development Build)/TILT Extension ${{ github.ref_name }}/" ./index.js zip tilt-release.zip -r ./dist ./client ./index.js ./README.md ./LICENSE.md - name: Create Release diff --git a/client/tilt-properties/extensions-helper.js b/client/tilt-properties/io-extension-helper.js similarity index 64% rename from client/tilt-properties/extensions-helper.js rename to client/tilt-properties/io-extension-helper.js index aff38df..15e17aa 100644 --- a/client/tilt-properties/extensions-helper.js +++ b/client/tilt-properties/io-extension-helper.js @@ -31,4 +31,19 @@ export function createElement(elementType, properties, parent, factory) { export function createExtensionElements(element, bpmnFactory) { const bo = getBusinessObject(element); return createElement('bpmn:ExtensionElements', { values: []}, bo, bpmnFactory); +} + +export function removeDollarProperties(options){ + const pick = (obj, keys) => Object.keys(obj).filter(k => keys.includes(k)).reduce((res, k) => Object.assign(res, {[k]: obj[k]}), {}); + return pick(options,Object.keys(options).filter(item => !item.includes("$"))) +} + +export function updateTiltProperty(element, property, newProps, modeling) { + const currentProps = property; + var props = {} + props = removeDollarProperties({ + ...currentProps, + ...newProps + }); + return modeling.updateModdleProperties(element, property, props); } \ No newline at end of file diff --git a/client/tilt-properties/props/tilt-property-groups.js b/client/tilt-properties/props/tilt-property-groups.js index 1ced54b..7bea91c 100644 --- a/client/tilt-properties/props/tilt-property-groups.js +++ b/client/tilt-properties/props/tilt-property-groups.js @@ -5,9 +5,10 @@ import { TextFieldEntry } from '@bpmn-io/properties-panel'; import { findExtensions, createExtensionElements, - createElement -} from '../extensions-helper'; -import { updateTiltProperty } from '../tilt-io-helper'; + createElement, + removeDollarProperties, + updateTiltProperty +} from '../io-extension-helper'; import { createMetaPropertyGroup } from './meta-property-group'; import { createControllerPropertyGroup } from './controller-property-group'; @@ -48,7 +49,6 @@ function addFactory(tilt_type, element, injector){ } export function removeFactory(element, property, modeling) { - return function(event) { event.stopPropagation(); const extensionElements = getBusinessObject(element).get('extensionElements'); @@ -56,6 +56,13 @@ export function removeFactory(element, property, modeling) { modeling.updateModdleProperties(element, extensionElements, { values: extensionElements.get('values').filter(value => value !== property) }); + + if (extensionElements.values.length == 0){ + var updated_bo = getBusinessObject(element) + delete updated_bo.extensionElements; + updated_bo = removeDollarProperties(updated_bo) + modeling.updateModdleProperties(element,getBusinessObject(element),updated_bo) + } }; } @@ -77,7 +84,7 @@ export function createTiltPropertiesGroup(element,injector,extension_type="tilt: }; const tiltGroup = { - id: "tilt-specification-group", + id: `tilt-specification-group-${element.id}`, label: "TILT elements", add:addButton, component: ListGroup, @@ -98,8 +105,6 @@ export function createTextField(props){ validation_text } = props; - var tilt_type = id.split("-")[0]; - const modeling = useService('modeling'); const translate = useService('translate'); const debounce = useService('debounceInput'); @@ -107,7 +112,7 @@ export function createTextField(props){ const setValue = (value) => { var newPropertyObject = {}; newPropertyObject[type_name] = value || ''; - updateTiltProperty(element, properties, newPropertyObject, modeling, tilt_type); + updateTiltProperty(element, properties, newPropertyObject, modeling); }; const getValue = () => { diff --git a/client/tilt-properties/tilt-io-helper.js b/client/tilt-properties/tilt-io-helper.js deleted file mode 100644 index 690a942..0000000 --- a/client/tilt-properties/tilt-io-helper.js +++ /dev/null @@ -1,46 +0,0 @@ -export function composeTiltMetaPropertyProps(options){ - var { - name, - created, - modified, - version, - language, - status, - url - } = options; - return {name,created,modified,version,language,status,url}; -} - -export function composeTiltControllerPropertyProps(options){ - var { - name, - division, - address, - country - } = options; - return {name,division,address,country}; -} - -export function updateTiltProperty(element, property, newProps, modeling, tilt_type) { - const currentProps = property; - var props = {} - switch(tilt_type){ - case "meta": - props = composeTiltMetaPropertyProps({ - ...currentProps, - ...newProps - }); - break; - case "controller": - props = composeTiltControllerPropertyProps({ - ...currentProps, - ...newProps - }); - break; - default: - console.error(`The tilt property ${tilt_type} cannot be updated.`) - break; - } - - return modeling.updateModdleProperties(element, property, props); -} diff --git a/index.js b/index.js index 6174ad6..e5cece3 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ 'use strict'; module.exports = { - name: 'TILT Extension', + name: `TILT Extension (Development Build)`, script: './dist/client.js' //menu: './client/tilt-extractor/menu.js' };