mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 15:59:51 +02:00
Fix conditional logic
This commit is contained in:
@@ -155,35 +155,28 @@ export const getNotes = function () {
|
|||||||
export const addRelation = function (relation: ClassRelation) {
|
export const addRelation = function (relation: ClassRelation) {
|
||||||
log.debug('Adding relation: ' + JSON.stringify(relation));
|
log.debug('Adding relation: ' + JSON.stringify(relation));
|
||||||
// Due to relationType cannot just check if it is equal to 'none' or it complains, can fix this later
|
// Due to relationType cannot just check if it is equal to 'none' or it complains, can fix this later
|
||||||
|
const invalidTypes = [
|
||||||
|
relationType.LOLLIPOP,
|
||||||
|
relationType.AGGREGATION,
|
||||||
|
relationType.COMPOSITION,
|
||||||
|
relationType.DEPENDENCY,
|
||||||
|
relationType.EXTENSION,
|
||||||
|
];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
relation.relation.type1 === relationType.LOLLIPOP &&
|
relation.relation.type1 === relationType.LOLLIPOP &&
|
||||||
relation.relation.type2 !==
|
!invalidTypes.includes(relation.relation.type2)
|
||||||
(relationType.LOLLIPOP ||
|
|
||||||
relationType.AGGREGATION ||
|
|
||||||
relationType.COMPOSITION ||
|
|
||||||
relationType.DEPENDENCY ||
|
|
||||||
relationType.EXTENSION)
|
|
||||||
) {
|
) {
|
||||||
addClass(relation.id2);
|
addClass(relation.id2);
|
||||||
addInterface(relation.id1, relation.id2);
|
addInterface(relation.id1, relation.id2);
|
||||||
relation.id1 = `interface${interfaces.length - 1}`;
|
relation.id1 = `interface${interfaces.length - 1}`;
|
||||||
// Also can't set the type to 'none'
|
|
||||||
// relation.relation.type1 = -1;
|
|
||||||
// relation.relation.type2 = relationType.LOLLIPOP;
|
|
||||||
} else if (
|
} else if (
|
||||||
relation.relation.type2 === relationType.LOLLIPOP &&
|
relation.relation.type2 === relationType.LOLLIPOP &&
|
||||||
relation.relation.type1 !==
|
!invalidTypes.includes(relation.relation.type1)
|
||||||
(relationType.LOLLIPOP ||
|
|
||||||
relationType.AGGREGATION ||
|
|
||||||
relationType.COMPOSITION ||
|
|
||||||
relationType.DEPENDENCY ||
|
|
||||||
relationType.EXTENSION)
|
|
||||||
) {
|
) {
|
||||||
addClass(relation.id1);
|
addClass(relation.id1);
|
||||||
addInterface(relation.id2, relation.id1);
|
addInterface(relation.id2, relation.id1);
|
||||||
relation.id2 = `interface${interfaces.length - 1}`;
|
relation.id2 = `interface${interfaces.length - 1}`;
|
||||||
// relation.relation.type1 = relationType.LOLLIPOP;
|
|
||||||
// relation.relation.type2 = -1;
|
|
||||||
} else {
|
} else {
|
||||||
addClass(relation.id1);
|
addClass(relation.id1);
|
||||||
addClass(relation.id2);
|
addClass(relation.id2);
|
||||||
|
Reference in New Issue
Block a user