aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/LinkMenu.tsx
blob: 577aba3984fd8957652721fb86d36d27d36f6911 (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
55
56
57
58
import { observable, computed, action } from "mobx";
import React = require("react");
import { SelectionManager } from "../../util/SelectionManager";
import { observer } from "mobx-react";
import './LinkMenu.scss'
import { KeyStore } from '../../../fields/KeyStore'
import { props } from "bluebird";
import { DocumentView } from "./DocumentView";
import { LinkBox } from "./LinkBox"
import { Document } from "../../../fields/Document";
import { ListField } from "../../../fields/ListField";
import { TextField } from "../../../fields/TextField";
import { FieldWaiting } from "../../../fields/Field";

interface Props {
    docView: DocumentView;
    changeFlyout: () => void
}

@observer
export class LinkMenu extends React.Component<Props> {

    render() {
        //get list of links from document
        let linkFrom: Document[] = this.props.docView.props.Document.GetData(KeyStore.LinkedFromDocs, ListField, []);
        let linkTo: Document[] = this.props.docView.props.Document.GetData(KeyStore.LinkedToDocs, ListField, []);

        return (
            <div id="menu-container">
                <input id="search-bar" type="text" placeholder="Search..."></input>
                <div id="link-list">

                    {linkTo.map(link => {
                        let name = link.GetData(KeyStore.Title, TextField, new String);
                        let doc = link.GetT(KeyStore.LinkedToDocs, Document);
                        if (doc && doc != FieldWaiting) {
                            return <LinkBox linkDoc={link} linkName={name} pairedDoc={doc} type={"Destination: "} />
                        } else {
                            return <div></div>
                        }

                    })}

                    {linkFrom.map(link => {
                        let name = link.GetData(KeyStore.Title, TextField, new String);
                        let doc = link.GetT(KeyStore.LinkedFromDocs, Document);
                        if (doc && doc != FieldWaiting) {
                            return <LinkBox linkDoc={link} linkName={name} pairedDoc={doc} type={"Source: "} />
                        } else {
                            return <div></div>
                        }
                    })}
                </div>

            </div>
        )
    }
}