From b985c1641030acb65e5b5d33433dbae9a286d2e2 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Fri, 12 Jul 2019 00:35:53 -0400 Subject: fixed type errors and removed some unused code in documents.ts. --- src/client/documents/Documents.ts | 92 +++------------------------------------ 1 file changed, 7 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index e491dded4..30e4637b0 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -91,10 +91,11 @@ export namespace Docs { type LayoutSource = { LayoutString: () => string }; type CollectionLayoutSource = { LayoutString: (fieldStr: string, fieldExt?: string) => string }; + type CollectionViewType = [CollectionLayoutSource, string, string?] type PrototypeTemplate = { layout: { view: LayoutSource, - collectionView?: [CollectionLayoutSource, string, string?] + collectionView?: CollectionViewType }, options?: Partial }; @@ -109,11 +110,11 @@ export namespace Docs { options: { height: 150, backgroundColor: "#f1efeb" } }], [DocumentType.HIST, { - layout: { view: HistogramBox, collectionView: [CollectionView, data] }, + layout: { view: HistogramBox, collectionView: [CollectionView, data] as CollectionViewType }, options: { height: 300, backgroundColor: "black" } }], [DocumentType.IMG, { - layout: { view: ImageBox, collectionView: [CollectionView, data, anno] }, + layout: { view: ImageBox, collectionView: [CollectionView, data, anno] as CollectionViewType }, options: { nativeWidth: 600, curPage: 0 } }], [DocumentType.WEB, { @@ -129,7 +130,7 @@ export namespace Docs { options: { height: 150 } }], [DocumentType.VID, { - layout: { view: VideoBox, collectionView: [CollectionVideoView, data, anno] }, + layout: { view: VideoBox, collectionView: [CollectionVideoView, data, anno] as CollectionViewType }, options: { nativeWidth: 600, curPage: 0 }, }], [DocumentType.AUDIO, { @@ -137,7 +138,7 @@ export namespace Docs { options: { height: 150 } }], [DocumentType.PDF, { - layout: { view: PDFBox, collectionView: [CollectionPDFView, data, anno] }, + layout: { view: PDFBox, collectionView: [CollectionPDFView, data, anno] as CollectionViewType }, options: { nativeWidth: 1200, curPage: 1 } }], [DocumentType.ICON, { @@ -375,10 +376,7 @@ export namespace Docs { return InstanceFromProto(Prototypes.get(DocumentType.KVP), document, { title: document.title + ".kvp", ...options }); } - export function FreeformDocument(documents: Array, options: DocumentOptions, makePrototype: boolean = true) { - if (!makePrototype) { - return MakeDataDelegate(Prototypes.get(DocumentType.COL), { ...options, viewType: CollectionViewType.Freeform }, new List(documents)); - } + export function FreeformDocument(documents: Array, options: DocumentOptions) { return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { schemaColumns: new List(["title"]), ...options, viewType: CollectionViewType.Freeform }); } @@ -464,82 +462,6 @@ export namespace Docs { } return ctor ? ctor(path, options) : undefined; } - - } - - export namespace Templating { - - export function CaptionDocument(doc: Doc) { - const captionDoc = Doc.MakeAlias(doc); - captionDoc.overlayLayout = FixedCaption(); - captionDoc.width = Cast(doc.width, "number", 0); - captionDoc.height = Cast(doc.height, "number", 0); - return captionDoc; - } - - /** - * An example of custom display string for an image that shows a caption. - */ - export function EmbeddedCaption() { - return ( - `
-
${ImageBox.LayoutString()}
-
${FormattedTextBox.LayoutString("caption")}
-
` - ); - } - - export function FixedCaption(fieldName: string = "caption") { - return ( - `
-
${FormattedTextBox.LayoutString(fieldName)}
-
` - ); - } - - export function OuterCaption() { - return (` -
-
- {layout} -
-
- -
-
- `); - } - - export function InnerCaption() { - return (` -
-
- {layout} -
-
- -
-
- `); - } } } -- cgit v1.2.3-70-g09d2