aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionViewChromes.tsx
diff options
context:
space:
mode:
authorfawn <fangrui_tong@brown.edu>2019-07-29 17:34:57 -0400
committerfawn <fangrui_tong@brown.edu>2019-07-29 17:34:57 -0400
commit1190dc51c66cb48d48c16988f14100fd9a7004e2 (patch)
treee633a1548d705851dca318d5c056e135a718c594 /src/client/views/collections/CollectionViewChromes.tsx
parentf1cb6a2212b11ba6d18dfa2e800b2c8e4ad94a88 (diff)
color + type on schemaheaderfields fixed and schemas can toggle textwrapping
Diffstat (limited to 'src/client/views/collections/CollectionViewChromes.tsx')
-rw-r--r--src/client/views/collections/CollectionViewChromes.tsx33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 2bffe3cc0..8691bea8a 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -17,6 +17,9 @@ import { CompileScript } from "../../util/Scripting";
import { ScriptField } from "../../../new_fields/ScriptField";
import { CollectionSchemaView } from "./CollectionSchemaView";
import { COLLECTION_BORDER_WIDTH } from "../globalCssVariables.scss";
+import { listSpec } from "../../../new_fields/Schema";
+import { List } from "../../../new_fields/List";
+import { Id } from "../../../new_fields/FieldSymbols";
const datepicker = require('js-datepicker');
interface CollectionViewChromeProps {
@@ -365,6 +368,7 @@ export class CollectionStackingViewChrome extends React.Component<CollectionView
@observer
export class CollectionSchemaViewChrome extends React.Component<CollectionViewChromeProps> {
+ // private _textwrapAllRows: boolean = Cast(this.props.CollectionView.props.Document.textwrappedSchemaRows, listSpec("string"), []).length > 0;
togglePreview = () => {
let dividerWidth = 4;
@@ -373,14 +377,43 @@ export class CollectionSchemaViewChrome extends React.Component<CollectionViewCh
let previewWidth = NumCast(this.props.CollectionView.props.Document.schemaPreviewWidth);
let tableWidth = panelWidth - 2 * borderWidth - dividerWidth - previewWidth;
this.props.CollectionView.props.Document.schemaPreviewWidth = previewWidth === 0 ? Math.min(tableWidth / 3, 200) : 0;
+ }
+ @action
+ toggleTextwrap = async () => {
+ console.log("toggle text wrap");
+ let textwrappedRows = Cast(this.props.CollectionView.props.Document.textwrappedSchemaRows, listSpec("string"), []);
+ if (textwrappedRows.length) {
+ console.log("unwrap");
+ this.props.CollectionView.props.Document.textwrappedSchemaRows = new List<string>([]);
+ } else {
+ console.log("wrap");
+ let docs: Doc | Doc[] | Promise<Doc> | Promise<Doc[]> | (() => DocLike)
+ = () => DocListCast(this.props.CollectionView.props.Document[this.props.CollectionView.props.fieldExt ? this.props.CollectionView.props.fieldExt : this.props.CollectionView.props.fieldKey]);
+ if (typeof docs === "function") {
+ docs = docs();
+ }
+ docs = await docs;
+ if (docs instanceof Doc) {
+ let allRows = [docs[Id]];
+ console.log(...[...allRows]);
+ this.props.CollectionView.props.Document.textwrappedSchemaRows = new List<string>(allRows);
+ } else {
+ let allRows = docs.map(doc => doc[Id]);
+ console.log(...[...allRows]);
+ this.props.CollectionView.props.Document.textwrappedSchemaRows = new List<string>(allRows);
+ }
+ }
}
render() {
let previewWidth = NumCast(this.props.CollectionView.props.Document.schemaPreviewWidth);
+ let textWrapped = Cast(this.props.CollectionView.props.Document.textwrappedSchemaRows, listSpec("string"), []).length > 0;
+
return (
<div className="collectionStackingViewChrome-cont">
+ <div id=""><input type="checkbox" key={"Toggle textwrap"} checked={textWrapped} onChange={this.toggleTextwrap} />Textwrap</div>
<div id="preview-schema-checkbox-div"><input type="checkbox" key={"Show Preview"} checked={previewWidth !== 0} onChange={this.togglePreview} />Show Preview</div>
</div>
);