blob: 52c92d1740022ebd22b7f7c9cf41212f74078c48 (
plain)
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
|
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;
}
}
|