mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2025-07-24 05:28:49 +02:00
15 demo of global dialog with reactive state
This commit is contained in:
@ -3,17 +3,30 @@ import { defineStore } from "pinia";
|
||||
|
||||
const moduleStore = defineStore("moduleStore", {
|
||||
state: () => ({
|
||||
modules: [] as Module[],
|
||||
modules: new Map<string, Module>(),
|
||||
}),
|
||||
actions: {
|
||||
addModule(module: Module) {
|
||||
this.modules.push(module);
|
||||
this.modules.set(module.uuid, module);
|
||||
},
|
||||
removeModule(module: Module) {
|
||||
this.modules.splice(this.modules.indexOf(module), 1);
|
||||
this.modules.delete(module.uuid);
|
||||
},
|
||||
hasModule(module: Module): boolean {
|
||||
return this.modules.has(module.uuid) &&
|
||||
(this.modules.get(module.uuid)?.isEqual(module) ?? false);
|
||||
},
|
||||
removeAllModules() {
|
||||
this.modules = [];
|
||||
this.modules.clear();
|
||||
},
|
||||
overwriteModules(modules: Module[]) {
|
||||
this.modules.clear();
|
||||
modules.forEach((module) => {
|
||||
this.modules.set(module.uuid, module);
|
||||
});
|
||||
},
|
||||
getAllModules(): Module[] {
|
||||
return Array.from(this.modules.values());
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Reference in New Issue
Block a user