aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Schicke <tyler_schicke@brown.edu>2019-07-29 14:08:59 -0400
committerTyler Schicke <tyler_schicke@brown.edu>2019-07-29 14:08:59 -0400
commit5d68a57121ac35339d5e223f5dc40ebfd414fd0f (patch)
tree599522f02fd8a1ee7ced3f12253c808b18469abe
parentbb607ecb02a7ecb8fe782d60e10ebf5bdedd790b (diff)
parenta09d610e2a5c09e473b15be23c32f0c3cc370a17 (diff)
Merge branch 'master' of github-tsch-brown:browngraphicslab/Dash-Web
-rw-r--r--src/.DS_Storebin6148 -> 6148 bytes
-rw-r--r--src/client/documents/Documents.ts1
-rw-r--r--src/client/views/ContextMenuItem.tsx13
-rw-r--r--src/client/views/GlobalKeyHandler.ts7
-rw-r--r--src/client/views/collections/CollectionSchemaCells.tsx3
-rw-r--r--src/client/views/collections/CollectionSchemaHeaders.tsx39
-rw-r--r--src/client/views/collections/CollectionSchemaView.scss50
-rw-r--r--src/client/views/collections/CollectionSchemaView.tsx85
-rw-r--r--src/client/views/collections/CollectionStackingView.scss1
-rw-r--r--src/client/views/collections/CollectionStackingView.tsx6
-rw-r--r--src/client/views/collections/CollectionStackingViewFieldColumn.tsx12
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx10
-rw-r--r--src/client/views/collections/CollectionView.tsx35
-rw-r--r--src/client/views/collections/CollectionViewChromes.scss7
-rw-r--r--src/client/views/collections/CollectionViewChromes.tsx31
-rw-r--r--src/client/views/collections/KeyRestrictionRow.tsx3
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
-rw-r--r--src/client/views/nodes/DocumentView.tsx2
-rw-r--r--src/client/views/nodes/KeyValueBox.tsx17
-rw-r--r--src/client/views/nodes/PDFBox.tsx2
-rw-r--r--src/client/views/pdf/PDFViewer.tsx2
-rw-r--r--src/new_fields/SchemaHeaderField.ts5
-rw-r--r--src/scraping/buxton/scraper.py4
23 files changed, 238 insertions, 99 deletions
diff --git a/src/.DS_Store b/src/.DS_Store
index 071dafa1e..c544bc837 100644
--- a/src/.DS_Store
+++ b/src/.DS_Store
Binary files differ
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index ee1b9fd0d..18709499a 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -164,7 +164,6 @@ export namespace Docs {
[DocumentType.LINKDOC, {
data: new List<Doc>(),
layout: { view: EmptyBox },
- options: {}
}],
[DocumentType.BUTTON, {
layout: { view: ButtonBox },
diff --git a/src/client/views/ContextMenuItem.tsx b/src/client/views/ContextMenuItem.tsx
index badb9cf19..a1787e78f 100644
--- a/src/client/views/ContextMenuItem.tsx
+++ b/src/client/views/ContextMenuItem.tsx
@@ -4,12 +4,14 @@ import { observer } from "mobx-react";
import { IconProp, library } from '@fortawesome/fontawesome-svg-core';
import { faAngleRight } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { UndoManager } from "../util/UndoManager";
library.add(faAngleRight);
export interface OriginalMenuProps {
description: string;
event: () => void;
+ undoable?: boolean;
icon: IconProp; //maybe should be optional (icon?)
closeMenu?: () => void;
}
@@ -35,9 +37,14 @@ export class ContextMenuItem extends React.Component<ContextMenuProps & { select
}
}
- handleEvent = (e: React.MouseEvent<HTMLDivElement>) => {
+ handleEvent = async (e: React.MouseEvent<HTMLDivElement>) => {
if ("event" in this.props) {
- this.props.event();
+ let batch: UndoManager.Batch | undefined;
+ if (this.props.undoable !== false) {
+ batch = UndoManager.StartBatch(`Context menu event: ${this.props.description}`);
+ }
+ await this.props.event();
+ batch && batch.end();
this.props.closeMenu && this.props.closeMenu();
}
}
@@ -94,7 +101,7 @@ export class ContextMenuItem extends React.Component<ContextMenuProps & { select
) : null}
<div className="contextMenu-description">
{this.props.description}
- <FontAwesomeIcon icon={faAngleRight} size="lg" style={{ position: "absolute", right: "10px"}} />
+ <FontAwesomeIcon icon={faAngleRight} size="lg" style={{ position: "absolute", right: "10px" }} />
</div>
{submenu}
</div>
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index d52c05b2f..e31b44514 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -133,6 +133,13 @@ export default class KeyManager {
}
MainView.Instance.mainFreeform && CollectionDockingView.Instance.CloseRightSplit(MainView.Instance.mainFreeform);
break;
+ case "backspace":
+ if (document.activeElement) {
+ if (document.activeElement.tagName === "INPUT" || document.activeElement.tagName === "TEXTAREA") {
+ return { stopPropagation: false, preventDefault: false };
+ }
+ }
+ break;
case "f":
MainView.Instance.isSearchVisible = !MainView.Instance.isSearchVisible;
break;
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index f1e013edd..194765880 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -25,6 +25,7 @@ import { library } from '@fortawesome/fontawesome-svg-core';
import { faExpand } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { SchemaHeaderField } from "../../../new_fields/SchemaHeaderField";
+import { KeyCodes } from "../../northstar/utils/KeyCodes";
library.add(faExpand);
@@ -66,7 +67,7 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
@action
onKeyDown = (e: KeyboardEvent): void => {
- if (this.props.isFocused && this.props.isEditable) {
+ if (this.props.isFocused && this.props.isEditable && e.keyCode === KeyCodes.ENTER) {
document.removeEventListener("keydown", this.onKeyDown);
this._isEditing = true;
this.props.setIsEditing(true);
diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx
index 9fc28eafa..387107c55 100644
--- a/src/client/views/collections/CollectionSchemaHeaders.tsx
+++ b/src/client/views/collections/CollectionSchemaHeaders.tsx
@@ -129,6 +129,10 @@ export class CollectionSchemaColumnMenu extends React.Component<ColumnMenuProps>
}
}
+ changeColumnColor = (color: string): void => {
+
+ }
+
renderTypes = () => {
if (this.props.typeConst) return <></>;
return (
@@ -168,6 +172,40 @@ export class CollectionSchemaColumnMenu extends React.Component<ColumnMenuProps>
);
}
+ renderColors = () => {
+ return (
+ <div className="collectionSchema-headerMenu-group">
+ <label>Color:</label>
+ <div className="columnMenu-colors">
+ <input type="radio" name="column-color" id="pink" value="#FFB4E8" onClick={() => this.changeColumnColor("#FFB4E8")} />
+ <label htmlFor="pink">
+ <div className="columnMenu-colorPicker" style={{ backgroundColor: "#FFB4E8" }}></div>
+ </label>
+ <input type="radio" name="column-color" id="purple" value="#b28dff" onClick={() => this.changeColumnColor("#b28dff")} />
+ <label htmlFor="purple">
+ <div className="columnMenu-colorPicker" style={{ backgroundColor: "#FFB4E8" }}></div>
+ </label>
+ <input type="radio" name="column-color" id="blue" value="#afcbff" onClick={() => this.changeColumnColor("#afcbff")} />
+ <label htmlFor="blue">
+ <div className="columnMenu-colorPicker" style={{ backgroundColor: "#FFB4E8" }}></div>
+ </label>
+ <input type="radio" name="column-color" id="yellow" value="#f3ffe3" onClick={() => this.changeColumnColor("#f3ffe3")} />
+ <label htmlFor="yellow">
+ <div className="columnMenu-colorPicker" style={{ backgroundColor: "#FFB4E8" }}></div>
+ </label>
+ <input type="radio" name="column-color" id="red" value="#ffc9de" onClick={() => this.changeColumnColor("#ffc9de")} />
+ <label htmlFor="red">
+ <div className="columnMenu-colorPicker" style={{ backgroundColor: "#FFB4E8" }}></div>
+ </label>
+ <input type="radio" name="column=color" id="none" value="#f1efeb" onClick={() => this.changeColumnColor("#f1efeb")} />
+ <label htmlFor="none">
+ <div className="columnMenu-colorPicker" style={{ backgroundColor: "#FFB4E8" }}></div>
+ </label>
+ </div>
+ </div>
+ );
+ }
+
renderContent = () => {
return (
<div className="collectionSchema-header-menuOptions">
@@ -187,6 +225,7 @@ export class CollectionSchemaColumnMenu extends React.Component<ColumnMenuProps>
<>
{this.renderTypes()}
{this.renderSorting()}
+ {this.renderColors()}
<div className="collectionSchema-headerMenu-group">
<button onClick={() => this.props.deleteColumn(this.props.keyValue)}>Delete Column</button>
</div>
diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss
index e0de76247..b1e98b162 100644
--- a/src/client/views/collections/CollectionSchemaView.scss
+++ b/src/client/views/collections/CollectionSchemaView.scss
@@ -6,14 +6,15 @@
border-style: solid;
border-radius: $border-radius;
box-sizing: border-box;
- // position: absolute;
+ position: absolute;
+ top: 0;
width: 100%;
- height: calc(100% - 50px);
+ transition: height .5s;
+ height: 100%;
// overflow: hidden;
// overflow-x: scroll;
// border: none;
overflow: hidden;
- transition: top 0.5s;
// .collectionSchemaView-cellContents {
// height: $MAX_ROW_HEIGHT;
@@ -78,7 +79,7 @@
overflow-x: auto;
height: 100%;
display: -webkit-inline-box;
- direction: ltr;
+ direction: ltr;
}
.rt-thead {
@@ -122,7 +123,7 @@
font-size: 13px;
text-align: center;
background-color: $light-color-secondary;
-
+
&:last-child {
overflow: visible;
}
@@ -147,7 +148,7 @@
// &:nth-child(even) {
// background-color: $light-color;
// }
-
+
// &:nth-child(odd) {
// background-color: $light-color-secondary;
// }
@@ -175,7 +176,7 @@
padding: 0;
font-size: 13px;
text-align: center;
-
+
// white-space: normal;
.imageBox-cont {
@@ -195,6 +196,11 @@
height: 100%;
}
}
+
+ .rt-resizer {
+ width: 20px;
+ right: -10px;
+ }
}
.documentView-node-topmost {
@@ -207,18 +213,19 @@
background: $light-color;
}
-.collectionSchema-col{
+.collectionSchema-col {
height: 100%;
.collectionSchema-col-wrapper {
&.col-before {
border-left: 2px solid red;
}
+
&.col-after {
border-right: 2px solid red;
}
}
-}
+}
.collectionSchemaView-header {
@@ -285,7 +292,7 @@ button.add-column {
background-color: $light-color;
border: 1px solid $light-color-secondary;
padding: 2px 3px;
-
+
&:not(:last-child) {
border-top: 0;
}
@@ -305,6 +312,19 @@ button.add-column {
border-radius: 20px;
}
}
+
+ .columnMenu-colors {
+
+
+ input[type="radio"] {
+ display: none;
+ }
+
+ .columnMenu-colorPicker {
+ width: 20px;
+ height: 20px;
+ }
+ }
}
.collectionSchema-row {
@@ -312,8 +332,8 @@ button.add-column {
height: 100%;
background-color: white;
- &.row-focused {
- background-color: rgb(255, 246, 246);//$light-color-secondary;
+ &.row-focused .rt-tr {
+ background-color: rgb(255, 246, 246); //$light-color-secondary;
}
&.row-wrapped {
@@ -358,9 +378,11 @@ button.add-column {
&.row-above {
border-top: 1px solid red;
}
+
&.row-below {
border-bottom: 1px solid red;
}
+
&.row-inside {
border: 1px solid red;
}
@@ -461,7 +483,9 @@ button.add-column {
.rt-table {
overflow-x: hidden; // todo; this shouldnt be like this :((
overflow-y: visible;
- } // TODO fix
+ }
+
+ // TODO fix
.row-dragger {
background-color: rgb(252, 252, 252);
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 77ed2d8dc..996118c00 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -72,7 +72,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
@observable private _node: HTMLDivElement | null = null;
@observable private _focusedTable: Doc = this.props.Document;
- @computed get chromeCollapsed() { return this.props.chromeCollapsed; }
@computed get previewWidth() { return () => NumCast(this.props.Document.schemaPreviewWidth); }
@computed get previewHeight() { return () => this.props.PanelHeight() - 2 * this.borderWidth; }
@computed get tableWidth() { return this.props.PanelWidth() - 2 * this.borderWidth - this.DIVIDER_WIDTH - this.previewWidth(); }
@@ -199,13 +198,13 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
get schemaTable() {
return (
<SchemaTable
- Document={this.props.Document} // child doc
+ Document={this.props.Document}
PanelHeight={this.props.PanelHeight}
PanelWidth={this.props.PanelWidth}
childDocs={this.childDocs}
CollectionView={this.props.CollectionView}
ContainingCollectionView={this.props.ContainingCollectionView}
- fieldKey={this.props.fieldKey} // might just be this.
+ fieldKey={this.props.fieldKey}
renderDepth={this.props.renderDepth}
moveDocument={this.props.moveDocument}
ScreenToLocalTransform={this.props.ScreenToLocalTransform}
@@ -237,8 +236,8 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
// if (SelectionManager.SelectedDocuments().length > 0) console.log(StrCast(SelectionManager.SelectedDocuments()[0].Document.title));
// if (DocumentManager.Instance.getDocumentView(this.props.Document)) console.log(StrCast(this.props.Document.title), SelectionManager.IsSelected(DocumentManager.Instance.getDocumentView(this.props.Document)!))
return (
- <div className="collectionSchemaView-container" onPointerDown={this.onPointerDown} onWheel={this.onWheel}
- onDrop={(e: React.DragEvent) => this.onDrop(e, {})} ref={this.createTarget}>
+ <div className="collectionSchemaView-container"
+ onPointerDown={this.onPointerDown} onWheel={this.onWheel} onDrop={(e: React.DragEvent) => this.onDrop(e, {})} ref={this.createTarget}>
{this.schemaTable}
{this.dividerDragger}
{!this.previewWidth() ? (null) : this.previewPanel}
@@ -252,7 +251,7 @@ export interface SchemaTableProps {
dataDoc?: Doc;
PanelHeight: () => number;
PanelWidth: () => number;
- childDocs: Doc[];
+ childDocs?: Doc[];
CollectionView: CollectionView | CollectionPDFView | CollectionVideoView;
ContainingCollectionView: Opt<CollectionView | CollectionPDFView | CollectionVideoView>;
fieldKey: string;
@@ -287,8 +286,19 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
@computed get previewHeight() { return () => this.props.PanelHeight() - 2 * this.borderWidth; }
@computed get tableWidth() { return this.props.PanelWidth() - 2 * this.borderWidth - this.DIVIDER_WIDTH - this.previewWidth(); }
@computed get columns() {
+ console.log("columns");
return Cast(this.props.Document.schemaColumns, listSpec(SchemaHeaderField), []);
}
+ @computed get childDocs() {
+ if (this.props.childDocs) return this.props.childDocs;
+
+ let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ return DocListCast(doc[this.props.fieldKey]);
+ }
+ set childDocs(docs: Doc[]) {
+ let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ doc[this.props.fieldKey] = new List<Doc>(docs);
+ }
set columns(columns: SchemaHeaderField[]) { this.props.Document.schemaColumns = new List<SchemaHeaderField>(columns); }
@computed get borderWidth() { return Number(COLLECTION_BORDER_WIDTH); }
@computed get tableColumns(): Column<Doc>[] {
@@ -301,7 +311,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
// let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
// let children = DocListCast(cdoc[this.props.fieldKey]);
- let children = this.props.childDocs;
+ let children = this.childDocs;
if (children.reduce((found, doc) => found || doc.type === "collection", false)) {
columns.push(
@@ -405,8 +415,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
super(props);
// convert old schema columns (list of strings) into new schema columns (list of schema header fields)
let oldSchemaColumns = Cast(this.props.Document.schemaColumns, listSpec("string"), []);
- if (oldSchemaColumns && oldSchemaColumns.length) {
- let newSchemaColumns = oldSchemaColumns.map(i => typeof i === "string" ? new SchemaHeaderField(i) : i);
+ if (oldSchemaColumns && oldSchemaColumns.length && typeof oldSchemaColumns[0] !== "object") {
+ console.log("REMAKING COLUMNs");
+ let newSchemaColumns = oldSchemaColumns.map(i => typeof i === "string" ? new SchemaHeaderField(i, "#f1efeb") : i);
this.props.Document.schemaColumns = new List<SchemaHeaderField>(newSchemaColumns);
}
}
@@ -424,11 +435,12 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
}
tableRemoveDoc = (document: Doc): boolean => {
- let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ // let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
// let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
- let children = this.props.childDocs;
+ let children = this.childDocs;
if (children.indexOf(document) !== -1) {
children.splice(children.indexOf(document), 1);
+ this.childDocs = children;
return true;
}
return false;
@@ -520,9 +532,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
let direction = e.key === "Tab" ? "tab" : e.which === 39 ? "right" : e.which === 37 ? "left" : e.which === 38 ? "up" : e.which === 40 ? "down" : "";
this.changeFocusedCellByDirection(direction);
- let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ // let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
// let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
- let children = this.props.childDocs;
+ let children = this.childDocs;
const pdoc = FieldValue(children[this._focusedCell.row]);
pdoc && this.props.setPreviewDoc(pdoc);
}
@@ -530,9 +542,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
@action
changeFocusedCellByDirection = (direction: string): void => {
- let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ // let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
// let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
- let children = this.props.childDocs;
+ let children = this.childDocs;
switch (direction) {
case "tab":
if (this._focusedCell.col + 1 === this.columns.length && this._focusedCell.row + 1 === children.length) {
@@ -562,7 +574,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
@action
changeFocusedCellByIndex = (row: number, col: number): void => {
- let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ // let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
// let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
this._focusedCell = { row: row, col: col };
@@ -573,14 +585,15 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
}
createRow = () => {
- let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ // let doc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
// let children = Cast(doc[this.props.fieldKey], listSpec(Doc), []);
- let children = this.props.childDocs;
+ let children = this.childDocs;
let newDoc = Docs.Create.TextDocument({ width: 100, height: 30 });
let proto = Doc.GetProto(newDoc);
proto.title = "";
children.push(newDoc);
+ this.childDocs = children;
}
@action
@@ -588,20 +601,24 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
let index = 0;
let found = this.columns.findIndex(col => col.heading.toUpperCase() === "New field".toUpperCase()) > -1;
if (!found) {
- this.columns.push(new SchemaHeaderField("New field"));
+ console.log("create column found");
+ this.columns.push(new SchemaHeaderField("New field", "#f1efeb"));
return;
}
while (found) {
index++;
found = this.columns.findIndex(col => col.heading.toUpperCase() === ("New field (" + index + ")").toUpperCase()) > -1;
}
- this.columns.push(new SchemaHeaderField("New field (" + index + ")"));
+ console.log("create column new");
+ this.columns.push(new SchemaHeaderField("New field (" + index + ")", "#f1efeb"));
}
@action
deleteColumn = (key: string) => {
+ console.log("deleting columnnn");
let list = Cast(this.props.Document.schemaColumns, listSpec(SchemaHeaderField));
if (list === undefined) {
+ console.log("delete column");
this.props.Document.schemaColumns = list = new List<SchemaHeaderField>([]);
} else {
const index = list.map(c => c.heading).indexOf(key);
@@ -613,16 +630,19 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
@action
changeColumns = (oldKey: string, newKey: string, addNew: boolean) => {
+ console.log("changingin columnsdfhs");
let list = Cast(this.props.Document.schemaColumns, listSpec(SchemaHeaderField));
if (list === undefined) {
- this.props.Document.schemaColumns = list = new List<SchemaHeaderField>([new SchemaHeaderField(newKey)]);
+ console.log("change columns new");
+ this.props.Document.schemaColumns = list = new List<SchemaHeaderField>([new SchemaHeaderField(newKey, "f1efeb")]);
} else {
+ console.log("change column");
if (addNew) {
- this.columns.push(new SchemaHeaderField(newKey));
+ this.columns.push(new SchemaHeaderField(newKey, "f1efeb"));
} else {
const index = list.map(c => c.heading).indexOf(oldKey);
if (index > -1) {
- list[index] = new SchemaHeaderField(newKey);
+ list[index] = new SchemaHeaderField(newKey, "f1efeb");
}
}
}
@@ -687,8 +707,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
}
get documentKeys() {
- // const docs = DocListCast(this.props.Document[this.props.fieldKey]);
- let docs = this.props.childDocs;
+ const docs = DocListCast(this.props.Document[this.props.fieldKey]);
+
+ // let docs = this.childDocs;
let keys: { [key: string]: boolean } = {};
// bcz: ugh. this is untracked since otherwise a large collection of documents will blast the server for all their fields.
// then as each document's fields come back, we update the documents _proxies. Each time we do this, the whole schema will be
@@ -716,9 +737,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
@computed
get reactTable() {
- let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ // let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
// let children = DocListCast(cdoc[this.props.fieldKey]);
- let children = this.props.childDocs;
+ let children = this.childDocs;
let previewWidth = this.previewWidth(); // + 2 * this.borderWidth + this.DIVIDER_WIDTH + 1;
let hasCollectionChild = children.reduce((found, doc) => found || doc.type === "collection", false);
@@ -745,7 +766,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
row => {
if (row.original.type === "collection") {
// let childDocs = DocListCast(row.original[this.props.fieldKey]);
- return <div className="sub"><SchemaTable {...this.props} Document={row.original} /></div>;
+ return <div className="sub"><SchemaTable {...this.props} Document={row.original} childDocs={undefined} /></div>;
}
}
: undefined}
@@ -764,7 +785,9 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
let csv: string = this.columns.reduce((val, col) => val + col + ",", "");
csv = csv.substr(0, csv.length - 1) + "\n";
let self = this;
- this.props.childDocs.map(doc => {
+ let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
+ // let children = DocListCast(cdoc[this.props.fieldKey]);
+ this.childDocs.map(doc => {
csv += self.columns.reduce((val, col) => val + (doc[col.heading] ? doc[col.heading]!.toString() : "0") + ",", "");
csv = csv.substr(0, csv.length - 1) + "\n";
});
@@ -784,8 +807,8 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
// const docs = DocListCast(this.props.Document[this.props.fieldKey]);
let cdoc = this.props.dataDoc ? this.props.dataDoc : this.props.Document;
- // const docs = DocListCast(cdoc[this.props.fieldKey]);
- let docs = this.props.childDocs;
+ const docs = DocListCast(cdoc[this.props.fieldKey]);
+ // let docs = this.childDocs;
row = row % docs.length;
while (row < 0) row += docs.length;
diff --git a/src/client/views/collections/CollectionStackingView.scss b/src/client/views/collections/CollectionStackingView.scss
index 9dbe4ccb8..004b57eff 100644
--- a/src/client/views/collections/CollectionStackingView.scss
+++ b/src/client/views/collections/CollectionStackingView.scss
@@ -5,6 +5,7 @@
width: 100%;
position: absolute;
display: flex;
+ top: 0;
overflow-y: auto;
flex-wrap: wrap;
transition: top .5s;
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index b96b1f8c8..287c8a461 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -140,12 +140,12 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
previewScript={undefined}>
</CollectionSchemaPreview>;
}
- getDocHeight(d: Doc) {
+ getDocHeight(d: Doc, columnScale: number = 1) {
let nw = NumCast(d.nativeWidth);
let nh = NumCast(d.nativeHeight);
if (!BoolCast(d.ignoreAspect) && nw && nh) {
let aspect = nw && nh ? nh / nw : 1;
- let wid = Math.min(d[WidthSym](), this.columnWidth);
+ let wid = Math.min(d[WidthSym](), this.columnWidth / columnScale);
return wid * aspect;
}
return d[HeightSym]();
@@ -278,7 +278,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
};
// let uniqueHeadings = headings.map((i, idx) => headings.indexOf(i) === idx);
return (
- <div className="collectionStackingView" style={{ top: this.chromeCollapsed ? 0 : 100 }}
+ <div className="collectionStackingView"
ref={this.createRef} onDrop={this.onDrop.bind(this)} onWheel={(e: React.WheelEvent) => e.stopPropagation()} >
{/* {sectionFilter as boolean ? [
["width > height", this.filteredChildren.filter(f => f[WidthSym]() >= 1 + f[HeightSym]())],
diff --git a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
index cf5bc451a..c45b0c60a 100644
--- a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
+++ b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
@@ -74,8 +74,8 @@ export class CollectionStackingViewFieldColumn extends React.Component<CSVFieldC
let headings = this.props.headings();
let uniqueHeadings = headings.map((i, idx) => headings.indexOf(i) === idx);
let pair = Doc.GetLayoutDataDocPair(parent.props.Document, parent.props.DataDoc, parent.props.fieldKey, d);
- let width = () => (d.nativeWidth && !BoolCast(d.ignoreAspect) ? Math.min(pair.layout[WidthSym](), parent.columnWidth) : parent.columnWidth) / (uniqueHeadings.length + 1);
- let height = () => parent.getDocHeight(pair.layout);
+ let width = () => (d.nativeWidth && !BoolCast(d.ignoreAspect) ? Math.min(pair.layout[WidthSym](), parent.columnWidth / (uniqueHeadings.length + 1)) : parent.columnWidth / (uniqueHeadings.length + 1));/// (uniqueHeadings.length + 1);
+ let height = () => parent.getDocHeight(pair.layout, uniqueHeadings.length + 1);// / (d.nativeWidth && !BoolCast(d.ignoreAspect) ? uniqueHeadings.length + 1 : 1);
let dref = React.createRef<HTMLDivElement>();
// if (uniqueHeadings.length > 0) {
let dxf = () => this.getDocTransform(pair.layout, dref.current!);
@@ -88,7 +88,7 @@ export class CollectionStackingViewFieldColumn extends React.Component<CSVFieldC
// }
let rowHgtPcnt = height();
let rowSpan = Math.ceil((height() + parent.gridGap) / parent.gridGap);
- let style = parent.singleColumn ? { width: width(), marginTop: i === 0 ? 0 : parent.gridGap, height: `${rowHgtPcnt}` } : { gridRowEnd: `span ${rowSpan}` };
+ let style = parent.singleColumn ? { width: width(), margin: "auto", marginTop: i === 0 ? 0 : parent.gridGap, height: `${rowHgtPcnt}` } : { gridRowEnd: `span ${rowSpan}` };
return <div className={`collectionStackingView-${parent.singleColumn ? "columnDoc" : "masonryDoc"}`} key={d[Id]} ref={dref} style={style} >
{this.props.parent.getDisplayDoc(pair.layout, pair.data, dxf, width)}
</div>;
@@ -266,9 +266,9 @@ export class CollectionStackingViewFieldColumn extends React.Component<CSVFieldC
{headingView}
<div key={`${heading}-stack`} className={`collectionStackingView-masonry${singleColumn ? "Single" : "Grid"}`}
style={{
- padding: singleColumn ? `${style.yMargin}px ${0}px ${style.yMargin}px ${0}px` : `${style.yMargin}px ${0}px`,
- margin: "auto 5px",
- width: singleColumn ? undefined : `${cols * (style.columnWidth + style.gridGap) + 2 * style.xMargin - style.gridGap}px`,
+ padding: singleColumn ? `${style.yMargin}px ${5}px ${style.yMargin}px ${5}px` : `${style.yMargin}px ${0}px`,
+ margin: "auto",
+ width: "max-content", //singleColumn ? undefined : `${cols * (style.columnWidth + style.gridGap) + 2 * style.xMargin - style.gridGap}px`,
height: 'max-content',
position: "relative",
gridGap: style.gridGap,
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 4d31c3ae7..b045869b7 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -237,10 +237,10 @@ class TreeView extends React.Component<TreeViewProps> {
if (DocumentManager.Instance.getDocumentViews(this.dataDoc).length) {
ContextMenu.Instance.addItem({ description: "Focus", event: () => DocumentManager.Instance.getDocumentViews(this.dataDoc).map(view => view.props.focus(this.props.document, true)), icon: "camera" });
}
- ContextMenu.Instance.addItem({ description: "Delete Item", event: undoBatch(() => this.props.deleteDoc(this.props.document)), icon: "trash-alt" });
+ ContextMenu.Instance.addItem({ description: "Delete Item", event: () => this.props.deleteDoc(this.props.document), icon: "trash-alt" });
} else {
- ContextMenu.Instance.addItem({ description: "Open as Workspace", event: undoBatch(() => MainView.Instance.openWorkspace(this.dataDoc)), icon: "caret-square-right" });
- ContextMenu.Instance.addItem({ description: "Delete Workspace", event: undoBatch(() => this.props.deleteDoc(this.props.document)), icon: "trash-alt" });
+ ContextMenu.Instance.addItem({ description: "Open as Workspace", event: () => MainView.Instance.openWorkspace(this.dataDoc), icon: "caret-square-right" });
+ ContextMenu.Instance.addItem({ description: "Delete Workspace", event: () => this.props.deleteDoc(this.props.document), icon: "trash-alt" });
}
ContextMenu.Instance.addItem({ description: "Open Fields", event: () => { let kvp = Docs.Create.KVPDocument(this.props.document, { width: 300, height: 300 }); this.props.addDocTab(kvp, this.props.dataDoc ? this.props.dataDoc : kvp, "onRight"); }, icon: "layer-group" });
ContextMenu.Instance.displayMenu(e.pageX > 156 ? e.pageX - 156 : 0, e.pageY - 15);
@@ -522,8 +522,8 @@ export class CollectionTreeView extends CollectionSubView(Document) {
onContextMenu = (e: React.MouseEvent): void => {
// need to test if propagation has stopped because GoldenLayout forces a parallel react hierarchy to be created for its top-level layout
if (!e.isPropagationStopped() && this.props.Document.workspaceLibrary) { // excludeFromLibrary means this is the user document
- ContextMenu.Instance.addItem({ description: "Create Workspace", event: undoBatch(() => MainView.Instance.createNewWorkspace()), icon: "plus" });
- ContextMenu.Instance.addItem({ description: "Delete Workspace", event: undoBatch(() => this.remove(this.props.Document)), icon: "minus" });
+ ContextMenu.Instance.addItem({ description: "Create Workspace", event: () => MainView.Instance.createNewWorkspace(), icon: "plus" });
+ ContextMenu.Instance.addItem({ description: "Delete Workspace", event: () => this.remove(this.props.Document), icon: "minus" });
e.stopPropagation();
e.preventDefault();
ContextMenu.Instance.displayMenu(e.pageX - 15, e.pageY - 15);
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 81c84852a..55e014c66 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -18,7 +18,7 @@ import { CollectionTreeView } from "./CollectionTreeView";
import { StrCast, PromiseValue } from '../../../new_fields/Types';
import { DocumentType } from '../../documents/Documents';
import { CollectionStackingViewChrome, CollectionViewBaseChrome } from './CollectionViewChromes';
-import { observable, action, runInAction } from 'mobx';
+import { observable, action, runInAction, IReactionDisposer, reaction } from 'mobx';
import { faEye } from '@fortawesome/free-regular-svg-icons';
export const COLLECTION_BORDER_WIDTH = 2;
@@ -37,14 +37,23 @@ library.add(faImage, faEye);
export class CollectionView extends React.Component<FieldViewProps> {
@observable private _collapsed = false;
+ private _reactionDisposer: IReactionDisposer | undefined;
+
public static LayoutString(fieldStr: string = "data", fieldExt: string = "") { return FieldView.LayoutString(CollectionView, fieldStr, fieldExt); }
componentDidMount = () => {
- // chrome status is one of disabled, collapsed, or visible. this determines initial state from document
- let chromeStatus = this.props.Document.chromeStatus;
- if (chromeStatus && (chromeStatus === "disabled" || chromeStatus === "collapsed")) {
- runInAction(() => this._collapsed = true);
- }
+ this._reactionDisposer = reaction(() => StrCast(this.props.Document.chromeStatus),
+ () => {
+ // chrome status is one of disabled, collapsed, or visible. this determines initial state from document
+ let chromeStatus = this.props.Document.chromeStatus;
+ if (chromeStatus && (chromeStatus === "disabled" || chromeStatus === "collapsed")) {
+ runInAction(() => this._collapsed = true);
+ }
+ });
+ }
+
+ componentWillUnmount = () => {
+ this._reactionDisposer && this._reactionDisposer();
}
private SubViewHelper = (type: CollectionViewType, renderProps: CollectionRenderProps) => {
@@ -87,14 +96,14 @@ export class CollectionView extends React.Component<FieldViewProps> {
onContextMenu = (e: React.MouseEvent): void => {
if (!this.isAnnotationOverlay && !e.isPropagationStopped() && this.props.Document[Id] !== CurrentUserUtils.MainDocId) { // need to test this because GoldenLayout causes a parallel hierarchy in the React DOM for its children and the main document view7
let subItems: ContextMenuProps[] = [];
- subItems.push({ description: "Freeform", event: undoBatch(() => this.props.Document.viewType = CollectionViewType.Freeform), icon: "signature" });
+ subItems.push({ description: "Freeform", event: () => this.props.Document.viewType = CollectionViewType.Freeform, icon: "signature" });
if (CollectionBaseView.InSafeMode()) {
- ContextMenu.Instance.addItem({ description: "Test Freeform", event: undoBatch(() => this.props.Document.viewType = CollectionViewType.Invalid), icon: "project-diagram" });
+ ContextMenu.Instance.addItem({ description: "Test Freeform", event: () => this.props.Document.viewType = CollectionViewType.Invalid, icon: "project-diagram" });
}
- subItems.push({ description: "Schema", event: undoBatch(() => this.props.Document.viewType = CollectionViewType.Schema), icon: "th-list" });
- subItems.push({ description: "Treeview", event: undoBatch(() => this.props.Document.viewType = CollectionViewType.Tree), icon: "tree" });
- subItems.push({ description: "Stacking", event: undoBatch(() => this.props.Document.viewType = CollectionViewType.Stacking), icon: "ellipsis-v" });
- subItems.push({ description: "Masonry", event: undoBatch(() => this.props.Document.viewType = CollectionViewType.Masonry), icon: "columns" });
+ subItems.push({ description: "Schema", event: () => this.props.Document.viewType = CollectionViewType.Schema, icon: "th-list" });
+ subItems.push({ description: "Treeview", event: () => this.props.Document.viewType = CollectionViewType.Tree, icon: "tree" });
+ subItems.push({ description: "Stacking", event: () => this.props.Document.viewType = CollectionViewType.Stacking, icon: "ellipsis-v" });
+ subItems.push({ description: "Masonry", event: () => this.props.Document.viewType = CollectionViewType.Masonry, icon: "columns" });
switch (this.props.Document.viewType) {
case CollectionViewType.Freeform: {
subItems.push({ description: "Custom", icon: "fingerprint", event: CollectionFreeFormView.AddCustomLayout(this.props.Document, this.props.fieldKey) });
@@ -102,7 +111,7 @@ export class CollectionView extends React.Component<FieldViewProps> {
}
}
ContextMenu.Instance.addItem({ description: "View Modes...", subitems: subItems, icon: "eye" });
- ContextMenu.Instance.addItem({ description: "Apply Template", event: undoBatch(() => this.props.addDocTab && this.props.addDocTab(Doc.ApplyTemplate(this.props.Document)!, undefined, "onRight")), icon: "project-diagram" });
+ ContextMenu.Instance.addItem({ description: "Apply Template", event: () => this.props.addDocTab && this.props.addDocTab(Doc.ApplyTemplate(this.props.Document)!, undefined, "onRight"), icon: "project-diagram" });
}
}
diff --git a/src/client/views/collections/CollectionViewChromes.scss b/src/client/views/collections/CollectionViewChromes.scss
index 6525f3b07..989315194 100644
--- a/src/client/views/collections/CollectionViewChromes.scss
+++ b/src/client/views/collections/CollectionViewChromes.scss
@@ -3,16 +3,19 @@
.collectionViewChrome-cont {
position: relative;
+ opacity: 0.9;
z-index: 9001;
transition: top .5s;
- background: lightslategray;
+ background: lightgrey;
+ transition: margin-top .5s;
+ background: lightgray;
padding: 10px;
.collectionViewChrome {
display: grid;
grid-template-columns: 1fr auto;
padding-bottom: 10px;
- border-bottom: .5px solid lightgrey;
+ border-bottom: .5px solid rgb(180, 180, 180);
.collectionViewBaseChrome {
display: flex;
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 044d5336a..2bffe3cc0 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -31,7 +31,7 @@ let stopPropagation = (e: React.SyntheticEvent) => e.stopPropagation();
export class CollectionViewBaseChrome extends React.Component<CollectionViewChromeProps> {
@observable private _viewSpecsOpen: boolean = false;
@observable private _dateWithinValue: string = "";
- @observable private _dateValue: Date = new Date();
+ @observable private _dateValue: Date | string = "";
@observable private _keyRestrictions: [JSX.Element, string][] = [];
@observable private _collapsed: boolean = false;
@computed private get filterValue() { return Cast(this.props.CollectionView.props.Document.viewSpecScript, ScriptField); }
@@ -124,10 +124,24 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
let monthOffset = this._dateWithinValue[1] === 'm' ? parseInt(this._dateWithinValue[0]) : 0;
let weekOffset = this._dateWithinValue[1] === 'w' ? parseInt(this._dateWithinValue[0]) : 0;
let dayOffset = (this._dateWithinValue[1] === 'd' ? parseInt(this._dateWithinValue[0]) : 0) + weekOffset * 7;
- let lowerBound = new Date(this._dateValue.getFullYear() - yearOffset, this._dateValue.getMonth() - monthOffset, this._dateValue.getDate() - dayOffset);
- let upperBound = new Date(this._dateValue.getFullYear() + yearOffset, this._dateValue.getMonth() + monthOffset, this._dateValue.getDate() + dayOffset + 1);
- let dateRestrictionScript = `((doc.creationDate as any).date >= ${lowerBound.valueOf()} && (doc.creationDate as any).date <= ${upperBound.valueOf()})`;
- let fullScript = `return ${dateRestrictionScript} && ${keyRestrictionScript}`;
+ let dateRestrictionScript = "";
+ if (this._dateValue instanceof Date) {
+ let lowerBound = new Date(this._dateValue.getFullYear() - yearOffset, this._dateValue.getMonth() - monthOffset, this._dateValue.getDate() - dayOffset);
+ let upperBound = new Date(this._dateValue.getFullYear() + yearOffset, this._dateValue.getMonth() + monthOffset, this._dateValue.getDate() + dayOffset + 1);
+ dateRestrictionScript = `((doc.creationDate as any).date >= ${lowerBound.valueOf()} && (doc.creationDate as any).date <= ${upperBound.valueOf()})`;
+ }
+ else {
+ let createdDate = new Date(this._dateValue);
+ if (!isNaN(createdDate.getTime())) {
+ let lowerBound = new Date(createdDate.getFullYear() - yearOffset, createdDate.getMonth() - monthOffset, createdDate.getDate() - dayOffset);
+ let upperBound = new Date(createdDate.getFullYear() + yearOffset, createdDate.getMonth() + monthOffset, createdDate.getDate() + dayOffset + 1);
+ dateRestrictionScript = `((doc.creationDate as any).date >= ${lowerBound.valueOf()} && (doc.creationDate as any).date <= ${upperBound.valueOf()})`;
+ }
+ }
+ let fullScript = dateRestrictionScript.length || keyRestrictionScript.length ? dateRestrictionScript.length ?
+ `return ${dateRestrictionScript} ${keyRestrictionScript.length ? "&&" : ""} ${keyRestrictionScript}` :
+ `return ${keyRestrictionScript} ${dateRestrictionScript.length ? "&&" : ""} ${dateRestrictionScript}` :
+ "return true";
let compiled = CompileScript(fullScript, { params: { doc: Doc.name } });
if (compiled.compiled) {
this.props.CollectionView.props.Document.viewSpecScript = new ScriptField(compiled);
@@ -171,11 +185,11 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
render() {
return (
- <div className="collectionViewChrome-cont" style={{ top: this._collapsed ? -100 : 0 }}>
+ <div className="collectionViewChrome-cont" style={{ marginTop: this._collapsed ? -70 : 0, height: 70 }}>
<div className="collectionViewChrome">
<div className="collectionViewBaseChrome">
<button className="collectionViewBaseChrome-collapse"
- style={{ top: this._collapsed ? 90 : 10, transform: `rotate(${this._collapsed ? 180 : 0}deg)` }}
+ style={{ marginTop: this._collapsed ? 60 : 0, transform: `rotate(${this._collapsed ? 180 : 0}deg)` }}
title="Collapse collection chrome" onClick={this.toggleCollapse}>
<FontAwesomeIcon icon="caret-up" size="2x" />
</button>
@@ -221,7 +235,8 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
</select>
<input className="collectionViewBaseChrome-viewSpecsMenu-rowRight"
id={this._datePickerElGuid}
- value={this._dateValue.toLocaleDateString()}
+ value={this._dateValue instanceof Date ? this._dateValue.toLocaleDateString() : this._dateValue}
+ onChange={(e) => runInAction(() => this._dateValue = e.target.value)}
onPointerDown={this.openDatePicker}
placeholder="Value" />
</div>
diff --git a/src/client/views/collections/KeyRestrictionRow.tsx b/src/client/views/collections/KeyRestrictionRow.tsx
index 4f3d82114..9c3c9c07c 100644
--- a/src/client/views/collections/KeyRestrictionRow.tsx
+++ b/src/client/views/collections/KeyRestrictionRow.tsx
@@ -26,6 +26,9 @@ export default class KeyRestrictionRow extends React.Component<IKeyRestrictionPr
let scriptText = `${this._contains ? "" : "!"}((doc.${this._key} as ${type})${type === "string" ? ".includes" : "<="}(${parsedValue}))`;
this.props.script(scriptText);
}
+ else {
+ this.props.script("");
+ }
return (
<div className="collectionViewBaseChrome-viewSpecsMenu-row">
<input className="collectionViewBaseChrome-viewSpecsMenu-rowLeft"
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index d70022280..0780320d6 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -496,7 +496,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
let layoutItems: ContextMenuProps[] = [];
layoutItems.push({
description: `${this.fitToBox ? "Unset" : "Set"} Fit To Container`,
- event: undoBatch(async () => this.props.Document.fitToBox = !this.fitToBox),
+ event: async () => this.props.Document.fitToBox = !this.fitToBox,
icon: !this.fitToBox ? "expand-arrows-alt" : "compress-arrows-alt"
});
layoutItems.push({
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 99f073459..f101222ae 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -716,7 +716,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
transformOrigin: "top left", transform: `scale(${1 / this.props.ContentScaling()})`
}}>
<EditableView
- contents={(this.dataDoc || this.layoutDoc)[showTitle]}
+ contents={this.layoutDoc[showTitle]}
display={"block"}
height={72}
fontSize={12}
diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index 77824b4ff..e8075d076 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -20,6 +20,7 @@ import { RichTextField } from "../../../new_fields/RichTextField";
import { ImageField } from "../../../new_fields/URLField";
import { SelectionManager } from "../../util/SelectionManager";
import { listSpec } from "../../../new_fields/Schema";
+import { CollectionViewType } from "../collections/CollectionBaseView";
export type KVPScript = {
script: CompiledScript;
@@ -195,6 +196,9 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
}
let fieldTemplate = await this.inferType(sourceDoc[metaKey], metaKey);
+ if (!fieldTemplate) {
+ return;
+ }
let previousViewType = fieldTemplate.viewType;
Doc.MakeTemplate(fieldTemplate, metaKey, Doc.GetProto(parentStackingDoc));
previousViewType && (fieldTemplate.viewType = previousViewType);
@@ -211,14 +215,17 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
return Docs.Create.StackingDocument([], options);
}
let first = await Cast(data[0], Doc);
- if (!first) {
+ if (!first || !first.data) {
return Docs.Create.StackingDocument([], options);
}
- switch (first.type) {
- case "image":
- return Docs.Create.StackingDocument([], options);
- case "text":
+ switch (first.data.constructor) {
+ case RichTextField:
return Docs.Create.TreeDocument([], options);
+ case ImageField:
+ return Docs.Create.MasonryDocument([], options);
+ default:
+ console.log(`Template for ${first.data.constructor} not supported!`);
+ return undefined;
}
} else if (data instanceof ImageField) {
return Docs.Create.ImageDocument("https://image.flaticon.com/icons/png/512/23/23765.png", options);
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index f527c0595..4973340df 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -167,7 +167,7 @@ export class PDFBox extends DocComponent<FieldViewProps, PdfDocument>(PdfDocumen
scrollTo(y: number) {
if (this._mainCont.current) {
- this._mainCont.current.scrollTo({ top: y, behavior: "auto" });
+ this._mainCont.current.scrollTo({ top: Math.max(y - (this._mainCont.current!.offsetHeight / 2), 0), behavior: "auto" });
}
}
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 6fef8a4de..5eb02a6da 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -212,7 +212,7 @@ export class Viewer extends React.Component<IViewerProps> {
scrollTo(y: number) {
if (this.props.mainCont.current) {
- this.props.parent.scrollTo(y - this.props.mainCont.current.clientHeight);
+ this.props.parent.scrollTo(y);
}
}
diff --git a/src/new_fields/SchemaHeaderField.ts b/src/new_fields/SchemaHeaderField.ts
index a6df31e81..d124a3907 100644
--- a/src/new_fields/SchemaHeaderField.ts
+++ b/src/new_fields/SchemaHeaderField.ts
@@ -48,11 +48,12 @@ export class SchemaHeaderField extends ObjectField {
color: string;
type: number;
- constructor(heading: string = "", color: string = RandomPastel(), type?: ColumnType) {
+ constructor(heading: string = "", color?: string, type?: ColumnType) {
+ console.log("CREATING SCHEMA HEADER FIELD");
super();
this.heading = heading;
- this.color = color;
+ this.color = color === "" || color === undefined ? RandomPastel() : color;
if (type) {
this.type = type;
}
diff --git a/src/scraping/buxton/scraper.py b/src/scraping/buxton/scraper.py
index 182b22a1a..1ff0e3b31 100644
--- a/src/scraping/buxton/scraper.py
+++ b/src/scraping/buxton/scraper.py
@@ -139,7 +139,7 @@ def write_text_doc(content):
data_doc = {
"_id": data_doc_guid,
"fields": {
- "proto": protofy("commonImportProto"),
+ "proto": protofy("textProto"),
"data": {
"Data": '{"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"' + content + '"}]}]},"selection":{"type":"text","anchor":1,"head":1}' + '}',
"__type": "RichTextField"
@@ -235,7 +235,7 @@ def parse_document(file_name: str):
count += 1
view_guids.append(write_image(pure_name, image))
copyfile(dir_path + "/" + image, dir_path +
- "/" + image.replace(".", "_o.", 1))
+ "/" + image.replace(".", "_o.", 1))
os.rename(dir_path + "/" + image, dir_path +
"/" + image.replace(".", "_m.", 1))
print(f"extracted {count} images...")