aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/KeyValueBox.tsx
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-07-01 15:40:55 -0400
committerab <abdullah_ahmed@brown.edu>2019-07-01 15:40:55 -0400
commit0fc7edd5f9bd1234f8de6e5b1c7b8f23668d784c (patch)
tree2ddff97c032657fb86de37c3be2cf2d201980088 /src/client/views/nodes/KeyValueBox.tsx
parent4f8b7cecea3ceed6861c38bde9ce03c9c46e2d09 (diff)
parent6bd79baf2d9301304194d87667bb5c66c17e5298 (diff)
Merge branch 'monikasearch2' of https://github.com/browngraphicslab/Dash-Web into text_box_ab
Diffstat (limited to 'src/client/views/nodes/KeyValueBox.tsx')
-rw-r--r--src/client/views/nodes/KeyValueBox.tsx22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/client/views/nodes/KeyValueBox.tsx b/src/client/views/nodes/KeyValueBox.tsx
index 4beb70284..0e798d291 100644
--- a/src/client/views/nodes/KeyValueBox.tsx
+++ b/src/client/views/nodes/KeyValueBox.tsx
@@ -99,8 +99,16 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
let rows: JSX.Element[] = [];
let i = 0;
+ const self = this;
for (let key of Object.keys(ids).sort()) {
- rows.push(<KeyValuePair doc={realDoc} ref={(el) => { if (el) this.rows.push(el); }} keyWidth={100 - this.splitPercentage} rowStyle={"keyValueBox-" + (i++ % 2 ? "oddRow" : "evenRow")} key={key} keyName={key} />);
+ rows.push(<KeyValuePair doc={realDoc} ref={(function () {
+ let oldEl: KeyValuePair | undefined;
+ return (el: KeyValuePair) => {
+ if (oldEl) self.rows.splice(self.rows.indexOf(oldEl), 1);
+ oldEl = el;
+ if (el) self.rows.push(el);
+ };
+ })()} keyWidth={100 - this.splitPercentage} rowStyle={"keyValueBox-" + (i++ % 2 ? "oddRow" : "evenRow")} key={key} keyName={key} />);
}
return rows;
}
@@ -145,7 +153,9 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
}
getTemplate = async () => {
- let parent = Docs.FreeformDocument([], { width: 800, height: 800, title: "Template" });
+ let parent = Docs.StackingDocument([], { width: 800, height: 800, title: "Template" });
+ parent.singleColumn = false;
+ parent.columnWidth = 50;
for (let row of this.rows.filter(row => row.isChecked)) {
await this.createTemplateField(parent, row);
row.uncheck();
@@ -167,8 +177,8 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
let template = Doc.MakeAlias(target);
template.proto = parent;
template.title = metaKey;
- template.nativeWidth = 300;
- template.nativeHeight = 300;
+ template.nativeWidth = 0;
+ template.nativeHeight = 0;
template.embed = true;
template.isTemplate = true;
template.templates = new List<string>([Templates.TitleBar(metaKey)]);
@@ -189,7 +199,7 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
if (field instanceof RichTextField || typeof field === "string" || typeof field === "number") {
return Docs.TextDocument(options);
} else if (field instanceof List) {
- return Docs.FreeformDocument([], options);
+ return Docs.StackingDocument([], options);
} else if (field instanceof ImageField) {
return Docs.ImageDocument("https://www.freepik.com/free-icon/picture-frame-with-mountain-image_748687.htm", options);
}
@@ -218,4 +228,4 @@ export class KeyValueBox extends React.Component<FieldViewProps> {
{dividerDragger}
</div>);
}
-} \ No newline at end of file
+}