├── .babelrc ├── .eslintignore ├── .eslintrc ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── BUG_REPORT.md │ └── FEATURE_REQUEST.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── docs └── project │ ├── COMMIT_MESSAGES.md │ ├── SETUP.md │ ├── setup-alternative.sh │ ├── setup.bat │ └── setup.sh ├── index.js ├── lib ├── Modeler.js ├── NavigatedViewer.js ├── Viewer.js ├── core │ ├── ItemRegistry.js │ └── index.js ├── draw │ ├── CmmnRenderer.js │ ├── PathMap.js │ └── index.js ├── features │ ├── auto-resize │ │ ├── CmmnAutoResizeProvider.js │ │ └── index.js │ ├── context-pad │ │ ├── ContextPadProvider.js │ │ └── index.js │ ├── editor-actions │ │ ├── CmmnEditorActions.js │ │ └── index.js │ ├── keyboard │ │ ├── CmmnKeyboardBindings.js │ │ └── index.js │ ├── label-editing │ │ ├── LabelEditingProvider.js │ │ ├── LabelUtil.js │ │ ├── cmd │ │ │ └── UpdateLabelHandler.js │ │ └── index.js │ ├── modeling │ │ ├── CmmnFactory.js │ │ ├── CmmnLayouter.js │ │ ├── CmmnUpdater.js │ │ ├── ElementFactory.js │ │ ├── Modeling.js │ │ ├── behavior │ │ │ ├── AttachCriterionBehavior.js │ │ │ ├── CaseFileItemUpdater.js │ │ │ ├── LabelBehavior.js │ │ │ ├── PlanItemDefinitionUpdater.js │ │ │ ├── PlanningTableUpdater.js │ │ │ ├── ReplaceConnectionBehavior.js │ │ │ ├── ReplaceElementBehavior.js │ │ │ ├── ResizeCasePlanModelBehavior.js │ │ │ ├── SentryUpdater.js │ │ │ ├── UnclaimIdBehavior.js │ │ │ └── index.js │ │ ├── cmd │ │ │ ├── AppendShapeHandler.js │ │ │ ├── IdClaimHandler.js │ │ │ ├── ReconnectConnectionHandler.js │ │ │ ├── ReplaceShapeHandler.js │ │ │ ├── UpdateControlsHandler.js │ │ │ ├── UpdatePropertiesHandler.js │ │ │ └── UpdateSemanticParentHandler.js │ │ ├── index.js │ │ └── util │ │ │ ├── ModelingUtil.js │ │ │ └── PlanItemDefinitionUtil.js │ ├── ordering │ │ ├── CmmnOrderingProvider.js │ │ └── index.js │ ├── outline │ │ ├── Outline.js │ │ └── index.js │ ├── palette │ │ ├── PaletteProvider.js │ │ └── index.js │ ├── popup-menu │ │ ├── ReplaceMenuProvider.js │ │ └── index.js │ ├── replace-preview │ │ ├── CmmnReplacePreview.js │ │ └── index.js │ ├── replace │ │ ├── CmmnReplace.js │ │ ├── ReplaceOptions.js │ │ └── index.js │ ├── rules │ │ ├── CmmnRules.js │ │ └── index.js │ ├── search │ │ ├── CmmnSearchProvider.js │ │ └── index.js │ └── snapping │ │ ├── CmmnConnectSnapping.js │ │ ├── CmmnCreateMoveSnapping.js │ │ ├── CmmnResizeSnapping.js │ │ ├── CmmnSnappingUtil.js │ │ └── index.js ├── import │ ├── CmmnImporter.js │ ├── CmmnTreeWalker.js │ ├── Importer.js │ ├── Util.js │ └── index.js └── util │ ├── DiUtil.js │ ├── LabelUtil.js │ ├── ModelUtil.js │ └── PoweredByUtil.js ├── package-lock.json ├── package.json ├── resources ├── banner-min.txt ├── banner.txt ├── initial.cmmn └── logo.svg ├── tasks ├── build-distro.js ├── bundle.js ├── helpers.js ├── stages │ └── update-examples └── test-distro.js └── test ├── .eslintrc ├── TestHelper.js ├── config ├── karma.distro.js └── karma.unit.js ├── distro ├── cmmn-modeler.js ├── cmmn-navigated-viewer.js ├── cmmn-viewer.js └── helper.js ├── fixtures └── cmmn │ ├── complex.cmmn │ ├── containers.cmmn │ ├── empty-definitions.cmmn │ ├── error │ ├── cmmn-shape-no-cmmn-element-ref.cmmn │ └── missing-namespace.cmmn │ ├── multiple-cases.cmmn │ ├── renderer │ ├── case-file-item-on-part.cmmn │ ├── case-file-item.cmmn │ ├── case-plan-model.cmmn │ ├── case-task.cmmn │ ├── collapsed-discretionary-stage.cmmn │ ├── collapsed-plan-fragment.cmmn │ ├── collapsed-stage.cmmn │ ├── connection.cmmn │ ├── decision-task.cmmn │ ├── discretionary-case-task.cmmn │ ├── discretionary-decision-task.cmmn │ ├── discretionary-human-task.cmmn │ ├── discretionary-manual-task.cmmn │ ├── discretionary-milestone.cmmn │ ├── discretionary-process-task.cmmn │ ├── discretionary-timer-event-listener.cmmn │ ├── discretionary-untyped-event-listener.cmmn │ ├── discretionary-untyped-task.cmmn │ ├── discretionary-user-event-listener.cmmn │ ├── entry-criterion.cmmn │ ├── exit-criterion-on-case-plan-model.cmmn │ ├── exit-criterion.cmmn │ ├── expanded-discretionary-stage.cmmn │ ├── expanded-plan-fragment.cmmn │ ├── expanded-stage.cmmn │ ├── human-task.cmmn │ ├── manual-task.cmmn │ ├── milestone.cmmn │ ├── plan-item-on-part-references-exit-criterion.cmmn │ ├── plan-item-on-part.cmmn │ ├── process-task.cmmn │ ├── timer-event-listener.cmmn │ ├── untyped-event-listener.cmmn │ ├── untyped-task.cmmn │ └── user-event-listener.cmmn │ └── simple.cmmn ├── helper └── index.js ├── spec ├── ModelerSpec.js ├── NavigatedViewerSpec.js ├── ViewerSpec.js ├── core │ └── ItemRegistrySpec.js ├── draw │ └── CmmnRendererSpec.js ├── features │ ├── auto-resize │ │ ├── AutoResizeSpec.js │ │ └── auto-resize.cmmn │ ├── context-pad │ │ ├── ContextPad.activation.cmmn │ │ └── ContextPadProviderSpec.js │ ├── keyboard │ │ └── CmmnKeyboardBindingsSpec.js │ ├── label-editing │ │ ├── LabelEditingProviderSpec.js │ │ └── labels.cmmn │ ├── modeling │ │ ├── AppendShape.criterion.cmmn │ │ ├── AppendShapeSpec.js │ │ ├── CmmnFactorySpec.js │ │ ├── CmmnLayouter.connections.cmmn │ │ ├── CmmnLayouterSpec.js │ │ ├── CmmnUpdater.association.cmmn │ │ ├── CmmnUpdater.case-file-item-on-part.cmmn │ │ ├── CmmnUpdater.case-file-item.cmmn │ │ ├── CmmnUpdater.cmmn │ │ ├── CmmnUpdater.discretionary-connection.cmmn │ │ ├── CmmnUpdater.plan-item-on-part.cmmn │ │ ├── CmmnUpdaterSpec.js │ │ ├── IdClaimSpec.js │ │ ├── LabelBoundsSpec.cmmn │ │ ├── LabelBoundsSpec.js │ │ ├── UpdateAttachment.cmmn │ │ ├── UpdateAttachmentSpec.js │ │ ├── behavior │ │ │ ├── AttachCriterionBehavior.cmmn │ │ │ ├── AttachCriterionBehaviorSpec.js │ │ │ ├── CaseFileItemUpdater.children.cmmn │ │ │ ├── CaseFileItemUpdater.references.cmmn │ │ │ ├── CaseFileItemUpdater.simple.cmmn │ │ │ ├── CaseFileItemUpdaterSpec.js │ │ │ ├── LabelBehavior.cmmn │ │ │ ├── LabelBehaviorSpec.js │ │ │ ├── PlanItemDefinitionUpdater.add.cmmn │ │ │ ├── PlanItemDefinitionUpdater.chain-discretionary-connection.cmmn │ │ │ ├── PlanItemDefinitionUpdater.create-discretionary-connection.cmmn │ │ │ ├── PlanItemDefinitionUpdater.delete-discretionary-connection.cmmn │ │ │ ├── PlanItemDefinitionUpdater.different-parents.cmmn │ │ │ ├── PlanItemDefinitionUpdater.discretionary-to-human-task.cmmn │ │ │ ├── PlanItemDefinitionUpdater.morph-to-plan-fragment.cmmn │ │ │ ├── PlanItemDefinitionUpdater.move-plan-fragment.cmmn │ │ │ ├── PlanItemDefinitionUpdater.move-shared-definition-duplicate.cmmn │ │ │ ├── PlanItemDefinitionUpdater.move-shared-definition.cmmn │ │ │ ├── PlanItemDefinitionUpdater.move.cmmn │ │ │ ├── PlanItemDefinitionUpdater.nested-planning-table.cmmn │ │ │ ├── PlanItemDefinitionUpdater.reconnect-end-discretionary-connection.cmmn │ │ │ ├── PlanItemDefinitionUpdater.reconnect-start-discretionary-connection.cmmn │ │ │ ├── PlanItemDefinitionUpdater.replace.cmmn │ │ │ ├── PlanItemDefinitionUpdater.shared-definition.cmmn │ │ │ ├── PlanItemDefinitionUpdater.simple-move.cmmn │ │ │ ├── PlanItemDefinitionUpdater.simple-remove.cmmn │ │ │ ├── PlanItemDefinitionUpdaterAddSpec.js │ │ │ ├── PlanItemDefinitionUpdaterDiscretionaryConnectionSpec.js │ │ │ ├── PlanItemDefinitionUpdaterMoveSpec.js │ │ │ ├── PlanItemDefinitionUpdaterRemoveSpec.js │ │ │ ├── PlanItemDefinitionUpdaterReplaceSpec.js │ │ │ ├── PlanningTableUpdater.add.cmmn │ │ │ ├── PlanningTableUpdater.discretionary-connection.cmmn │ │ │ ├── PlanningTableUpdater.move-to-case-plan.cmmn │ │ │ ├── PlanningTableUpdater.move.cmmn │ │ │ ├── PlanningTableUpdater.remove.cmmn │ │ │ ├── PlanningTableUpdater.switch-source-target.cmmn │ │ │ ├── PlanningTableUpdater.without-discretionary-connection.cmmn │ │ │ ├── PlanningTableUpdaterAddSpec.js │ │ │ ├── PlanningTableUpdaterDiscretionaryConnectionSpec.js │ │ │ ├── PlanningTableUpdaterMoveSpec.js │ │ │ ├── PlanningTableUpdaterRemoveSpec.js │ │ │ ├── ReplaceConnectionBehavior.connection.cmmn │ │ │ ├── ReplaceConnectionBehavior.move.cmmn │ │ │ ├── ReplaceConnectionBehavior.replace.cmmn │ │ │ ├── ReplaceConnectionBehaviorSpec.js │ │ │ ├── ReplaceElementBehavior.cmmn │ │ │ ├── ReplaceElementBehavior.discretionary-item.cmmn │ │ │ ├── ReplaceElementBehavior.on-part.cmmn │ │ │ ├── ReplaceElementBehavior.replace-connection-end.cmmn │ │ │ ├── ReplaceElementBehaviorSpec.js │ │ │ ├── SentryUpdater.add.cmmn │ │ │ ├── SentryUpdater.case-file-item-on-part.cmmn │ │ │ ├── SentryUpdater.discretionary-connection.cmmn │ │ │ ├── SentryUpdater.discretionary-to-human-task.cmmn │ │ │ ├── SentryUpdater.discretionary-to-stage.cmmn │ │ │ ├── SentryUpdater.move-nested-human-task-criterion-not-visible.cmmn │ │ │ ├── SentryUpdater.move-nested-human-task.cmmn │ │ │ ├── SentryUpdater.move-shared-case-item-on-parts.cmmn │ │ │ ├── SentryUpdater.move-shared-plan-item-on-parts.cmmn │ │ │ ├── SentryUpdater.move.cmmn │ │ │ ├── SentryUpdater.plan-item-on-part.cmmn │ │ │ ├── SentryUpdater.remove.cmmn │ │ │ ├── SentryUpdater.replace.cmmn │ │ │ ├── SentryUpdater.standard-event.cmmn │ │ │ ├── SentryUpdaterAddSpec.js │ │ │ ├── SentryUpdaterCaseFileItemOnPartSpec.js │ │ │ ├── SentryUpdaterDiscretionaryConnectionSpec.js │ │ │ ├── SentryUpdaterMoveSpec.js │ │ │ ├── SentryUpdaterPlanItemOnPartConnectionSpec.js │ │ │ ├── SentryUpdaterRemoveSpec.js │ │ │ ├── SentryUpdaterReplace.cmmn │ │ │ ├── SentryUpdaterReplaceSpec.js │ │ │ └── SentryUpdaterStandardEventSpec.js │ │ └── cmd │ │ │ ├── UpdateControls.autoComplete.cmmn │ │ │ ├── UpdateControls.blocking.cmmn │ │ │ ├── UpdateControls.delete-rules.cmmn │ │ │ ├── UpdateControls.set-rules.cmmn │ │ │ ├── UpdateControlsHandlerSpec.js │ │ │ └── UpdatePropertiesHandlerSpec.js │ ├── ordering │ │ ├── CmmnOrderingProviderSpec.js │ │ ├── Helper.js │ │ └── Ordering.cmmn │ ├── outline │ │ └── OutlineSpec.js │ ├── palette │ │ └── PaletteProviderSpec.js │ ├── popup-menu │ │ ├── ReplaceMenuProvider.replace-menu.cmmn │ │ ├── ReplaceMenuProvider.toggle.cmmn │ │ └── ReplaceMenuProviderSpec.js │ ├── remove │ │ ├── RemovePlanItem.cmmn │ │ └── RemovePlanItemSpec.js │ ├── replace-preview │ │ ├── CmmnReplacePreview.cmmn │ │ └── CmmnReplacePreviewSpec.js │ ├── replace │ │ ├── CmmnReplace.cmmn │ │ ├── CmmnReplace.connection.cmmn │ │ ├── CmmnReplace.properties.cmmn │ │ └── CmmnReplaceSpec.js │ ├── resize │ │ ├── ResizeStage.cmmn │ │ ├── ResizeStage.discretionary.cmmn │ │ └── ResizeStageSpec.js │ ├── rules │ │ ├── CmmnRules.artifact.cmmn │ │ ├── CmmnRules.cmmn │ │ ├── CmmnRules.connection.cmmn │ │ ├── CmmnRules.criterion.cmmn │ │ ├── CmmnRules.external-label.cmmn │ │ ├── CmmnRulesSpec.js │ │ └── Helper.js │ ├── search │ │ ├── CmmnSearchProvider.cmmn │ │ └── CmmnSearchProviderSpec.js │ └── snapping │ │ ├── CmmnSnapping.caseplanmodel-resize.cmmn │ │ ├── CmmnSnapping.discretionaryitem-stage-resize.cmmn │ │ ├── CmmnSnapping.planitem-stage-resize.cmmn │ │ ├── CmmnSnapping.sentries.cmmn │ │ ├── CmmnSnapping.siblings.cmmn │ │ ├── CmmnSnapping.text-annotation.cmmn │ │ └── CmmnSnappingSpec.js └── import │ ├── Importer.association.cmmn │ ├── Importer.case-file-item.cmmn │ ├── Importer.case-plan-model-without-di.cmmn │ ├── Importer.cmmn │ ├── Importer.connections.cmmn │ ├── Importer.discretionary-association.cmmn │ ├── Importer.multiple-cases.cmmn │ ├── Importer.multiple-discretionary-connection.cmmn │ ├── Importer.text-annotation.cmmn │ └── ImporterSpec.js └── util ├── KeyEvents.js ├── MockEvents.js └── custom-rules ├── CustomRules.js └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ "env" ] 3 | } -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | dist -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "plugin:bpmn-io/es5", 3 | "env": { 4 | "browser": true 5 | } 6 | } -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | We love you to contribute to this project by filing bugs, helping others on the [issue tracker](https://github.com/bpmn-io/cmmn-js/issues), by contributing features/bug fixes through pull requests or by helping out in our [forums](https://forum.bpmn.io/). 4 | 5 | 6 | ## Creating issues 7 | 8 | We use our [issue tracker](https://github.com/bpmn-io/cmmn-js/issues) for project communication. 9 | When using the issue tracker: 10 | 11 | * Be descriptive when creating an issue (what, where, when and how does a problem pop up)? 12 | * Attach steps to reproduce (if applicable) 13 | * Attach code samples, configuration options or stack traces that may indicate a problem 14 | * Be helpful and respect others when commenting 15 | 16 | Create a pull request if you would like to have an in-depth discussion about some piece of code. 17 | 18 | 19 | ## Setting up the project locally 20 | 21 | The project development runs on top of the [diagram-js](https://github.com/bpmn-io/diagram-js) master branch. The following code snippet sets up both libraries linking diagram-js to cmmn-js. 22 | 23 | ```sh 24 | mkdir bpmn.io 25 | cd bpmn.io 26 | 27 | git clone git@github.com:bpmn-io/diagram-js.git 28 | (cd diagram-js && npm i) 29 | 30 | git clone git@github.com:bpmn-io/cmmn-js.git 31 | (cd cmmn-js && npm install && npm link ../diagram-js) 32 | 33 | // Run the test suite 34 | npm test 35 | 36 | // Running the test suite with every file change 37 | TEST_BROWSERS=(Chrome|Firefox|IE) npm run dev 38 | ``` 39 | 40 | ## Creating pull requests 41 | 42 | We use pull requests for feature discussion and bug fixes. If you are not yet familiar on how to create a pull request, [read this great guide](https://gun.io/blog/how-to-github-fork-branch-and-pull-request). 43 | 44 | Some things that make it easier for us to accept your pull requests 45 | 46 | * The code adheres to our conventions 47 | * spaces instead of tabs 48 | * single-quotes 49 | * ... 50 | * The code is tested 51 | * The `npm run all` build passes (executes tests + linting) 52 | * The work is combined into a single commit 53 | * The commit messages adhere to the [conventional commits guideline](https://www.conventionalcommits.org) 54 | 55 | 56 | We'd be glad to assist you if you do not get these things right in the first place. 57 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us fix a library error 4 | --- 5 | 6 | 13 | 14 | 15 | __Describe the Bug__ 16 | 17 | A clear and concise description of what the bug is. 18 | 19 | 20 | __Steps to Reproduce__ 21 | 22 | Steps to reproduce the behavior: 23 | 24 | 1. do this 25 | 2. do that 26 | 27 | If you report a modeling related issue, ensure you can reproduce it on [demo.bpmn.io](https://demo.bpmn.io/cmmn/new) 28 | 29 | When reporting a library error, try to build an example that reproduces your problem. You can use our playgrounds for [viewer](https://jsfiddle.net/x2doq4vn/) or [modeler](https://jsfiddle.net/nrko5hyt/) as a starting point or put a demo up on [GitHub](https://github.com/) for inspection. 30 | 31 | 32 | __Expected Behavior__ 33 | 34 | A clear and concise description of what you expected to happen. 35 | 36 | 37 | __Environment__ 38 | 39 | Please complete the following information: 40 | 41 | - Browser: [e.g. IE 11, Chrome 69] 42 | - OS: [e.g. Windows 7] 43 | - Library version: [e.g. 2.0.0] -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea or general improvement 4 | --- 5 | 6 | 14 | 15 | 16 | __Is your feature request related to a problem? Please describe.__ 17 | 18 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 19 | 20 | 21 | __Describe the solution you'd like__ 22 | 23 | A clear and concise description of what you want to happen. 24 | 25 | __Describe alternatives you've considered__ 26 | 27 | A clear and concise description of any alternative solutions or features you've considered. 28 | 29 | 30 | __Additional context__ 31 | 32 | Add any other context or screenshots about the feature request here. 33 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | __Which issue does this PR address?_ 10 | 11 | Closes # -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | .idea 4 | *.iml 5 | .DS_Store -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | !dist 2 | .github 3 | docs 4 | resources 5 | tasks 6 | test/* 7 | !test/util 8 | !test/helper 9 | .eslintignore 10 | .eslintrc 11 | .travis.yml -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 'node' 4 | 5 | sudo: false 6 | 7 | script: npm test 8 | 9 | jobs: 10 | include: 11 | - stage: test 12 | addons: 13 | firefox: "latest-esr" 14 | script: 15 | - TEST_BROWSERS=Firefox,ChromeHeadless xvfb-run npm run all 16 | - stage: update examples 17 | script: './tasks/stages/update-examples' 18 | 19 | stages: 20 | - test 21 | - name: update examples 22 | if: tag =~ ^v\d -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2018 camunda services GmbH 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in the 5 | Software without restriction, including without limitation the rights to use, copy, 6 | modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 7 | and to permit persons to whom the Software is furnished to do so, subject to the 8 | following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | The source code responsible for displaying the bpmn.io logo (two green cogwheels in 14 | a box) that links back to http://bpmn.io as part of rendered diagrams MUST NOT be 15 | removed or changed. When this software is being used in a website or application, 16 | the logo must stay fully visible and not visually overlapped by other elements. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 19 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 20 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 21 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 23 | OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cmmn-js - CMMN 1.1 for the web 2 | 3 | [![Build Status](https://travis-ci.com/bpmn-io/cmmn-js.svg?branch=develop)](https://travis-ci.com/bpmn-io/cmmn-js) 4 | 5 | View and edit CMMN 1.1 diagrams in the browser. 6 | 7 | 8 | ## Installation 9 | 10 | Use the library [pre-packaged](https://github.com/bpmn-io/cmmn-js-examples/tree/master/pre-packaged) 11 | or include it [via npm](https://github.com/bpmn-io/cmmn-js-examples/tree/master/bundling) 12 | into your node-style web-application. 13 | 14 | ## Usage 15 | 16 | To get started, create a [cmmn-js](https://github.com/bpmn-io/cmmn-js) instance 17 | and render [CMMN 1.1 diagrams](http://www.omg.org/spec/CMMN/1.1/) in the browser: 18 | 19 | ```javascript 20 | var xml; // my CMMN 1.1 xml 21 | var viewer = new CmmnJS({ 22 | container: 'body' 23 | }); 24 | 25 | viewer.importXML(xml, function(err) { 26 | 27 | if (err) { 28 | console.log('error rendering', err); 29 | } else { 30 | console.log('rendered'); 31 | } 32 | }); 33 | ``` 34 | 35 | Checkout our [examples](https://github.com/bpmn-io/cmmn-js-examples) for many 36 | more supported usage scenarios. 37 | 38 | 39 | ### Dynamic Attach/Detach 40 | 41 | You may attach or detach the viewer dynamically to any element on the page, too: 42 | 43 | ```javascript 44 | var viewer = new CmmnJS(); 45 | 46 | // attach it to some element 47 | viewer.attachTo('#container'); 48 | 49 | // detach the panel 50 | viewer.detach(); 51 | ``` 52 | 53 | 54 | ## Resources 55 | 56 | * [Demo](http://demo.bpmn.io/cmmn) 57 | * [Issues](https://github.com/bpmn-io/cmmn-js/issues) 58 | * [Examples](https://github.com/bpmn-io/cmmn-js-examples) 59 | * [Forum](https://forum.bpmn.io) 60 | 61 | 62 | ## Building the Project 63 | 64 | Perform the following steps to build the library, including running all tests: 65 | 66 | ``` 67 | cd cmmn-js 68 | npm install 69 | npm run all 70 | ``` 71 | 72 | You may need to perform [additional project setup](./docs/project/SETUP.md) when 73 | building the latest development snapshot. 74 | 75 | Please checkout our [contributing guidelines](./.github/CONTRIBUTING.md) if you plan to 76 | file an issue or pull request. 77 | 78 | 79 | ## Related 80 | 81 | cmmn-js builds on top of a few additional powerful tools: 82 | 83 | * [cmmn-moddle](https://github.com/bpmn-io/cmmn-moddle): Read / write support for CMMN 1.1 XML in the browsers 84 | * [diagram-js](https://github.com/bpmn-io/diagram-js): Diagram rendering and editing toolkit 85 | 86 | 87 | ## License 88 | 89 | Use under the terms of the [bpmn.io license](http://bpmn.io/license). 90 | -------------------------------------------------------------------------------- /docs/project/COMMIT_MESSAGES.md: -------------------------------------------------------------------------------- 1 | # Commit Messages 2 | 3 | Contributors should adhere to our [commit message guidelines](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit?pli=1). 4 | 5 | The goal is to achive better readability of the projects commit log and eventually use the log as a low level change tracker. 6 | 7 | ```plain 8 | feat(context-pad): add delete button 9 | fix(modeling): assign valid semantic ids 10 | fix(Viewer): correctly fire imported event 11 | ``` 12 | 13 | It is important for [semantic versioning](http://semver.org/) during releases and for project change tracking. 14 | 15 | 16 | ## General Syntax 17 | 18 | ```plain 19 | (): 20 | 21 | 22 | 23 | Closes # 24 | 25 | [BREAKING CHANGE: 26 | 27 | * migration notes ] 28 | ``` 29 | 30 | 31 | ## Hints 32 | 33 | Consider the following hints when writing commit messages 34 | 35 | * Classify what you did 36 | 37 | * `fix` commit fixes a bug, patches the project 38 | * `feat` commit adds a feature, increases the minor version 39 | * `docs` commit improves or adds documentation 40 | * `refactor` commit cleans up mess in a non-api-breaking manner 41 | 42 | * State the module your change applies to 43 | 44 | * `viewer` commit changes viewer code 45 | * `context-pad` commit alters context pad 46 | * `modeling/CmmnFactory` commit fixes a specific bug in the `CmmnFactory` (use in rare important cases only) 47 | * use lower case for modules, camelCase for files (according to file names) 48 | 49 | * beware of public api (everything that has been blogged about on [bpmn.io](http://bpmn.io/blog)) 50 | 51 | * mark breaking public api via `BREAKING CHANGE: ...` 52 | 53 | * try not to swallow bug fixes (`fix`) in feature commits (`feat`). People may wait for a fixes forever. 54 | 55 | 56 | ## Examples 57 | 58 | ```plain 59 | feat(modeler): add create diagram option 60 | 61 | This commit adds the ability to create a new diagram in the modeler via 62 | 63 | Modeler#createDiagram(done) 64 | 65 | Related to #12 66 | ``` 67 | 68 | 69 | ```plain 70 | fix(modeling): generate valid semantic ids 71 | 72 | IDs in XML documents must not start with a number as per XML spec. 73 | 74 | This commit changes our id generation behavior to use semantic ids that 75 | are prefixed with the elements type (never starts with a number): 76 | 77 | Before: asdas123se8as 78 | Now: PlanItem_asdas123se8as 79 | 80 | Closes #108 81 | ``` 82 | -------------------------------------------------------------------------------- /docs/project/SETUP.md: -------------------------------------------------------------------------------- 1 | # Project Setup 2 | 3 | This document describes the necessary steps to setup a `cmmn-js` development environment. 4 | 5 | 6 | ## TLDR; 7 | 8 | On Linux/Unix? [git](http://git-scm.com/), [NodeJS](nodejs.org) and [npm](https://www.npmjs.org/doc/cli/npm.html) ready? Check out the [setup script section](https://github.com/bpmn-io/cmmn-js/blob/master/docs/project/SETUP.md#setup-via-script) below. 9 | 10 | 11 | ## Manual Steps 12 | 13 | Make sure you have [git](http://git-scm.com/), [NodeJS](nodejs.org) and [npm](https://www.npmjs.org/doc/cli/npm.html) installed before you continue. 14 | 15 | 16 | ### Get Project + Dependencies 17 | 18 | The following projects from the [bpmn-io](https://github.com/bpmn-io) project on GitHub 19 | 20 | * [cmmn-js](https://github.com/bpmn-io/cmmn-js) 21 | * [diagram-js](https://github.com/bpmn-io/diagram-js) 22 | * [cmmn-moddle](https://github.com/bpmn-io/cmmn-moddle) 23 | * [moddle](https://github.com/bpmn-io/moddle) 24 | * [moddle-xml](https://github.com/bpmn-io/moddle-xml) 25 | 26 | and clone them into a common directory via 27 | 28 | ``` 29 | git clone git@github.com:bpmn-io/PROJECT_NAME.git 30 | ``` 31 | 32 | 33 | ### Link Projects 34 | 35 | [Link dependent projects](http://blog.nodejs.org/2011/04/06/npm-1-0-link/) between each other to pick up changes immediately. 36 | 37 | ``` 38 | . 39 | cmmn-js 40 | │ └─node_modules 41 | │ ├─diagram-js 42 | │ ├─moddle 43 | │ └─cmmn-moddle 44 | ├─cmmn-moddle 45 | │ └─node_modules 46 | │ ├─moddle 47 | │ └─moddle-xml 48 | ├─diagram-js 49 | ├─moddle 50 | └─moddle-xml 51 | └─node_modules 52 | └─moddle 53 | ``` 54 | 55 | #### On Linux 56 | 57 | Use [npm-link](https://www.npmjs.org/doc/link.html) or `ln -s `. 58 | 59 | #### On Windows 60 | 61 | Use `mklink /d ` [(docs)](http://technet.microsoft.com/en-us/library/cc753194.aspx). 62 | 63 | 64 | ### Install Dependencies 65 | 66 | Execute `npm install` on each of the projects to grab their dependencies. 67 | 68 | 69 | ### Verify Things are O.K. 70 | 71 | Execute `grunt` on each project. Things should be fine. 72 | 73 | 74 | ## Setup via Script 75 | 76 | The whole setup can be automated through setup scripts for [Linux](https://github.com/bpmn-io/cmmn-js/blob/master/docs/project/setup.sh) and [Windows](https://github.com/bpmn-io/cmmn-js/blob/master/docs/project/setup.bat). 77 | -------------------------------------------------------------------------------- /docs/project/setup-alternative.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### 4 | # Setup script to be executed in a bpmn.io project root (some empty folder chosen by YOU). Use if you do not want to rely on npm link. 5 | ### 6 | 7 | base=`pwd` 8 | 9 | echo cloning repositories 10 | 11 | git clone git@github.com:bpmn-io/diagram-js.git 12 | git clone git@github.com:bpmn-io/moddle.git 13 | git clone git@github.com:bpmn-io/moddle-xml.git 14 | git clone git@github.com:bpmn-io/cmmn-js.git 15 | git clone git@github.com:bpmn-io/cmmn-moddle.git 16 | 17 | 18 | echo done. 19 | 20 | echo setup diagram-js 21 | 22 | cd $base/diagram-js 23 | npm install 24 | 25 | 26 | echo setup moddle 27 | 28 | cd $base/moddle 29 | npm install 30 | 31 | 32 | echo setup moddle-xml 33 | 34 | cd $base/moddle-xml 35 | mkdir node_modules 36 | ln -s $base/moddle node_modules/moddle 37 | npm install 38 | 39 | 40 | echo setup cmmn-moddle 41 | 42 | cd $base/cmmn-moddle 43 | mkdir node_modules 44 | ln -s $base/moddle node_modules/moddle 45 | ln -s $base/moddle-xml node_modules/moddle-xml 46 | npm install 47 | 48 | 49 | echo setup cmmn-js 50 | 51 | cd $base/cmmn-js 52 | mkdir node_modules 53 | ln -s $base/moddle node_modules/moddle 54 | ln -s $base/cmmn-moddle node_modules/cmmn-moddle 55 | ln -s $base/diagram-js node_modules/diagram-js 56 | npm install 57 | 58 | 59 | cd $base 60 | 61 | echo all done. -------------------------------------------------------------------------------- /docs/project/setup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem ### 4 | rem # Setup script to be executed in a bpmn.io project root (some empty folder chosen by YOU) 5 | rem ## 6 | 7 | set BASE=%CD% 8 | 9 | echo cloning repositories 10 | 11 | git clone git@github.com:bpmn-io/diagram-js.git 12 | git clone git@github.com:bpmn-io/moddle.git 13 | git clone git@github.com:bpmn-io/moddle-xml.git 14 | git clone git@github.com:bpmn-io/cmmn-js.git 15 | git clone git@github.com:bpmn-io/cmmn-moddle.git 16 | 17 | 18 | echo done. 19 | 20 | 21 | echo setup diagram-js 22 | 23 | cd %BASE%\diagram-js 24 | npm install 25 | 26 | 27 | echo setup moddle 28 | 29 | cd %BASE%\moddle 30 | npm install 31 | 32 | 33 | echo setup moddle-xml 34 | 35 | cd %BASE%\moddle-xml 36 | mkdir node_modules 37 | mklink /D %BASE%\moddle-xml\node_modules\moddle %BASE%\moddle 38 | npm install 39 | 40 | 41 | echo setup cmmn-moddle 42 | 43 | cd %BASE%\cmmn-moddle 44 | mkdir node_modules 45 | mklink /D %BASE%\cmmn-moddle\node_modules\moddle-xml %BASE%\moddle-xml 46 | mklink /D %BASE%\cmmn-moddle\node_modules\moddle %BASE%\moddle 47 | npm install 48 | 49 | 50 | echo prepare setup cmmn-js 51 | 52 | mkdir %BASE%\cmmn-js\node_modules 53 | 54 | rem link cmmn-js 55 | mklink /D %BASE%\cmmn-js\node_modules\cmmn-moddle %BASE%\cmmn-moddle 56 | mklink /D %BASE%\cmmn-js\node_modules\diagram-js %BASE%\diagram-js 57 | 58 | 59 | echo setup cmmn-js 60 | 61 | cd %BASE%\cmmn-js 62 | npm install 63 | 64 | 65 | cd %BASE% -------------------------------------------------------------------------------- /docs/project/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ### 4 | # Setup script to be executed in a bpmn.io project root (some empty folder chosen by YOU) 5 | ### 6 | 7 | base=`pwd` 8 | 9 | echo cloning repositories 10 | 11 | git clone git@github.com:bpmn-io/diagram-js.git 12 | git clone git@github.com:bpmn-io/moddle.git 13 | git clone git@github.com:bpmn-io/moddle-xml.git 14 | git clone git@github.com:bpmn-io/cmmn-js.git 15 | git clone git@github.com:bpmn-io/cmmn-moddle.git 16 | 17 | echo done. 18 | 19 | 20 | echo setup diagram-js 21 | 22 | cd $base/diagram-js 23 | npm install 24 | npm link 25 | 26 | 27 | echo setup moddle 28 | 29 | cd $base/moddle 30 | npm install 31 | npm link 32 | 33 | 34 | echo setup moddle-xml 35 | 36 | cd $base/moddle-xml 37 | npm link moddle 38 | npm install 39 | npm link 40 | 41 | 42 | echo setup cmmn-moddle 43 | 44 | cd $base/cmmn-moddle 45 | npm link moddle-xml 46 | npm link moddle 47 | npm install 48 | npm link 49 | 50 | 51 | echo setup cmmn-js 52 | 53 | cd $base/cmmn-js 54 | npm install 55 | npm link diagram-js 56 | npm link cmmn-moddle 57 | npm link 58 | 59 | 60 | cd $base 61 | 62 | echo all done. 63 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/Viewer'); -------------------------------------------------------------------------------- /lib/NavigatedViewer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var inherits = require('inherits'); 4 | 5 | var Viewer = require('./Viewer'); 6 | 7 | 8 | /** 9 | * A viewer that includes mouse navigation facilities 10 | * 11 | * @param {Object} options 12 | */ 13 | function NavigatedViewer(options) { 14 | Viewer.call(this, options); 15 | } 16 | 17 | inherits(NavigatedViewer, Viewer); 18 | 19 | module.exports = NavigatedViewer; 20 | 21 | NavigatedViewer.prototype._navigationModules = [ 22 | require('diagram-js/lib/navigation/zoomscroll').default, 23 | require('diagram-js/lib/navigation/movecanvas').default 24 | ]; 25 | 26 | NavigatedViewer.prototype._modules = [].concat( 27 | NavigatedViewer.prototype._modules, 28 | NavigatedViewer.prototype._navigationModules); -------------------------------------------------------------------------------- /lib/core/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('../draw'), 4 | require('../import') 5 | ], 6 | itemRegistry: [ 'type', require('./ItemRegistry') ] 7 | }; -------------------------------------------------------------------------------- /lib/draw/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __init__: [ 'cmmnRenderer' ], 3 | cmmnRenderer: [ 'type', require('./CmmnRenderer') ], 4 | pathMap: [ 'type', require('./PathMap') ] 5 | }; -------------------------------------------------------------------------------- /lib/features/auto-resize/CmmnAutoResizeProvider.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var is = require('../../util/ModelUtil').is, 4 | getDefinition = require('../../util/ModelUtil').getDefinition; 5 | 6 | var inherits = require('inherits'); 7 | 8 | var forEach = require('min-dash').forEach; 9 | 10 | var AutoResizeProvider = require('diagram-js/lib/features/auto-resize/AutoResizeProvider').default; 11 | 12 | /** 13 | * This module provides a CMMN specific check if an element 14 | * can be resized. 15 | */ 16 | function CmmnAutoResizeProvider(eventBus) { 17 | AutoResizeProvider.call(this, eventBus); 18 | } 19 | 20 | inherits(CmmnAutoResizeProvider, AutoResizeProvider); 21 | 22 | CmmnAutoResizeProvider.$inject = [ 'eventBus' ]; 23 | 24 | module.exports = CmmnAutoResizeProvider; 25 | 26 | /** 27 | * Check if the given shape can be expanded 28 | * 29 | * @param {Array} elements 30 | * @param {djs.model.Shape} target 31 | * 32 | * @return {boolean} 33 | */ 34 | CmmnAutoResizeProvider.prototype.canResize = function(elements, target) { 35 | 36 | if (!is(target, 'cmmn:CMMNElement')) { 37 | return; 38 | } 39 | 40 | var criterionsOnly = true; 41 | 42 | forEach(elements, function(element) { 43 | if (!is(element, 'cmmn:Criterion')) { 44 | criterionsOnly = false; 45 | return; 46 | } 47 | }); 48 | 49 | // prevent auto expand if the selected elements are exclusively criterions 50 | if (criterionsOnly) { 51 | return; 52 | } 53 | 54 | var definition = getDefinition(target); 55 | 56 | return is(definition, 'cmmn:PlanFragment'); 57 | }; 58 | -------------------------------------------------------------------------------- /lib/features/auto-resize/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __init__: [ 'cmmnAutoResizeProvider' ], 3 | __depends__: [ 4 | require('diagram-js/lib/features/auto-resize').default 5 | ], 6 | cmmnAutoResizeProvider: [ 'type', require('./CmmnAutoResizeProvider') ] 7 | }; 8 | -------------------------------------------------------------------------------- /lib/features/context-pad/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('diagram-js/lib/features/connect').default, 4 | require('diagram-js/lib/features/context-pad').default, 5 | require('diagram-js/lib/features/create').default, 6 | require('diagram-js/lib/features/selection').default, 7 | require('../popup-menu') 8 | ], 9 | __init__: [ 'contextPadProvider' ], 10 | contextPadProvider: [ 'type', require('./ContextPadProvider') ] 11 | }; -------------------------------------------------------------------------------- /lib/features/editor-actions/index.js: -------------------------------------------------------------------------------- 1 | var EditorActionsModule = require('diagram-js/lib/features/editor-actions').default; 2 | 3 | var CmmnEditorActions = require('./CmmnEditorActions'); 4 | 5 | module.exports = { 6 | __depends__: [ 7 | EditorActionsModule 8 | ], 9 | editorActions: [ 'type', CmmnEditorActions ] 10 | }; 11 | -------------------------------------------------------------------------------- /lib/features/keyboard/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('diagram-js/lib/features/keyboard').default 4 | ], 5 | __init__: [ 'keyboardBindings' ], 6 | keyboardBindings: [ 'type', require('./CmmnKeyboardBindings') ] 7 | }; 8 | -------------------------------------------------------------------------------- /lib/features/label-editing/LabelUtil.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var is = require('../../util/ModelUtil').is; 4 | var isAny = require('../modeling/util/ModelingUtil').isAny; 5 | 6 | var getBusinessObject = require('../../util/ModelUtil').getBusinessObject; 7 | 8 | function getLabelAttr(element) { 9 | if (is(element, 'cmmn:TextAnnotation')) { 10 | return 'text'; 11 | } 12 | 13 | return 'name'; 14 | } 15 | 16 | function getSemantic(element) { 17 | var bo = getBusinessObject(element); 18 | 19 | if (is(bo, 'cmmndi:CMMNEdge') && bo.cmmnElementRef) { 20 | bo = bo.cmmnElementRef; 21 | } 22 | 23 | return bo; 24 | } 25 | 26 | /** 27 | * Check if the given element is of a type which has a reference to a definition. 28 | * This could be either plan items or discretionary items or case file items. 29 | * 30 | * @param {djs.model.Base} element 31 | * 32 | * @return {Boolean} 33 | */ 34 | var isReferencing = function(element) { 35 | return isAny(element, [ 36 | 'cmmn:PlanItem', 37 | 'cmmn:DiscretionaryItem', 38 | 'cmmn:CaseFileItem' 39 | ]); 40 | }; 41 | 42 | function hasEditableLabel(element) { 43 | return !isAny(element, [ 44 | 'cmmn:Association', 45 | 'cmmn:Criterion', 46 | 'cmmndi:CMMNEdge' 47 | ]); 48 | } 49 | 50 | var getLabel = function(element) { 51 | 52 | var semantic = getSemantic(element), 53 | attr = getLabelAttr(semantic); 54 | 55 | if (!hasEditableLabel(semantic)) { 56 | return; 57 | } 58 | 59 | // Get definition as semantic if 60 | // * the element has no name property set 61 | // * the element type has a reference to a definition 62 | if (!semantic[attr] && isReferencing(element)) { 63 | semantic = semantic.definitionRef; 64 | } 65 | 66 | return semantic[attr] || ''; 67 | }; 68 | 69 | module.exports.getLabel = getLabel; 70 | 71 | 72 | var setLabel = function(element, text, isExternal, isExclusiveRef) { 73 | 74 | var semantic = getSemantic(element), 75 | attr = getLabelAttr(semantic); 76 | 77 | // Get definition as semantic if 78 | // * the element has no name property set 79 | // * the element type has a reference to a definition 80 | // * the element is the only reference to a defition 81 | if (!semantic[attr] && isReferencing(element) && isExclusiveRef) { 82 | semantic = semantic.definitionRef; 83 | } 84 | 85 | semantic[attr] = text; 86 | 87 | // show external label if not empty 88 | if (isExternal) { 89 | element.hidden = !text; 90 | } 91 | 92 | return element; 93 | }; 94 | 95 | module.exports.setLabel = setLabel; 96 | -------------------------------------------------------------------------------- /lib/features/label-editing/cmd/UpdateLabelHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var LabelUtil = require('../LabelUtil'); 4 | 5 | var getDefinition = require('../../../util/ModelUtil').getDefinition; 6 | 7 | /** 8 | * A handler that updates the text of a CMMN element. 9 | */ 10 | function UpdateLabelHandler(itemRegistry) { 11 | 12 | /** 13 | * Set the label and return the changed elements. 14 | * 15 | * Element parameter can be label itself or connection (i.e. sequence flow). 16 | * 17 | * @param {djs.model.Base} element 18 | * @param {String} text 19 | */ 20 | function setText(element, text) { 21 | 22 | // external label if present 23 | var label = element.label || element; 24 | 25 | var labelTarget = element.labelTarget || element; 26 | 27 | LabelUtil.setLabel(label, text, labelTarget !== label, isExclusiveRef(element)); 28 | 29 | return [ label, labelTarget ]; 30 | } 31 | 32 | /** 33 | * Return a function which checks if the element is the only reference to a definition 34 | * 35 | * @param {djs.model.Base} element 36 | * 37 | * @return {Function} 38 | */ 39 | function isExclusiveRef(element) { 40 | var definition = getDefinition(element); 41 | return definition ? itemRegistry.getReferences(definition).length === 1 : true; 42 | } 43 | 44 | 45 | function execute(ctx) { 46 | ctx.oldLabel = LabelUtil.getLabel(ctx.element); 47 | return setText(ctx.element, ctx.newLabel); 48 | } 49 | 50 | function revert(ctx) { 51 | return setText(ctx.element, ctx.oldLabel); 52 | } 53 | 54 | // API 55 | 56 | this.execute = execute; 57 | this.revert = revert; 58 | } 59 | 60 | 61 | UpdateLabelHandler.$inject = [ 'itemRegistry' ]; 62 | 63 | module.exports = UpdateLabelHandler; 64 | -------------------------------------------------------------------------------- /lib/features/label-editing/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('diagram-js/lib/command').default, 4 | require('diagram-js/lib/features/change-support').default, 5 | require('diagram-js-direct-editing').default 6 | ], 7 | __init__: [ 'labelEditingProvider' ], 8 | labelEditingProvider: [ 'type', require('./LabelEditingProvider') ] 9 | }; 10 | -------------------------------------------------------------------------------- /lib/features/modeling/CmmnLayouter.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var inherits = require('inherits'); 4 | 5 | var BaseLayouter = require('diagram-js/lib/layout/BaseLayouter').default, 6 | ManhattanLayout = require('diagram-js/lib/layout/ManhattanLayout'); 7 | 8 | var getMid = require('diagram-js/lib/layout/LayoutUtil').getMid; 9 | 10 | 11 | function CmmnLayouter() {} 12 | 13 | inherits(CmmnLayouter, BaseLayouter); 14 | 15 | module.exports = CmmnLayouter; 16 | 17 | 18 | CmmnLayouter.prototype.layoutConnection = function(connection, hints) { 19 | 20 | hints = hints || {}; 21 | 22 | var source = hints.source || connection.source, 23 | target = hints.target || connection.target, 24 | waypoints = connection.waypoints, 25 | start = hints.connectionStart, 26 | end = hints.connectionEnd; 27 | 28 | 29 | if (!start) { 30 | start = getConnectionDocking(waypoints && waypoints[0], source); 31 | } 32 | 33 | if (!end) { 34 | end = getConnectionDocking(waypoints && waypoints[waypoints.length - 1], target); 35 | } 36 | 37 | var updatedWaypoints = 38 | ManhattanLayout.repairConnection( 39 | source, target, 40 | start, end, 41 | waypoints, 42 | hints); 43 | 44 | return updatedWaypoints || [ start, end ]; 45 | }; 46 | 47 | function getConnectionDocking(point, shape) { 48 | return point ? (point.original || point) : getMid(shape); 49 | } -------------------------------------------------------------------------------- /lib/features/modeling/behavior/AttachCriterionBehavior.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var inherits = require('inherits'); 4 | 5 | var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default; 6 | 7 | var ModelUtil = require('../../../util/ModelUtil'), 8 | is = ModelUtil.is, 9 | isCasePlanModel = ModelUtil.isCasePlanModel; 10 | 11 | /* 12 | * If a criterion is (re-)attached to a case plan model, 13 | * then the (visual) parent must be the case plan model itself, 14 | * and not the root element. 15 | */ 16 | function AttachCriterionBehavior(eventBus) { 17 | 18 | CommandInterceptor.call(this, eventBus); 19 | 20 | this.preExecute([ 'shape.create', 'elements.move' ], function(context) { 21 | 22 | var shape = context.shape, 23 | shapes = context.shapes, 24 | parent = context.parent || context.newParent, 25 | host = context.host || context.newHost; 26 | 27 | if (!parent) { 28 | return; 29 | } 30 | 31 | if (!host || !isCasePlanModel(host)) { 32 | return; 33 | } 34 | 35 | if (shapes && shapes.length > 1) { 36 | return; 37 | } 38 | 39 | shape = shape || shapes[0]; 40 | 41 | if (!is(shape, 'cmmn:Criterion')) { 42 | return; 43 | } 44 | 45 | context.parent = context.parent && host; 46 | context.newParent = context.newParent && host; 47 | 48 | }, true); 49 | 50 | 51 | 52 | } 53 | 54 | AttachCriterionBehavior.$inject = [ 'eventBus' ]; 55 | 56 | inherits(AttachCriterionBehavior, CommandInterceptor); 57 | 58 | module.exports = AttachCriterionBehavior; 59 | -------------------------------------------------------------------------------- /lib/features/modeling/behavior/UnclaimIdBehavior.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var forEach = require('min-dash').forEach; 4 | 5 | var inherits = require('inherits'); 6 | 7 | var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor').default; 8 | 9 | function UnclaimIdBehavior(eventBus, modeling) { 10 | 11 | CommandInterceptor.call(this, eventBus); 12 | 13 | this.preExecute('elements.delete', function(event) { 14 | var context = event.context, 15 | elements = context.elements; 16 | 17 | forEach(elements, function(element) { 18 | modeling.unclaimId(element.businessObject.id, element.businessObject); 19 | }); 20 | 21 | }); 22 | } 23 | 24 | inherits(UnclaimIdBehavior, CommandInterceptor); 25 | 26 | UnclaimIdBehavior.$inject = [ 'eventBus', 'modeling' ]; 27 | 28 | module.exports = UnclaimIdBehavior; 29 | -------------------------------------------------------------------------------- /lib/features/modeling/behavior/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __init__: [ 3 | 'attachCriterionBehavior', 4 | 'caseFileItemUpdater', 5 | 'labelBehavior', 6 | 'planItemDefinitionUpdater', 7 | 'planningTableUpdater', 8 | 'replaceConnectionBehavior', 9 | 'replaceElementBehavior', 10 | 'resizeCasePlanModelBehavior', 11 | 'sentryUpdater', 12 | 'unclaimIdBehavior' 13 | ], 14 | attachCriterionBehavior: [ 'type', require('./AttachCriterionBehavior') ], 15 | caseFileItemUpdater: [ 'type', require('./CaseFileItemUpdater') ], 16 | labelBehavior: [ 'type', require('./LabelBehavior') ], 17 | planItemDefinitionUpdater: [ 'type', require('./PlanItemDefinitionUpdater') ], 18 | planningTableUpdater: [ 'type', require('./PlanningTableUpdater') ], 19 | replaceConnectionBehavior: [ 'type', require('./ReplaceConnectionBehavior') ], 20 | replaceElementBehavior: [ 'type', require('./ReplaceElementBehavior') ], 21 | resizeCasePlanModelBehavior: [ 'type', require('./ResizeCasePlanModelBehavior') ], 22 | sentryUpdater: [ 'type', require('./SentryUpdater') ], 23 | unclaimIdBehavior: [ 'type', require('./UnclaimIdBehavior') ] 24 | }; 25 | -------------------------------------------------------------------------------- /lib/features/modeling/cmd/AppendShapeHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var inherits = require('inherits'); 4 | 5 | var is = require('../../../util/ModelUtil').is; 6 | 7 | var BaseHandler = require('diagram-js/lib/features/modeling/cmd/AppendShapeHandler').default; 8 | 9 | 10 | function AppendShapeHandler(modeling, cmmnRules) { 11 | this._modeling = modeling; 12 | this._cmmnRules = cmmnRules; 13 | } 14 | 15 | inherits(AppendShapeHandler, BaseHandler); 16 | 17 | 18 | AppendShapeHandler.$inject = [ 'modeling', 'cmmnRules' ]; 19 | 20 | module.exports = AppendShapeHandler; 21 | 22 | 23 | // api ///////////////// 24 | 25 | AppendShapeHandler.prototype.preExecute = function(context) { 26 | 27 | if (!context.source) { 28 | throw new Error('source required'); 29 | } 30 | 31 | var cmmnRules = this._cmmnRules; 32 | 33 | var shape = context.shape, 34 | source = context.source, 35 | parent = context.target || context.source.parent, 36 | position = context.position, 37 | isAttach = context.attach; 38 | 39 | if (isCriterion(shape)) { 40 | isAttach = cmmnRules.canAttach(shape, parent, source, position) === 'attach'; 41 | } 42 | 43 | context.shape = this._modeling.createShape(shape, position, parent, { 44 | attach: isAttach, 45 | nested: true 46 | }); 47 | 48 | }; 49 | 50 | function isCriterion(element) { 51 | return is(element, 'cmmn:Criterion'); 52 | } -------------------------------------------------------------------------------- /lib/features/modeling/cmd/IdClaimHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | function IdClaimHandler(moddle) { 5 | this._moddle = moddle; 6 | } 7 | 8 | IdClaimHandler.$inject = [ 'moddle' ]; 9 | 10 | module.exports = IdClaimHandler; 11 | 12 | 13 | IdClaimHandler.prototype.execute = function(context) { 14 | var ids = this._moddle.ids, 15 | id = context.id, 16 | element = context.element, 17 | claiming = context.claiming; 18 | 19 | if (claiming) { 20 | ids.claim(id, element); 21 | } else { 22 | ids.unclaim(id); 23 | } 24 | }; 25 | 26 | 27 | IdClaimHandler.prototype.revert = function(context) { 28 | var ids = this._moddle.ids, 29 | id = context.id, 30 | element = context.element, 31 | claiming = context.claiming; 32 | 33 | if (claiming) { 34 | ids.unclaim(id); 35 | } else { 36 | ids.claim(id, element); 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /lib/features/modeling/cmd/ReconnectConnectionHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var inherits = require('inherits'); 4 | 5 | var isArray = require('min-dash').isArray; 6 | 7 | var BaseHandler = require('diagram-js/lib/features/modeling/cmd/ReconnectConnectionHandler').default; 8 | 9 | /** 10 | * Overwrites the behavior of diagram-js/ReconnectConnectionHandler to enable 11 | * a switch between source and target of a connection on reconnect. 12 | */ 13 | function ReconnectConnectionHandler(injector) { 14 | injector.invoke(BaseHandler, this); 15 | } 16 | 17 | inherits(ReconnectConnectionHandler, BaseHandler); 18 | 19 | ReconnectConnectionHandler.$inject = [ 'injector' ]; 20 | 21 | module.exports = ReconnectConnectionHandler; 22 | 23 | 24 | ReconnectConnectionHandler.prototype.execute = function(context) { 25 | 26 | var newSource = context.newSource, 27 | newTarget = context.newTarget, 28 | connection = context.connection, 29 | dockingOrPoints = context.dockingOrPoints; 30 | 31 | if (!newSource && !newTarget) { 32 | throw new Error('newSource or newTarget are required'); 33 | } 34 | 35 | // removed from corresponding method in diagram-js@3.3.0 36 | 37 | // if (newSource && newTarget) { 38 | // throw new Error('must specify either newSource or newTarget'); 39 | // } 40 | 41 | if (isArray(dockingOrPoints)) { 42 | context.oldWaypoints = connection.waypoints; 43 | connection.waypoints = dockingOrPoints; 44 | } 45 | 46 | if (newSource) { 47 | context.oldSource = connection.source; 48 | connection.source = newSource; 49 | } 50 | 51 | if (newTarget) { 52 | context.oldTarget = connection.target; 53 | connection.target = newTarget; 54 | } 55 | 56 | return connection; 57 | }; -------------------------------------------------------------------------------- /lib/features/modeling/cmd/ReplaceShapeHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var inherits = require('inherits'); 4 | 5 | var BaseHandler = require('diagram-js/lib/features/modeling/cmd/ReplaceShapeHandler').default; 6 | 7 | 8 | function ReplaceShapeHandler(modeling, rules) { 9 | this._modeling = modeling; 10 | this._rules = rules; 11 | } 12 | 13 | inherits(ReplaceShapeHandler, BaseHandler); 14 | 15 | ReplaceShapeHandler.$inject = [ 'modeling', 'rules' ]; 16 | 17 | module.exports = ReplaceShapeHandler; 18 | 19 | 20 | // api ///////////////// 21 | 22 | 23 | ReplaceShapeHandler.prototype.createShape = function(shape, position, target) { 24 | var modeling = this._modeling; 25 | return modeling.createShape(shape, position, target, { 26 | nested: true 27 | }); 28 | }; 29 | 30 | 31 | ReplaceShapeHandler.prototype.reconnectStart = function(connection, newSource, dockingPoint) { 32 | var modeling = this._modeling; 33 | modeling.reconnectStart(connection, newSource, dockingPoint, { 34 | nested: true, 35 | startChanged: true 36 | }); 37 | }; 38 | 39 | 40 | ReplaceShapeHandler.prototype.reconnectEnd = function(connection, newTarget, dockingPoint) { 41 | var modeling = this._modeling; 42 | modeling.reconnectEnd(connection, newTarget, dockingPoint, { 43 | nested: true, 44 | endChanged: true 45 | }); 46 | }; 47 | -------------------------------------------------------------------------------- /lib/features/modeling/cmd/UpdateSemanticParentHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var flatten = require('min-dash').flatten; 4 | 5 | var Collections = require('diagram-js/lib/util/Collections'); 6 | 7 | 8 | function UpdateSemanticParentHandler() { 9 | } 10 | 11 | module.exports = UpdateSemanticParentHandler; 12 | 13 | 14 | // api ///////////////// 15 | 16 | UpdateSemanticParentHandler.prototype.preExecute = function(context) { 17 | var element = context.element, 18 | shape = context.shape; 19 | 20 | if (!element) { 21 | throw new Error('element required'); 22 | } 23 | 24 | var bo = element.businessObject || element; 25 | 26 | context.businessObject = bo; 27 | context.oldParent = bo.$parent; 28 | 29 | var changed = []; 30 | 31 | if (element.businessObject) { 32 | changed.push(element); 33 | } 34 | 35 | if (shape) { 36 | changed.push(shape); 37 | } 38 | 39 | context.changed = flatten(changed); 40 | }; 41 | 42 | UpdateSemanticParentHandler.prototype.execute = function(context) { 43 | 44 | var businessObject = context.businessObject, 45 | newParent = context.newParent, 46 | containment = context.containment; 47 | 48 | this.updateSemanticParent(businessObject, newParent, containment); 49 | 50 | // indicate changed on objects affected by the update 51 | return context.changed; 52 | }; 53 | 54 | 55 | UpdateSemanticParentHandler.prototype.revert = function(context) { 56 | 57 | var businessObject = context.businessObject, 58 | newParent = context.oldParent, 59 | containment = context.containment; 60 | 61 | this.updateSemanticParent(businessObject, newParent, containment); 62 | 63 | return context.changed; 64 | }; 65 | 66 | 67 | UpdateSemanticParentHandler.prototype.updateSemanticParent = function(element, newParent, containment) { 68 | 69 | if (element.$parent === newParent) { 70 | return; 71 | } 72 | 73 | var children; 74 | 75 | if (element.$parent && containment) { 76 | // remove from old parent 77 | children = element.$parent.get(containment); 78 | Collections.remove(children, element); 79 | } 80 | 81 | element.$parent = null; 82 | 83 | if (newParent) { 84 | 85 | if (containment) { 86 | // add to new parent 87 | children = newParent.get(containment); 88 | children.push(element); 89 | } 90 | 91 | element.$parent = newParent; 92 | } 93 | 94 | }; 95 | -------------------------------------------------------------------------------- /lib/features/modeling/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __init__: [ 'modeling', 'cmmnUpdater' ], 3 | __depends__: [ 4 | require('./behavior'), 5 | require('../ordering'), 6 | require('../replace'), 7 | require('../rules'), 8 | require('diagram-js/lib/command').default, 9 | require('diagram-js/lib/features/selection').default, 10 | require('diagram-js/lib/features/label-support').default, 11 | require('diagram-js/lib/features/attach-support').default, 12 | require('diagram-js/lib/features/change-support').default 13 | ], 14 | cmmnFactory: [ 'type', require('./CmmnFactory') ], 15 | cmmnUpdater: [ 'type', require('./CmmnUpdater') ], 16 | elementFactory: [ 'type', require('./ElementFactory') ], 17 | modeling: [ 'type', require('./Modeling') ], 18 | layouter: [ 'type', require('./CmmnLayouter') ], 19 | connectionDocking: [ 'type', require('diagram-js/lib/layout/CroppingConnectionDocking').default ] 20 | }; 21 | -------------------------------------------------------------------------------- /lib/features/ordering/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __init__: [ 'cmmnOrderingProvider' ], 3 | cmmnOrderingProvider: [ 'type', require('./CmmnOrderingProvider') ] 4 | }; -------------------------------------------------------------------------------- /lib/features/outline/Outline.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var BaseOutline = require('diagram-js/lib/features/outline/Outline').default; 4 | 5 | var inherits = require('inherits'); 6 | 7 | var isCasePlanModel = require('../../util/ModelUtil').isCasePlanModel; 8 | 9 | var svgAttr = require('tiny-svg').attr; 10 | 11 | 12 | /** 13 | * This is a subclass of the Outline module from diagram-js. 14 | * It defines outlines which differ from the element size basis. 15 | * 16 | * @param {EventBus} eventBus 17 | * @param {Styles} styles 18 | * @param {ElementRegistry} elementRegistry 19 | */ 20 | function Outline(eventBus, styles, elementRegistry) { 21 | BaseOutline.call(this, eventBus, styles, elementRegistry); 22 | } 23 | 24 | inherits(Outline, BaseOutline); 25 | 26 | Outline.$inject = [ 'eventBus', 'styles', 'elementRegistry' ]; 27 | 28 | Outline.prototype.baseUpdateShapeOutline = BaseOutline.prototype.updateShapeOutline; 29 | 30 | Outline.prototype.updateShapeOutline = function(outline, element) { 31 | 32 | if (!isCasePlanModel(element)) { 33 | 34 | this.baseUpdateShapeOutline(outline, element); 35 | } else { 36 | 37 | // update outlines for casePlanModels 38 | svgAttr(outline, { 39 | x: -this.offset, 40 | y: -this.offset - 18, 41 | width: element.width + this.offset * 2, 42 | height: element.height + 18 + this.offset * 2 43 | }); 44 | } 45 | }; 46 | 47 | module.exports = Outline; 48 | -------------------------------------------------------------------------------- /lib/features/outline/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | __init__: [ 'outline' ], 5 | outline: [ 'type', require('./Outline') ] 6 | }; 7 | -------------------------------------------------------------------------------- /lib/features/palette/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('diagram-js/lib/features/palette').default, 4 | require('diagram-js/lib/features/create').default, 5 | require('diagram-js/lib/features/space-tool').default, 6 | require('diagram-js/lib/features/lasso-tool').default, 7 | require('diagram-js/lib/features/hand-tool').default, 8 | require('diagram-js/lib/features/global-connect').default 9 | ], 10 | __init__: [ 'paletteProvider' ], 11 | paletteProvider: [ 'type', require('./PaletteProvider') ] 12 | }; 13 | -------------------------------------------------------------------------------- /lib/features/popup-menu/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __init__: [ 'replaceMenuProvider' ], 3 | replaceMenuProvider: [ 'type', require('./ReplaceMenuProvider') ] 4 | }; -------------------------------------------------------------------------------- /lib/features/replace-preview/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('diagram-js/lib/features/move').default 4 | ], 5 | __init__: ['cmmnReplacePreview'], 6 | cmmnReplacePreview: [ 'type', require('./CmmnReplacePreview') ] 7 | }; 8 | -------------------------------------------------------------------------------- /lib/features/replace/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('diagram-js/lib/features/popup-menu').default, 4 | require('diagram-js/lib/features/replace').default, 5 | require('diagram-js/lib/features/selection').default 6 | ], 7 | cmmnReplace: [ 'type', require('./CmmnReplace') ] 8 | }; -------------------------------------------------------------------------------- /lib/features/rules/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('diagram-js/lib/features/rules').default 4 | ], 5 | __init__: [ 'cmmnRules' ], 6 | cmmnRules: [ 'type', require('./CmmnRules') ] 7 | }; -------------------------------------------------------------------------------- /lib/features/search/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __depends__: [ 3 | require('diagram-js/lib/features/search-pad').default 4 | ], 5 | __init__: [ 'cmmnSearch'], 6 | cmmnSearch: [ 'type', require('./CmmnSearchProvider') ] 7 | }; 8 | -------------------------------------------------------------------------------- /lib/features/snapping/CmmnResizeSnapping.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var is = require('../../util/ModelUtil').is, 4 | getDefinition = require('../../util/ModelUtil').getDefinition, 5 | isCollapsed = require('../../util/DiUtil').isCollapsed; 6 | 7 | var SLIGHTLY_HIGHER_PRIORITY = 1001; 8 | 9 | 10 | /** 11 | * Cmmn specific resize snapping functionality 12 | * 13 | * @param {EventBus} eventBus 14 | * @param {CmmnRules} cmmnRules 15 | */ 16 | function CmmnResizeSnapping(eventBus) { 17 | 18 | eventBus.on('resize.start', SLIGHTLY_HIGHER_PRIORITY + 500, function(event) { 19 | var context = event.context, 20 | shape = context.shape; 21 | 22 | if (isStage(shape) && !isCollapsed(shape)) { 23 | context.minDimensions = { width: 140, height: 120 }; 24 | } 25 | 26 | if (is(shape, 'cmmn:TextAnnotation')) { 27 | context.minDimensions = { width: 50, height: 30 }; 28 | } 29 | 30 | }); 31 | 32 | } 33 | 34 | CmmnResizeSnapping.$inject = [ 'eventBus', 'cmmnRules', 'injector' ]; 35 | 36 | module.exports = CmmnResizeSnapping; 37 | 38 | // helpers ////////// 39 | 40 | function isStage(element) { 41 | return is(getDefinition(element), 'cmmn:PlanFragment'); 42 | } 43 | -------------------------------------------------------------------------------- /lib/features/snapping/CmmnSnappingUtil.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var getOrientation = require('diagram-js/lib/layout/LayoutUtil').getOrientation; 4 | 5 | var is = require('../../util/ModelUtil').is, 6 | getDefinition = require('../../util/ModelUtil').getDefinition; 7 | 8 | 9 | /** 10 | * Get orientation of the given position rectangle in relation to the 11 | * given target rectangle. When the position is near a corner (respecting 12 | * the given offet) the string 'corner' is returned. 13 | * 14 | * A padding (positive or negative) may be passed to influence 15 | * horizontal / vertical orientation and intersection. 16 | * 17 | * @param {Bounds} position 18 | * @param {Bounds} target 19 | * @param {Point|Number} padding 20 | * @param {Number} offset 21 | */ 22 | function getCornerlessOrientation(position, target, padding, offset) { 23 | 24 | // don't snap to top left corner 25 | if (position.x - offset < target.x && 26 | position.y - offset < target.y) { 27 | return 'corner'; 28 | } 29 | 30 | // don't snap to top right corner 31 | if (position.x + offset > target.x + target.width && 32 | position.y - offset < target.y) { 33 | return 'corner'; 34 | } 35 | 36 | // don't snap to bottom left corner 37 | if (position.x - offset < target.x && 38 | position.y + offset > target.y + target.height) { 39 | return 'corner'; 40 | } 41 | 42 | // don't snap to bottom right corner 43 | if (position.x + offset > target.x + target.width && 44 | position.y + offset > target.y + target.height) { 45 | return 'corner'; 46 | } 47 | 48 | return getOrientation(position, target, padding); 49 | } 50 | 51 | 52 | function getCriterionAttachment(position, target) { 53 | 54 | var orientation; 55 | 56 | var definition = getDefinition(target); 57 | 58 | if (is(target, 'cmmn:PlanItem') && is(definition, 'cmmn:Stage')) { 59 | orientation = getCornerlessOrientation(position, target, -15, 20); 60 | 61 | } else 62 | if (is(definition, 'cmmn:Milestone')) { 63 | orientation = getCornerlessOrientation(position, target, -3, 7); 64 | 65 | } else { 66 | orientation = getOrientation(position, target, -15); 67 | } 68 | 69 | if (orientation !== 'intersect') { 70 | return orientation; 71 | } else { 72 | return null; 73 | } 74 | } 75 | 76 | module.exports.getCriterionAttachment = getCriterionAttachment; -------------------------------------------------------------------------------- /lib/features/snapping/index.js: -------------------------------------------------------------------------------- 1 | var CmmnConnectSnapping = require('./CmmnConnectSnapping'); 2 | var CmmnCreateMoveSnapping = require('./CmmnCreateMoveSnapping'); 3 | var CmmnResizeSnapping = require('./CmmnResizeSnapping'); 4 | var SnappingModule = require('diagram-js/lib/features/snapping').default; 5 | 6 | 7 | module.exports = { 8 | __depends__: [ SnappingModule ], 9 | __init__: [ 10 | 'connectSnapping', 11 | 'createMoveSnapping', 12 | 'resizeSnapping' 13 | ], 14 | connectSnapping: [ 'type', CmmnConnectSnapping ], 15 | createMoveSnapping: [ 'type', CmmnCreateMoveSnapping], 16 | resizeSnapping: [ 'type', CmmnResizeSnapping ] 17 | }; -------------------------------------------------------------------------------- /lib/import/Importer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var CmmnTreeWalker = require('./CmmnTreeWalker'); 4 | 5 | 6 | /** 7 | * Import the definitions into a diagram. 8 | * 9 | * Errors and warnings are reported through the specified callback. 10 | * 11 | * @param {Diagram} diagram 12 | * @param {ModdleElement} definitions 13 | * @param {Function} done the callback, invoked with (err, [ warning ]) once the import is done 14 | */ 15 | function importCmmnDiagram(diagram, definitions, done) { 16 | 17 | var importer = diagram.get('cmmnImporter'), 18 | eventBus = diagram.get('eventBus'), 19 | itemRegistry = diagram.get('itemRegistry'); 20 | 21 | var error, 22 | warnings = []; 23 | 24 | /** 25 | * Walk the diagram semantically, importing (=drawing) 26 | * all elements you encounter. 27 | * 28 | * @param {ModdleElement} definitions 29 | */ 30 | function render(definitions) { 31 | 32 | var visitor = { 33 | 34 | root: function(element) { 35 | return importer.root(element); 36 | }, 37 | 38 | element: function(element, parentShape) { 39 | return importer.add(element, parentShape); 40 | }, 41 | 42 | error: function(message, context) { 43 | warnings.push({ message: message, context: context }); 44 | }, 45 | 46 | addItem: function(item) { 47 | itemRegistry.add(item); 48 | } 49 | }; 50 | 51 | var walker = new CmmnTreeWalker(visitor); 52 | 53 | // import 54 | walker.handleDefinitions(definitions); 55 | } 56 | 57 | eventBus.fire('import.render.start', { definitions: definitions }); 58 | 59 | try { 60 | render(definitions); 61 | } catch (e) { 62 | error = e; 63 | } 64 | 65 | eventBus.fire('import.render.complete', { 66 | error: error, 67 | warnings: warnings 68 | }); 69 | 70 | done(error, warnings); 71 | } 72 | 73 | module.exports.importCmmnDiagram = importCmmnDiagram; -------------------------------------------------------------------------------- /lib/import/Util.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.elementToString = function(e) { 4 | if (!e) { 5 | return ''; 6 | } 7 | 8 | return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />'; 9 | }; -------------------------------------------------------------------------------- /lib/import/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | cmmnImporter: [ 'type', require('./CmmnImporter') ] 3 | }; -------------------------------------------------------------------------------- /lib/util/DiUtil.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var is = require('./ModelUtil').is, 4 | getBusinessObject = require('./ModelUtil').getBusinessObject, 5 | isCasePlanModel = require('./ModelUtil').isCasePlanModel; 6 | 7 | module.exports.isCollapsed = function(element) { 8 | 9 | if (!isCasePlanModel(element)) { 10 | 11 | element = getBusinessObject(element); 12 | 13 | var definition = element.definitionRef; 14 | if (is(definition, 'cmmn:PlanFragment')) { 15 | return !!(element && element.di && element.di.isCollapsed); 16 | } 17 | } 18 | 19 | return false; 20 | }; 21 | 22 | module.exports.isPlanningTableCollapsed = function(element) { 23 | 24 | element = getBusinessObject(element); 25 | 26 | if (is(element, 'cmmn:Stage') || 27 | (element.definitionRef && (is(element.definitionRef, 'cmmn:Stage') || 28 | is(element.definitionRef, 'cmmn:HumanTask')))) { 29 | return element.di && element.di.isPlanningTableCollapsed; 30 | } 31 | 32 | return false; 33 | }; 34 | 35 | module.exports.isStandardEventVisible = function(element) { 36 | element = getBusinessObject(element); 37 | var cmmnElement = element.cmmnElementRef; 38 | return !!(is(cmmnElement, 'cmmn:OnPart') && element.isStandardEventVisible); 39 | }; -------------------------------------------------------------------------------- /resources/banner-min.txt: -------------------------------------------------------------------------------- 1 | /*! cmmn-js - {{ variant }} v{{ version }} | Copyright (c) 2014-present, camunda Services GmbH | bpmn.io/license */ -------------------------------------------------------------------------------- /resources/banner.txt: -------------------------------------------------------------------------------- 1 | /*! 2 | * cmmn-js - {{ variant }} v{{ version }} 3 | * 4 | * Copyright (c) 2014-present, camunda Services GmbH 5 | * 6 | * Released under the bpmn.io license 7 | * http://bpmn.io/license 8 | * 9 | * Source Code: https://github.com/bpmn-io/cmmn-js 10 | * 11 | * Date: {{ date }} 12 | */ 13 | -------------------------------------------------------------------------------- /resources/initial.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /resources/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tasks/build-distro.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var bundle = require('./bundle'); 4 | 5 | var path = require('path'); 6 | 7 | var mkdirp = require('mkdirp').sync, 8 | cp = require('cpx').copySync, 9 | del = require('del').sync; 10 | 11 | var dest = process.env.DISTRO_DIST || 'dist'; 12 | 13 | 14 | function resolve(module, sub) { 15 | var pkg = require.resolve(module + '/package.json'); 16 | 17 | return path.dirname(pkg) + sub; 18 | } 19 | 20 | console.log('clean ' + dest); 21 | del(dest); 22 | 23 | console.log('mkdir -p ' + dest); 24 | mkdirp(dest); 25 | 26 | console.log('copy cmmn-font to ' + dest + '/cmmn-font'); 27 | cp(resolve('cmmn-font', '/dist/{font,css}/**'), dest + '/assets/cmmn-font'); 28 | 29 | console.log('copy diagram-js.css to ' + dest); 30 | cp(resolve('diagram-js', '/assets/**'), dest + '/assets'); 31 | 32 | bundle(dest, { 33 | 'cmmn-viewer': 'lib/Viewer.js', 34 | 'cmmn-navigated-viewer': 'lib/NavigatedViewer.js', 35 | 'cmmn-modeler': 'lib/Modeler.js' 36 | }, function(err) { 37 | 38 | if (err) { 39 | console.error('bundling failed', err); 40 | 41 | process.exit(1); 42 | } 43 | }); -------------------------------------------------------------------------------- /tasks/helpers.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports.asyncSeries = function(fns, done) { 4 | 5 | var idx = 0; 6 | 7 | function next(err) { 8 | 9 | if (err) { 10 | return done(err); 11 | } 12 | 13 | var fn = fns[idx++]; 14 | 15 | if (!fn) { 16 | return done(); 17 | } else { 18 | fn(next); 19 | } 20 | } 21 | 22 | next(); 23 | }; -------------------------------------------------------------------------------- /tasks/stages/update-examples: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # update cmmn-js version in the project 4 | 5 | PWD="$(pwd)" 6 | WORKDIR="$(pwd)/tmp" 7 | EXAMPLES_DIR="$WORKDIR/cmmn-js-examples" 8 | 9 | # create work dir 10 | mkdir -p "$WORKDIR" 11 | 12 | git clone --depth=1 https://github.com/bpmn-io/cmmn-js-examples.git "$EXAMPLES_DIR" 13 | 14 | cd "$EXAMPLES_DIR" 15 | 16 | TOOLKIT_VERSION="${TRAVIS_TAG:1}" 17 | echo "Updating toolkit version to $TOOLKIT_VERSION" 18 | 19 | sed -i -E "s#(\"cmmn-js\": )\"[^\"]+\"#\1\"^$TOOLKIT_VERSION\"#" **/package.json 20 | sed -i -E "s#/cmmn-js@[^/]+/#/cmmn-js@$TOOLKIT_VERSION/#" **/*.{html,md} 21 | 22 | if [[ "x$SKIP_COMMIT" = "x" ]]; then 23 | 24 | git config user.email "$BPMN_IO_EMAIL" 25 | git config user.name "$BPMN_IO_USERNAME" 26 | git config push.default simple 27 | 28 | # add all resources 29 | git add -A 30 | git commit -m "chore(project): bump examples to $TRAVIS_TAG" 31 | git tag "$TRAVIS_TAG" 32 | git push -q "https://$GITHUB_AUTH@github.com/bpmn-io/cmmn-js-examples.git" &2>/dev/null 33 | git push --tags -q "https://$GITHUB_AUTH@github.com/bpmn-io/cmmn-js-examples.git" &2>/dev/null 34 | else 35 | echo "Skipping commit (SKIP_COMMIT=$SKIP_COMMIT)" 36 | fi 37 | 38 | cd "$PWD" -------------------------------------------------------------------------------- /tasks/test-distro.js: -------------------------------------------------------------------------------- 1 | var execSync = require('execa').sync; 2 | 3 | var failures = 0; 4 | 5 | function runTest(variant, env) { 6 | 7 | var NODE_ENV = process.env.NODE_ENV; 8 | 9 | process.env.VARIANT = variant; 10 | process.env.NODE_ENV = env; 11 | 12 | console.log('[TEST] ' + variant + '@' + env); 13 | 14 | try { 15 | execSync('karma', [ 'start', 'test/config/karma.distro.js' ]); 16 | } catch (e) { 17 | console.error('[TEST] FAILURE'); 18 | console.error(e); 19 | 20 | failures++; 21 | } finally { 22 | process.env.NODE_ENV = NODE_ENV; 23 | } 24 | } 25 | 26 | function test() { 27 | 28 | runTest('cmmn-modeler', 'development'); 29 | runTest('cmmn-modeler', 'production'); 30 | 31 | runTest('cmmn-navigated-viewer', 'development'); 32 | runTest('cmmn-navigated-viewer', 'production'); 33 | 34 | runTest('cmmn-viewer', 'development'); 35 | runTest('cmmn-viewer', 'production'); 36 | 37 | if (failures) { 38 | process.exit(1); 39 | } 40 | } 41 | 42 | 43 | test(); -------------------------------------------------------------------------------- /test/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "plugin:bpmn-io/mocha" 3 | } -------------------------------------------------------------------------------- /test/TestHelper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var TestHelper = module.exports = require('./helper'); 4 | 5 | TestHelper.insertCSS('diagram-js.css', 6 | require('diagram-js/assets/diagram-js.css') 7 | ); 8 | 9 | TestHelper.insertCSS('cmmn-embedded.css', 10 | require('cmmn-font/dist/css/cmmn-embedded.css') 11 | ); 12 | 13 | TestHelper.insertCSS('diagram-js-testing.css', 14 | '.test-container .result { height: 500px; }' + '.test-container > div' 15 | ); 16 | 17 | global.chai.use(require('diagram-js/test/matchers/BoundsMatchers').default); 18 | global.chai.use(require('diagram-js/test/matchers/ConnectionMatchers').default); 19 | -------------------------------------------------------------------------------- /test/config/karma.distro.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* global process */ 4 | 5 | // configures browsers to run test against 6 | // any of [ 'ChromeHeadless', 'Chrome', 'Firefox', 'IE', 'PhantomJS' ] 7 | var browsers = 8 | (process.env.TEST_BROWSERS || 'ChromeHeadless') 9 | .replace(/^\s+|\s+$/, '') 10 | .split(/\s*,\s*/g) 11 | .map(function(browser) { 12 | if (browser === 'ChromeHeadless') { 13 | process.env.CHROME_BIN = require('puppeteer').executablePath(); 14 | 15 | // workaround https://github.com/GoogleChrome/puppeteer/issues/290 16 | if (process.platform === 'linux') { 17 | return 'ChromeHeadless_Linux'; 18 | } 19 | } 20 | 21 | return browser; 22 | }); 23 | 24 | 25 | var VARIANT = process.env.VARIANT; 26 | 27 | var NODE_ENV = process.env.NODE_ENV; 28 | 29 | module.exports = function(karma) { 30 | karma.set({ 31 | 32 | basePath: '../../', 33 | 34 | frameworks: [ 35 | 'mocha', 36 | 'sinon-chai' 37 | ], 38 | 39 | files: [ 40 | 'dist/' + VARIANT + '.' + (NODE_ENV === 'production' ? 'production.min' : 'development') + '.js', 41 | 'dist/assets/cmmn-font/css/cmmn.css', 42 | 'dist/assets/diagram-js.css', 43 | { pattern: 'resources/initial.cmmn', included: false }, 44 | { pattern: 'dist/assets/**/*', included: false }, 45 | 'test/distro/helper.js', 46 | 'test/distro/' + VARIANT + '.js' 47 | ], 48 | 49 | reporters: [ 'spec' ], 50 | 51 | customLaunchers: { 52 | ChromeHeadless_Linux: { 53 | base: 'ChromeHeadless', 54 | flags: [ 55 | '--no-sandbox', 56 | '--disable-setuid-sandbox' 57 | ], 58 | debug: true 59 | } 60 | }, 61 | 62 | browsers: browsers, 63 | 64 | browserNoActivityTimeout: 30000, 65 | 66 | singleRun: true, 67 | autoWatch: false 68 | }); 69 | 70 | }; 71 | -------------------------------------------------------------------------------- /test/config/karma.unit.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var path = require('path'); 4 | 5 | var basePath = '../../'; 6 | 7 | var absoluteBasePath = path.resolve(path.join(__dirname, basePath)); 8 | 9 | /* global process */ 10 | 11 | // configures browsers to run test against 12 | // any of [ 'ChromeHeadless', 'Chrome', 'Firefox', 'IE', 'PhantomJS' ] 13 | var browsers = 14 | (process.env.TEST_BROWSERS || 'ChromeHeadless') 15 | .replace(/^\s+|\s+$/, '') 16 | .split(/\s*,\s*/g) 17 | .map(function(browser) { 18 | if (browser === 'ChromeHeadless') { 19 | process.env.CHROME_BIN = require('puppeteer').executablePath(); 20 | 21 | // workaround https://github.com/GoogleChrome/puppeteer/issues/290 22 | if (process.platform === 'linux') { 23 | return 'ChromeHeadless_Linux'; 24 | } 25 | } 26 | 27 | return browser; 28 | }); 29 | 30 | 31 | module.exports = function(karma) { 32 | karma.set({ 33 | 34 | basePath: basePath, 35 | 36 | frameworks: [ 37 | 'browserify', 38 | 'mocha', 39 | 'sinon-chai' 40 | ], 41 | 42 | files: [ 43 | 'test/spec/**/*Spec.js' 44 | ], 45 | 46 | preprocessors: { 47 | 'test/spec/**/*Spec.js': [ 'browserify' ] 48 | }, 49 | 50 | reporters: [ 'spec' ], 51 | 52 | customLaunchers: { 53 | ChromeHeadless_Linux: { 54 | base: 'ChromeHeadless', 55 | flags: [ 56 | '--no-sandbox', 57 | '--disable-setuid-sandbox' 58 | ], 59 | debug: true 60 | } 61 | }, 62 | 63 | browsers: browsers, 64 | 65 | browserNoActivityTimeout: 30000, 66 | 67 | singleRun: true, 68 | autoWatch: false, 69 | 70 | // browserify configuration 71 | browserify: { 72 | debug: true, 73 | paths: [ absoluteBasePath ], 74 | transform: [ 75 | [ 'babelify', { 76 | global: true, 77 | babelrc: false, 78 | presets: [ 79 | 'env' 80 | ] 81 | } ], 82 | [ 'stringify', { 83 | global: true, 84 | extensions: [ 85 | '.cmmn', 86 | '.xml', 87 | '.css' 88 | ] 89 | } ] 90 | ] 91 | } 92 | }); 93 | }; 94 | -------------------------------------------------------------------------------- /test/distro/cmmn-modeler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | describe('cmmn-modeler', function() { 5 | 6 | it('should expose globals', function() { 7 | 8 | var CmmnJS = window.CmmnJS; 9 | 10 | // then 11 | expect(CmmnJS).to.exist; 12 | expect(new CmmnJS()).to.exist; 13 | }); 14 | 15 | 16 | it('should expose Viewer and NavigatedViewer', function() { 17 | 18 | var CmmnJS = window.CmmnJS; 19 | 20 | // then 21 | expect(CmmnJS.NavigatedViewer).to.exist; 22 | expect(new CmmnJS.NavigatedViewer()).to.exist; 23 | 24 | expect(CmmnJS.Viewer).to.exist; 25 | expect(new CmmnJS.Viewer()).to.exist; 26 | }); 27 | 28 | 29 | it('should import initial diagram', function(done) { 30 | 31 | var CmmnJS = window.CmmnJS; 32 | 33 | // then 34 | /* global testImport */ 35 | testImport(CmmnJS, done); 36 | }); 37 | 38 | }); -------------------------------------------------------------------------------- /test/distro/cmmn-navigated-viewer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | describe('cmmn-navigated-viewer', function() { 5 | 6 | it('should expose globals', function() { 7 | 8 | var CmmnJS = window.CmmnJS; 9 | 10 | // then 11 | expect(CmmnJS).to.exist; 12 | expect(new CmmnJS()).to.exist; 13 | }); 14 | 15 | 16 | it('should expose Viewer', function() { 17 | 18 | var CmmnJS = window.CmmnJS; 19 | 20 | // then 21 | expect(CmmnJS.Viewer).not.to.exist; 22 | }); 23 | 24 | 25 | it('should import initial diagram', function(done) { 26 | 27 | var CmmnJS = window.CmmnJS; 28 | 29 | // then 30 | /* global testImport */ 31 | testImport(CmmnJS, done); 32 | }); 33 | 34 | }); -------------------------------------------------------------------------------- /test/distro/cmmn-viewer.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | describe('cmmn-navigated-viewer', function() { 5 | 6 | it('should expose globals', function() { 7 | 8 | var CmmnJS = window.CmmnJS; 9 | 10 | // then 11 | expect(CmmnJS).to.exist; 12 | expect(new CmmnJS()).to.exist; 13 | }); 14 | 15 | 16 | it('should import initial diagram', function(done) { 17 | 18 | var CmmnJS = window.CmmnJS; 19 | 20 | // then 21 | /* global testImport */ 22 | testImport(CmmnJS, done); 23 | }); 24 | 25 | }); -------------------------------------------------------------------------------- /test/distro/helper.js: -------------------------------------------------------------------------------- 1 | 2 | function testImport(CmmnJS, done) { 3 | 4 | var container = document.createElement('div'); 5 | container.style.height = '500px'; 6 | container.style.border = 'solid 1px #666'; 7 | 8 | document.body.appendChild(container); 9 | 10 | get('/base/resources/initial.cmmn', function(err, text) { 11 | 12 | if (err) { 13 | return done(err); 14 | } 15 | 16 | var modeler = new CmmnJS({ container: container }); 17 | 18 | modeler.importXML(text, function(err, warnings) { 19 | return done(err, warnings, modeler); 20 | }); 21 | }); 22 | 23 | } 24 | 25 | function get(url, done) { 26 | var httpRequest = new XMLHttpRequest(); 27 | 28 | if (!httpRequest) { 29 | return done(new Error('cannot create XMLHttpRequest')); 30 | } 31 | 32 | httpRequest.onreadystatechange = checkDone; 33 | httpRequest.open('GET', url); 34 | httpRequest.send(); 35 | 36 | function checkDone() { 37 | if (httpRequest.readyState === XMLHttpRequest.DONE) { 38 | if (httpRequest.status === 200) { 39 | return done(null, httpRequest.responseText); 40 | } else { 41 | return done(new Error('status = ' + httpRequest.status), null, httpRequest); 42 | } 43 | } 44 | } 45 | } 46 | 47 | window.testImport = testImport; -------------------------------------------------------------------------------- /test/fixtures/cmmn/empty-definitions.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/error/cmmn-shape-no-cmmn-element-ref.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/error/missing-namespace.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/multiple-cases.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/case-file-item.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/case-plan-model.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/case-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/collapsed-discretionary-stage.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/collapsed-plan-fragment.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/collapsed-stage.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/connection.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/decision-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-case-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-decision-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-human-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-manual-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-milestone.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-process-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-timer-event-listener.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-untyped-event-listener.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-untyped-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/discretionary-user-event-listener.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/entry-criterion.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/exit-criterion-on-case-plan-model.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/exit-criterion.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/expanded-discretionary-stage.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/expanded-plan-fragment.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/expanded-stage.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/human-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/manual-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/milestone.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/process-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/timer-event-listener.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/untyped-event-listener.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/untyped-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/fixtures/cmmn/renderer/user-event-listener.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/spec/NavigatedViewerSpec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var NavigatedViewer = require('../../lib/NavigatedViewer'); 4 | 5 | 6 | describe('NavigatedViewer', function() { 7 | 8 | var container; 9 | 10 | beforeEach(function() { 11 | container = document.createElement('div'); 12 | document.body.appendChild(container); 13 | }); 14 | 15 | 16 | 17 | function createViewer(xml, done) { 18 | var viewer = new NavigatedViewer({ container: container }); 19 | 20 | viewer.importXML(xml, function(err, warnings) { 21 | done(err, warnings, viewer); 22 | }); 23 | } 24 | 25 | 26 | it('should import simple process', function(done) { 27 | var xml = require('../fixtures/cmmn/simple.cmmn'); 28 | createViewer(xml, done); 29 | }); 30 | 31 | 32 | describe('navigation features', function() { 33 | 34 | var xml = require('../fixtures/cmmn/simple.cmmn'); 35 | 36 | it('should include zoomScroll', function(done) { 37 | 38 | createViewer(xml, function(err, warnings, viewer) { 39 | expect(viewer.get('zoomScroll')).to.exist; 40 | 41 | done(err); 42 | }); 43 | }); 44 | 45 | 46 | it('should include moveCanvas', function(done) { 47 | createViewer(xml, function(err, warnings, viewer) { 48 | expect(viewer.get('moveCanvas')).to.exist; 49 | 50 | done(err); 51 | }); 52 | }); 53 | 54 | }); 55 | 56 | }); 57 | -------------------------------------------------------------------------------- /test/spec/features/modeling/AppendShape.criterion.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/spec/features/modeling/CmmnUpdater.association.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/spec/features/modeling/CmmnUpdater.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/spec/features/modeling/LabelBoundsSpec.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/spec/features/modeling/UpdateAttachment.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/CaseFileItemUpdater.simple.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/LabelBehaviorSpec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* global bootstrapModeler, inject */ 4 | 5 | var modelingModule = require('../../../../../lib/features/modeling'), 6 | coreModule = require('../../../../../lib/core'); 7 | 8 | 9 | describe('behavior - LabelBehavior', function() { 10 | 11 | var diagramXML = require('./LabelBehavior.cmmn'); 12 | 13 | var testModules = [ modelingModule, coreModule ]; 14 | 15 | beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); 16 | 17 | 18 | describe('add label', function() { 19 | 20 | it('should add to case plan item on part connection', inject(function(elementRegistry, modeling) { 21 | 22 | // given 23 | var source = elementRegistry.get('CaseFileItem_1'), 24 | target = elementRegistry.get('ExitCriterion_2'); 25 | 26 | // when 27 | var connection = modeling.connect(source, target); 28 | 29 | // then 30 | expect(connection.label).to.exist; 31 | })); 32 | 33 | 34 | it('should add to plan item on part connection', inject(function(elementRegistry, modeling) { 35 | 36 | // given 37 | var source = elementRegistry.get('PI_HumanTask_2'), 38 | target = elementRegistry.get('ExitCriterion_1'); 39 | 40 | // when 41 | var connection = modeling.connect(source, target); 42 | 43 | // then 44 | expect(connection.label).to.exist; 45 | })); 46 | 47 | 48 | it('should add to event listener', inject(function(elementFactory, elementRegistry, modeling) { 49 | 50 | // given 51 | var casePlanModel = elementRegistry.get('CasePlanModel_1'), 52 | newShapeAttrs = elementFactory.createPlanItemShape('cmmn:EventListener'); 53 | 54 | // when 55 | var newShape = modeling.createShape(newShapeAttrs, { x: 300, y: 300 }, casePlanModel); 56 | 57 | // then 58 | expect(newShape.label).to.exist; 59 | })); 60 | 61 | 62 | it('should not add to task', inject(function(elementFactory, elementRegistry, modeling) { 63 | 64 | // given 65 | var casePlanModel = elementRegistry.get('CasePlanModel_1'), 66 | newShapeAttrs = elementFactory.createPlanItemShape('cmmn:Task'); 67 | 68 | // when 69 | var newShape = modeling.createShape(newShapeAttrs, { x: 300, y: 300 }, casePlanModel); 70 | 71 | // then 72 | expect(newShape.label).not.to.exist; 73 | })); 74 | 75 | }); 76 | 77 | 78 | }); 79 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanItemDefinitionUpdater.create-discretionary-connection.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanItemDefinitionUpdater.different-parents.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanItemDefinitionUpdater.morph-to-plan-fragment.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanItemDefinitionUpdater.move-plan-fragment.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanItemDefinitionUpdater.move.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanItemDefinitionUpdater.nested-planning-table.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanItemDefinitionUpdater.replace.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanningTableUpdater.switch-source-target.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/PlanningTableUpdater.without-discretionary-connection.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/ReplaceConnectionBehavior.move.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/SentryUpdater.add.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/SentryUpdater.discretionary-to-human-task.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/SentryUpdater.discretionary-to-stage.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/SentryUpdater.move-nested-human-task-criterion-not-visible.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/SentryUpdaterReplace.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/spec/features/modeling/behavior/SentryUpdaterReplaceSpec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* global bootstrapModeler, inject */ 4 | 5 | var modelingModule = require('../../../../../lib/features/modeling'), 6 | coreModule = require('../../../../../lib/core'); 7 | 8 | 9 | describe('features/modeling - #SentryUpdater', function() { 10 | 11 | var testModules = [ coreModule, modelingModule ]; 12 | 13 | describe('replace', function() { 14 | 15 | describe('should retain sentry', function() { 16 | 17 | var diagramXML = require('./SentryUpdaterReplace.cmmn'); 18 | 19 | beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); 20 | 21 | var oldElement, newElement, sentry; 22 | 23 | beforeEach(inject(function(elementRegistry, modeling, cmmnReplace) { 24 | 25 | // given 26 | oldElement = elementRegistry.get('PI_Stage_1'); 27 | 28 | sentry = elementRegistry.get('EntryCriterion_1').businessObject.sentryRef; 29 | 30 | var newElementData = { 31 | type: 'cmmn:DiscretionaryItem', 32 | definitionType: 'cmmn:PlanFragment' 33 | }; 34 | 35 | // when 36 | newElement = cmmnReplace.replaceElement(oldElement, newElementData); 37 | 38 | })); 39 | 40 | 41 | it('should execute', function() { 42 | // then 43 | expect(newElement.businessObject.definitionRef.get('sentries')).to.include(sentry); 44 | expect(oldElement.businessObject.definitionRef.get('sentries')).not.to.include(sentry); 45 | 46 | expect(sentry.$parent).to.equal(newElement.businessObject.definitionRef); 47 | }); 48 | 49 | 50 | it('should undo', inject(function(commandStack) { 51 | // when 52 | commandStack.undo(); 53 | 54 | // then 55 | expect(newElement.businessObject.definitionRef.get('sentries')).not.to.include(sentry); 56 | expect(oldElement.businessObject.definitionRef.get('sentries')).to.include(sentry); 57 | 58 | expect(sentry.$parent).to.equal(oldElement.businessObject.definitionRef); 59 | })); 60 | 61 | 62 | it('should redo', inject(function(commandStack) { 63 | // when 64 | commandStack.undo(); 65 | commandStack.redo(); 66 | 67 | // then 68 | expect(newElement.businessObject.definitionRef.get('sentries')).to.include(sentry); 69 | expect(oldElement.businessObject.definitionRef.get('sentries')).not.to.include(sentry); 70 | 71 | expect(sentry.$parent).to.equal(newElement.businessObject.definitionRef); 72 | })); 73 | 74 | }); 75 | 76 | }); 77 | 78 | }); 79 | -------------------------------------------------------------------------------- /test/spec/features/ordering/CmmnOrderingProviderSpec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Helper = require('./Helper'); 4 | 5 | /* global bootstrapModeler, inject */ 6 | 7 | var move = Helper.move, 8 | attach = Helper.attach, 9 | expectZOrder = Helper.expectZOrder; 10 | 11 | var modelingModule = require('../../../../lib/features/modeling'), 12 | coreModule = require('../../../../lib/core'); 13 | 14 | 15 | describe('features/modeling - ordering', function() { 16 | 17 | var testModules = [ coreModule, modelingModule ]; 18 | 19 | 20 | describe('criterions', function() { 21 | 22 | describe('move', function() { 23 | 24 | var diagramXML = require('./Ordering.cmmn'); 25 | 26 | beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); 27 | 28 | 29 | it('should stay in front of Task', inject(function() { 30 | 31 | // when 32 | move('PI_Task_1'); 33 | 34 | // then 35 | expectZOrder('PI_Task_1', 'EntryCriterion_1'); 36 | })); 37 | 38 | 39 | it('should stay in front of Task, moving both', inject(function() { 40 | 41 | // when 42 | move([ 'EntryCriterion_1', 'PI_Task_1' ], 'CasePlanModel_2'); 43 | 44 | // then 45 | expectZOrder('PI_Task_1', 'EntryCriterion_1'); 46 | })); 47 | 48 | }); 49 | 50 | 51 | describe('add', function() { 52 | 53 | var diagramXML = require('./Ordering.cmmn'); 54 | 55 | beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); 56 | 57 | 58 | it('should add in front of Task', inject(function() { 59 | 60 | // when 61 | var criterionShape = attach({ type: 'cmmn:ExitCriterion' }, { x: 320, y: 160 }, 'PI_Task_1'); 62 | 63 | // then 64 | expectZOrder('PI_Task_1', criterionShape.id); 65 | })); 66 | 67 | }); 68 | 69 | }); 70 | 71 | }); 72 | -------------------------------------------------------------------------------- /test/spec/features/ordering/Ordering.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/spec/features/outline/OutlineSpec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | require('../../../TestHelper'); 4 | 5 | var coreModule = require('../../../../lib/core'), 6 | selectionModule = require('diagram-js/lib/features/selection').default, 7 | outlineModule = require('../../../../lib/features/outline'); 8 | 9 | var domQuery = require('min-dom').query; 10 | 11 | /* global bootstrapModeler, inject */ 12 | 13 | 14 | describe('features - outline', function() { 15 | 16 | var diagramXML = require('../../../fixtures/cmmn/simple.cmmn'); 17 | 18 | var testModules = [ coreModule, selectionModule, outlineModule ]; 19 | 20 | beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); 21 | 22 | 23 | it('should fit case plan model height', inject(function(outline, elementRegistry, selection) { 24 | 25 | // given 26 | var casePlanModel = elementRegistry.get('CasePlanModel_1'); 27 | 28 | // when 29 | selection.select(casePlanModel); 30 | 31 | // then 32 | var gfx = elementRegistry.getGraphics(casePlanModel); 33 | 34 | var outlineBBox = domQuery('.djs-outline', gfx).getBBox(); 35 | 36 | expect(outlineBBox.y).to.equal(-24); 37 | expect(outlineBBox.height).to.equal(280); 38 | })); 39 | 40 | }); 41 | -------------------------------------------------------------------------------- /test/spec/features/palette/PaletteProviderSpec.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* global bootstrapModeler, inject */ 4 | 5 | var modelingModule = require('../../../../lib/features/modeling'), 6 | paletteModule = require('../../../../lib/features/palette'), 7 | coreModule = require('../../../../lib/core'); 8 | 9 | var domQuery = require('min-dom').query, 10 | domQueryAll = require('min-dom').queryAll; 11 | 12 | describe('features/palette', function() { 13 | 14 | var diagramXML = require('../../../fixtures/cmmn/simple.cmmn'); 15 | 16 | var testModules = [ coreModule, modelingModule, paletteModule ]; 17 | 18 | beforeEach(bootstrapModeler(diagramXML, { modules: testModules })); 19 | 20 | 21 | it('should provide CMMN modeling palette', inject(function(canvas, palette) { 22 | 23 | // when 24 | var paletteElement = domQuery('.djs-palette', canvas._container); 25 | var entries = domQueryAll('.entry', paletteElement); 26 | 27 | // then 28 | expect(entries.length).to.equal(11); 29 | })); 30 | 31 | }); 32 | -------------------------------------------------------------------------------- /test/spec/features/popup-menu/ReplaceMenuProvider.toggle.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /test/spec/features/remove/RemovePlanItem.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /test/spec/features/replace/CmmnReplace.properties.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /test/spec/features/resize/ResizeStage.discretionary.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/spec/features/rules/CmmnRules.artifact.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /test/spec/features/rules/CmmnRules.external-label.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /test/spec/features/snapping/CmmnSnapping.caseplanmodel-resize.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/spec/features/snapping/CmmnSnapping.discretionaryitem-stage-resize.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /test/spec/features/snapping/CmmnSnapping.planitem-stage-resize.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /test/spec/features/snapping/CmmnSnapping.sentries.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /test/spec/features/snapping/CmmnSnapping.text-annotation.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/spec/import/Importer.case-plan-model-without-di.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /test/spec/import/Importer.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /test/spec/import/Importer.discretionary-association.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /test/spec/import/Importer.multiple-cases.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /test/spec/import/Importer.multiple-discretionary-connection.cmmn: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /test/util/KeyEvents.js: -------------------------------------------------------------------------------- 1 | var isString = require('min-dash').isString; 2 | var assign = require('min-dash').assign; 3 | 4 | /** 5 | * Create a fake key event for testing purposes. 6 | * 7 | * @param {String|Number} key the key or keyCode/charCode 8 | * @param {Object} [attrs] 9 | * 10 | * @return {Event} 11 | */ 12 | function createKeyEvent(key, attrs) { 13 | var event = document.createEvent('Events') || new document.defaultView.CustomEvent('keyEvent'); 14 | 15 | // init and mark as bubbles / cancelable 16 | event.initEvent('keydown', false, true); 17 | 18 | var keyAttrs = isString(key) ? { key: key } : { keyCode: key, which: key }; 19 | 20 | return assign(event, keyAttrs, attrs || {}); 21 | } 22 | 23 | module.exports.createKeyEvent = createKeyEvent; -------------------------------------------------------------------------------- /test/util/MockEvents.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var assign = require('min-dash').assign; 4 | 5 | var TestHelper = require('../TestHelper'); 6 | 7 | 8 | /** 9 | * Create an event with global coordinates 10 | * computed based on the loaded diagrams canvas position and the 11 | * specified canvas local coordinates. 12 | * 13 | * @param {Point} point of the event local the canvas (closure) 14 | * @param {Object} data 15 | * 16 | * @return {Event} event, scoped to the given canvas 17 | */ 18 | function createCanvasEvent(position, data) { 19 | 20 | return TestHelper.getCmmnJs().invoke(function(canvas) { 21 | 22 | var target = canvas._svg; 23 | 24 | var clientRect = canvas._container.getBoundingClientRect(); 25 | 26 | var absolutePosition = { 27 | x: position.x + clientRect.left, 28 | y: position.y + clientRect.top 29 | }; 30 | 31 | return createEvent(target, absolutePosition, data); 32 | }); 33 | } 34 | 35 | module.exports.createCanvasEvent = createCanvasEvent; 36 | 37 | 38 | function createEvent(target, position, data) { 39 | 40 | return TestHelper.getCmmnJs().invoke(function(eventBus) { 41 | data = assign({ 42 | target: target, 43 | x: position.x, 44 | y: position.y, 45 | clientX: position.x, 46 | clientY: position.y, 47 | offsetX: position.x, 48 | offsetY: position.y 49 | }, data || {}); 50 | 51 | return eventBus.createEvent(data); 52 | }); 53 | } 54 | 55 | module.exports.createEvent = createEvent; -------------------------------------------------------------------------------- /test/util/custom-rules/CustomRules.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var inherits = require('inherits'); 4 | 5 | var RuleProvider = require('diagram-js/lib/features/rules/RuleProvider').default; 6 | 7 | function CustomRules(eventBus) { 8 | RuleProvider.call(this, eventBus); 9 | } 10 | 11 | CustomRules.$inject = [ 'eventBus' ]; 12 | 13 | inherits(CustomRules, RuleProvider); 14 | 15 | CustomRules.prototype.init = function() { 16 | // placeholder 17 | }; 18 | 19 | module.exports = CustomRules; -------------------------------------------------------------------------------- /test/util/custom-rules/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | __init__: [ 'customRules' ], 3 | customRules: [ 'type', require('./CustomRules') ] 4 | }; 5 | --------------------------------------------------------------------------------