Skip to content

Commit

Permalink
fix(search): do not suggest subprocess planes
Browse files Browse the repository at this point in the history
closes #2143
  • Loading branch information
marstamm committed Jun 5, 2024
1 parent 49e42a7 commit f470cd5
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 39 deletions.
4 changes: 2 additions & 2 deletions lib/features/search/BpmnSearchProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BpmnSearchProvider.$inject = [
* @return {SearchResult[]}
*/
BpmnSearchProvider.prototype.find = function(pattern) {
var rootElement = this._canvas.getRootElement();
var rootElements = this._canvas.getRootElements();

var elements = this._elementRegistry.filter(function(element) {
if (element.labelTarget) {
Expand All @@ -56,7 +56,7 @@ BpmnSearchProvider.prototype.find = function(pattern) {

// do not include root element
elements = filter(elements, function(element) {
return element !== rootElement;
return !rootElements.includes(element);
});

elements = map(elements, function(element) {
Expand Down
17 changes: 16 additions & 1 deletion test/spec/features/search/BpmnSearchProviderSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('features - BPMN search provider', function() {
// then
expect(elements).to.have.length(0);
}));

});


Expand Down Expand Up @@ -94,6 +95,21 @@ describe('features - BPMN search provider', function() {
}));


it('should not return root element (collabsed subprocess)', inject(function(bpmnSearch, elementRegistry) {

// given
var subprocessShape = elementRegistry.get('collapsed');
var pattern = 'Collapsed';

// when
var elements = bpmnSearch.find(pattern);

// then
expect(elements).to.have.length(1);
expect(elements[0].element).to.eql(subprocessShape);
}));


describe('should split result into matched and non matched tokens', function() {

it('matched all', inject(function(bpmnSearch) {
Expand Down Expand Up @@ -162,7 +178,6 @@ describe('features - BPMN search provider', function() {
});



});

});
80 changes: 44 additions & 36 deletions test/spec/features/search/bpmn-search.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.22.0">
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:task id="Task_1j5i0e6" name="Second 123456 task here">
<bpmn:outgoing>SequenceFlow_0wgiusn</bpmn:outgoing>
Expand Down Expand Up @@ -30,71 +30,79 @@
<bpmn:outgoing>SequenceFlow_1bhe9h2</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceFlow id="SequenceFlow_1bhe9h2" sourceRef="Task_0vuhy0s" targetRef="Task_asdfasd" />
<bpmn:subProcess id="collapsed" name="Collapsed" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="Task_1j5i0e6_di" bpmnElement="Task_1j5i0e6">
<dc:Bounds x="195" y="106" width="100" height="80" />
<dc:Bounds x="355" y="186" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="IntermediateThrowEvent_1lhurmj_di" bpmnElement="IntermediateThrowEvent_1lhurmj">
<dc:Bounds x="227" y="299" width="36" height="36" />
<dc:Bounds x="387" y="379" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="200" y="335" width="90" height="20" />
<dc:Bounds x="373" y="415" width="64" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0wgiusn_di" bpmnElement="SequenceFlow_0wgiusn">
<di:waypoint xsi:type="dc:Point" x="245" y="186" />
<di:waypoint xsi:type="dc:Point" x="245" y="299" />
<bpmndi:BPMNLabel>
<dc:Bounds x="339" y="265" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="DataStoreReference_093mpev_di" bpmnElement="some_DataStore_123456_id">
<dc:Bounds x="371" y="121" width="50" height="50" />
<dc:Bounds x="531" y="201" width="50" height="50" />
<bpmndi:BPMNLabel>
<dc:Bounds x="351" y="186" width="90" height="20" />
<dc:Bounds x="517" y="266" width="78" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_0dso4ju_di" bpmnElement="Task_0dso4ju">
<dc:Bounds x="0" y="0" width="100" height="80" />
<dc:Bounds x="160" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_0vyzyuo_di" bpmnElement="Task_asdfasd">
<dc:Bounds x="622.5883069427528" y="246.96102314250913" width="100" height="80" />
<dc:Bounds x="783" y="327" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Task_1wkhcs9_di" bpmnElement="Task_asdfasddgg">
<dc:Bounds x="783" y="247" width="100" height="80" />
<dc:Bounds x="943" y="327" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_02ymelh_di" bpmnElement="SequenceFlow_02ymelh">
<di:waypoint xsi:type="dc:Point" x="723" y="287" />
<di:waypoint xsi:type="dc:Point" x="783" y="287" />
<bpmndi:BPMNLabel>
<dc:Bounds x="708" y="277" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Task_1m7fa4o_di" bpmnElement="Task_asdfasdsdfgg">
<dc:Bounds x="939" y="247" width="100" height="80" />
<dc:Bounds x="1099" y="327" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_0ugwp0d_di" bpmnElement="SequenceFlow_0ugwp0d">
<di:waypoint xsi:type="dc:Point" x="883" y="287" />
<di:waypoint xsi:type="dc:Point" x="939" y="287" />
<bpmndi:BPMNShape id="Task_0vuhy0s_di" bpmnElement="Task_0vuhy0s">
<dc:Bounds x="631" y="327" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_14an2wn_di" bpmnElement="collapsed" isExpanded="false">
<dc:Bounds x="631" y="186" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="DataOutputAssociation_1jomsz7_di" bpmnElement="DataOutputAssociation_1jomsz7">
<di:waypoint x="455" y="226" />
<di:waypoint x="531" y="226" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0wgiusn_di" bpmnElement="SequenceFlow_0wgiusn">
<di:waypoint x="405" y="266" />
<di:waypoint x="405" y="379" />
<bpmndi:BPMNLabel>
<dc:Bounds x="866" y="277" width="90" height="20" />
<dc:Bounds x="339" y="265" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Task_0vuhy0s_di" bpmnElement="Task_0vuhy0s">
<dc:Bounds x="471" y="247" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1bhe9h2_di" bpmnElement="SequenceFlow_1bhe9h2">
<di:waypoint xsi:type="dc:Point" x="571" y="287" />
<di:waypoint xsi:type="dc:Point" x="623" y="287" />
<di:waypoint x="731" y="367" />
<di:waypoint x="783" y="367" />
<bpmndi:BPMNLabel>
<dc:Bounds x="552" y="277" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="DataOutputAssociation_1jomsz7_di" bpmnElement="DataOutputAssociation_1jomsz7">
<di:waypoint xsi:type="dc:Point" x="295" y="146" />
<di:waypoint xsi:type="dc:Point" x="371" y="146" />
<bpmndi:BPMNEdge id="SequenceFlow_02ymelh_di" bpmnElement="SequenceFlow_02ymelh">
<di:waypoint x="883" y="367" />
<di:waypoint x="943" y="367" />
<bpmndi:BPMNLabel>
<dc:Bounds x="708" y="277" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0ugwp0d_di" bpmnElement="SequenceFlow_0ugwp0d">
<di:waypoint x="1043" y="367" />
<di:waypoint x="1099" y="367" />
<bpmndi:BPMNLabel>
<dc:Bounds x="866" y="277" width="90" height="20" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_0tt6svc">
<bpmndi:BPMNPlane id="BPMNPlane_0rfm64a" bpmnElement="collapsed" />
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit f470cd5

Please sign in to comment.