From 436719e0d5f37a46a981287f4c3e903563663567 Mon Sep 17 00:00:00 2001 From: Sam Wilkins Date: Mon, 27 Apr 2020 00:44:23 -0700 Subject: merged detailView templates, now only exists in current_user_utils --- .../views/collections/CollectionTreeView.tsx | 33 +--------------- .../authentication/models/current_user_utils.ts | 44 ++++++++++++++-------- 2 files changed, 30 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx index dcb5e116c..d938bd7ad 100644 --- a/src/client/views/collections/CollectionTreeView.tsx +++ b/src/client/views/collections/CollectionTreeView.tsx @@ -729,39 +729,10 @@ export class CollectionTreeView extends CollectionSubView ({ - type: "paragraph", - content: [{ type: "dashField", attrs: { fieldKey } }] - })) - }, - selection: { type: "text", anchor: 1, head: 1 }, - storedMarks: [] - }; - textDoc.data = new RichTextField(JSON.stringify(detailedTemplate), buxtonFieldKeys.join(" ")); - + const detailView = Cast(Cast(Doc.UserDoc()["template-button-detail"], Doc, null)?.dragFactory, Doc, null); const heroView = ImageDocument(fallbackImg, { title: "heroView", isTemplateDoc: true, isTemplateForField: "hero", }); // this acts like a template doc and a template field ... a little weird, but seems to work? heroView.proto!.layout = ImageBox.LayoutString("hero"); heroView._showTitle = "title"; diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts index 627f3b324..5535f4bcf 100644 --- a/src/server/authentication/models/current_user_utils.ts +++ b/src/server/authentication/models/current_user_utils.ts @@ -83,23 +83,35 @@ export class CurrentUserUtils { } if (doc["template-button-detail"] === undefined) { - const { TextDocument, ImageDocument, MasonryDocument, StackingDocument, CarouselDocument, TreeDocument } = Docs.Create; - const detailedTemplate = `{ "doc": { "type": "doc", "content": [ { "type": "paragraph", "content": [ { "type": "dashField", "attrs": { "fieldKey": "year" } } ] }, { "type": "paragraph", "content": [ { "type": "dashField", "attrs": { "fieldKey": "company" } } ] } ] }, "selection":{"type":"text","anchor":1,"head":1},"storedMarks":[] }`; - - const textDoc1 = TextDocument("", { title: "shortDescription", treeViewOpen: true, treeViewExpandedView: "layout", _height: 50 }); - const textDoc2 = TextDocument("", { title: "longDescription", treeViewOpen: false, treeViewExpandedView: "layout", _height: 350 }); - const detailView = Docs.Create.StackingDocument([ - CarouselDocument([], { title: "data", _height: 350, _itemIndex: 0, backgroundColor: "#9b9b9b3F" }), - MasonryDocument([ - textDoc1, - textDoc2, - // TreeDocument([], { title: "narratives", _height: 75, treeViewHideTitle: true }), - ], { title: "stuff", _height: 300, _xMargin: 0, _autoHeight: true, columnWidth: -1, _chromeStatus: "disabled", treeViewHideTitle: true, _pivotField: "title" }) - ], { _chromeStatus: "disabled", _width: 300, _autoHeight: true, _xMargin: 0, _fontFamily: "Comic Sans MS", _fontSize: 12, title: "detailView" }); - textDoc1.text = new RichTextField(detailedTemplate, "year company"); + const { TextDocument, MasonryDocument, CarouselDocument } = Docs.Create; + + const carousel = CarouselDocument([], { title: "data", _height: 350, _itemIndex: 0, backgroundColor: "#9b9b9b3F" }); + + const short = TextDocument("", { title: "shortDescription", treeViewOpen: true, treeViewExpandedView: "layout", _height: 50 }); + const long = TextDocument("", { title: "longDescription", treeViewOpen: false, treeViewExpandedView: "layout", _height: 350 }); + short.title = "A Short Description"; + long.title = "Long Description"; + + const shared = { _chromeStatus: "disabled", _autoHeight: true, _xMargin: 0 }; + const detailViewOpts = { title: "detailView", _width: 300, _fontFamily: "Arial", _fontSize: 12 }; + const descriptionWrapperOpts = { title: "descriptions", _height: 300, columnWidth: -1, treeViewHideTitle: true, _pivotField: "title" }; + + const descriptionWrapper = MasonryDocument([short, long], { ...shared, ...descriptionWrapperOpts }); + const detailView = Docs.Create.StackingDocument([carousel, descriptionWrapper], { ...shared, ...detailViewOpts }); detailView.isTemplateDoc = makeTemplate(detailView); - textDoc1.title = "A Short Description"; - textDoc2.title = "Long Description"; + + const buxtonFieldKeys = ["year", "originalPrice", "degreesOfFreedom", "company", "attribute", "primaryKey", "secondaryKey", "dimensions"]; + const detailedTemplate = { + doc: { + type: "doc", content: buxtonFieldKeys.map(fieldKey => ({ + type: "paragraph", + content: [{ type: "dashField", attrs: { fieldKey } }] + })) + }, + selection: { type: "text", anchor: 1, head: 1 }, + storedMarks: [] + }; + short.text = new RichTextField(JSON.stringify(detailedTemplate), buxtonFieldKeys.join(" ")); doc["template-button-detail"] = CurrentUserUtils.ficon({ onDragStart: ScriptField.MakeFunction('getCopy(this.dragFactory, true)'), -- cgit v1.2.3-70-g09d2