aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionSchemaCells.tsx
diff options
context:
space:
mode:
author0x85FB9C51 <77808164+0x85FB9C51@users.noreply.github.com>2021-06-28 16:57:56 -0400
committer0x85FB9C51 <77808164+0x85FB9C51@users.noreply.github.com>2021-06-28 16:57:56 -0400
commit501bf6a5d6c81ea1e58509e51ab8c252eaf178ca (patch)
treebb459bbdd7a34f644a3fe9e64a9872193baf02e2 /src/client/views/collections/CollectionSchemaCells.tsx
parent40f52d119be06b60515e5058607633409f847e4f (diff)
resolved bugs and removes console.log
Diffstat (limited to 'src/client/views/collections/CollectionSchemaCells.tsx')
-rw-r--r--src/client/views/collections/CollectionSchemaCells.tsx22
1 files changed, 12 insertions, 10 deletions
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<CellProps> {
}
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<CellProps> {
}
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<CellProps> {
}
// 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<CellProps> {
}
}
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) {