aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/util/RichTextSchema.tsx2
-rw-r--r--src/client/views/collections/CollectionSubView.tsx8
-rw-r--r--src/new_fields/Doc.ts7
-rw-r--r--src/new_fields/util.ts4
4 files changed, 13 insertions, 8 deletions
diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index a81c6515d..29fd28994 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -1025,7 +1025,7 @@ export class DashFieldView {
this._fieldWrapper.appendChild(this._fieldSpan);
this._fieldWrapper.appendChild(this._enumerables);
(this as any).dom = this._fieldWrapper;
- updateText(false);
+ //updateText(false);
}
destroy() {
this._reactionDisposer?.();
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 11f214625..8b7136876 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -48,8 +48,8 @@ export interface SubCollectionViewProps extends CollectionViewProps {
layoutEngine?: () => string;
}
-export function CollectionSubView<T,X>(schemaCtor: (doc: Doc) => T, moreProps?:X) {
- class CollectionSubView extends DocComponent<X&SubCollectionViewProps, T>(schemaCtor) {
+export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?: X) {
+ class CollectionSubView extends DocComponent<X & SubCollectionViewProps, T>(schemaCtor) {
private dropDisposer?: DragManager.DragDropDisposer;
private gestureDisposer?: GestureUtils.GestureEventDisposer;
protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
@@ -92,7 +92,7 @@ export function CollectionSubView<T,X>(schemaCtor: (doc: Doc) => T, moreProps?:X
}
@computed get dataDoc() {
- return (this.props.DataDoc && this.props.Document.isTemplateForField ? Doc.GetProto(this.props.DataDoc) :
+ return (this.props.DataDoc instanceof Doc && this.props.Document.isTemplateForField ? Doc.GetProto(this.props.DataDoc) :
this.props.Document.resolvedDataDoc ? this.props.Document : Doc.GetProto(this.props.Document)); // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template
}
@@ -195,7 +195,7 @@ export function CollectionSubView<T,X>(schemaCtor: (doc: Doc) => T, moreProps?:X
@undoBatch
@action
protected onInternalDrop(e: Event, de: DragManager.DropEvent): boolean {
- const docDragData = de.complete.docDragData;
+ const docDragData = de.complete.docDragData;
(this.props.Document.dropConverter instanceof ScriptField) &&
this.props.Document.dropConverter.script.run({ dragData: docDragData }); /// bcz: check this
if (docDragData) {
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 9d90c569a..e84ddc684 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -475,8 +475,9 @@ export namespace Doc {
// If it doesn't find the expanded layout, then it makes a delegate of the template layout and
// saves it on the data doc indexed by the template layout's id.
//
+ const params = templateParams?.match(/\(([a-zA-Z0-9_-]*)\)/)?.[1]
const layoutFielddKey = Doc.LayoutFieldKey(templateLayoutDoc);
- const expandedLayoutFieldKey = (templateField || layoutFielddKey) + "-layout[" + templateLayoutDoc[Id] + "]";
+ const expandedLayoutFieldKey = (templateField || layoutFielddKey) + "-layout[" + templateLayoutDoc[Id] + params + "]";
let expandedTemplateLayout = targetDoc?.[expandedLayoutFieldKey];
if (templateLayoutDoc.resolvedDataDoc instanceof Promise) {
expandedTemplateLayout = undefined;
@@ -486,10 +487,10 @@ export namespace Doc {
setTimeout(action(() => {
if (!targetDoc[expandedLayoutFieldKey]) {
const newLayoutDoc = Doc.MakeDelegate(templateLayoutDoc, undefined, "[" + templateLayoutDoc.title + "]");
+ newLayoutDoc["@params"] = params;
newLayoutDoc.expandedTemplate = targetDoc;
// the template's parameters are stored in params which are derefenced to find
// the actual field key where the template data is stored. Currently this is only used in RichTextSchema's docView
- newLayoutDoc["@params"] = templateParams?.match(/\(([a-zA-Z0-9_-]*)\)/)?.[1];
targetDoc[expandedLayoutFieldKey] = newLayoutDoc;
const dataDoc = Doc.GetProto(targetDoc);
newLayoutDoc.resolvedDataDoc = dataDoc;
@@ -511,7 +512,7 @@ export namespace Doc {
}
const existingResolvedDataDoc = childDoc[DataSym] !== Doc.GetProto(childDoc)[DataSym] && childDoc[DataSym];
const resolvedDataDoc = existingResolvedDataDoc || (Doc.AreProtosEqual(containerDataDoc, containerDoc) || !containerDataDoc || (!childDoc.isTemplateDoc && !childDoc.isTemplateForField) ? undefined : containerDataDoc);
- return { layout: Doc.expandTemplateLayout(childDoc, resolvedDataDoc), data: resolvedDataDoc };
+ return { layout: Doc.expandTemplateLayout(childDoc, resolvedDataDoc, "(" + StrCast(containerDoc["@params"]) + ")"), data: resolvedDataDoc };
}
export function Overwrite(doc: Doc, overwrite: Doc, copyProto: boolean = false): Doc {
diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts
index 3ab1b299b..0b98be953 100644
--- a/src/new_fields/util.ts
+++ b/src/new_fields/util.ts
@@ -128,6 +128,10 @@ export function getter(target: any, in_prop: string | symbol | number, receiver:
}
if (target.__LAYOUT__) return target.__LAYOUT__[prop];
}
+ if (typeof prop === "string" && prop.startsWith("@@")) {
+ const expanded = target.__fields["expandedTemplate"];
+ if (expanded) return expanded.cache[target.__fields[prop.substring(1)]];
+ }
if (prop === "then") {//If we're being awaited
return undefined;
}