diff --git a/src/components/NetworkMap.vue b/src/components/NetworkMap.vue index 74573c2..cc77f80 100644 --- a/src/components/NetworkMap.vue +++ b/src/components/NetworkMap.vue @@ -236,16 +236,31 @@ export default defineComponent({ }); }); + let clickTimeoutId: number | null = null; const clickAlter = (alter: Alter) => { - console.log(alter.name + " clicked"); - if (isConnectMode.value && store.state.view.editIndex != null) { const editId = store.state.nwk.alteri[store.state.view.editIndex].id; const payload = { id1: editId, id2: alter.id }; store.commit("toggleConnection", payload); } else { - // toggleSelection - store.commit("view/selectSingleAlter", alter.id); + if (clickTimeoutId == null) { + clickTimeoutId = setTimeout(() => { + // simple click + clickTimeoutId = null; + console.log(alter.name + " clicked"); + + // toggleSelection + store.commit("view/selectSingleAlter", alter.id); + }, 500); //tolerance in ms + } else { + // double click + clearTimeout(clickTimeoutId); + clickTimeoutId = null; + console.log(alter.name + " dblclick"); + + // open form + store.commit("openAlterFormById", { alterId: alter.id }); + } } }; diff --git a/src/store/index.ts b/src/store/index.ts index 9bea321..1a7bff6 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -63,6 +63,14 @@ const mutations = { state.view.editIndex = null; state.view.editTab = ""; }, + openAlterFormById( + state: IStoreState, + payload: { alterId: number; tab?: string } + ): void { + const index = state.nwk.alteri.findIndex((a) => a.id === payload.alterId); + state.view.editIndex = index; + state.view.editTab = payload.tab ? payload.tab : TAB_BASE; + }, }; const plugins =