diff options
author | bob <bcz@cs.brown.edu> | 2020-02-07 15:06:46 -0500 |
---|---|---|
committer | bob <bcz@cs.brown.edu> | 2020-02-07 15:06:46 -0500 |
commit | d310058e80f0896e2724f8723d5b95e1077296c1 (patch) | |
tree | 400bc2038464c8a57c8f09e0c57369a837e025df /src | |
parent | ea5e85e30b83b40135c83025d4f1be1ed188b9b7 (diff) |
fixed __LAYOUT__ and added action() to pivot-in action
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/collections/CollectionTimeView.tsx | 10 | ||||
-rw-r--r-- | src/new_fields/Doc.ts | 15 | ||||
-rw-r--r-- | src/new_fields/util.ts | 15 |
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]; // } } |