diff --git a/src/components/nodes/subProcess/subProcess.vue b/src/components/nodes/subProcess/subProcess.vue
index 5400ad549..ce34b821c 100644
--- a/src/components/nodes/subProcess/subProcess.vue
+++ b/src/components/nodes/subProcess/subProcess.vue
@@ -44,7 +44,7 @@
import debounce from 'lodash/debounce';
import { util } from 'jointjs';
import portsConfig from '@/mixins/portsConfig';
-import TaskShape from '@/components/nodes/task/shape';
+import { getTaskShape } from '@/components/nodes/task/shape';
import { taskHeight } from '@/components/nodes/task/taskConfig';
import store from '@/store';
import hasMarkers, { markerSize } from '@/mixins/hasMarkers';
@@ -196,7 +196,7 @@ export default {
},
},
mounted() {
- this.shape = new TaskShape();
+ this.shape = getTaskShape(store.getters.isForDocumenting);
this.$set(this.markers.bottomCenter, 'subprocess', subprocessIcon);
let bounds = this.node.diagram.bounds;
this.shape.position(bounds.x, bounds.y);
diff --git a/src/mixins/linkEditing.js b/src/mixins/linkEditing.js
index b009de068..8a70f1644 100644
--- a/src/mixins/linkEditing.js
+++ b/src/mixins/linkEditing.js
@@ -455,10 +455,10 @@ export default {
if (doc) {
const nodeNumber = this.getNodeNumber(view.model.component.id);
- if (nodeNumber >= 0) {
+ if (nodeNumber > 0) {
window.ProcessMaker.EventBus.$emit(
'show-documentation', {
- number: nodeNumber + 1,
+ number: nodeNumber,
text: doc,
position: pos,
node: view.model.component.node,
@@ -469,6 +469,11 @@ export default {
},
getNodeNumber(nodeId) {
+ const documentationNumber = window.ProcessMaker?.modeler?.documentationNumbers?.[nodeId];
+ if (documentationNumber) {
+ return documentationNumber;
+ }
+
const xmlString = window.ProcessMaker.$modeler.currentXML;
const extractIds = (xml) => {
@@ -483,7 +488,7 @@ export default {
const ids = extractIds(xmlString);
- return ids.indexOf(nodeId);
+ return ids.indexOf(nodeId) + 1;
},
},
};
\ No newline at end of file
diff --git a/tests/unit/components/nodes/task/taskShape.spec.js b/tests/unit/components/nodes/task/taskShape.spec.js
new file mode 100644
index 000000000..d964dd60f
--- /dev/null
+++ b/tests/unit/components/nodes/task/taskShape.spec.js
@@ -0,0 +1,17 @@
+import { getTaskShape } from '@/components/nodes/task/shape';
+
+describe('task documentation shape', () => {
+ it('includes documentation markers in documenting mode', () => {
+ const shape = getTaskShape(true);
+ const selectors = shape.markup.map(item => item.selector);
+
+ expect(selectors).toEqual(expect.arrayContaining(['doccircle', 'doclabel']));
+ });
+
+ it('excludes documentation markers in designer mode', () => {
+ const shape = getTaskShape(false);
+ const selectors = shape.markup.map(item => item.selector);
+
+ expect(selectors).not.toEqual(expect.arrayContaining(['doccircle', 'doclabel']));
+ });
+});
diff --git a/tests/unit/linkEditing.documentationNumber.spec.js b/tests/unit/linkEditing.documentationNumber.spec.js
new file mode 100644
index 000000000..9f8e2e54a
--- /dev/null
+++ b/tests/unit/linkEditing.documentationNumber.spec.js
@@ -0,0 +1,29 @@
+import linkEditing from '@/mixins/linkEditing';
+
+describe('linkEditing documentation numbering', () => {
+ afterEach(() => {
+ delete window.ProcessMaker;
+ });
+
+ it('uses the numbering map generated by the documentation API', () => {
+ window.ProcessMaker = {
+ modeler: {
+ documentationNumbers: {
+ task_1: 4,
+ },
+ },
+ };
+
+ expect(linkEditing.methods.getNodeNumber.call({}, 'task_1')).toBe(4);
+ });
+
+ it('falls back to the XML order when no numbering map exists', () => {
+ window.ProcessMaker = {
+ $modeler: {
+ currentXML: '',
+ },
+ };
+
+ expect(linkEditing.methods.getNodeNumber.call({}, 'end_1')).toBe(2);
+ });
+});