Skip to content

Commit

Permalink
Implemented Tilt Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousjaki committed Jan 15, 2023
1 parent c91b935 commit 819fdd1
Show file tree
Hide file tree
Showing 6 changed files with 1,813 additions and 18 deletions.
8 changes: 4 additions & 4 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { config, resolver } from '../.bpmnlintrc';
import tiltPropertiesExtensionModule from './tilt-properties';
import tiltModdleDescriptor from "./descriptors/tilt";

import ExtractButton from './tilt-extractor/extract-button';
//import ExtractButton from './tilt-extractor/extract-button';

//var tiltExtractor = require('./tilt-extractor/tilt-extractor');
var tiltExtractor = require('./tilt-extractor/tilt-extractor');

registerPlatformBpmnJSPlugin(tiltPropertiesExtensionModule);
registerBpmnJSModdleExtension(tiltModdleDescriptor);
Expand All @@ -19,6 +19,6 @@ registerBpmnJSModdleExtension(tiltModdleDescriptor);
registerClientPlugin({ config, resolver }, 'lintRules.cloud-bpmn');
registerClientPlugin({ config, resolver }, 'lintRules.bpmn');

//registerBpmnJSPlugin(tiltExtractor);
registerBpmnJSPlugin(tiltExtractor);

registerClientExtension(ExtractButton);
//registerClientExtension(ExtractButton);
15 changes: 9 additions & 6 deletions client/tilt-extractor/extract-button.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import React, { Fragment, PureComponent } from 'camunda-modeler-plugin-helpers/react';
import { Fill } from 'camunda-modeler-plugin-helpers/components';
import { v4 as uuidv4 } from 'uuid';

import classNames from 'classnames';

export default class ExtractButton extends PureComponent {
constructor(eventBus, bpmnRules, editorActions, canvas, commandStack, elementRegistry, modeling, config) {
constructor(eventBus,canvas) {
debugger;
super();
this.eventBus = eventBus;
this.editorActions = editorActions;
//this.editorActions = editorActions;
this.canvas = canvas;
this.elementRegistry = elementRegistry;
this.config = config;
//this.elementRegistry = elementRegistry;
//this.config = config;
this._buttonRef = React.createRef();
}
createTiltObject(){
alert("Hello World")
debugger;

uuidv4(); // '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
}

/**
Expand All @@ -39,7 +41,8 @@ export default class ExtractButton extends PureComponent {
}

ExtractButton.$inject = [
'eventBus', 'bpmnRules', 'editorActions', 'canvas', 'commandStack', 'elementRegistry', 'modeling','config'
'eventBus',
'canvas'
];


Expand Down
52 changes: 46 additions & 6 deletions client/tilt-extractor/tilt-extractor.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,69 @@
const { getBusinessObject } = require('bpmn-js/lib/util/ModelUtil');
// const {fs} = require("fs")
//const { dialog } = require('electron')

function TiltExtractor(eventBus, bpmnRules, editorActions, canvas, commandStack, elementRegistry, modeling, config) {
//this.commandStack = commandStack;
this.config = config;
this.editorActions = editorActions;
this.modeling = modeling;
debugger;
var self = this;
this.canvas = canvas;

editorActions.register({
extractTiltFromBpmn: function() {
debugger;
let bo = getBusinessObject(canvas.getRootElement())
console.log(canvas)
self.extract();
//console.log("Hello")
}
});
}

TiltExtractor.prototype.getTiltElements = function(element = null) {
if(!element){
element = getBusinessObject(this.canvas.getRootElement());
}
var element_properties = [];
var tilt_properties = [];

if(element instanceof Object && !(element instanceof Array || element instanceof Function)){
element_properties = Object.getOwnPropertyNames(element);
element_properties = element_properties.filter(e =>
!e.startsWith("$") &&
!['di','messageFlows','sourceRef','targetRef','incoming','outgoing','flowNodeRef'].includes(e))

}else if(Array.isArray(element)){
for(let i in element){
tilt_properties.push(...this.getTiltElements(element[i]));
}
return tilt_properties;

}else{
return tilt_properties;

}

if(element.hasOwnProperty("$type") && element.$type.startsWith("tilt")){
tilt_properties.push(element);
console.log(element)
return tilt_properties;

}

for(let p in element_properties){

if(element[element_properties[p]] instanceof Object && typeof(element[element_properties[p]]) != "string"){
tilt_properties.push(...this.getTiltElements(element[element_properties[p]]));

}
}
return tilt_properties;
};

TiltExtractor.prototype.extract = function() {
console.log("Im extracting TILT");
tilt_object = {}
var tilt_elements = this.getTiltElements();

debugger;

//var savepath = await window.showSaveFilePicker()
//dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] });
};
Expand Down
2 changes: 1 addition & 1 deletion client/tilt-properties/props/tilt-property-groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function createExistingPropertyGroupsList(element, injector){
export function createTiltPropertiesGroup(element, injector, blueprint_array = [], max_extensions_to_create = [1]){
var existing_groups = createExistingPropertyGroupsList(element, injector)
var items_list = existing_groups[0], field_counter = existing_groups[1]
debugger;
//debugger;
// return nothing if there are no tilt Elements to create and if there is no tilt Element to add:
if (items_list.length == 0 && blueprint_array.length == 0){
return null
Expand Down
Loading

0 comments on commit 819fdd1

Please sign in to comment.