Commit 43a62cec authored by Dorian Goepp's avatar Dorian Goepp

Allow for widgets to share data

parent c6d3b29d
......@@ -12,8 +12,6 @@ import { Backgrounds, Iteration, Actions, Mood,
Legend } from './figureElements';
class InteractionTraceStore {
currentInteraction = null;
showInteraction = false;
config = {};
configSchema = {
title: "Interaction trace",
......@@ -55,8 +53,6 @@ class InteractionTraceStore {
</div>);
}
decorate(InteractionTraceStore, {
currentInteraction: observable,
showInteraction: observable,
config: observable,
})
......@@ -308,7 +304,7 @@ class InteractionTrace extends Component {
y: 4,
xScale: xScale,
minActions: this.nbPrimitiveActions,
interactionStore: this.interactionStore,
store: this.props.store.sharedData,
},
{ // Labels for all figure elements
component: ComponentLabels,
......
......@@ -59,15 +59,14 @@ export function Actions(props) {
}
// These two methods will handle when the mouse hovers and leaves an action. As a result, the hovered interaction
// is stored in props.interactionStore (mobx). The intent is to display information of this interaction somewhere
// else in the application.
const interactionStore = props.interactionStore
// is stored in props.store (mobx). The intent is to display information of this interaction somewhere else in the
// application.
const handleOver = () => {
props.interactionStore.currentInteraction = interaction;
interactionStore.showInteraction = true;
props.store.set('currentInteraction', interaction);
props.store.set('showInteraction', true);
}
const handleOut = () => {
interactionStore.showInteraction = false;
props.store.set('showInteraction', false);
}
const actions = cloneDeep(interaction.enacted.action_names);
......
......@@ -7,10 +7,10 @@ export const LatestInteraction = observer(
function LatestInteraction(props) {
let intended, enacted;
let iteration = null;
if ('int-trace' in props.store.components && props.store.components['int-trace'].showInteraction) {
intended = props.store.components['int-trace'].currentInteraction.intended;
enacted = props.store.components['int-trace'].currentInteraction.enacted;
const iteration_id = props.store.components['int-trace'].currentInteraction.id;
if (props.store.sharedData.has('currentInteraction') && props.store.sharedData.get('showInteraction')) {
intended = props.store.sharedData.get('currentInteraction').intended;
enacted = props.store.sharedData.get('currentInteraction').enacted;
const iteration_id = props.store.sharedData.get('currentInteraction').id;
iteration = [<p key="first"><span className="label">Iteration:</span> {iteration_id}</p>, <hr key="last"/>];
} else {
intended = props.intended;
......
......@@ -17,6 +17,7 @@ import './Common.css'
class ObservableStore {
components = {}
sharedData = observable.map()
modal = {
enabled: false,
mode: null,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment