Skip to content

Commit 14005c8

Browse files
authored
[REFACTOR] Update for 0.7.0 release (#95)
* Replace 0.6.0 demo by 0.7.0 demo * Replace all 0.6.0 references by 0.7.0
1 parent ee8e3a7 commit 14005c8

23 files changed

Lines changed: 351 additions & 61 deletions

File tree

demo/0.7.0/bpmn-visualization.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

demo/index.es.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
<div id="options-panel">
1212
<div>
1313
<h3>Options</h3>
14-
<label>Fit on load:
14+
<label for="fitOnLoad">Fit on load
15+
<input type="checkbox" id="fitOnLoad" name="fitOnLoad" checked>
16+
</label><br>
17+
<label>Fit type
1518
<select name="fitTypes" id="fitType-selected">
1619
<option value="None" selected="yes">None</option>
1720
<option value="HorizontalVertical">Horizontal-Vertical</option>
@@ -20,6 +23,9 @@ <h3>Options</h3>
2023
<option value="Center">Center</option>
2124
</select>
2225
</label>
26+
<label for="fit-margin">Fit margin
27+
<input type="number" id="fit-margin" min="0" max="100" maxlength="3" oninput="validity.valid||(value='');">
28+
</label>
2329
</div>
2430
</div>
2531
<div id="file-panel">

demo/navigation-diagram.html

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424
.tooltip {
2525
visibility: hidden;
26-
width: 160px;
26+
width: 300px;
2727
background-color: black;
2828
color: #fff;
2929
fill: #B0B0B0;
@@ -39,6 +39,33 @@
3939
.info:hover .tooltip {
4040
visibility: visible;
4141
}
42+
#zoom-config-controls {
43+
visibility: hidden;
44+
}
45+
.zoom-config {
46+
font-size: 0.7em;
47+
width: 38px;
48+
position: absolute;
49+
left: -6px;
50+
}
51+
#zoom-throttle {
52+
top: 70px;
53+
}
54+
#zoom-debounce {
55+
top: 130px;
56+
}
57+
.info label {
58+
position: absolute;
59+
left: -5px;
60+
margin-top: 10px;
61+
font-size: 0.7em;
62+
}
63+
label[for="zoom-throttle"] {
64+
top: 40px;
65+
}
66+
label[for="zoom-debounce"] {
67+
top: 100px;
68+
}
4269
</style>
4370
</head>
4471
<body>
@@ -47,7 +74,14 @@
4774
<svg width="2em" height="2em" viewBox="0 0 16 16" class="bi bi-info-square-fill" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
4875
<path fill-rule="evenodd" d="M0 2a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2zm8.93 4.588l-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM8 5.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2z"/>
4976
</svg>
50-
<span class="tooltip">Drag and Drop a BPMN file</span>
77+
<div class="tooltip">
78+
<p>Drag and Drop a BPMN file</p>
79+
<p>To show zoom config controls add this to the url: .../navigation-diagram.html?zoomConfigControls=true</p>
80+
</div>
81+
<div id="zoom-config-controls">
82+
<label for="zoom-throttle">throttle</label><input id="zoom-throttle" class="zoom-config" type="number" placeholder="thr" value="40" disabled title="to play with throttle pass parameter in url like this: .../navigation-diagram.html?zoomConfigControls=true&zoomThrottle=40"/>
83+
<label for="zoom-debounce">debounce</label><input id="zoom-debounce" class="zoom-config" type="number" placeholder="deb" value="30" disabled title="to play with debounce pass parameter in url like this: .../navigation-diagram.html?zoomConfigControls=true&zoomDebounce=30"/>
84+
</div>
5185
</div>
5286

5387
<div id="bpmn-viewport"></div>

