diff options
| author | bobzel <zzzman@gmail.com> | 2023-12-29 17:01:40 -0500 |
|---|---|---|
| committer | bobzel <zzzman@gmail.com> | 2023-12-29 17:01:40 -0500 |
| commit | 9b9f54a43793ca6ffb26c56f962d11ba8325abd2 (patch) | |
| tree | 026063b95da59556eb0a416b5f6fafd2ebccd737 /src/client/views/collections/KeyRestrictionRow.tsx | |
| parent | a567eb1b6469db202d41d4d54f2c96137e49ea9c (diff) | |
cleaned up imports, mobx observable initialization and some compile errors.
Diffstat (limited to 'src/client/views/collections/KeyRestrictionRow.tsx')
| -rw-r--r-- | src/client/views/collections/KeyRestrictionRow.tsx | 37 |
1 files changed, 14 insertions, 23 deletions
diff --git a/src/client/views/collections/KeyRestrictionRow.tsx b/src/client/views/collections/KeyRestrictionRow.tsx index f3071b316..4523a4f1e 100644 --- a/src/client/views/collections/KeyRestrictionRow.tsx +++ b/src/client/views/collections/KeyRestrictionRow.tsx @@ -1,6 +1,6 @@ -import * as React from "react"; -import { observable, runInAction } from "mobx"; -import { observer } from "mobx-react"; +import { observable, runInAction } from 'mobx'; +import { observer } from 'mobx-react'; +import * as React from 'react'; interface IKeyRestrictionProps { contains: boolean; @@ -19,37 +19,28 @@ export default class KeyRestrictionRow extends React.Component<IKeyRestrictionPr if (this._key && this._value) { let parsedValue: string | number = `"${this._value}"`; const parsed = parseInt(this._value); - let type = "string"; + let type = 'string'; if (!isNaN(parsed)) { parsedValue = parsed; - type = "number"; + type = 'number'; } - const scriptText = `${this._contains ? "" : "!"}(((doc.${this._key} && (doc.${this._key} as ${type})${type === "string" ? ".includes" : "<="}(${parsedValue}))) || - ((doc.data_ext && doc.data_ext.${this._key}) && (doc.data_ext.${this._key} as ${type})${type === "string" ? ".includes" : "<="}(${parsedValue}))))`; + const scriptText = `${this._contains ? '' : '!'}(((doc.${this._key} && (doc.${this._key} as ${type})${type === 'string' ? '.includes' : '<='}(${parsedValue}))) || + ((doc.data_ext && doc.data_ext.${this._key}) && (doc.data_ext.${this._key} as ${type})${type === 'string' ? '.includes' : '<='}(${parsedValue}))))`; // let doc = new Doc(); // ((doc.data_ext && doc.data_ext!.text) && (doc.data_ext!.text as string).includes("hello")); this.props.script(scriptText); - } - else { - this.props.script(""); + } else { + this.props.script(''); } return ( <div className="collectionViewBaseChrome-viewSpecsMenu-row"> - <input className="collectionViewBaseChrome-viewSpecsMenu-rowLeft" - value={this._key} - onChange={(e) => runInAction(() => this._key = e.target.value)} - placeholder="KEY" /> - <button className="collectionViewBaseChrome-viewSpecsMenu-rowMiddle" - style={{ background: this._contains ? "#77dd77" : "#ff6961" }} - onClick={() => runInAction(() => this._contains = !this._contains)}> - {this._contains ? "CONTAINS" : "DOES NOT CONTAIN"} + <input className="collectionViewBaseChrome-viewSpecsMenu-rowLeft" value={this._key} onChange={e => runInAction(() => (this._key = e.target.value))} placeholder="KEY" /> + <button className="collectionViewBaseChrome-viewSpecsMenu-rowMiddle" style={{ background: this._contains ? '#77dd77' : '#ff6961' }} onClick={() => runInAction(() => (this._contains = !this._contains))}> + {this._contains ? 'CONTAINS' : 'DOES NOT CONTAIN'} </button> - <input className="collectionViewBaseChrome-viewSpecsMenu-rowRight" - value={this._value} - onChange={(e) => runInAction(() => this._value = e.target.value)} - placeholder="VALUE" /> + <input className="collectionViewBaseChrome-viewSpecsMenu-rowRight" value={this._value} onChange={e => runInAction(() => (this._value = e.target.value))} placeholder="VALUE" /> </div> ); } -}
\ No newline at end of file +} |
