aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorSam Wilkins <samwilkins333@gmail.com>2019-07-30 03:49:18 -0400
committerSam Wilkins <samwilkins333@gmail.com>2019-07-30 03:49:18 -0400
commit79f47098381fef8e247ddb45ce56993669f218cb (patch)
treec7fb7e88586c2eba65ad0b5e8e2bf11a2c1b29cd /src/client/documents/Documents.ts
parent3152e69dfafe1c393bed38f3aad1e55881e62a33 (diff)
parente041988b84553797699a5a232e26e72252460e01 (diff)
successful implementation of different approach
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 3859f2255..d1b3071ed 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -39,6 +39,7 @@ import { DocumentManager } from "../util/DocumentManager";
import DirectoryImportBox from "../util/Import & Export/DirectoryImportBox";
import { Scripting } from "../util/Scripting";
import { ButtonBox } from "../views/nodes/ButtonBox";
+import { SchemaHeaderField, RandomPastel } from "../../new_fields/SchemaHeaderField";
var requestImageSize = require('../util/request-image-size');
var path = require('path');
@@ -81,10 +82,11 @@ export interface DocumentOptions {
backgroundColor?: string;
dropAction?: dropActionType;
backgroundLayout?: string;
+ chromeStatus?: string;
curPage?: number;
documentText?: string;
borderRounding?: string;
- schemaColumns?: List<string>;
+ schemaColumns?: List<SchemaHeaderField>;
dockingConfig?: string;
dbDoc?: Doc;
// [key: string]: Opt<Field>;
@@ -163,7 +165,6 @@ export namespace Docs {
[DocumentType.LINKDOC, {
data: new List<Doc>(),
layout: { view: EmptyBox },
- options: {}
}],
[DocumentType.BUTTON, {
layout: { view: ButtonBox },
@@ -403,19 +404,23 @@ export namespace Docs {
}
export function FreeformDocument(documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { schemaColumns: new List(["title"]), ...options, viewType: CollectionViewType.Freeform });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title")]), ...options, viewType: CollectionViewType.Freeform });
}
- export function SchemaDocument(schemaColumns: string[], documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { schemaColumns: new List(schemaColumns), ...options, viewType: CollectionViewType.Schema });
+ export function SchemaDocument(schemaColumns: SchemaHeaderField[], documents: Array<Doc>, options: DocumentOptions) {
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { chromeStatus: "collapsed", schemaColumns: new List(schemaColumns), ...options, viewType: CollectionViewType.Schema });
}
export function TreeDocument(documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { schemaColumns: new List(["title"]), ...options, viewType: CollectionViewType.Tree });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title")]), ...options, viewType: CollectionViewType.Tree });
}
export function StackingDocument(documents: Array<Doc>, options: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { schemaColumns: new List(["title"]), ...options, viewType: CollectionViewType.Stacking });
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title")]), ...options, viewType: CollectionViewType.Stacking });
+ }
+
+ export function MasonryDocument(documents: Array<Doc>, options: DocumentOptions) {
+ return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title")]), ...options, viewType: CollectionViewType.Masonry });
}
export function ButtonDocument(options?: DocumentOptions) {
@@ -577,12 +582,12 @@ export namespace Docs {
export namespace DocUtils {
export function MakeLink(source: Doc, target: Doc, targetContext?: Doc, title: string = "", description: string = "", tags: string = "Default", sourceContext?: Doc) {
- if (LinkManager.Instance.doesLinkExist(source, target)) return;
+ if (LinkManager.Instance.doesLinkExist(source, target)) return undefined;
let sv = DocumentManager.Instance.getDocumentView(source);
if (sv && sv.props.ContainingCollectionView && sv.props.ContainingCollectionView.props.Document === target) return;
- if (target === CurrentUserUtils.UserDocument) return;
+ if (target === CurrentUserUtils.UserDocument) return undefined;
- let linkDoc;
+ let linkDoc: Doc | undefined;
UndoManager.RunInBatch(() => {
linkDoc = Docs.Create.TextDocument({ width: 100, height: 30, borderRounding: "100%" });
linkDoc.type = DocumentType.LINK;