diff options
author | Monika Hedman <monika_hedman@brown.edu> | 2019-02-12 16:26:22 -0500 |
---|---|---|
committer | Monika Hedman <monika_hedman@brown.edu> | 2019-02-12 16:26:22 -0500 |
commit | 05a710e2a541a07347d1626489a1811874126c79 (patch) | |
tree | feb751e46036d2104bb81c5bcc4e4ab0b6336c08 /src/client/util/SelectionManager.ts | |
parent | 6445930e05e8eb81a36930615926712986bc1a9d (diff) | |
parent | 7a93f60c9529e5d175e617fc7c07145a9b33e572 (diff) |
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web into hedmanLocal
Diffstat (limited to 'src/client/util/SelectionManager.ts')
-rw-r--r-- | src/client/util/SelectionManager.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts new file mode 100644 index 000000000..0759ae110 --- /dev/null +++ b/src/client/util/SelectionManager.ts @@ -0,0 +1,39 @@ +import { CollectionFreeFormDocumentView } from "../views/nodes/CollectionFreeFormDocumentView"; +import { observable, action } from "mobx"; + +export namespace SelectionManager { + class Manager { + @observable + SelectedDocuments: Array<CollectionFreeFormDocumentView> = []; + + @action + SelectDoc(doc: CollectionFreeFormDocumentView, ctrlPressed: boolean): void { + // if doc is not in SelectedDocuments, add it + if (!ctrlPressed) { + manager.SelectedDocuments = []; + } + + if (manager.SelectedDocuments.indexOf(doc) === -1) { + manager.SelectedDocuments.push(doc) + } + } + } + + const manager = new Manager; + + export function SelectDoc(doc: CollectionFreeFormDocumentView, ctrlPressed: boolean): void { + manager.SelectDoc(doc, ctrlPressed) + } + + export function IsSelected(doc: CollectionFreeFormDocumentView): boolean { + return manager.SelectedDocuments.indexOf(doc) !== -1; + } + + export function DeselectAll(): void { + manager.SelectedDocuments = [] + } + + export function SelectedDocuments(): Array<CollectionFreeFormDocumentView> { + return manager.SelectedDocuments; + } +}
\ No newline at end of file |