diff --git a/lib/features/drilldown/DrilldownBreadcrumbs.js b/lib/features/drilldown/DrilldownBreadcrumbs.js index 20447a86..c3a9a4a9 100644 --- a/lib/features/drilldown/DrilldownBreadcrumbs.js +++ b/lib/features/drilldown/DrilldownBreadcrumbs.js @@ -21,15 +21,28 @@ export default function DrilldownBreadcrumbs(eventBus, elementRegistry, overlays var containerClasses = classes(container); container.appendChild(breadcrumbs); - function updateBreadcrumbs(element) { - var parents = getParentChain(element); + function updateBreadcrumbs(currentRoot) { + var parents = getParentChain(currentRoot); - var path = parents.map(function(el) { - var title = escapeHTML(el.name || el.id); + var path = parents.map(function(parent) { + var title = escapeHTML(parent.name || parent.id); var link = domify('
  • ' + title + '
  • '); + var parentPlane = canvas.findRoot(planeId(parent)) || canvas.findRoot(parent.id); + + if (!parentPlane && is(parent, 'bpmn:Process')) { + + // root is a collaboration + var participant = elementRegistry.find(function(element) { + var bo = getBusinessObject(element); + return bo && bo.processRef && bo.processRef === parent; + }); + + parentPlane = canvas.findRoot(participant.id); + } + link.addEventListener('click', function() { - canvas.setRootElement(canvas.findRoot(planeId(el)) || canvas.findRoot(el.id)); + canvas.setRootElement(parentPlane); }); return link; diff --git a/test/spec/features/drilldown/DrilldownSpec.js b/test/spec/features/drilldown/DrilldownSpec.js index 6d5055d2..3786ad1b 100644 --- a/test/spec/features/drilldown/DrilldownSpec.js +++ b/test/spec/features/drilldown/DrilldownSpec.js @@ -15,6 +15,7 @@ describe('features - drilldown', function() { DrilldownModule ]; + var collaborationXML = require('./collaboration-subprocesses.bpmn'); var multiLayerXML = require('./nested-subprocesses.bpmn'); var legacyXML = require('./legacy-subprocesses.bpmn'); @@ -257,6 +258,148 @@ describe('features - drilldown', function() { }); + describe('Collaboration', function() { + + beforeEach(bootstrapViewer(collaborationXML, { modules: testModules })); + + describe('Overlays', function() { + + it('should show overlay', inject(function(elementRegistry, overlays) { + + // given + var collapsedProcess = elementRegistry.get('collapsedProcess'); + var overlay = overlays.get({ element: collapsedProcess }); + + // then + expect(overlay).to.exist; + })); + + + it('should switch plane on click', inject(function(elementRegistry, overlays, canvas) { + + // given + var collapsedProcess = elementRegistry.get('collapsedProcess'); + var overlay = overlays.get({ element: collapsedProcess })[0]; + + // when + overlay.html.click(); + + // then + var collapsedRoot = canvas.getRootElement(); + + expect(collapsedRoot.businessObject).to.equal(collapsedProcess.businessObject); + })); + + }); + + + describe('Breadcrumbs', function() { + + it('should not show breadcrumbs in root view', inject(function(canvas) { + + // given + var container = canvas.getContainer(); + + // then + expect(classes(container).contains('bjs-breadcrumbs-shown')).to.be.false; + })); + + + it('should show breadcrumbs in subprocess view', inject(function(canvas) { + + // given + var container = canvas.getContainer(); + + // when + canvas.setRootElement(canvas.findRoot('collapsedProcess_plane')); + + // then + expect(classes(container).contains('bjs-breadcrumbs-shown')).to.be.true; + })); + + + it('should show execution tree', inject(function(canvas) { + + // when + canvas.setRootElement(canvas.findRoot('collapsedProcess_2_plane')); + + // then + expectBreadcrumbs([ + 'Root', + 'Collapsed Process', + 'Expanded Process', + 'Collapsed Process 2' + ]); + })); + + + it('should switch to process plane on click', inject(function(canvas) { + + // given + var subRoot = canvas.findRoot('collapsedProcess_plane'); + var nestedRoot = canvas.findRoot('collapsedProcess_2_plane'); + + canvas.setRootElement(nestedRoot); + + // when + clickBreadcrumb(1); + + // then + expectBreadcrumbs([ + 'Root', + 'Collapsed Process' + ]); + + expect( + canvas.getRootElement() + ).to.equal(subRoot); + })); + + + it('should switch to root', inject(function(canvas) { + + // given + var collaboration = canvas.findRoot('Collaboration_0wnumpk'); + var nestedRoot = canvas.findRoot('collapsedProcess_2_plane'); + + canvas.setRootElement(nestedRoot); + + // when + clickBreadcrumb(0); + + expect( + canvas.getRootElement() + ).to.equal(collaboration); + })); + + + it('should switch to containing process plane on embedded click', inject(function(canvas) { + + // given + var subRoot = canvas.findRoot('collapsedProcess_plane'); + var nestedRoot = canvas.findRoot('collapsedProcess_2_plane'); + + canvas.setRootElement(nestedRoot); + + // when + clickBreadcrumb(2); + + // then + expectBreadcrumbs([ + 'Root', + 'Collapsed Process' + ]); + + expect( + canvas.getRootElement() + ).to.equal(subRoot); + })); + + }); + + }); + + describe('Legacy Processes', function() { beforeEach(bootstrapViewer(legacyXML, { modules: testModules })); diff --git a/test/spec/features/drilldown/collaboration-subprocesses.bpmn b/test/spec/features/drilldown/collaboration-subprocesses.bpmn new file mode 100644 index 00000000..2f0e19b2 --- /dev/null +++ b/test/spec/features/drilldown/collaboration-subprocesses.bpmn @@ -0,0 +1,407 @@ + + + + + + + + + sid-89A3F9F2-CCC8-46C7-816B-DD8AC8A98300 + + + sid-89A3F9F2-CCC8-46C7-816B-DD8AC8A98300 + sid-F06605E1-AEC1-4B39-8843-4AD3F547B557 + sid-FC2ECAF5-771E-4ED3-BEF6-EFAB45E79500 + + + sid-F06605E1-AEC1-4B39-8843-4AD3F547B557 + sid-31F6EC44-E44C-4121-B4FE-BD69AF208C05 + + sid-EB275CF2-5EF1-44FA-B41B-71EB37CC2657 + + + sid-EB275CF2-5EF1-44FA-B41B-71EB37CC2657 + sid-FB543319-8DFB-4445-AAA3-720137FB230B + + + + + + + sid-FB543319-8DFB-4445-AAA3-720137FB230B + sid-B99D259B-1BD5-45FF-BD57-FB99C360BAC0 + + sid-472B540C-A0CD-46F4-9640-DF692EC1BFFC + + + sid-472B540C-A0CD-46F4-9640-DF692EC1BFFC + sid-910420B0-D11B-4F9D-B285-703D8AC0BA90 + + sid-A7460113-CB75-491D-817B-5E1A8C606B8C + + + sid-A7460113-CB75-491D-817B-5E1A8C606B8C + sid-01982395-64E8-43EF-A6D3-CDD276C312AA + + + sid-01982395-64E8-43EF-A6D3-CDD276C312AA + + + + + + sid-910420B0-D11B-4F9D-B285-703D8AC0BA90 + + + + + + sid-B99D259B-1BD5-45FF-BD57-FB99C360BAC0 + + + + + + + sid-FC2ECAF5-771E-4ED3-BEF6-EFAB45E79500 + sid-5B23450F-AF5E-4519-B134-32107776BD44 + + sid-E71F5783-AFE7-44ED-8A9C-378C95087448 + + + sid-E71F5783-AFE7-44ED-8A9C-378C95087448 + sid-6B9741CD-D94B-41C7-A2EA-63A4C9445E16 + + sid-3BB6D6CA-BF45-4D15-A1AB-64686C41DB32 + + + sid-3BB6D6CA-BF45-4D15-A1AB-64686C41DB32 + sid-4E25B80E-EF68-4EE5-BB08-C1F54F1A7C39 + + + sid-4E25B80E-EF68-4EE5-BB08-C1F54F1A7C39 + + + + + + sid-6B9741CD-D94B-41C7-A2EA-63A4C9445E16 + sid-1A9DABC6-6079-4BF2-9D49-C4DC9569C519 + + sid-E5404926-738D-4447-87FE-FC6DD1E8BEFC + + + sid-E5404926-738D-4447-87FE-FC6DD1E8BEFC + sid-FED62A8F-6C3A-4BB2-8DE9-18FB0B35B50E + + + sid-FED62A8F-6C3A-4BB2-8DE9-18FB0B35B50E + + + + + + sid-1A9DABC6-6079-4BF2-9D49-C4DC9569C519 + + + + + + + + + + + + + + + sid-5B23450F-AF5E-4519-B134-32107776BD44 + sid-31F6EC44-E44C-4121-B4FE-BD69AF208C05 + sid-F7DA1903-6A1A-4858-AF4B-286A968C957F + + + sid-DCB98638-BEBD-4548-B501-F0E29AC71ED4 + + + sid-F7DA1903-6A1A-4858-AF4B-286A968C957F + sid-3FAE72F2-4037-4CBA-8B89-01D7FC7FF3E3 + + + sid-3FAE72F2-4037-4CBA-8B89-01D7FC7FF3E3 + + + sid-DCB98638-BEBD-4548-B501-F0E29AC71ED4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +