diff options
| author | bobzel <zzzman@gmail.com> | 2025-03-24 16:29:32 -0400 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2025-03-24 16:29:32 -0400 |
| commit | 858f5d2f1621695a703b0e3f8297521c3ebe692d (patch) | |
| tree | 3180f91ee18bf8accef98cbbb6db6688666e8340 /src/client/views/nodes/KeyValuePair.tsx | |
| parent | 9c5d14fdd562dc1bcc8aa0f73ce7ad189c9fbf23 (diff) | |
| parent | b6cf21b5a52184f89909898d292a79c57c043d7e (diff) | |
Merge branch 'fieldSyntaxUpdate' into aarav_edit
Diffstat (limited to 'src/client/views/nodes/KeyValuePair.tsx')
| -rw-r--r-- | src/client/views/nodes/KeyValuePair.tsx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx index 85aff04c3..93f5231cb 100644 --- a/src/client/views/nodes/KeyValuePair.tsx +++ b/src/client/views/nodes/KeyValuePair.tsx @@ -61,17 +61,18 @@ export class KeyValuePair extends ObservableReactComponent<KeyValuePairProps> { render() { // let fieldKey = Object.keys(props.Document).indexOf(props.fieldKey) !== -1 ? props.fieldKey : "(" + props.fieldKey + ")"; - let protoCount = 0; - let { doc } = this._props; + const layoutField = this._props.keyName.startsWith('_'); + let doc = layoutField ? Doc.Layout(this._props.doc) : this._props.doc; + let protoCount = doc !== this._props.doc && !layoutField ? 1 : 0; while (doc) { - if (Object.keys(doc).includes(this._props.keyName)) { + if (Object.keys(doc).includes(this._props.keyName.replace(/^_/, ''))) { break; } protoCount++; doc = DocCast(doc.proto); } - const parenCount = Math.max(0, protoCount - 1); - const keyStyle = protoCount === 0 ? 'black' : 'blue'; + const parenCount = Math.max(0, protoCount); + const keyStyle = protoCount === 0 && doc === this._props.doc ? 'black' : 'blue'; const hover = { transition: '0.3s ease opacity', opacity: this.isPointerOver || this.isChecked ? 1 : 0 }; @@ -99,10 +100,9 @@ export class KeyValuePair extends ObservableReactComponent<KeyValuePairProps> { </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(/^_/, '') === this._props.keyName)?.[1].description ?? ''}> - <div className="keyValuePair-keyField" style={{ marginLeft: 20 * (this._props.keyName.replace(/__/g, '').match(/_/g)?.length || 0), color: keyStyle }}> - {'('.repeat(parenCount)} - {this._props.keyName} - {')'.repeat(parenCount)} + <div className="keyValuePair-keyField" style={{ marginLeft: 20 * (this._props.keyName.replace(/__/g, '').replace(/^_/, '').match(/_/g)?.length || 0), color: keyStyle }}> + {(layoutField ? '_' : '$').repeat(parenCount)} + {(keyStyle === 'blue' && !layoutField && !parenCount ? '$' : '') + this._props.keyName} </div> </Tooltip> </div> |