demo/rendering-diagram.html

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>BPMN Visualization - Diagram Rendering</title>
6+
<link rel="shortcut icon" href="./static/img/favicon.ico">
7+
8+
<link href='https://css.gg/close.css' rel='stylesheet'>
9+
<link href='https://css.gg/code.css' rel='stylesheet'>
10+
<link href='https://css.gg/select.css' rel='stylesheet'>
11+
<link href='https://css.gg/minimize.css' rel='stylesheet'>
12+
<link href='https://css.gg/maximize.css' rel='stylesheet'>
13+
14+
<style>
15+
.flex-container{
16+
display: flex;
17+
justify-content: space-between;
18+
align-items: center;
19+
}
20+
.flex-container > div {
21+
top: 20px;
22+
bottom: 20px;
23+
position: absolute;
24+
}
25+
.flex-sub-container{
26+
display: flex;
27+
flex-direction: column;
28+
justify-content: space-around;
29+
opacity: 0;
30+
}
31+
#bpmn-container {
32+
left: 50px;
33+
right: 20px;
34+
border-style: solid;
35+
border-color: #B0B0B0;
36+
border-width: 1px;
37+
overflow: hidden;
38+
}
39+
button {
40+
border-radius: 4px;
41+
padding: 0px;
42+
width:28px;
43+
height:28px;
44+
background-color: #f9dfe8;
45+
}
46+
</style>
47+
</head>
48+
<body>
49+
<div class="flex-container">
50+
<div class="flex-sub-container" style="flex-grow: 1">
51+
<button type="button" id="None">
52+
<svg
53+
width="24"
54+
height="24"
55+
viewBox="0 0 24 24"
56+
fill="none"
57+
xmlns="http://www.w3.org/2000/svg"
58+
>
59+
<path
60+
d="M6.2253 4.81108C5.83477 4.42056 5.20161 4.42056 4.81108 4.81108C4.42056 5.20161 4.42056 5.83477 4.81108 6.2253L10.5858 12L4.81114 17.7747C4.42062 18.1652 4.42062 18.7984 4.81114 19.1889C5.20167 19.5794 5.83483 19.5794 6.22535 19.1889L12 13.4142L17.7747 19.1889C18.1652 19.5794 18.7984 19.5794 19.1889 19.1889C19.5794 18.7984 19.5794 18.1652 19.1889 17.7747L13.4142 12L19.189 6.2253C19.5795 5.83477 19.5795 5.20161 19.189 4.81108C18.7985 4.42056 18.1653 4.42056 17.7748 4.81108L12 10.5858L6.2253 4.81108Z"
61+
fill="currentColor"
62+
/>
63+
</svg>
64+
</button>
65+
<button type="button" id="HorizontalVertical">
66+
<svg
67+
width="24"
68+
height="24"
69+
viewBox="0 0 24 24"
70+
fill="none"
71+
xmlns="http://www.w3.org/2000/svg"
72+
>
73+
<path d="M3 3H9V5H5V9H3V3Z" fill="currentColor" />
74+
<path d="M3 21H9V19H5V15H3V21Z" fill="currentColor" />
75+
<path d="M15 21H21V15H19V19H15V21Z" fill="currentColor" />
76+
<path d="M21 3H15V5H19V9H21V3Z" fill="currentColor" />
77+
</svg>
78+
</button>
79+
<button type="button" id="Horizontal">
80+
<svg
81+
width="24"
82+
height="24"
83+
viewBox="0 0 24 24"
84+
fill="none"
85+
xmlns="http://www.w3.org/2000/svg"
86+
>
87+
<path
88+
d="M9.95263 16.9123L8.59323 18.3608L2.03082 12.2016L8.18994 5.63922L9.64826 7.00791L4.85783 12.112L9.95212 16.8932L9.95263 16.9123Z"
89+
fill="currentColor"
90+
/>
91+
<path
92+
d="M14.0474 16.9123L15.4068 18.3608L21.9692 12.2016L15.8101 5.63922L14.3517 7.00791L19.1422 12.112L14.0479 16.8932L14.0474 16.9123Z"
93+
fill="currentColor"
94+
/>
95+
</svg>
96+
</button>
97+
<button type="button" id="Vertical">
98+
<svg
99+
width="24"
100+
height="24"
101+
viewBox="0 0 24 24"
102+
fill="none"
103+
xmlns="http://www.w3.org/2000/svg"
104+
>
105+
<path
106+
d="M6 9.65685L7.41421 11.0711L11.6569 6.82843L15.8995 11.0711L17.3137 9.65685L11.6569 4L6 9.65685Z"
107+
fill="currentColor"
108+
/>
109+
<path
110+
d="M6 14.4433L7.41421 13.0291L11.6569 17.2717L15.8995 13.0291L17.3137 14.4433L11.6569 20.1001L6 14.4433Z"
111+
fill="currentColor"
112+
/>
113+
</svg>
114+
</button>
115+
<button type="button" id="Center">
116+
<svg
117+
width="24"
118+
height="24"
119+
viewBox="0 0 24 24"
120+
fill="none"
121+
xmlns="http://www.w3.org/2000/svg"
122+
>
123+
<path d="M9 9H3V7H7V3H9V9Z" fill="currentColor" />
124+
<path d="M9 15H3V17H7V21H9V15Z" fill="currentColor" />
125+
<path d="M21 15H15V21H17V17H21V15Z" fill="currentColor" />
126+
<path d="M15 9.00012H21V7.00012H17V3.00012H15V9.00012Z" fill="currentColor" />
127+
</svg>
128+
</button>
129+
</div>
130+
131+
<div id="bpmn-container"></div>
132+
</div>
133+
134+
<!-- load global settings -->
135+
<script src="./static/js/configureMxGraphGlobals.js"></script>
136+
<!-- load mxGraph client library -->
137+
<script src="./static/js/mxClient.min.js"></script>
138+
<!-- load app -->
139+
<script src="./static/js/rendering-diagram.js" type="module"></script>
140+
</body>
141+
</html>

