aboutsummaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2019-02-05 22:37:46 -0500
committerbobzel <zzzman@gmail.com>2019-02-05 22:37:46 -0500
commit4ac7a62d813738b0047caefbcf40d3063ec9e6c1 (patch)
treeb26d6d72f986b05cc8595300efb75af9d8b2183d /src/views
parent26af9562cc515627be4be8759b70ebfbab8bb83c (diff)
checkpoint
Diffstat (limited to 'src/views')
-rw-r--r--src/views/collections/CollectionDockingView.tsx6
-rw-r--r--src/views/collections/CollectionFreeFormView.tsx3
-rw-r--r--src/views/collections/CollectionSchemaView.tsx3
-rw-r--r--src/views/nodes/CollectionFreeFormDocumentView.tsx5
-rw-r--r--src/views/nodes/DocumentView.tsx7
-rw-r--r--src/views/nodes/ImageBox.tsx20
6 files changed, 24 insertions, 20 deletions
diff --git a/src/views/collections/CollectionDockingView.tsx b/src/views/collections/CollectionDockingView.tsx
index 51e2cfbbc..adb885859 100644
--- a/src/views/collections/CollectionDockingView.tsx
+++ b/src/views/collections/CollectionDockingView.tsx
@@ -99,7 +99,8 @@ export class CollectionDockingView extends CollectionViewBase {
const value: Document[] = Document.GetFieldValue(fieldKey, ListField, []);
for (var i: number = 0; i < value.length; i++) {
if (value[i].Id === component) {
- return (<DocumentView key={value[i].Id} ContainingCollectionView={this} Document={value[i]} DocumentView={undefined} />);
+ var data = value[i].GetField(KeyStore.Data);
+ return (<DocumentView key={value[i].Id} ContainingCollectionView={this} Document={value[i]} DocumentView={undefined} Data={data} />);
}
}
if (component === "text") {
@@ -239,8 +240,9 @@ export class CollectionDockingView extends CollectionViewBase {
var containingDiv = "component_" + me.nextId();
container.getElement().html("<div id='" + containingDiv + "'></div>");
setTimeout(function () {
+ var data = state.doc.GetField(KeyStore.Data);
ReactDOM.render((
- <DocumentView key={state.doc.Id} Document={state.doc} ContainingCollectionView={me} DocumentView={undefined} />
+ <DocumentView key={state.doc.Id} Document={state.doc} ContainingCollectionView={me} DocumentView={undefined} Data={data} />
),
document.getElementById(containingDiv)
);
diff --git a/src/views/collections/CollectionFreeFormView.tsx b/src/views/collections/CollectionFreeFormView.tsx
index 2c10c8056..ad470f9e2 100644
--- a/src/views/collections/CollectionFreeFormView.tsx
+++ b/src/views/collections/CollectionFreeFormView.tsx
@@ -189,6 +189,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
const panx: number = Document.GetNumberField(KeyStore.PanX, 0);
const pany: number = Document.GetNumberField(KeyStore.PanY, 0);
const currScale: number = Document.GetNumberField(KeyStore.Scale, 1);
+ const data = Document.GetField(KeyStore.Data);
return (
<div className="border" style={{
@@ -205,7 +206,7 @@ export class CollectionFreeFormView extends CollectionViewBase {
<div className="node-container" ref={this._nodeContainerRef}>
{value.map(doc => {
- return (<CollectionFreeFormDocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentView={undefined} />);
+ return (<CollectionFreeFormDocumentView key={doc.Id} ContainingCollectionView={this} Document={doc} DocumentView={undefined} Data={data} />);
})}
</div>
</div>
diff --git a/src/views/collections/CollectionSchemaView.tsx b/src/views/collections/CollectionSchemaView.tsx
index 8503aaf1e..bde727fea 100644
--- a/src/views/collections/CollectionSchemaView.tsx
+++ b/src/views/collections/CollectionSchemaView.tsx
@@ -74,7 +74,8 @@ export class CollectionSchemaView extends CollectionViewBase {
[KS.Title, KS.Data, KS.Author])
let content;
if (this.selectedIndex != -1) {
- content = (<DocumentView Document={children[this.selectedIndex]} DocumentView={undefined} ContainingCollectionView={this} />)
+ var data = this.props.DocumentForCollection.GetField(KS.Data);
+ content = (<DocumentView Document={children[this.selectedIndex]} DocumentView={undefined} ContainingCollectionView={this} Data={data} />)
} else {
content = <div />
}
diff --git a/src/views/nodes/CollectionFreeFormDocumentView.tsx b/src/views/nodes/CollectionFreeFormDocumentView.tsx
index 08068b384..9f13733c9 100644
--- a/src/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -11,6 +11,7 @@ import "./NodeView.scss";
import React = require("react");
import { DocumentView, DocumentViewProps } from "./DocumentView";
import { WAITING } from "../../fields/Field";
+import { ImageField } from '../../fields/ImageField';
@observer
@@ -206,6 +207,8 @@ export class CollectionFreeFormDocumentView extends DocumentView {
render() {
var freestyling = this.props.ContainingCollectionView instanceof CollectionFreeFormView;
+ let data = this.props.Document.GetFieldT(KeyStore.Data, ImageField);
+ console.log("CollectionFFDocView " + this.props.Document.Title + "<" + data + "> x=" + this.x);
return (
<div className="node" ref={this._mainCont} style={{
transform: freestyling ? this.transform : "",
@@ -217,7 +220,7 @@ export class CollectionFreeFormDocumentView extends DocumentView {
onContextMenu={this.onContextMenu}
onPointerDown={this.onPointerDown}>
- <DocumentView {...this.props} DocumentView={this} />
+ <DocumentView {...this.props} DocumentView={this} Data={data} />
</div>
);
}
diff --git a/src/views/nodes/DocumentView.tsx b/src/views/nodes/DocumentView.tsx
index 334ea1cb2..94fe0440f 100644
--- a/src/views/nodes/DocumentView.tsx
+++ b/src/views/nodes/DocumentView.tsx
@@ -21,6 +21,7 @@ export interface DocumentViewProps {
Document: Document;
DocumentView: Opt<DocumentView> // needed only to set ContainingDocumentView on CollectionViewProps when invoked from JsxParser -- is there a better way?
ContainingCollectionView: Opt<CollectionViewBase>;
+ Data: any;
}
@observer
export class DocumentView extends React.Component<DocumentViewProps> {
@@ -131,15 +132,15 @@ export class DocumentView extends React.Component<DocumentViewProps> {
let bindings = { ...this.props } as any;
for (const key of this.layoutKeys) {
bindings[key.Name + "Key"] = key;
+ let val = this.props.Document.GetField(key);
}
if (bindings.DocumentView === undefined)
bindings.DocumentView = this;
for (const key of this.layoutFields) {
let field = doc.GetField(key);
- if (field && field != WAITING) {
- bindings[key.Name] = field.GetValue();
- }
+ bindings[key.Name] = field && field != WAITING ? field.GetValue() : field;
}
+ console.log("DocumentView Rendering " + doc.Title + " data = " + this.props.Data);
return (
<div className="node" ref={this._mainCont} style={{ width: "100%", height: "100%", }}>
<JsxParser
diff --git a/src/views/nodes/ImageBox.tsx b/src/views/nodes/ImageBox.tsx
index 65a3b7437..fa55c6811 100644
--- a/src/views/nodes/ImageBox.tsx
+++ b/src/views/nodes/ImageBox.tsx
@@ -8,6 +8,7 @@ import { ImageField } from '../../fields/ImageField';
import { FieldViewProps, FieldView } from './FieldView';
import { CollectionFreeFormDocumentView } from './CollectionFreeFormDocumentView';
import { WAITING } from '../../fields/Field';
+import { Key, KeyStore } from '../../fields/Key';
interface ImageBoxState {
photoIndex: number,
@@ -61,22 +62,17 @@ export class ImageBox extends React.Component<FieldViewProps, ImageBoxState> {
render() {
let field = this.props.doc.GetFieldT(this.props.fieldKey, ImageField);
- let path = "";
- if (field) {
- if (field === WAITING) {
- path = "https://image.flaticon.com/icons/svg/66/66163.svg"
- } else {
- path = field.Data.href;
- }
- }
- const images = [path,];
+ let path = field == WAITING ? "https://image.flaticon.com/icons/svg/66/66163.svg" :
+ field instanceof ImageField ? field.Data.href : "";
+ console.log("ImageBox Rendering " + this.props.doc.Title);
var lightbox = () => {
+ const images = [path, "http://www.cs.brown.edu/~bcz/face.gif"];
const { photoIndex } = this.state;
if (this.state.isOpen && this.props.DocumentViewForField instanceof CollectionFreeFormDocumentView && SelectionManager.IsSelected(this.props.DocumentViewForField)) {
return (<Lightbox
mainSrc={images[photoIndex]}
- nextSrc={photoIndex + 1 < images.length ? images[(photoIndex + 1) % images.length] : undefined}
- prevSrc={photoIndex - 1 > 0 ? images[(photoIndex + images.length - 1) % images.length] : undefined}
+ nextSrc={images[(photoIndex + 1) % images.length]}
+ prevSrc={images[(photoIndex + images.length - 1) % images.length]}
onCloseRequest={() => this.setState({ isOpen: false })}
onMovePrevRequest={() =>
this.setState({ photoIndex: (photoIndex + images.length - 1) % images.length, })
@@ -89,7 +85,7 @@ export class ImageBox extends React.Component<FieldViewProps, ImageBoxState> {
}
return (
<div className="imageBox-cont" onPointerDown={this.onPointerDown} ref={this._ref} >
- <img src={images[0]} width="100%" alt="Image not found" />
+ <img src={path} width="100%" alt="Image not found" />
{lightbox()}
</div>)
}