Skip to content

Commit

Permalink
Use ArrowMixin.js in Interaction.vue.
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCoder committed Nov 1, 2024
1 parent 0c6ce3a commit 9382fe8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ export default {
},
methods: {
isJointOccurrence(participant) {
let ancestorContextForParticipant = this.findOwningContext(participant);

let ancestorContextForParticipant =
this.findContextForReceiver(participant);
console.debug("owning context", ancestorContextForParticipant);
// If no owning context found, it means this is a bare connection
if (!ancestorContextForParticipant) {
return false;
Expand All @@ -35,9 +36,13 @@ export default {
ancestorContextForParticipant instanceof sequenceParser.CreationContext
);
},
findOwningContext(participant) {
// Input `participant` is the receiver. This method
findContextForReceiver(participant) {
let currentContext = this.context;

const messageContext = this.context.message();
if (messageContext && messageContext.Owner() === participant) {
return messageContext;
}
while (currentContext) {
if (!currentContext.Owner) {
currentContext = currentContext.parentCtx;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
:class="{
highlight: isCurrent,
self: isSelf,
'from-no-occurrence': providedFrom && providedFrom !== origin,
'inited-from-occurrence': isInitedFromOccurrence,
'right-to-left': rightToLeft,
}"
:style="{
...borderWidth,
width: isSelf ? undefined : interactionWidth + 'px',
transform: 'translateX(' + translateX + 'px)',
}"
Expand Down Expand Up @@ -73,6 +72,7 @@ import { mapGetters } from "vuex";
import SelfInvocation from "./SelfInvocation/SelfInvocation.vue";
import { CodeRange } from "@/parser/CodeRange";
import { ProgContext } from "@/parser";
import ArrowMixin from "@/components/DiagramFrame/SeqDiagram/MessageLayer/Block/Statement/ArrowMixin";
export default {
name: "interaction",
Expand All @@ -83,6 +83,7 @@ export default {
"number",
// "inheritFromOccurrence",
],
mixins: [ArrowMixin],
computed: {
// add tracker to the mapGetters
...mapGetters(["participants", "distance2", "cursor", "onElementClick"]),
Expand All @@ -104,6 +105,13 @@ export default {
from: function () {
return this.providedFrom || this.origin;
},
// used by ArrowMixin
source: function () {
return this.from;
},
target: function () {
return this.to;
},
outOfBand: function () {
return !!this.providedFrom && this.providedFrom !== this.origin;
},
Expand Down Expand Up @@ -166,9 +174,6 @@ export default {
// this.to === undefined if it is a self interaction and root message.
return !this.to || this.to === this.from;
},
isInitedFromOccurrence: function () {
return this.message?.isInitedFromOccurrence(this.context);
},
},
methods: {
onClick() {
Expand Down
11 changes: 7 additions & 4 deletions src/parser/Owner.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Owner is the receiver of the message.
* For example, in `S -> A.m1 {B.m2 {C.m3}} D->E:m4`,
* | | | |
* Owner of m1 m2 m3 m4
*/

import { default as sequenceParser } from "../generated-parser/sequenceParser";

const seqParser = sequenceParser;
Expand Down Expand Up @@ -25,10 +32,6 @@ CreationContext.prototype.To = function () {
return this.Constructor();
};

// Owner is essentially the 'to' or receiver of a message.
// For example, in `S -> A.m1 {B.m2 {C.m3}}`,
// | | |
// Owner of m1 m2 m3
CreationContext.prototype.Owner = function () {
if (!this.Constructor()) {
return "Missing Constructor";
Expand Down

0 comments on commit 9382fe8

Please sign in to comment.