1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
| import { detach, types } from "mobx-state-tree";
| import Types from "../../core/Types";
|
| /**
| * Shared Store Model is used to hold children of tags such Taxonomy and Choices.
| *
| * Every tag that uses the SharedStoreMixin will have a reference to the same store
| * defined by `sharedStore` attribute.
| */
| export const SharedStoreModel = types
| .model("SharedStoreModel", {
| id: types.identifier,
| locked: false,
| children: Types.unionArray(["choice"]),
| })
| .actions((self) => ({
| setChildren(val) {
| self.children = val;
| },
| clear() {
| self.children = [];
| },
| lock() {
| self.locked = true;
| },
| unlock() {
| self.locked = false;
| },
| destroy() {
| self.clear();
| detach(self);
| },
| }));
|
|