blob: 658bf8f9305fa75a4d12bc9953a0d12735bd39c8 (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
import { CollectionFreeFormDocumentView } from "../views/nodes/CollectionFreeFormDocumentView";
import { observable, action } from "mobx";
import { CollectionFreeFormView } from "../views/collections/CollectionFreeFormView";
export namespace SelectionManager {
class Manager {
@observable
SelectedDocuments: Array<CollectionFreeFormDocumentView> = [];
@action
SelectDoc(doc: CollectionFreeFormDocumentView, ctrlPressed: boolean): void {
//remove preview cursor from collection
if (doc.props.ContainingCollectionView != undefined && doc.props.ContainingCollectionView instanceof CollectionFreeFormView) {
doc.props.ContainingCollectionView.hidePreviewCursor();
}
// 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;
}
}
|