diff options
author | tschicke-brown <tyler_schicke@brown.edu> | 2019-01-20 15:09:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-20 15:09:32 -0500 |
commit | 6cf622dda54e5b1793138c0492d71b574a6e8d75 (patch) | |
tree | 22382a06e682a1d86be144382209fac2183165c9 /src/util/SelectionManager.ts | |
parent | 957bb8a462d233b8064ad1a957f2525dbd5995bc (diff) | |
parent | 08e2d1fd54824a1e8638a66ff031253ae72ab77b (diff) |
Merge pull request #2 from browngraphicslab/move_doc_get_out_the_way
Move doc get out the way
Diffstat (limited to 'src/util/SelectionManager.ts')
-rw-r--r-- | src/util/SelectionManager.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/util/SelectionManager.ts b/src/util/SelectionManager.ts new file mode 100644 index 000000000..2a63248c4 --- /dev/null +++ b/src/util/SelectionManager.ts @@ -0,0 +1,39 @@ +import { DocumentView } from "../views/nodes/DocumentView"; +import { observable, action } from "mobx"; + +export namespace SelectionManager { + class Manager { + @observable + SelectedDocuments: Array<DocumentView> = []; + + @action + SelectDoc(doc: DocumentView, 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: DocumentView, ctrlPressed: boolean): void { + manager.SelectDoc(doc, ctrlPressed) + } + + export function IsSelected(doc: DocumentView): boolean { + return manager.SelectedDocuments.indexOf(doc) !== -1; + } + + export function DeselectAll(): void { + manager.SelectedDocuments = [] + } + + export function SelectedDocuments(): Array<DocumentView> { + return manager.SelectedDocuments; + } +}
\ No newline at end of file |