From 501bf6a5d6c81ea1e58509e51ab8c252eaf178ca Mon Sep 17 00:00:00 2001 From: 0x85FB9C51 <77808164+0x85FB9C51@users.noreply.github.com> Date: Mon, 28 Jun 2021 16:57:56 -0400 Subject: resolved bugs and removes console.log --- .../views/collections/CollectionSchemaCells.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/client/views/collections/CollectionSchemaCells.tsx') diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx index 38b3b1628..42c5375ce 100644 --- a/src/client/views/collections/CollectionSchemaCells.tsx +++ b/src/client/views/collections/CollectionSchemaCells.tsx @@ -251,9 +251,10 @@ export class CollectionSchemaCell extends React.Component { } console.log(inputIsNum); } - console.log("value: " + value); - if (!inputIsNum && !value.startsWith("=")) { - console.log("I don't beep because I'm not a computer."); + // check if the input is a boolean + let inputIsBool: boolean = value == "false" || value == "true"; + + if (!inputIsNum && !inputIsBool && !value.startsWith("=")) { // if it's not a number, it's a string, and should be processed as such // strips the string of quotes when it is edited to prevent quotes form being added to the text automatically // after each edit @@ -266,8 +267,6 @@ export class CollectionSchemaCell extends React.Component { } let inputAsString = '"'; // escape any quotes in the string - //TODO: remove this note to self: when the type is number, it behaves like I want any to behave - //TODO: fix type laziness for (const i of valueSansQuotes) { if (i == '"') { inputAsString += '\\"'; @@ -277,13 +276,12 @@ export class CollectionSchemaCell extends React.Component { } // add a closing quote inputAsString += '"'; - console.log(inputAsString); //two options here: we can strip off outer quotes or we can figure out what's going on with the script const script = CompileScript(inputAsString, { requiredType: type, typecheck: false, editable: true, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } }); - script.compiled && (retVal = this.applyToDoc(valueSansQuotes.length !== value.length ? this._rowDoc : this._rowDataDoc, this.props.row, this.props.col, script.run)); - } else { + script.compiled && (retVal = this.applyToDoc(inputAsString.length !== value.length ? this._rowDoc : this._rowDataDoc, this.props.row, this.props.col, script.run)); + // handle numbers and expressions + } else if (inputIsNum || value.startsWith("=")) { //TODO: make accept numbers - console.log("I beep because I'm a computer"); const inputscript = value.substring(value.startsWith("=") ? 1 : 0); // if commas are not stripped, the parser only considers the numbers after the last comma let inputSansCommas = ""; @@ -293,7 +291,11 @@ export class CollectionSchemaCell extends React.Component { } } const script = CompileScript(inputSansCommas, { requiredType: type, typecheck: false, editable: true, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } }); - script.compiled && (retVal = this.applyToDoc(inputscript.length !== value.length ? this._rowDoc : this._rowDataDoc, this.props.row, this.props.col, script.run)); + script.compiled && (retVal = this.applyToDoc(inputSansCommas.length + 2 !== value.length ? this._rowDoc : this._rowDataDoc, this.props.row, this.props.col, script.run)); + // handle booleans + } else if (inputIsBool) { + const script = CompileScript(value, { requiredType: type, typecheck: false, editable: true, addReturn: true, params: { this: Doc.name, $r: "number", $c: "number", $: "any" } }); + script.compiled && (retVal = this.applyToDoc(value.length + 2 !== value.length ? this._rowDoc : this._rowDataDoc, this.props.row, this.props.col, script.run)); } } if (retVal) { -- cgit v1.2.3-70-g09d2