Skip to content

Commit

Permalink
working version as per POC
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Jun 27, 2024
1 parent 7f846b0 commit a576227
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
7 changes: 3 additions & 4 deletions app/static/src/app/components/code/CodeTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
<div class="mt-3">
<vertical-collapse v-if="showSelectedVariables" title="Select variables" collapse-id="select-variables">
<div class="ms-2">
Drag variables to move to another graph, or to hide variable. Press the Ctrl key on drag to make a
copy of a variable.
Drag variables to move to another graph, or to hide variable.
</div>
<selected-variables
v-for="(_, index) in graphsConfig"
Expand Down Expand Up @@ -52,7 +51,7 @@ import SelectedVariables from "./SelectedVariables.vue";
import HiddenVariables from "./HiddenVariables.vue";
import VerticalCollapse from "../VerticalCollapse.vue";
import GenericHelp from "../help/GenericHelp.vue";
import { GraphsAction } from "@/app/store/graphs/actions";
import { GraphsAction } from "../../store/graphs/actions";
export default defineComponent({
name: "CodeTab",
Expand Down Expand Up @@ -82,7 +81,7 @@ export default defineComponent({
const graphsConfig = computed(() => store.state.graphs.config);
const compile = () => store.dispatch(`model/${ModelAction.CompileModel}`);
const addGraph = () => {
store.commit(`graphs/${GraphsAction.NewGraph}`);
store.dispatch(`graphs/${GraphsAction.NewGraph}`);
};
const loadingMessage = userMessages.code.isValidating;
const setDraggingVariable = (value: boolean) => (draggingVariable.value = value);
Expand Down
7 changes: 4 additions & 3 deletions app/static/src/app/components/code/HiddenVariables.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ export default defineComponent({
const srcGraph = dataTransfer!!.getData("srcGraph");
if (srcGraph !== "hidden") {
// remove from source graph
const srcVariables = [...store.state.model.graphs[srcGraph].selectedVariables].filter(
const srcGraphInt = parseInt(srcGraph);
const srcVariables = [...store.state.graphs.config[srcGraphInt].selectedVariables].filter(
(v) => v !== variable
);
store.dispatch(`model/${GraphsAction.UpdateSelectedVariables}`, {
index: srcGraph,
store.dispatch(`graphs/${GraphsAction.UpdateSelectedVariables}`, {
graphIndex: srcGraphInt,
selectedVariables: srcVariables
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/static/src/app/store/graphs/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GraphsState } from "./state";

export enum GraphsAction {
UpdateSelectedVariables = "UpdateSelectedVariables",
NewGraph = "AddGraph"
NewGraph = "NewGraph"
}

export const actions: ActionTree<GraphsState, AppState> = {
Expand Down
9 changes: 2 additions & 7 deletions app/static/src/app/store/graphs/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@ export const getters: GraphsGetters & GetterTree<GraphsState, AppState> = {
[GraphsGetter.allSelectedVariables]: (state: GraphsState): string[] => {
return state.config.flatMap((c) => c.selectedVariables); // TODO: dedupe, in mrc-5443
},
[GraphsGetter.hiddenVariables]: (
state: GraphsState,
graphsGetters: GraphsGetters,
rootState,
rootGetters
): string[] => {
const allSelected = graphsGetters[GraphsGetter.allSelectedVariables](state, getters, rootState, rootGetters);
[GraphsGetter.hiddenVariables]: (_, graphsGetters, rootState): string[] => {
const allSelected = graphsGetters[GraphsGetter.allSelectedVariables] as string[];
return rootState.model.odinModelResponse?.metadata?.variables.filter((s) => !allSelected.includes(s)) || [];
}
};

0 comments on commit a576227

Please sign in to comment.