aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/CollectionTimeView.tsx10
-rw-r--r--src/new_fields/Doc.ts15
-rw-r--r--src/new_fields/util.ts15
3 files changed, 24 insertions, 16 deletions
diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx
index 0c1f93829..4983acbc2 100644
--- a/src/client/views/collections/CollectionTimeView.tsx
+++ b/src/client/views/collections/CollectionTimeView.tsx
@@ -1,6 +1,6 @@
import { faEdit } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { action, computed, observable, trace } from "mobx";
+import { action, computed, observable, trace, runInAction } from "mobx";
import { observer } from "mobx-react";
import { Set } from "typescript-collections";
import { Doc, DocListCast, Field } from "../../../new_fields/Doc";
@@ -323,7 +323,9 @@ Scripting.addGlobal(function pivotColumnClick(pivotDoc: Doc, bounds: ViewDefBoun
let pfilterIndex = NumCast(pivotDoc._pfilterIndex);
pivotDoc["_pfilter" + pfilterIndex] = ObjectField.MakeCopy(pivotDoc._docFilter as ObjectField);
pivotDoc._pfilterIndex = ++pfilterIndex;
- pivotDoc._docFilter = new List();
- (bounds.payload as string[]).map(filterVal =>
- Doc.setDocFilter(pivotDoc, StrCast(pivotDoc._pivotField), filterVal, "check"));
+ runInAction(() => {
+ pivotDoc._docFilter = new List();
+ (bounds.payload as string[]).map(filterVal =>
+ Doc.setDocFilter(pivotDoc, StrCast(pivotDoc._pivotField), filterVal, "check"));
+ });
}); \ No newline at end of file
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 69717e612..3abd6aaa4 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -112,8 +112,11 @@ export class Doc extends RefField {
get: getter,
// getPrototypeOf: (target) => Cast(target[SelfProxy].proto, Doc) || null, // TODO this might be able to replace the proto logic in getter
has: (target, key) => key in target.__fields,
- ownKeys: target => Object.keys(target.__fields),
+ ownKeys: target => Object.keys(target.__allfields),
getOwnPropertyDescriptor: (target, prop) => {
+ if (prop.toString() === "__LAYOUT__") {
+ return Reflect.getOwnPropertyDescriptor(target, prop);
+ }
if (prop in target.__fields) {
return {
configurable: true,//TODO Should configurable be true?
@@ -140,6 +143,12 @@ export class Doc extends RefField {
private get __fields() {
return this.___fields;
}
+ private get __allfields() {
+ let obj = this.___fields;
+ obj.__LAYOUT__ = this.__LAYOUT__;
+ return obj;
+ }
+
private set __fields(value) {
this.___fields = value;
@@ -173,10 +182,8 @@ export class Doc extends RefField {
const layoutKey = StrCast(this[SelfProxy].layoutKey);
const resolvedLayout = Cast(this[SelfProxy][layoutKey], Doc);
if (resolvedLayout instanceof Doc) {
- let x = resolvedLayout[Id];
let layout = (resolvedLayout.layout as string).split("'")[1];
- const layoutDoc = this[SelfProxy][layout + "-layout[" + x + "]"];
- return layoutDoc || this[SelfProxy];
+ return this[SelfProxy][layout + "-layout[" + resolvedLayout[Id] + "]"];
}
return undefined;
}
diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts
index 26c10525e..52bb7afcd 100644
--- a/src/new_fields/util.ts
+++ b/src/new_fields/util.ts
@@ -110,15 +110,16 @@ export function setter(target: any, in_prop: string | symbol | number, value: an
console.log(prop + " is deprecated - switch to _" + prop);
prop = "_" + prop;
}
- const self = target[Self];
- const layoutDoc = (self || target).__LAYOUT__;
- if (layoutDoc) layoutDoc[prop] = value;
+ if (target.__LAYOUT__) {
+ target.__LAYOUT__[prop] = value;
+ return true;
+ }
// const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver);
// if (resolvedLayout instanceof Doc) {
// let x = resolvedLayout[Id];
// let layout = (resolvedLayout.layout as string).split("'")[1];
// let expanded = getFieldImpl(target, layout + "-layout[" + x + "]", receiver);
- // expanded && (expanded[prop] = value);
+ // //expanded && (expanded[prop] = value);
// // resolvedLayout[prop] = value;
// return true;
// }
@@ -134,15 +135,13 @@ export function getter(target: any, in_prop: string | symbol | number, receiver:
console.log(prop + " is deprecated - switch to _" + prop);
prop = "_" + prop;
}
- const self = target[Self];
- const layoutDoc = (self || target).__LAYOUT__;
- if (layoutDoc) return layoutDoc[prop];
+ if (target.__LAYOUT__) return target.__LAYOUT__[prop];
// const resolvedLayout = getFieldImpl(target, getFieldImpl(target, "layoutKey", receiver), receiver);
// if (resolvedLayout instanceof Doc) {
// let x = resolvedLayout[Id];
// let layout = (resolvedLayout.layout as string).split("'")[1];
// let expanded = getFieldImpl(target, layout + "-layout[" + x + "]", receiver);
- // return (expanded || resolvedLayout)?.[prop];
+ // return (expanded)?.[prop];
// //return resolvedLayout[prop];
// }
}