aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSchemaView.tsx
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-05-31 00:31:04 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-05-31 00:31:04 -0400
commit6fff8632e85884bbf4bff33e845d4443d66b6250 (patch)
tree70e2a8d3b8011697028ae28c8e6d7ad07b9923f9 /src/client/views/collections/CollectionSchemaView.tsx
parent435f0c8ef035995001dde92f8e7a04fe35a3a41d (diff)
parent2814e59614c516aa2ba6a8e7555ace3e79911c38 (diff)
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web
Diffstat (limited to 'src/client/views/collections/CollectionSchemaView.tsx')
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 1af13765b..10db6e0bb 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -64,6 +64,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
@observable _columnsPercentage = 0;
@observable _keys: string[] = [];
@observable _newKeyName: string = "";
+ @observable previewScript: string = "";
@computed get previewWidth() { return () => NumCast(this.props.Document.schemaPreviewWidth); }
@computed get previewHeight() { return () => this.props.PanelHeight() - 2 * this.borderWidth; }
@@ -346,7 +347,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
@computed
get previewPanel() {
trace();
- return !this.previewDocument ? (null) : <CollectionSchemaPreview
+ return <CollectionSchemaPreview
Document={this.previewDocument}
width={this.previewWidth}
height={this.previewHeight}
@@ -357,8 +358,14 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
active={this.props.active}
whenActiveChanged={this.props.whenActiveChanged}
addDocTab={this.props.addDocTab}
+ setPreviewScript={this.setPreviewScript}
+ previewScript={this.previewScript}
/>
}
+ @action
+ setPreviewScript = (script: string) => {
+ this.previewScript = script;
+ }
render() {
trace();
@@ -374,7 +381,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
}
}
interface CollectionSchemaPreviewProps {
- Document: Doc;
+ Document?: Doc;
width: () => number;
height: () => number;
CollectionView: CollectionView | CollectionPDFView | CollectionVideoView;
@@ -384,13 +391,14 @@ interface CollectionSchemaPreviewProps {
active: () => boolean;
whenActiveChanged: (isActive: boolean) => void;
addDocTab: (document: Doc, where: string) => void;
+ setPreviewScript: (script: string) => void;
+ previewScript: string;
}
@observer
class CollectionSchemaPreview extends React.Component<CollectionSchemaPreviewProps>{
- @observable previewScript: string = "";
- private get nativeWidth() { return NumCast(this.props.Document.nativeWidth, this.props.width()); }
- private get nativeHeight() { return NumCast(this.props.Document.nativeHeight, this.props.height()); }
+ private get nativeWidth() { return NumCast(this.props.Document!.nativeWidth, this.props.width()); }
+ private get nativeHeight() { return NumCast(this.props.Document!.nativeHeight, this.props.height()); }
private contentScaling = () => {
let wscale = this.props.width() / (this.nativeWidth ? this.nativeWidth : this.props.width());
if (wscale * this.nativeHeight > this.props.height()) {
@@ -404,15 +412,15 @@ class CollectionSchemaPreview extends React.Component<CollectionSchemaPreviewPro
get centeringOffset() { return (this.props.width() - this.nativeWidth * this.contentScaling()) / 2; }
@action
onPreviewScriptChange = (e: React.ChangeEvent<HTMLInputElement>) => {
- this.previewScript = e.currentTarget.value;
+ this.props.setPreviewScript(e.currentTarget.value);
}
render() {
trace();
+ console.log(this.props.Document);
return (<div className="collectionSchemaView-previewRegion" style={{ width: this.props.width() }}>
{!this.props.Document || !this.props.width ? (null) : (
<div className="collectionSchemaView-previewDoc" style={{ transform: `translate(${this.centeringOffset}px, 0px)` }}>
<DocumentView Document={this.props.Document} isTopMost={false} selectOnLoad={false}
- toggleMinimized={emptyFunction}
addDocument={this.props.addDocument} removeDocument={this.props.removeDocument}
ScreenToLocalTransform={this.getTransform}
ContentScaling={this.contentScaling}
@@ -423,9 +431,10 @@ class CollectionSchemaPreview extends React.Component<CollectionSchemaPreviewPro
whenActiveChanged={this.props.whenActiveChanged}
bringToFront={emptyFunction}
addDocTab={this.props.addDocTab}
+ toggleMinimized={emptyFunction}
/>
</div>)}
- <input className="collectionSchemaView-input" value={this.previewScript} onChange={this.onPreviewScriptChange}
+ <input className="collectionSchemaView-input" value={this.props.previewScript} onChange={this.onPreviewScriptChange}
style={{ left: `calc(50% - ${Math.min(75, (this.props.Document ? this.PanelWidth() / 2 : 75))}px)` }} />
</div>);
}