Skip to content

Commit

Permalink
Use ArrowMixin.js in Interaction-async.vue.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCoder committed Nov 1, 2024
1 parent 2323c54 commit 0c6ce3a
Showing 1 changed file with 2 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import SelfInvocationAsync from "./SelfInvocationAsync/SelfInvocation-async.vue"
import Message from "../Message/Message.vue";
import { mapGetters } from "vuex";
import { CodeRange } from "@/parser/CodeRange";
import sequenceParser from "@/generated-parser/sequenceParser";
import ArrowMixin from "@/components/DiagramFrame/SeqDiagram/MessageLayer/Block/Statement/ArrowMixin";

function isNullOrUndefined(value) {
return value === null || value === undefined;
Expand All @@ -55,6 +55,7 @@ function isNullOrUndefined(value) {
export default {
name: "interaction-async",
props: ["context", "comment", "commentObj", "selfCallIndent", "number"],
mixins: [ArrowMixin],
computed: {
...mapGetters(["distance", "cursor", "onElementClick"]),
from: function () {
Expand Down Expand Up @@ -92,22 +93,6 @@ export default {
target: function () {
return this.asyncMessage?.to()?.getFormattedText();
},
borderWidth: function () {
const border = {
borderLeftWidth: "7px",
borderRightWidth: "7px",
};
const endSide = this.rightToLeft ? "Left" : "Right";
const startSide = this.rightToLeft ? "Right" : "Left";

if (!this.isJointOccurrence(this.source)) {
border[`border${startSide}Width`] = "0px";
}
if (!this.isJointOccurrence(this.target)) {
border[`border${endSide}Width`] = "0px";
}
return border;
},
isCurrent: function () {
const start = this.asyncMessage.start.start;
const stop = this.asyncMessage.stop.stop + 1;
Expand Down Expand Up @@ -136,38 +121,6 @@ export default {
onClick() {
this.onElementClick(CodeRange.from(this.context));
},
isJointOccurrence(participant) {
let ancestorContextForParticipant = this.findOwningContext(participant);

// If no owning context found, it means this is a bare connection
if (!ancestorContextForParticipant) {
return false;
}

// Check if the owning context creates an occurrence point
return (
ancestorContextForParticipant instanceof
sequenceParser.MessageContext ||
ancestorContextForParticipant instanceof sequenceParser.CreationContext
);
},
findOwningContext(participant) {
let currentContext = this.context;

while (currentContext) {
if (!currentContext.Owner) {
currentContext = currentContext.parentCtx;
continue;
}

if (currentContext.Owner() === participant) {
return currentContext;
}

currentContext = currentContext.parentCtx;
}
return null;
},
},
components: {
Comment,
Expand Down

0 comments on commit 0c6ce3a

Please sign in to comment.