added store with actions for actionsMenu
This commit is contained in:
parent
69a2379e53
commit
67627637aa
4 changed files with 76 additions and 14 deletions
36
front/src/Stores/ActionsMenuStore.ts
Normal file
36
front/src/Stores/ActionsMenuStore.ts
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { writable } from "svelte/store";
|
||||
|
||||
export interface ActionsMenuInterface {
|
||||
displayName: string;
|
||||
callback: Function;
|
||||
}
|
||||
|
||||
function createActionsMenuStore() {
|
||||
|
||||
const actions = new Map<string, ActionsMenuInterface>();
|
||||
const { subscribe, update, set } = writable<Map<string, ActionsMenuInterface>>(actions);
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
addPossibleAction: (key: string, displayName: string, callback: Function) => {
|
||||
update((actions) => {
|
||||
actions.set(key, { displayName, callback });
|
||||
return actions;
|
||||
});
|
||||
},
|
||||
removePossibleAction: (key: string) => {
|
||||
update((actions) => {
|
||||
actions.delete(key);
|
||||
return actions;
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Hides menu
|
||||
*/
|
||||
clearActions: () => {
|
||||
set(new Map<string, ActionsMenuInterface>());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export const actionsMenuStore = createActionsMenuStore();
|
Loading…
Add table
Add a link
Reference in a new issue