Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hide all other overlays when token simulation active #162

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions assets/css/bpmn-js-token-simulation.css
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,18 @@
top: 60px;
}

.bjs-container.simulation .djs-palette {
display: none;
}

.bjs-container.simulation .djs-outline,
.bjs-container.simulation .djs-bendpoint,
.bjs-container.simulation .djs-segment-dragger,
.bjs-container.simulation .djs-resizer {
.bjs-container.simulation .djs-outline,
.bjs-container.simulation .djs-palette,
.bjs-container.simulation .djs-resizer,
.bjs-container.simulation .djs-segment-dragger {
display: none !important;
}

.bjs-container.simulation .djs-overlay:not(.djs-overlay-bts-context-menu, .djs-overlay-bts-element-notification, .djs-overlay-bts-token-count) {
display: none !important;
}

.bts-palette {
position: absolute;
top: 60px;
Expand Down
2 changes: 1 addition & 1 deletion lib/features/context-pads/ContextPads.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ ContextPads.prototype._addOverlay = function(element, options) {
throw new Error('<handlerHash> required');
}

const overlayId = this._overlays.add(element, 'ts-context-menu', {
const overlayId = this._overlays.add(element, 'bts-context-menu', {
...options,
position: {
top: OFFSET_TOP,
Expand Down
9 changes: 2 additions & 7 deletions lib/features/disable-modeling/DisableModeling.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ export default function DisableModeling(
directEditing,
editorActions,
modeling,
palette,
paletteProvider) {
palette) {

let modelingDisabled = false;

Expand All @@ -23,7 +22,6 @@ export default function DisableModeling(

if (modelingDisabled) {
directEditing.cancel();
contextPad.close();
dragging.cancel();
}

Expand Down Expand Up @@ -57,8 +55,6 @@ export default function DisableModeling(
});
}

ignoreIfModelingDisabled(contextPad, 'open');

ignoreIfModelingDisabled(dragging, 'init');

ignoreIfModelingDisabled(directEditing, 'activate');
Expand Down Expand Up @@ -119,8 +115,7 @@ DisableModeling.$inject = [
'directEditing',
'editorActions',
'modeling',
'palette',
'paletteProvider',
'palette'
];


Expand Down
4 changes: 2 additions & 2 deletions lib/features/element-notifications/ElementNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ElementNotifications.prototype.addElementNotification = function(element, option
</div>
`);

this._overlays.add(element, 'element-notification', {
this._overlays.add(element, 'bts-element-notification', {
position,
html: html,
show: {
Expand All @@ -60,7 +60,7 @@ ElementNotifications.prototype.addElementNotification = function(element, option
};

ElementNotifications.prototype.clear = function() {
this._overlays.remove({ type: 'element-notification' });
this._overlays.remove({ type: 'bts-element-notification' });
};

ElementNotifications.prototype.removeElementNotification = function(element) {
Expand Down
2 changes: 1 addition & 1 deletion lib/features/token-count/TokenCount.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TokenCount.prototype.addTokenCount = function(element, scopes) {

const position = { bottom: OFFSET_BOTTOM, left: OFFSET_LEFT };

const overlayId = this._overlays.add(element, 'token-count', {
const overlayId = this._overlays.add(element, 'bts-token-count', {
position: position,
html: html,
show: {
Expand Down
54 changes: 53 additions & 1 deletion test/spec/ModelerSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import {

import { matchPattern } from 'min-dash';

import { queryAll as domQueryAll } from 'min-dom';


injectStyles();

var singleStart = window.__env__ && window.__env__.SINGLE_START === 'modeler';


describe('modeler extension', function() {

describe('basic', function() {
Expand Down Expand Up @@ -199,4 +200,55 @@ describe('modeler extension', function() {

});


describe('overlays', function() {

class FoobarOverlays {
constructor(eventBus, overlays) {
eventBus.on('shape.added', ({ element }) => {
overlays.add(element, 'foobar', {
html: '<h1>Foobar</h1>',
position: {
bottom: 0,
left: 0
}
});
});
}
}

FoobarOverlays.$inject = [ 'eventBus', 'overlays' ];

const FoobarOverlaysModule = {
__init__: [ 'foobarOverlays' ],
foobarOverlays: [ 'type', FoobarOverlays ]
};

const diagram = require('./simple.bpmn');

beforeEach(bootstrapModeler(diagram, {
additionalModules: [
TokenSimulationModelerModules,
FoobarOverlaysModule
]
}));


it('should hide overlays', inject(function(toggleMode) {

// given
const overlays = Array.from(domQueryAll('.djs-overlay-foobar'));

expect(overlays).to.have.length.greaterThan(0);
expect(overlays.every(element => window.getComputedStyle(element).display !== 'none')).to.be.true;

// when
toggleMode.toggleMode();

// then
expect(overlays.every(element => window.getComputedStyle(element).display === 'none')).to.be.true;
}));

});

});