aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-08-20 19:11:00 -0400
committerbobzel <zzzman@gmail.com>2024-08-20 19:11:00 -0400
commit5196009ec6bcb673fd2a4519c54442df218841f7 (patch)
tree79f4b1d559c20a6bfd9b4759a5cbe9d8f8c00fe1 /src/client/documents/Documents.ts
parent0e975569e5686138e52bdc554b3f0391f42aeead (diff)
parente57584a1be9d428fb40fc789494a7ac0ac14fb84 (diff)
fixed up a bunch of things in face recognition
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts50
1 files changed, 22 insertions, 28 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index ecea74fab..9ce465538 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -5,7 +5,7 @@ import { reaction } from 'mobx';
import { basename } from 'path';
import { ClientUtils, OmitKeys } from '../../ClientUtils';
import { DateField } from '../../fields/DateField';
-import { ActiveArrowEnd, ActiveArrowStart, ActiveDash, ActiveFillColor, ActiveInkBezierApprox, ActiveInkColor, ActiveInkWidth, ActiveIsInkMask, CreateLinkToActiveAudio, Doc, FieldType, Opt, updateCachedAcls } from '../../fields/Doc';
+import { CreateLinkToActiveAudio, Doc, FieldType, Opt, updateCachedAcls } from '../../fields/Doc';
import { Initializing } from '../../fields/DocSymbols';
import { HtmlField } from '../../fields/HtmlField';
import { InkField } from '../../fields/InkField';
@@ -142,7 +142,7 @@ class RtfInfo extends FInfo {
}
class ListInfo extends FInfo {
fieldType? = FInfoFieldType.list;
- values?: List<any>[] = [];
+ values?: List<FieldType>[] = [];
}
class MapInfo extends FInfo {
fieldType? = FInfoFieldType.map;
@@ -151,7 +151,7 @@ class MapInfo extends FInfo {
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;
@@ -262,6 +262,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');
@@ -364,7 +365,7 @@ 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');
columnHeaders?: List<SchemaHeaderField>; // headers for stacking views
schemaHeaders?: List<SchemaHeaderField>; // headers for schema view
@@ -470,13 +471,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;
@@ -491,7 +493,10 @@ export class DocumentOptions {
}
export const DocOptions = new DocumentOptions();
+
+// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Docs {
+ // eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Prototypes {
type LayoutSource = { LayoutString: (key: string) => string };
type PrototypeTemplate = {
@@ -499,7 +504,6 @@ export namespace Docs {
view: LayoutSource;
dataField: string;
};
- data?: any;
options?: Partial<DocumentOptions>;
};
type TemplateMap = Map<DocumentType, PrototypeTemplate>;
@@ -561,7 +565,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);
@@ -634,16 +638,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);
}
}
@@ -651,6 +654,7 @@ export namespace Docs {
* Encapsulates the factory used to create new document instances
* delegated from top-level prototypes
*/
+ // eslint-disable-next-line @typescript-eslint/no-namespace
export namespace Create {
/**
* This function receives the relevant document prototype and uses
@@ -674,10 +678,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();
@@ -700,7 +704,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
@@ -717,7 +721,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);
@@ -848,18 +852,7 @@ export namespace Docs {
return linkDoc;
}
- export function InkDocument(
- points: PointData[],
- options: DocumentOptions = {},
- strokeWidth = ActiveInkWidth(),
- color = ActiveInkColor(),
- strokeBezier = ActiveInkBezierApprox(),
- fillColor = ActiveFillColor(),
- arrowStart = ActiveArrowStart(),
- arrowEnd = ActiveArrowEnd(),
- dash = ActiveDash(),
- isInkMask = ActiveIsInkMask()
- ) {
+ export function InkDocument(points: PointData[], options: DocumentOptions = {}, strokeWidth: number, color: string, strokeBezier: string, fillColor: string, arrowStart: string, arrowEnd: string, dash: string, isInkMask: boolean) {
const ink = InstanceFromProto(Prototypes.get(DocumentType.INK), '', { title: 'ink', ...options });
const I = Doc.GetProto(ink);
// I.layout_hideOpenButton = true; // don't show open full screen button when selected
@@ -875,6 +868,7 @@ export namespace Docs {
I.text_align = 'center';
I.rotation = 0;
I.defaultDoubleClick = 'ignore';
+ I.keepZWhenDragged = true;
I.author_date = new DateField();
I.acl_Guest = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View;
// I.acl_Override = SharingPermissions.Unset;
@@ -934,7 +928,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) {