demo/static/css/main.css

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,22 @@
2323
#options-panel div {
2424
border-radius: 10px;
2525
border: 2px solid PowderBlue;
26-
margin-top: 5%;
27-
margin-left: 5%;
28-
margin-right: 10%;
29-
margin-bottom: 5%;
30-
margin-top: 15px;
31-
padding-bottom: 15px;
26+
margin: 15px 10% 5% 5%;
27+
padding-bottom: 35px;
3228
}
3329
#options-panel > * {
3430
padding-left: 5%;
3531
}
32+
#options-panel div label {
33+
padding-top: 5px;
34+
}
35+
36+
#fit-margin {
37+
width: 30%;
38+
}
39+
label[for=fit-margin] {
40+
float: left;
41+
}
3642

3743
.fixed-size {
3844
top: 10px;

demo/static/js/demo.js

Lines changed: 71 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,58 +13,102 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { documentReady, handleFileSelect, startBpmnVisualization, FitType, updateFitType } from '../../index.es.js';
16+
import { documentReady, handleFileSelect, startBpmnVisualization, FitType, fit, log, updateLoadOptions, getCurrentLoadOptions } from '../../index.es.js';
17+
18+
let fitOnLoad = true;
19+
let fitOptions = {};
1720

1821
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
19-
function updateFitTypeSelection(event) {
20-
updateFitType(event);
22+
function configureBpmnViewport() {
23+
const viewport = document.getElementById('graph');
2124

22-
if (event.target.value === 'None') {
23-
resetClass(container);
25+
const useFixedSize = !(fitOptions.type && FitType[fitOptions.type] === 'None'); // !== 'None'
26+
if (useFixedSize) {
27+
viewport.classList.add('fixed-size');
2428
} else {
25-
setFixedSizeClass(container);
29+
viewport.classList.remove('fixed-size');
2630
}
2731
}
2832

2933
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
30-
function setFixedSizeClass(htmlElementId) {
31-
const htmlElement = document.getElementById(htmlElementId);
32-
htmlElement.classList.add('fixed-size');
34+
function configureFitOnLoadCheckBox() {
35+
const fitOnLoadElt = document.getElementById('fitOnLoad');
36+
fitOnLoadElt.onchange = event => {
37+
fitOnLoad = event.target.checked;
38+
log('Fit on load updated!', fitOnLoad);
39+
updateLoadOptions(fitOnLoad ? fitOptions : {});
40+
};
41+
fitOnLoadElt.checked = fitOnLoad;
3342
}
3443

3544
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
36-
function resetClass(htmlElementId) {
37-
const htmlElement = document.getElementById(htmlElementId);
38-
htmlElement.classList.remove('fixed-size');
45+
function updateFitConfig(config) {
46+
log('Updating fit config', config);
47+
48+
fitOptions.margin = config.margin || fitOptions.margin;
49+
if (config.type) {
50+
fitOptions.type = FitType[config.type];
51+
}
52+
log('Fit config updated!', fitOptions);
53+
54+
if (fitOnLoad) {
55+
updateLoadOptions(fitOptions);
56+
}
3957
}
4058

4159
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
42-
function startDemo() {
43-
const parameters = new URLSearchParams(window.location.search);
60+
function configureFitTypeSelect() {
61+
const fitTypeSelectedElt = document.getElementById('fitType-selected');
62+
fitTypeSelectedElt.onchange = event => {
63+
updateFitConfig({ type: event.target.value });
64+
configureBpmnViewport();
65+
fit(fitOptions);
66+
};
4467

45-
// Update the selected option at the initialization
46-
const fitTypeSelected = document.getElementById('fitType-selected');
47-
fitTypeSelected.addEventListener('change', updateFitTypeSelection, false);
48-
49-
const parameterFitType = parameters.get('fitType');
50-
if (parameterFitType) {
51-
fitTypeSelected.value = parameterFitType;
68+
if (fitOptions.type) {
69+
fitTypeSelectedElt.value = FitType[fitOptions.type];
70+
} else {
71+
updateFitConfig({ type: fitTypeSelectedElt.value });
5272
}
5373

54-
if (fitTypeSelected.value !== 'None') {
55-
setFixedSizeClass('graph');
56-
}
74+
configureBpmnViewport();
75+
}
5776

58-
startBpmnVisualization({ container: 'graph', loadOptions: { fitType: FitType[fitTypeSelected.value] } });
59-
document.getElementById('bpmn-file').addEventListener('change', handleFileSelect, false);
77+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
78+
function configureFitMarginInput() {
79+
const fitMarginElt = document.getElementById('fit-margin');
80+
fitMarginElt.onchange = event => updateFitConfig({ margin: event.target.value });
6081

61-
// Update control panel
82+
if (fitOptions.margin) {
83+
fitMarginElt.value = fitOptions.margin;
84+
} else {
85+
updateFitConfig({ margin: fitMarginElt.value });
86+
}
87+
}
88+
89+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
90+
function configureControlPanel() {
91+
const parameters = new URLSearchParams(window.location.search);
6292
if (parameters.get('hideControls') === 'true') {
6393
const classList = document.getElementById('controls').classList;
6494
classList.remove('controls');
6595
classList.add('hidden');
6696
}
6797
}
6898

99+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
100+
function startDemo() {
101+
startBpmnVisualization({ container: 'graph' });
102+
103+
// Configure custom html elements
104+
document.getElementById('bpmn-file').addEventListener('change', handleFileSelect, false);
105+
106+
fitOptions = getCurrentLoadOptions().fit;
107+
configureFitTypeSelect();
108+
configureFitMarginInput();
109+
configureFitOnLoadCheckBox();
110+
configureControlPanel();
111+
}
112+
69113
// Start
70114
documentReady(startDemo);

0 commit comments

Comments
 (0)