Skip to content

Commit

Permalink
tidy component
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Jun 13, 2024
1 parent d1f17fd commit 4db2847
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 0 additions & 1 deletion app/static/src/app/components/code/HiddenVariables.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export default defineComponent({
};
const startDrag = (evt: DragEvent, variable: string) => {
console.log(`started dragging ${variable}`);
const { dataTransfer } = evt;
dataTransfer!!.dropEffect = "move";
dataTransfer!!.effectAllowed = "move";
Expand Down
11 changes: 8 additions & 3 deletions app/static/src/app/components/code/SelectedVariables.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<button
type="button"
class="btn btn-light mx-2"
style="background-color: #fff; border-width: 0"
v-if="graphKey !== 'Graph 1'"
@click="deleteGraph"
v-tooltip="'Delete Graph'"
Expand Down Expand Up @@ -98,21 +99,25 @@ export default defineComponent({
};
const startDrag = (evt: DragEvent, variable: string) => {
console.log(`started dragging ${variable}`);
const { dataTransfer } = evt;
const copy = evt.ctrlKey;
console.log(`started dragging ${variable} with ctrlKey ${copy}`);
dataTransfer!!.dropEffect = "move";
dataTransfer!!.effectAllowed = "move";
dataTransfer!!.setData("variable", variable);
dataTransfer!!.setData("srcGraph", props.graphKey);
dataTransfer!!.setData("copyVar", copy.toString());
};
const onDrop = (evt: DragEvent) => {
const { dataTransfer } = evt;
const variable = dataTransfer!!.getData("variable");
const srcGraph = dataTransfer!!.getData("srcGraph");
console.log(`copy on drop is ${dataTransfer!!.getData("copyVar")}`);
const copy = dataTransfer!!.getData("copyVar") === "true";
if (srcGraph !== props.graphKey) {
// remove from source graph
if (srcGraph !== "hidden") {
// remove from source graph - but not if ctrl key was held on start drag
if (srcGraph !== "hidden" && !copy) {
const srcVariables = [...store.state.model.graphs[srcGraph].selectedVariables].filter(
(v) => v !== variable
);
Expand Down

0 comments on commit 4db2847

Please sign in to comment.