aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
authormadelinegr <laura_wilson@brown.edu>2019-02-26 16:25:33 -0500
committermadelinegr <laura_wilson@brown.edu>2019-02-26 16:25:33 -0500
commitaa87aa5c549661d825f2b53fae0cdc549d454c60 (patch)
treeee02811202e3849ac9d2ca484cb5c489fec9907a /src/client/views/collections
parent6b61bc19641b3c10658aba00b9cc2cddb6254049 (diff)
parent3ff149e05a76fa0a0ace32a1b0c9876c4850aa2a (diff)
fixed merge conflicts
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionFreeFormView.scss5
-rw-r--r--src/client/views/collections/CollectionSchemaView.scss32
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx115
-rw-r--r--src/client/views/collections/CollectionTreeView.scss6
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx106
5 files changed, 152 insertions, 112 deletions
diff --git a/src/client/views/collections/CollectionFreeFormView.scss b/src/client/views/collections/CollectionFreeFormView.scss
index d583a8218..737f28318 100644
--- a/src/client/views/collections/CollectionFreeFormView.scss
+++ b/src/client/views/collections/CollectionFreeFormView.scss
@@ -2,10 +2,11 @@
::-webkit-scrollbar {
-webkit-appearance: none;
- width: 10px;
+ height:5px;
+ width:5px;
}
::-webkit-scrollbar-thumb {
- border-radius: 5px;
+ border-radius: 2px;
background-color: rgba(0,0,0,.5);
}
diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss
index 0bd5a2ed3..995d60f74 100644
--- a/src/client/views/collections/CollectionSchemaView.scss
+++ b/src/client/views/collections/CollectionSchemaView.scss
@@ -1,4 +1,5 @@
+
.collectionSchemaView-container {
border-style: solid;
box-sizing: border-box;
@@ -7,12 +8,39 @@
height: 100%;
::-webkit-scrollbar {
-webkit-appearance: none;
- width: 10px;
+ height:5px;
+ width:5px;
}
::-webkit-scrollbar-thumb {
- border-radius: 5px;
+ border-radius: 2px;
background-color: rgba(0,0,0,.5);
}
+ .collectionSchemaView-previewRegion {
+ position: relative;
+ background: black;
+ float: left;
+ height: 100%;
+ }
+ .collectionSchemaView-previewHandle {
+ position: absolute;
+ height: 37px;
+ width: 20px;
+ z-index: 20;
+ right: 0;
+ top: 0;
+ background: Black ;
+ }
+ .collectionSchemaView-dividerDragger{
+ position: relative;
+ background: black;
+ float: left;
+ height: 100%;
+ }
+ .collectionSchemaView-tableContainer {
+ position: relative;
+ float: left;
+ height: 100%;
+ }
.ReactTable {
position: absolute;
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 38217d7c4..106a5c4f5 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -15,11 +15,11 @@ import { FieldView, FieldViewProps } from "../nodes/FieldView";
import "./CollectionSchemaView.scss";
import { COLLECTION_BORDER_WIDTH } from "./CollectionView";
import { CollectionViewBase } from "./CollectionViewBase";
-import { DragManager } from "../../util/DragManager";
-import { CollectionDockingView } from "./CollectionDockingView";
+import { setupDrag } from "../../util/DragManager";
// bcz: need to add drag and drop of rows and columns. This seems like it might work for rows: https://codesandbox.io/s/l94mn1q657
+
@observer
export class CollectionSchemaView extends CollectionViewBase {
private _mainCont = React.createRef<HTMLDivElement>();
@@ -32,9 +32,6 @@ export class CollectionSchemaView extends CollectionViewBase {
@observable _selectedIndex = 0;
@observable _splitPercentage: number = 50;
-
-
-
renderCell = (rowProps: CellInfo) => {
let props: FieldViewProps = {
doc: rowProps.value[0],
@@ -48,31 +45,9 @@ export class CollectionSchemaView extends CollectionViewBase {
<FieldView {...props} />
)
let reference = React.createRef<HTMLDivElement>();
- let onRowMove = action((e: PointerEvent): void => {
- e.stopPropagation();
- e.preventDefault();
-
- document.removeEventListener("pointermove", onRowMove);
- document.removeEventListener('pointerup', onRowUp);
- DragManager.StartDrag(reference.current!, { document: props.doc });
- });
- let onRowUp = action((e: PointerEvent): void => {
- document.removeEventListener("pointermove", onRowMove);
- document.removeEventListener('pointerup', onRowUp);
- });
- let onRowDown = (e: React.PointerEvent) => {
- if (this.props.isSelected() || this.props.isTopMost) {
- if (e.shiftKey) {
- CollectionDockingView.Instance.StartOtherDrag(reference.current!, props.doc);
- e.stopPropagation();
- } else {
- document.addEventListener("pointermove", onRowMove);
- document.addEventListener('pointerup', onRowUp);
- }
- }
- }
+ let onItemDown = setupDrag(reference, props.doc);
return (
- <div onPointerDown={onRowDown} ref={reference}>
+ <div onPointerDown={onItemDown} ref={reference}>
<EditableView contents={contents}
height={36} GetValue={() => {
let field = props.doc.Get(props.fieldKey);
@@ -80,7 +55,8 @@ export class CollectionSchemaView extends CollectionViewBase {
return field.ToScriptString();
}
return field || "";
- }} SetValue={(value: string) => {
+ }}
+ SetValue={(value: string) => {
let script = CompileScript(value);
if (!script.compiled) {
return false;
@@ -97,7 +73,9 @@ export class CollectionSchemaView extends CollectionViewBase {
}
}
return false;
- }}></EditableView></div>
+ }}>
+ </EditableView>
+ </div>
)
}
@@ -116,8 +94,8 @@ export class CollectionSchemaView extends CollectionViewBase {
}
}),
style: {
- background: rowInfo.index == this._selectedIndex ? "#00afec" : "white",
- color: rowInfo.index == this._selectedIndex ? "white" : "black"
+ background: rowInfo.index == this._selectedIndex ? "lightGray" : "white",
+ //color: rowInfo.index == this._selectedIndex ? "white" : "black"
}
};
}
@@ -216,44 +194,43 @@ export class CollectionSchemaView extends CollectionViewBase {
}
</Measure>
)
- let handle = !this.props.active() ? (null) : (
- <div style={{ position: "absolute", height: "37px", width: "20px", zIndex: 20, right: 0, top: 0, background: "Black" }} onPointerDown={this.onExpanderDown} />);
+ let previewHandle = !this.props.active() ? (null) : (
+ <div className="collectionSchemaView-previewHandle" onPointerDown={this.onExpanderDown} />);
return (
- <div onPointerDown={this.onPointerDown} ref={this._mainCont} className="collectionSchemaView-container" style={{ borderWidth: `${COLLECTION_BORDER_WIDTH}px` }} >
- <Measure onResize={action((r: any) => {
- this._dividerX = r.entry.width;
- this._panelHeight = r.entry.height;
- })}>
- {({ measureRef }) =>
- <div ref={measureRef} className="collectionSchemaView-tableContainer" style={{ position: "relative", float: "left", width: `${this._splitPercentage}%`, height: "100%" }}>
- <ReactTable
- data={children}
- pageSize={children.length}
- page={0}
- showPagination={false}
- columns={columns.map(col => ({
- Header: col.Name,
- accessor: (doc: Document) => [doc, col],
- id: col.Id
- }))}
- column={{
- ...ReactTableDefaults.column,
- Cell: this.renderCell,
-
- }}
- getTrProps={this.getTrProps}
- />
- </div>
- }
- </Measure>
- <div className="collectionSchemaView-dividerDragger" style={{ position: "relative", background: "black", float: "left", width: `${this.DIVIDER_WIDTH}px`, height: "100%" }} onPointerDown={this.onDividerDown} />
- <div className="collectionSchemaView-previewRegion"
- onDrop={(e: React.DragEvent) => this.onDrop(e, {})}
- ref={this.createDropTarget}
- style={{ position: "relative", float: "left", width: `calc(${100 - this._splitPercentage}% - ${this.DIVIDER_WIDTH}px)`, height: "100%" }}>
- {content}
+ <div className="collectionSchemaView-container" onPointerDown={this.onPointerDown} ref={this._mainCont} style={{ borderWidth: `${COLLECTION_BORDER_WIDTH}px` }} >
+ <div className="collectionSchemaView-dropTarget" onDrop={(e: React.DragEvent) => this.onDrop(e, {})} ref={this.createDropTarget}>
+ <Measure onResize={action((r: any) => {
+ this._dividerX = r.entry.width;
+ this._panelHeight = r.entry.height;
+ })}>
+ {({ measureRef }) =>
+ <div ref={measureRef} className="collectionSchemaView-tableContainer" style={{ width: `${this._splitPercentage}%` }}>
+ <ReactTable
+ data={children}
+ pageSize={children.length}
+ page={0}
+ showPagination={false}
+ columns={columns.map(col => ({
+ Header: col.Name,
+ accessor: (doc: Document) => [doc, col],
+ id: col.Id
+ }))}
+ column={{
+ ...ReactTableDefaults.column,
+ Cell: this.renderCell,
+
+ }}
+ getTrProps={this.getTrProps}
+ />
+ </div>
+ }
+ </Measure>
+ <div className="collectionSchemaView-dividerDragger" onPointerDown={this.onDividerDown} style={{ width: `${this.DIVIDER_WIDTH}px` }} />
+ <div className="collectionSchemaView-previewRegion" style={{ width: `calc(${100 - this._splitPercentage}% - ${this.DIVIDER_WIDTH}px)` }}>
+ {content}
+ </div>
+ {previewHandle}
</div>
- {handle}
</div >
)
}
diff --git a/src/client/views/collections/CollectionTreeView.scss b/src/client/views/collections/CollectionTreeView.scss
index 452c56f54..75feebbbe 100644
--- a/src/client/views/collections/CollectionTreeView.scss
+++ b/src/client/views/collections/CollectionTreeView.scss
@@ -18,4 +18,10 @@ li {
.bullet {
width: 1.5em;
display: inline-block;
+}
+
+.collectionTreeView-dropTarget {
+ border-style: solid;
+ box-sizing: border-box;
+ height: 100%;
} \ No newline at end of file
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 273f312dd..4075ff423 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -8,6 +8,9 @@ import { TextField } from "../../../fields/TextField";
import { observable, action } from "mobx";
import "./CollectionTreeView.scss";
import { EditableView } from "../EditableView";
+import { setupDrag } from "../../util/DragManager";
+import { FieldWaiting } from "../../../fields/Field";
+import { COLLECTION_BORDER_WIDTH } from "./CollectionView";
export interface TreeViewProps {
document: Document;
@@ -42,38 +45,60 @@ class TreeView extends React.Component<TreeViewProps> {
/**
* Renders a single child document. If this child is a collection, it will call renderTreeView again. Otherwise, it will just append a list element.
- * @param document The document to render.
+ * @param childDocument The document to render.
*/
- renderChild(document: Document) {
- var children = document.GetT<ListField<Document>>(KeyStore.Data, ListField);
- let title = document.GetT<TextField>(KeyStore.Title, TextField);
+ renderChild(childDocument: Document) {
+ let reference = React.createRef<HTMLDivElement>();
+ var children = childDocument.GetT<ListField<Document>>(KeyStore.Data, ListField);
+ let title = childDocument.GetT<TextField>(KeyStore.Title, TextField);
+ let onItemDown = setupDrag(reference, childDocument);
- // if the title hasn't loaded, immediately return the div
- if (!title || title === "<Waiting>") {
- return <div key={document.Id}></div>;
- }
-
- // otherwise, check if it's a collection.
- else if (children && children !== "<Waiting>") {
+ if (title && title != FieldWaiting) {
// if it's not collapsed, then render the full TreeView.
+ var subView = null;
+
if (!this.collapsed) {
- return (
- <li key={document.Id} onClick={action(() => this.collapsed = true)} >
+ subView =
+ <li key={childDocument.Id} onClick={action(() => this.collapsed = true)} >
{this.renderBullet(BulletType.Collapsible)}
{title.Data}
- <ul key={document.Id}>
- <TreeView
- document={document}
- />
+ <ul key={childDocument.Id}>
+ <TreeView document={childDocument} />
</ul>
</li>
- );
} else {
- return <li key={document.Id} onClick={action(() => this.collapsed = false)}>
+ subView = <li key={childDocument.Id} onClick={action(() => this.collapsed = false)}>
{this.renderBullet(BulletType.Collapsed)}
{title.Data}
</li>
}
+
+ return <div className="treeViewItem-container" onPointerDown={onItemDown} ref={reference}>
+ {subView}
+ </div>
+
+
+ // let subView = !children || this.collapsed || children === FieldWaiting ? (null) :
+ // <ul key={childDocument.Id}>
+ // <TreeView document={childDocument} />
+ // </ul>;
+ // return <div className="treeViewItem-container" onPointerDown={onItemDown} ref={reference}>
+ // <li className={!children ? "leaf" : this.collapsed ? "collapsed" : "uncollapsed"}
+ // onClick={action(() => this.collapsed = !this.collapsed)} >
+ // {title.Data}
+ // {subView}
+ // </li>
+ // </div>
+ }
+
+ // if the title hasn't loaded, immediately return the div
+ if (!title || title === "<Waiting>") {
+ return <div key={childDocument.Id}></div>;
+ }
+
+ // otherwise, check if it's a collection.
+ else if (children && children !== "<Waiting>") {
+
}
// finally, if it's a normal document, then render it as such.
@@ -91,19 +116,19 @@ class TreeView extends React.Component<TreeViewProps> {
return true;
}}></EditableView>
</li>;
+
+ return (null);
}
}
render() {
var children = this.props.document.GetT<ListField<Document>>(KeyStore.Data, ListField);
-
- if (children && children !== "<Waiting>") {
- return (<div>
- {children.Data.map(value => this.renderChild(value))}
- </div>)
- } else {
- return <div></div>;
- }
+ return !children || children === FieldWaiting ? (null) :
+ (children.Data.map(value =>
+ <div key={value.Id}>
+ {this.renderChild(value)}
+ </div>)
+ )
}
}
@@ -114,21 +139,24 @@ export class CollectionTreeView extends CollectionViewBase {
render() {
let titleStr = "";
let title = this.props.Document.GetT<TextField>(KeyStore.Title, TextField);
- if (title && title !== "<Waiting>") {
+ if (title && title !== FieldWaiting) {
titleStr = title.Data;
}
return (
- <div id="body">
- <h3><EditableView contents={titleStr}
- height={72} GetValue={() => {
- let title = this.props.Document.GetT<TextField>(KeyStore.Title, TextField);
- if (title && title !== "<Waiting>")
- return title.Data;
- return "";
- }} SetValue={(value: string) => {
- this.props.Document.SetData(KeyStore.Title, value, TextField);
- return true;
- }}></EditableView></h3>
+ <div id="body" className="collectionTreeView-dropTarget" onDrop={(e: React.DragEvent) => this.onDrop(e, {})} ref={this.createDropTarget} style={{ borderWidth: `${COLLECTION_BORDER_WIDTH}px` }}>
+ <h3>
+ <EditableView contents={titleStr}
+ height={72} GetValue={() => {
+ let title = this.props.Document.GetT<TextField>(KeyStore.Title, TextField);
+ if (title && title !== "<Waiting>")
+ return title.Data;
+ return "";
+ }} SetValue={(value: string) => {
+ this.props.Document.SetData(KeyStore.Title, value, TextField);
+ return true;
+ }}>
+ </EditableView>
+ </h3>
<ul className="no-indent">
<TreeView
document={this.props.Document}