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

FOUR-18752: Change blue circle indicators for documantation to be visible always #1883

Merged
merged 5 commits into from
Oct 18, 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
17 changes: 17 additions & 0 deletions src/components/modeler/Modeler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,12 @@
return false;
},
},
forPrinting: {
type: Boolean,
default() {
return false;
},
},
},
mixins: [hotkeys, cloneSelection, linkEditing, transparentDragging],
data() {
Expand Down Expand Up @@ -540,9 +546,19 @@
},
},
methods: {
getSvg() {
const svg = document.querySelector('.mini-paper svg');
const css = 'text { font-family: sans-serif; }';
const style = document.createElement('style');
style.appendChild(document.createTextNode(css));
svg.appendChild(style);
const svgString = (new XMLSerializer()).serializeToString(svg);
return svgString;
},
mountedInit() {
store.commit('setReadOnly', this.readOnly);
store.commit('setForDocumenting', this.forDocumenting);
store.commit('setForPrinting', this.forPrinting);
this.graph = new dia.Graph();
store.commit('setGraph', this.graph);
this.graph.set('interactiveFunc', cellView => {
Expand Down Expand Up @@ -599,7 +615,7 @@
fill: '#1572C2',
strokeWidth: 0,
},
text: { text: event.number , fill: 'white', fontSize: 20, fontWeight: 'bold'},

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / setup

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (9)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (1)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (4)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (0)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (7)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (2)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (10)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (5)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (6)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (8)

A space is required before '}'

Check warning on line 618 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (3)

A space is required before '}'
},
});

Expand Down Expand Up @@ -1128,7 +1144,7 @@
}
},
registerStatusBar(component) {
this.owner.validationBar.push(component);

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / setup

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (9)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (1)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (4)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (0)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (7)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (2)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (10)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (5)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (6)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (8)

Unexpected mutation of "owner" prop

Check warning on line 1147 in src/components/modeler/Modeler.vue

View workflow job for this annotation

GitHub Actions / e2e (3)

Unexpected mutation of "owner" prop
},
/**
* Register a mixin into a node component.
Expand Down Expand Up @@ -1466,6 +1482,7 @@
if (emitChangeEvent) {
window.ProcessMaker.EventBus.$emit('modeler-change');
}
window.ProcessMaker.EventBus.$emit('modeler-xml-loaded');
},
getBoundaryEvents(process) {
return process.get('flowElements').filter(({ $type }) => $type === 'bpmn:BoundaryEvent');
Expand Down
121 changes: 104 additions & 17 deletions src/mixins/documentingIcons.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ export function docIconMarkup(selector) {
}

export function docIconAttrs(selector, customValues) {
const geometry = labelGeometry();
const attrs = [
{
selector: 'doclabel',
attributes: {
'ref-x': 26, 'ref-y': -4, ref: 'circle', fontSize: 20, fontWeight: 'bold',
'ref-x': geometry['ref-x'], 'ref-y': geometry['ref-y'], ref: 'circle',
fontSize: geometry.fontSize, fontWeight: 'bold',
width: 16, height: 16, 'data-test': 'nodeDocLabel', 'text':'',
fill: 'white', display: 'none',
},
Expand Down Expand Up @@ -79,14 +81,17 @@ export default {

const interval = window.setInterval(() => {
if (view.$('circle').length > 0 && store.getters.isForDocumenting) {
const nodeId = this?.node?.definition?.id;
const nodeNumber = this.getNodeNumber(nodeId) + 1;

view.model.attr({
doccircle: {
display:(doc ? 'block' : 'none'),
},
doclabel: {
display: 'none',
display: (store.getters.isForPrinting && doc ? 'block' : 'none'),
style: `text-anchor: middle; transform: translate(${params.labelX}, ${params.labelY});`,
text: null,
text: (store.getters.isForPrinting ? nodeNumber : ''),
},
});
clearInterval(interval);
Expand All @@ -95,27 +100,109 @@ export default {
},

initDocumentingIconsForFlow() {

if (!(store.getters.isForDocumenting ?? false)) {
return;
}

const docElement = this.node?.definition?.documentation;
const doc = Array.isArray(docElement)
? (docElement[0].text ?? '').trim()
: (docElement ?? '').trim();

if (doc && store.getters.isForDocumenting) {
this.shape.attr('line', {
sourceMarker: {
'type': 'circle',
'fill': '#8DC8FF',
'r': 10,
'cx': 20,
'stroke': '#2B9DFF',
'stroke-width': 3,
},
});
}
const geometry = labelGeometry();

const interval = window.setInterval(() => {
if (doc && store.getters.isForDocumenting) {
const nodeId = this?.node?.definition?.id;
const nodeNumber = this.getNodeNumber(nodeId) + 1;
this.shape.attr('line', {
sourceMarker: {
'type': 'circle',
'fill': '#8DC8FF',
'r': 10,
'cx': 20,
'stroke': '#2B9DFF',
'stroke-width': 3,
},
});

// add the node number when printing
if (store.getters.isForPrinting) {
this.shape.appendLabel({
attrs: {
rect: {
fill: 'none',
stroke: 'none',
},
text: {
text: nodeNumber,
fill: 'white',
fontSize: geometry.fontSize,
fontWeight: 'bold',
'font-size': geometry.fontSize,
'text-anchor': 'middle',
'y-alignment': 'middle',
},
},
position: {
distance: 40,
offset: {
x: -20,
y: 1,
},
},
});
}

clearInterval(interval);
}
}, 200);
},

getNodeNumber(nodeId) {
const xmlString = window.ProcessMaker.$modeler.currentXML;

const extractIds = (xml) => {
const idRegex = /id="([^"]*)"/g;
const ids = [];
let match;
while ((match = idRegex.exec(xml)) !== null) {
ids.push(match[1]);
}
return ids;
};

const ids = extractIds(xmlString);

return ids.indexOf(nodeId);
},
},
};
};

function labelGeometry() {
if (store.getters.isForDocumenting && store.getters.isForPrinting) {
return {
fontSize: 12,
forLink: {
distance: 40,
offset: { x: -10, y: 1 },
},
forGeneralShape : {
'ref-x': 26,
'ref-y': 0,
},
};
}

return {
fontSize: 20,
forLink: {
distance: 40,
offset: { x: -10, y: 1 },
},
forGeneralShape : {
'ref-x': 26,
'ref-y': -4,
},
};
}
5 changes: 5 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default new Vuex.Store({
clientLeftPaper: false,
readOnly: false,
forDocumenting: false,
forPrinting: false,
isMultiplayer: false,
},
getters: {
Expand All @@ -62,6 +63,7 @@ export default new Vuex.Store({
clientLeftPaper: state => state.clientLeftPaper,
isReadOnly: state => state.readOnly,
isForDocumenting: state => state.forDocumenting,
isForPrinting: state => state.forPrinting,
showComponent: state => !state.readOnly,
showPanTool: state => state.forDocumenting,
isMultiplayer: state => state.isMultiplayer,
Expand All @@ -73,6 +75,9 @@ export default new Vuex.Store({
setForDocumenting(state, value) {
state.forDocumenting = value;
},
setForPrinting(state, value) {
state.forPrinting = value;
},
preventSavingElementPosition(state) {
state.allowSavingElementPosition = false;
},
Expand Down
Loading