import { observable, computed, action } from "mobx"; import React = require("react"); import { SelectionManager } from "../../util/SelectionManager"; import { observer } from "mobx-react"; import './LinkBox.scss' import { KeyStore } from '../../../fields/KeyStore' import { props } from "bluebird"; import { DocumentView } from "./DocumentView"; import { Document } from "../../../fields/Document"; import { ListField } from "../../../fields/ListField"; import { DocumentManager } from "../../util/DocumentManager"; import { LinkEditor } from "./LinkEditor"; import { CollectionDockingView } from "../collections/CollectionDockingView"; interface Props { linkDoc: Document; linkName: String; pairedDoc: Document; type: String; showEditor: () => void } @observer export class LinkBox extends React.Component { onViewButtonPressed = (e: React.PointerEvent): void => { console.log("view down"); e.stopPropagation(); let docView = DocumentManager.Instance.getDocumentView(this.props.pairedDoc); if (docView) { docView.props.focus(this.props.pairedDoc); } else { CollectionDockingView.Instance.AddRightSplit(this.props.pairedDoc) } } onEditButtonPressed = (e: React.PointerEvent): void => { console.log("edit down"); e.stopPropagation(); this.props.showEditor(); } onDeleteButtonPressed = (e: React.PointerEvent): void => { console.log("delete down"); e.stopPropagation(); this.props.linkDoc.GetTAsync(KeyStore.LinkedFromDocs, Document, field => { if (field) { field.GetTAsync>(KeyStore.LinkedToDocs, ListField, field => { if (field) { field.Data.splice(field.Data.indexOf(this.props.linkDoc)); } }) } }); this.props.linkDoc.GetTAsync(KeyStore.LinkedToDocs, Document, field => { if (field) { field.GetTAsync>(KeyStore.LinkedFromDocs, ListField, field => { if (field) { field.Data.splice(field.Data.indexOf(this.props.linkDoc)); } }) } }); } render() { return ( //

{this.props.linkName}

{this.props.type}{this.props.pairedDoc.Title}

) } }