aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/KeyValuePair.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-03-26 23:19:28 -0400
committerbobzel <zzzman@gmail.com>2025-03-26 23:19:28 -0400
commit730d568fb4cb37c5d673517179e8e5dc532ad9c8 (patch)
tree8e9b15a2fdc7096238fb96a789181986d9a5ef86 /src/client/views/nodes/KeyValuePair.tsx
parent7f3c066672e323822c085caabc5821c0ae66695d (diff)
fixed keyValue box assignments so that '_' assigns to template unless value starts with '=' (then root doc). fixed deleting template keys in keyValuePair. fixed schemaTableCell to show current editable value (not last edited value) when editing layout and data doc values. updated DocumentOptions API.
Diffstat (limited to 'src/client/views/nodes/KeyValuePair.tsx')
-rw-r--r--src/client/views/nodes/KeyValuePair.tsx27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx
index 4c082b2ad..e3c481a75 100644
--- a/src/client/views/nodes/KeyValuePair.tsx
+++ b/src/client/views/nodes/KeyValuePair.tsx
@@ -61,31 +61,22 @@ export class KeyValuePair extends ObservableReactComponent<KeyValuePairProps> {
render() {
let doc = this._props.keyName.startsWith('_') ? Doc.Layout(this._props.doc) : this._props.doc;
- // let fieldKey = Object.keys(props.Document).indexOf(props.fieldKey) !== -1 ? props.fieldKey : "(" + props.fieldKey + ")";
const layoutField = doc !== this._props.doc;
const key = layoutField ? this._props.keyName.replace(/^_/, '') : this._props.keyName;
let protoCount = 0;
- while (doc) {
- if (Object.keys(doc).includes(key)) {
- break;
- }
+ while (doc && !Object.keys(doc).includes(key)) {
protoCount++;
doc = DocCast(doc.proto);
}
const parenCount = Math.max(0, protoCount - 1);
const keyStyle = layoutField ? 'red' : protoCount === 0 ? 'black' : 'blue';
-
const hover = { transition: '0.3s ease opacity', opacity: this.isPointerOver || this.isChecked ? 1 : 0 };
-
+ const docOpts = Object.entries(new DocumentOptions());
return (
<tr
- className={this._props.rowStyle}
- onPointerEnter={action(() => {
- this.isPointerOver = true;
- })}
- onPointerLeave={action(() => {
- this.isPointerOver = false;
- })}>
+ className={this._props.rowStyle} //
+ onPointerEnter={action(() => (this.isPointerOver = true))}
+ onPointerLeave={action(() => (this.isPointerOver = false))}>
<td className="keyValuePair-td-key" style={{ width: `${this._props.keyWidth}%` }}>
<div className="keyValuePair-td-key-container">
<button
@@ -93,14 +84,12 @@ export class KeyValuePair extends ObservableReactComponent<KeyValuePairProps> {
style={hover}
className="keyValuePair-td-key-delete"
onClick={undoable(() => {
- if (Object.keys(this._props.doc).indexOf(key) !== -1) {
- delete this._props.doc[key];
- } else delete DocCast(this._props.doc.proto)?.[key];
+ delete (Object.keys(doc).indexOf(key) !== -1 ? doc : DocCast(this._props.doc.proto))[key];
}, 'set key value')}>
X
</button>
<input className="keyValuePair-td-key-check" type="checkbox" style={hover} onChange={this.handleCheck} ref={this.checkbox} />
- <Tooltip title={Object.entries(new DocumentOptions()).find((pair: [string, FInfo]) => pair[0].replace(/^_/, '') === key)?.[1].description ?? ''}>
+ <Tooltip title={(docOpts.find(([k]) => k.replace(/^_/, '') === key)?.[1] as FInfo)?.description ?? ''}>
<div className="keyValuePair-keyField" style={{ marginLeft: 20 * (key.match(/_/g)?.length || 0), color: keyStyle }}>
{'('.repeat(parenCount)}
{(keyStyle === 'black' ? '' : layoutField ? '_' : '$') + key}
@@ -135,7 +124,7 @@ export class KeyValuePair extends ObservableReactComponent<KeyValuePairProps> {
pinToPres: returnZero,
}}
GetValue={() => Field.toKeyValueString(this._props.doc, this._props.keyName)}
- SetValue={(value: string) => Doc.SetField(this._props.doc, this._props.keyName, value)}
+ SetValue={value => Doc.SetField(this._props.doc, this._props.keyName, value)}
/>
</div>
</td>