import { CtlBase } from './CtlBase' import { CtlBpmnDefault } from './CtlDefaultValue' import { parseYvanPropChangeVJson } from './CtlUtils' import { YvEvent, YvEventDispatch } from './YvanEvent' import webix from 'webix' webix.protoUI( { name: 'bpmn', defaults: {}, $init: function (config: any) { this._domid = 'dd' + webix.uid(); this.$view.innerHTML = `
` this.$ready.push(this._ready) _.extend(this.config, config) if (config.on && typeof config.on.onInited === 'function') { config.on.onInited.call(this) } }, _ready: function (this: any) { this.isBpmnLoad = false; this.myDebounce = _.debounce(() => { this._updateScrollSize() }) }, _set_inner_size: function () { if (!this._bpmn || !this.$width) return this.myDebounce() }, destructor: function () { if (this.$destructed) { return; } this.$destructed = true; if (this.config.on && typeof this.config.on.onDestruct === 'function') { this.config.on.onDestruct.call(this) } }, _updateScrollSize: function () { console.log('_updateScrollSize') var box = this._bpmn._container; box.style.height = (this.$height || 0) + 'px' box.style.width = (this.$width || 0) + 'px' var canvas = this._bpmn.get('canvas') // _.debounce(() => { canvas.zoom('fit-viewport') // }) }, $setSize: function (x: any, y: any) { if (webix.ui.view.prototype.$setSize.call(this, x, y)) { _.defer(() => { this._set_inner_size() if (this.isBpmnLoad == false) { this.isBpmnLoad = true //@ts-ignore require(['bpmn-modeler', 'bpmn-navigated', 'bpmn-viewer'], (BpModeler: any, BpNavigated: any, BpmnViewer: any) => { const $dom = $('#' + this._domid) const bpmn = new BpNavigated({ container: $dom[0], ...this.config.bpmnConfig }); this._bpmn = bpmn; if (this.wrapper._todoDiagram) { this.wrapper.openDiagram(this.wrapper._todoDiagram); delete this.wrapper._todoDiagram } const eventBus = bpmn.get('eventBus'); if (this.wrapper.onHover) { eventBus.on('element.hover', (e: any) => { YvEventDispatch(this.wrapper.onHover, this.wrapper, e.element); }) } if (this.wrapper.onOut) { eventBus.on('element.out', (e: any) => { YvEventDispatch(this.wrapper.onOut, this.wrapper, e.element); }) } if (this.wrapper.onClick) { eventBus.on('element.click', (e: any) => { YvEventDispatch(this.wrapper.onClick, this.wrapper, e.element); }) } if (this.wrapper.onDblClick) { eventBus.on('element.dblclick', (e: any) => { YvEventDispatch(this.wrapper.onDblClick, this.wrapper, e.element); }) } if (this.wrapper.onMousedown) { eventBus.on('element.mousedown', (e: any) => { YvEventDispatch(this.wrapper.onMousedown, this.wrapper, e.element); }) } if (this.wrapper.onMouseup) { eventBus.on('element.mouseup', (e: any) => { YvEventDispatch(this.wrapper.onMouseup, this.wrapper, e.element); }) } }) } }) } } }, webix.ui.view ) export class CtlBpmn extends CtlBase