aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoranika-ahluwalia <anika.ahluwalia@gmail.com>2020-06-29 11:26:52 -0500
committeranika-ahluwalia <anika.ahluwalia@gmail.com>2020-06-29 11:26:52 -0500
commite28fc1fcb0f23d47dfc23dd9e58090b28201289c (patch)
treefd3888086172f9a60e1985d286c8c3240d6f761a /src
parentd6828dba3dc1fd809d0e1449e8230656bb7c5360 (diff)
fixed date type
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionSchemaCells.tsx23
-rw-r--r--src/fields/util.ts2
2 files changed, 16 insertions, 9 deletions
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index a0c5fcde4..5d5f1df57 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -345,15 +345,23 @@ export class CollectionSchemaStringCell extends CollectionSchemaCell {
@observer
export class CollectionSchemaDateCell extends CollectionSchemaCell {
- @observable private _date: Date = this.props.rowProps.original[this.props.rowProps.column.id as string] instanceof DateField ? DateCast(this.props.rowProps.original[this.props.rowProps.column.id as string]).date : new Date();
+ @observable private _date: Date = this.props.rowProps.original[this.props.rowProps.column.id as string] instanceof DateField ? DateCast(this.props.rowProps.original[this.props.rowProps.column.id as string]).date :
+ this.props.rowProps.original[this.props.rowProps.column.id as string] instanceof Date ? this.props.rowProps.original[this.props.rowProps.column.id as string] : new Date();
@action
handleChange = (date: any) => {
+ console.log(date);
this._date = date;
- const script = CompileScript(date.toString(), { requiredType: "Date", addReturn: true, params: { this: Doc.name } });
- if (script.compiled) {
- this.applyToDoc(this._document, this.props.row, this.props.col, script.run);
- }
+ // const script = CompileScript(date.toString(), { requiredType: "Date", addReturn: true, params: { this: Doc.name } });
+ // if (script.compiled) {
+ // console.log("scripting");
+ // this.applyToDoc(this._document, this.props.row, this.props.col, script.run);
+ // } else {
+ console.log(DateCast(date));
+ // ^ DateCast is always undefined for some reason, but that is what the field should be set to
+ this._document[this.props.rowProps.column.id as string] = date as Date;
+ console.log(this._document[this.props.rowProps.column.id as string]);
+ //}
}
render() {
@@ -420,8 +428,7 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
console.log(results.result);
this._doc = results.result;
- this.prop.Document[this.prop.fieldKey] = results.result;
- this.prop.Document[this.prop.fieldKey] = results.result;
+ this._document[this.prop.fieldKey] = results.result;
this._docTitle = this._doc?.title;
return true;
@@ -438,7 +445,7 @@ export class CollectionSchemaDocCell extends CollectionSchemaCell {
onOpenClick = () => {
this._preview = false;
if (this._doc) {
- this.prop.addDocTab(this._doc, "onRight");
+ this.props.addDocTab(this._doc, "onRight");
return true;
}
return false;
diff --git a/src/fields/util.ts b/src/fields/util.ts
index 2869ebed1..2dc21c987 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -78,7 +78,7 @@ const _setterImpl = action(function (target: any, prop: string | symbol | number
} else {
target.__fields[prop] = value;
}
- if (typeof value === "object" && !(value instanceof ObjectField)) debugger;
+ //if (typeof value === "object" && !(value instanceof ObjectField)) debugger;
if (writeToServer) {
if (value === undefined) target[Update]({ '$unset': { ["fields." + prop]: "" } });
else target[Update]({ '$set': { ["fields." + prop]: value instanceof ObjectField ? SerializationHelper.Serialize(value) : (value === undefined ? null : value) } });