aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionStackingView.tsx
blob: a1cb731230631070a01d891e7e97bc14046ee9cd (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
46
47
48
49
50
51
52
53
54
import React = require("react");
import { observer } from "mobx-react";
import { CollectionSubView } from "./CollectionSubView";
import Measure from "react-measure";
import { Doc, WidthSym, HeightSym } from "../../../new_fields/Doc";
import { DocumentView } from "../nodes/DocumentView";
import { Transform } from "../../util/Transform";
import { emptyFunction, returnOne } from "../../../Utils";
import "./CollectionStackingView.scss";
import { runInAction, action, observable, computed } from "mobx";
import { StrCast } from "../../../new_fields/Types";

@observer
export class CollectionStackingView extends CollectionSubView(doc => doc) {
    getPreviewTransform = (): Transform => this.props.ScreenToLocalTransform();

    @action
    moveDocument = (doc: Doc, targetCollection: Doc, addDocument: (document: Doc) => boolean): boolean => {
        this.props.removeDocument(doc);
        addDocument(doc);
        return true;
    }

    render() {
        const docs = this.childDocs;
        return (
            <div className="collectionStackingView" onWheel={(e: React.WheelEvent) => e.stopPropagation()}>
                <div className="collectionStackingView-description">{StrCast(this.props.Document.documentText, StrCast(this.props.Document.title, "stacking collection"))}</div>
                <div className="collectionStackingView-flexCont">
                    {docs.map(d => {
                        return (<div className="collectionStackingView-docView-container">
                            <DocumentView Document={d}
                                addDocument={this.props.addDocument} removeDocument={this.props.removeDocument}
                                moveDocument={this.moveDocument}
                                ContainingCollectionView={this.props.CollectionView}
                                isTopMost={false}
                                ScreenToLocalTransform={this.getPreviewTransform}
                                focus={emptyFunction}
                                ContentScaling={returnOne}
                                PanelWidth={d[WidthSym]}
                                PanelHeight={d[HeightSym]}
                                selectOnLoad={false}
                                parentActive={this.props.active}
                                addDocTab={this.props.addDocTab}
                                bringToFront={emptyFunction}
                                toggleMinimized={emptyFunction}
                                whenActiveChanged={this.props.active} />
                        </div>);
                    })}
                </div>
            </div>
        );
    }
}