blob: 52f7914f3421632d1c50bdabb686e49c925153ac (
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
59
60
61
62
63
64
65
66
|
import * as React from "react";
import './ParentDocumentSelector.scss';
import { Doc } from "../../../new_fields/Doc";
import { observer } from "mobx-react";
import { observable, action, runInAction } from "mobx";
import { Id } from "../../../new_fields/RefField";
import { SearchUtil } from "../../util/SearchUtil";
import { CollectionDockingView } from "./CollectionDockingView";
@observer
export class SelectorContextMenu extends React.Component<{ Document: Doc }> {
@observable private _docs: Doc[] = [];
constructor(props: { Document: Doc }) {
super(props);
this.fetchDocuments();
}
async fetchDocuments() {
const docs = await SearchUtil.Search(`data_l:"${this.props.Document[Id]}"`, true);
runInAction(() => this._docs = docs);
}
render() {
return (
<>
{this._docs.map(doc => <p><a onClick={() => CollectionDockingView.Instance.AddRightSplit(doc)}>{doc.title}</a></p>)}
</>
);
}
}
@observer
export class ParentDocSelector extends React.Component<{ Document: Doc }> {
@observable hover = false;
@action
onMouseLeave = () => {
this.hover = false;
}
@action
onMouseEnter = () => {
this.hover = true;
}
render() {
let flyout;
if (this.hover) {
flyout = (
<div className="PDS-flyout">
<SelectorContextMenu Document={this.props.Document} />
</div>
);
}
return (
<span style={{ position: "relative", display: "inline-block" }}
onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave}>
<p>^</p>
{flyout}
</span>
);
}
}
|