aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-09-02 09:26:37 -0400
committerbobzel <zzzman@gmail.com>2024-09-02 09:26:37 -0400
commitcda69e48361fce8d71a4dc66edd9dd976a27f52d (patch)
tree82b9a1a5967ae88a9534f89f7eaed3aeb289652f /src/client/documents/Documents.ts
parentc01828308714874589d1f60c33ca59df4c656c0c (diff)
parenta958577d4c27b276aa37484e3f895e196138b17c (diff)
Merge branch 'master' into alyssa-starter
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts48
1 files changed, 33 insertions, 15 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index b96fdb4bd..af181b031 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -37,6 +37,7 @@ export enum FInfoFieldType {
date = 'date',
list = 'list',
rtf = 'rich text',
+ map = 'map',
}
export class FInfo {
description: string = '';
@@ -141,12 +142,12 @@ class RtfInfo extends FInfo {
}
class ListInfo extends FInfo {
fieldType? = FInfoFieldType.list;
- values?: List<any>[] = [];
+ values?: List<FieldType>[] = [];
}
type BOOLt = BoolInfo | boolean;
type NUMt = NumInfo | number;
type STRt = StrInfo | string;
-type LISTt = ListInfo | List<any>;
+type LISTt = ListInfo | List<FieldType>;
type DOCt = DocInfo | Doc;
type RTFt = RtfInfo | RichTextField;
type DIMt = DimInfo; // | typeof DimUnit.Pixel | typeof DimUnit.Ratio;
@@ -256,6 +257,7 @@ export class DocumentOptions {
_layout_nativeDimEditable?: BOOLt = new BoolInfo('native dimensions can be modified using document decoration reizers', false);
_layout_reflowVertical?: BOOLt = new BoolInfo('permit vertical resizing with content "reflow"');
_layout_reflowHorizontal?: BOOLt = new BoolInfo('permit horizontal resizing with content reflow');
+ _layout_noSidebar?: BOOLt = new BoolInfo('whether to display the sidebar toggle button');
layout_boxShadow?: string; // box-shadow css string OR "standard" to use dash standard box shadow
layout_maxShown?: NUMt = new NumInfo('maximum number of children to display at one time (see multicolumnview)');
_layout_autoHeight?: BOOLt = new BoolInfo('whether document automatically resizes vertically to display contents');
@@ -358,8 +360,11 @@ export class DocumentOptions {
presentation_duration?: NUMt = new NumInfo('the duration of the slide in presentation view', false);
presentation_zoomText?: BOOLt = new BoolInfo('whether text anchors should shown in a larger box when following links to make them stand out', false);
- data?: any;
+ data?: FieldType;
data_useCors?: BOOLt = new BoolInfo('whether CORS protocol should be used for web page');
+ _face_showImages?: BOOLt = new BoolInfo('whether to show images in uniqe face Doc');
+ face?: DOCt = new DocInfo('face document');
+ faceDescriptor?: List<number>;
columnHeaders?: List<SchemaHeaderField>; // headers for stacking views
schemaHeaders?: List<SchemaHeaderField>; // headers for schema view
dockingConfig?: STRt = new StrInfo('configuration of golden layout windows (applies only if doc is rendered as a CollectionDockingView)', false);
@@ -464,13 +469,14 @@ export class DocumentOptions {
sidebar_color?: string; // background color of text sidebar
sidebar_type_collection?: string; // collection type of text sidebar
- data_dashboards?: List<any>; // list of dashboards used in shareddocs;
+ data_dashboards?: List<FieldType>; // list of dashboards used in shareddocs;
textTransform?: string;
letterSpacing?: string;
iconTemplate?: string; // name of icon template style
+ icon_fieldKey?: string; // specifies the icon template to use (e.g., icon_fieldKey='george', then the icon template's name is icon_george; otherwise, the template's name would be icon_<type> where type is the Doc's type(pdf,rich text, etc))
selectedIndex?: NUMt = new NumInfo("which item in a linear view has been selected using the 'thumb doc' ui");
- fieldValues?: List<any>; // possible values a field can have (used by FieldInfo's only)
+ fieldValues?: List<FieldType>; // possible values a field can have (used by FieldInfo's only)
fieldType?: string; // display type of a field, e.g. string, number, enumeration (used by FieldInfo's only)
clipboard?: Doc;
@@ -484,6 +490,7 @@ export class DocumentOptions {
}
export const DocOptions = new DocumentOptions();
+
export namespace Docs {
export namespace Prototypes {
type LayoutSource = { LayoutString: (key: string) => string };
@@ -492,7 +499,6 @@ export namespace Docs {
view: LayoutSource;
dataField: string;
};
- data?: any;
options?: Partial<DocumentOptions>;
};
type TemplateMap = Map<DocumentType, PrototypeTemplate>;
@@ -554,7 +560,7 @@ export namespace Docs {
const actualProtos = await DocServer.GetRefFields(prototypeIds);
// update this object to include any default values: DocumentOptions for all prototypes
prototypeIds.forEach(id => {
- const existing = actualProtos[id] as Doc;
+ const existing = actualProtos.get(id);
const type = id.replace(suffix, '') as DocumentType;
// get or create prototype of the specified type...
const target = buildPrototype(type, id, existing);
@@ -627,16 +633,15 @@ export namespace Docs {
acl_Guest: SharingPermissions.View,
...(template.options || {}),
layout: layout.view?.LayoutString(layout.dataField),
- data: template.data,
};
Object.entries(options)
.filter(pair => typeof pair[1] === 'string' && pair[1].startsWith('@'))
.forEach(pair => {
if (!existing || ScriptCast(existing[pair[0]])?.script.originalScript !== pair[1].substring(1)) {
- (options as any)[pair[0]] = ComputedField.MakeFunction(pair[1].substring(1));
+ (options as { [key: string]: unknown })[pair[0]] = ComputedField.MakeFunction(pair[1].substring(1));
}
});
- return Doc.assign(existing ?? new Doc(prototypeId, true), OmitKeys(options, Object.keys(existing ?? {})).omit, undefined, true);
+ return Doc.assign(existing ?? new Doc(prototypeId, true), OmitKeys(options, Object.keys(existing ?? {})).omit as { [key: string]: FieldType }, undefined, true);
}
}
@@ -644,6 +649,7 @@ export namespace Docs {
* Encapsulates the factory used to create new document instances
* delegated from top-level prototypes
*/
+
export namespace Create {
/**
* This function receives the relevant document prototype and uses
@@ -667,10 +673,10 @@ export namespace Docs {
function InstanceFromProto(proto: Doc, data: FieldType | undefined, options: DocumentOptions, delegId?: string, fieldKey: string = 'data', protoId?: string, placeholderDocIn?: Doc, noView?: boolean) {
const placeholderDoc = placeholderDocIn;
const viewKeys = ['x', 'y', 'isSystem']; // keys that should be addded to the view document even though they don't begin with an "_"
- const { omit: dataProps, extract: viewProps } = OmitKeys(options, viewKeys, '^_');
+ const { omit: dataProps, extract: viewProps } = OmitKeys(options, viewKeys, '^_') as { omit: { [key: string]: FieldType | undefined }; extract: { [key: string]: FieldType | undefined } };
// dataProps.acl_Override = SharingPermissions.Unset;
- dataProps.acl_Guest = options.acl_Guest ?? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View);
+ dataProps.acl_Guest = options.acl_Guest?.toString() ?? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View);
dataProps.isSystem = viewProps.isSystem;
dataProps.isDataDoc = true;
dataProps.author = ClientUtils.CurrentUserEmail();
@@ -693,7 +699,7 @@ export namespace Docs {
}
if (!noView) {
- const viewFirstProps: { [id: string]: any } = { author: ClientUtils.CurrentUserEmail() };
+ const viewFirstProps: { [id: string]: FieldType } = { author: ClientUtils.CurrentUserEmail() };
viewFirstProps.acl_Guest = options._acl_Guest ?? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View);
let viewDoc: Doc;
// determines whether viewDoc should be created using placeholder Doc or default
@@ -710,7 +716,7 @@ export namespace Docs {
viewDoc = Doc.assign(Doc.MakeDelegate(dataDoc, delegId), viewFirstProps, true, true);
}
Doc.assign(viewDoc, viewProps, true, true);
- if (![DocumentType.LINK, DocumentType.CONFIG, DocumentType.LABEL].includes(viewDoc.type as any)) {
+ if (![DocumentType.LINK, DocumentType.CONFIG, DocumentType.LABEL].includes(viewDoc.type as DocumentType)) {
CreateLinkToActiveAudio(() => viewDoc);
}
updateCachedAcls(dataDoc);
@@ -784,6 +790,18 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.SEARCH), new List<Doc>([]), options);
}
+ export function ImageGrouperDocument(options: DocumentOptions = {}) {
+ return InstanceFromProto(Prototypes.get(DocumentType.IMAGEGROUPER), undefined, options);
+ }
+
+ export function FaceCollectionDocument(options: DocumentOptions = {}) {
+ return InstanceFromProto(Prototypes.get(DocumentType.FACECOLLECTION), undefined, options);
+ }
+
+ export function UniqeFaceDocument(options: DocumentOptions = {}) {
+ return InstanceFromProto(Prototypes.get(DocumentType.UFACE), undefined, options);
+ }
+
export function LoadingDocument(file: File | string, options: DocumentOptions) {
return InstanceFromProto(Prototypes.get(DocumentType.LOADING), undefined, { _height: 150, _width: 200, title: typeof file === 'string' ? file : file.name, ...options }, undefined, '');
}
@@ -909,7 +927,7 @@ export namespace Docs {
}
export function ConfigDocument(options: DocumentOptions, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.CONFIG), options?.data, options, id, '', undefined, undefined, true);
+ return InstanceFromProto(Prototypes.get(DocumentType.CONFIG), undefined, options, id, '', undefined, undefined, true);
}
export function PileDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {