🔷 refactor context menu to accept context src

🔷 add a getCurrentDate function to get formatted date
This commit is contained in:
geoffrey45
2022-04-08 21:07:24 +03:00
parent 24db32ae09
commit 83330a7fad
13 changed files with 107 additions and 44 deletions
+11 -4
View File
@@ -1,23 +1,30 @@
import { defineStore } from "pinia";
import normalize from "../composables/normalizeContextMenu";
import { Option } from "../interfaces";
import { ContextSrc } from "../composables/enums";
export default defineStore("context-menu", {
state: () => ({
visible: false,
options: Array<Option>(),
options: <Option[]>[],
x: 500,
y: 500,
normalizedX: false,
normalizedY: false,
src: "",
}),
actions: {
showContextMenu(e: any, context_options: Promise<Option[]>) {
showContextMenu(
e: any,
context_options: Promise<Option[]>,
src: ContextSrc
) {
if (this.visible) {
this.visible = false;
return;
}
this.visible = true;
context_options.then((options) => {
this.options = options;
});
@@ -29,11 +36,11 @@ export default defineStore("context-menu", {
this.normalizedX = yo.normalizedX;
this.normalizedY = yo.normalizedY;
this.visible = true;
this.src = src;
},
hideContextMenu() {
this.visible = false;
this.src = null;
},
hasManyChildren() {
let result = false;