aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts1
-rw-r--r--src/client/views/collections/CollectionFreeFormView.scss10
-rw-r--r--src/client/views/collections/CollectionFreeFormView.tsx87
-rw-r--r--src/client/views/collections/CollectionView.tsx2
4 files changed, 59 insertions, 41 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 1d23b8c2c..837dfe815 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -119,6 +119,7 @@ export namespace Documents {
imageProto = setupPrototypeOptions(imageProtoId, "IMAGE_PROTO", CollectionView.LayoutString("AnnotationsKey"),
{ x: 0, y: 0, nativeWidth: 300, width: 300, layoutKeys: [KeyStore.Data, KeyStore.Annotations, KeyStore.Caption] });
imageProto.SetText(KeyStore.BackgroundLayout, ImageBox.LayoutString());
+ imageProto.SetNumber(KeyStore.CurPage, 0);
}
return imageProto;
}
diff --git a/src/client/views/collections/CollectionFreeFormView.scss b/src/client/views/collections/CollectionFreeFormView.scss
index 2dd345b6f..7012ce6b9 100644
--- a/src/client/views/collections/CollectionFreeFormView.scss
+++ b/src/client/views/collections/CollectionFreeFormView.scss
@@ -3,19 +3,15 @@
.collectionfreeformview-linkLine {
stroke: black;
stroke-width: 3;
- transform: translate(10000px,10000px)
-}
-.collectionfreeformview-svgContainer{
- transform: translate(-10000px,-10000px);
- position: absolute;
- width: 20000px;
- height: 20000px;
+ transform: translate(10000px,10000px);
+ pointer-events: all;
}
.collectionfreeformview-svgCanvas{
transform: translate(-10000px,-10000px);
position: absolute;
width: 20000px;
height: 20000px;
+ pointer-events: none;
}
.collectionfreeformview-container {
.collectionfreeformview > .jsx-parser {
diff --git a/src/client/views/collections/CollectionFreeFormView.tsx b/src/client/views/collections/CollectionFreeFormView.tsx
index 5ce42acc9..91faf0907 100644
--- a/src/client/views/collections/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/CollectionFreeFormView.tsx
@@ -1,4 +1,4 @@
-import { action, computed, observable, reaction, runInAction } from "mobx";
+import { action, computed, observable, reaction, runInAction, trace, untracked } from "mobx";
import { observer } from "mobx-react";
import { Document } from "../../../fields/Document";
import { FieldWaiting, Field, Opt } from "../../../fields/Field";
@@ -424,6 +424,7 @@ export class LinksView extends React.Component<CollectionViewProps> {
constructor(props: CollectionViewProps) {
super(props);
+ console.log("Create links View");
}
@observable _triples: { a: Document, b: Document, l: Document }[] = [];
@@ -432,42 +433,47 @@ export class LinksView extends React.Component<CollectionViewProps> {
let self = this.props.Document;
return DocumentManager.Instance.DocumentViews.reduce((pairs, dv) => {
- let srcViews = [dv];
- let srcAnnot = dv.props.Document.GetT(KeyStore.AnnotationOn, Document);
- if (srcAnnot && srcAnnot != FieldWaiting && srcAnnot instanceof Document) {
- srcViews = DocumentManager.Instance.getDocumentViews(srcAnnot.GetPrototype() as Document)
- }
- srcViews = srcViews.filter(sv =>
- sv.props.ContainingCollectionView && sv.props.ContainingCollectionView.props.Document == self
- );
- let linksList = dv.props.Document.GetT(KeyStore.LinkedToDocs, ListField);
- if (linksList && linksList != FieldWaiting && linksList.Data.length) {
- pairs.push(...linksList.Data.reduce((pairs, link) => {
- if (link instanceof Document) {
- let linkToDoc = link.GetT(KeyStore.LinkedToDocs, Document);
- if (linkToDoc && linkToDoc != FieldWaiting) {
- DocumentManager.Instance.getDocumentViews(linkToDoc).map(docView1 => {
-
- let targetViews = [docView1];
- let docAnnot = docView1.props.Document.GetT(KeyStore.AnnotationOn, Document);
- if (docAnnot && docAnnot != FieldWaiting && docAnnot instanceof Document) {
- targetViews = DocumentManager.Instance.getDocumentViews(docAnnot.GetPrototype() as Document)
- }
- targetViews.filter(tv =>
- tv.props.ContainingCollectionView && tv.props.ContainingCollectionView.props.Document == self
- ).map(tv => srcViews.map(sv =>
- pairs.push({ a: sv.props.Document, b: tv.props.Document, l: link })))
- })
+ untracked(() => {
+ let srcViews = [dv];
+ let srcAnnot = dv.props.Document.GetT(KeyStore.AnnotationOn, Document);
+ if (srcAnnot && srcAnnot != FieldWaiting && srcAnnot instanceof Document) {
+ srcViews = DocumentManager.Instance.getDocumentViews(srcAnnot.GetPrototype() as Document)
+ }
+ srcViews = srcViews.filter(sv =>
+ sv.props.ContainingCollectionView && sv.props.ContainingCollectionView.props.Document == self
+ );
+ let linksList = dv.props.Document.GetT(KeyStore.LinkedToDocs, ListField);
+ if (linksList && linksList != FieldWaiting && linksList.Data.length) {
+ pairs.push(...linksList.Data.reduce((pairs, link) => {
+ if (link instanceof Document) {
+ let linkToDoc = link.GetT(KeyStore.LinkedToDocs, Document);
+ if (linkToDoc && linkToDoc != FieldWaiting) {
+ DocumentManager.Instance.getDocumentViews(linkToDoc).map(docView1 => {
+ let targetViews = [docView1];
+ let docAnnot = docView1.props.Document.GetT(KeyStore.AnnotationOn, Document);
+ if (docAnnot && docAnnot != FieldWaiting && docAnnot instanceof Document) {
+ targetViews = DocumentManager.Instance.getDocumentViews(docAnnot.GetPrototype() as Document)
+ }
+ targetViews.filter(tv =>
+ tv.props.ContainingCollectionView && tv.props.ContainingCollectionView.props.Document == self
+ ).map(tv => srcViews.map(sv =>
+ pairs.push({ a: sv.props.Document, b: tv.props.Document, l: link })))
+ })
+ }
}
- }
- return pairs;
- }, [] as { a: Document, b: Document, l: Document }[]));
- }
+ return pairs;
+ }, [] as { a: Document, b: Document, l: Document }[]));
+ }
+ })
return pairs;
}, [] as { a: Document, b: Document, l: Document }[]);
}
componentDidMount() {
- reaction(() => this.findPairs(), (pairs) => runInAction(() => this._triples = pairs));
+ reaction(() => DocumentManager.Instance.DocumentViews.map(dv => [
+ dv.props.Document.Get(KeyStore.AnnotationOn, false),
+ dv.props.Document.Get(KeyStore.LinkedFromDocs, false),
+ dv.props.Document.Get(KeyStore.LinkedToDocs, false)
+ ]), () => runInAction(() => this._triples = this.findPairs()));
}
onPointerDown(e: React.PointerEvent) {
@@ -483,14 +489,29 @@ export class LinksView extends React.Component<CollectionViewProps> {
render() {
if (!this._triples.length)
return (null);
+ let y: { a: Document, b: Document, l: Document, n: number }[] = []
+ this._triples.map(t => {
+ if (!y.reduce((found, yi) => {
+ if (yi.a == t.a && yi.b == t.b) {
+ if (yi.l != t.l)
+ yi.n++;
+ return true;
+ }
+ return found;
+ }, false)) {
+ y.push({ a: t.a, b: t.b, l: t.l, n: 1 });
+ }
+ })
+ console.log("RENDERING " + y.length)
return <svg className="collectionfreeformview-svgCanvas">
- {this._triples.map(pair => {
+ {y.map(pair => {
let x1 = pair.a.GetNumber(KeyStore.X, 0) + pair.a.GetNumber(KeyStore.Width, 0) / 2;
let y1 = pair.a.GetNumber(KeyStore.Y, 0) + pair.a.GetNumber(KeyStore.Height, 0) / 2;
let x2 = pair.b.GetNumber(KeyStore.X, 0) + pair.b.GetNumber(KeyStore.Width, 0) / 2;
let y2 = pair.b.GetNumber(KeyStore.Y, 0) + pair.b.GetNumber(KeyStore.Height, 0) / 2;
return (
<line key={Utils.GenerateGuid()} id={pair.l.Id} className="collectionfreeformview-linkLine" onPointerDown={this.onPointerDown}
+ style={{ strokeWidth: `${pair.n * 5}` }}
x1={`${x1}`} y1={`${y1}`}
x2={`${x2}`} y2={`${y2}`} />
)
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 789f07e8c..c804085df 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -70,7 +70,7 @@ export class CollectionView extends React.Component<CollectionViewProps> {
public static AddDocument(props: CollectionViewProps, doc: Document, allowDuplicates: boolean): boolean {
var curPage = props.Document.GetNumber(KeyStore.CurPage, -1);
doc.SetOnPrototype(KeyStore.Page, new NumberField(curPage));
- if (curPage > 0) {
+ if (curPage >= 0) {
doc.SetOnPrototype(KeyStore.AnnotationOn, props.Document);
}
if (props.Document.Get(props.fieldKey) instanceof Field) {