-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEAT] Add API to search elements by BPMN Kinds
Let pass one or several BPMN Kinds to get BpmnElements. This implementation relies on CSS selectors for searching elements. It will be possible to avoid this when the BpmnModel will be available and will provide search capabilities.
- Loading branch information
Showing
8 changed files
with
571 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>BPMN Visualization Non Regression</title> | ||
<link rel="shortcut icon" href="./static/img/favicon.ico"> | ||
<style> | ||
#main-container { | ||
top: 140px; | ||
bottom: 10px; | ||
left: 10px; | ||
right: 10px; | ||
position: absolute; | ||
} | ||
#bpmn-container { | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
|
||
border-style: solid; | ||
border-color: #B0B0B0; | ||
border-width: 1px; | ||
|
||
position: absolute; | ||
overflow: hidden; | ||
} | ||
|
||
textarea { | ||
resize: none; | ||
height: 100px; | ||
right: 10px; | ||
position: absolute; | ||
width: 70%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="controls"> | ||
<label for="bpmn-kinds-select">Select by Kinds:</label><select id="bpmn-kinds-select"> | ||
<option value="task">Abstract Task</option> | ||
<option value="userTask">User Task</option> | ||
<option value="scriptTask">Script Task</option> | ||
<option value="serviceTask">Service Task</option> | ||
<option value="startEvent">Start Event</option> | ||
<option value="endEvent">End Event</option> | ||
<option value="intermediateCatchEvent">Catch Event</option> | ||
<option value="intermediateThrowEvent">Throw Event</option> | ||
<option value="lane">Lane</option> | ||
</select> | ||
<button id="bpmn-kinds-textarea-clean-btn">Clear</button> | ||
<textarea id="elements-result"></textarea> | ||
</div> | ||
|
||
<div id="main-container"> | ||
<div id="bpmn-container"></div> | ||
</div> | ||
|
||
<!-- load global settings --> | ||
<script src="./static/js/configureMxGraphGlobals.js"></script> | ||
<!-- load mxGraph client library --> | ||
<script src="./static/js/mxClient.min.js"></script> | ||
<!-- load app --> | ||
<script src="./static/js/elements-identification.js" type="module"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright 2020 Bonitasoft S.A. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { documentReady, FitType, getElementsByKinds, log, startBpmnVisualization, updateLoadOptions } from '../../index.es.js'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
function configureControls() { | ||
const textArea = document.getElementById('elements-result'); | ||
|
||
document.getElementById('bpmn-kinds-select').onchange = function (ev) { | ||
const bpmnKind = ev.target.value; | ||
log(`Searching for Bpmn elements of '${bpmnKind}' kind`); | ||
const elementsByKinds = getElementsByKinds(bpmnKind); | ||
|
||
const textHeader = `Found ${elementsByKinds.length} ${bpmnKind}(s)`; | ||
log(textHeader); | ||
const lines = elementsByKinds.map(elt => ` - ${elt.bpmnSemantic.id}: '${elt.bpmnSemantic.name}'`).join('\n'); | ||
|
||
textArea.value += [textHeader, lines].join('\n') + '\n'; | ||
textArea.scrollTop = textArea.scrollHeight; | ||
}; | ||
|
||
document.getElementById('bpmn-kinds-textarea-clean-btn').onclick = function () { | ||
textArea.value = ''; | ||
}; | ||
} | ||
|
||
documentReady(() => { | ||
startBpmnVisualization({ | ||
container: 'bpmn-container', | ||
globalOptions: { | ||
mouseNavigationSupport: true, | ||
}, | ||
}); | ||
updateLoadOptions({ type: FitType.Center, margin: 20 }); | ||
configureControls(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.