aboutsummaryrefslogtreecommitdiff
path: root/src/client/documents/Documents.ts
diff options
context:
space:
mode:
authorJames Hu <51237606+jameshu111@users.noreply.github.com>2023-07-26 12:15:46 -0400
committerJames Hu <51237606+jameshu111@users.noreply.github.com>2023-07-26 12:15:46 -0400
commit4a8cf5ee3fd6f01ff2d28ccc0a456e9782bd261b (patch)
treea1a4ac7200a38f55227fff941d8d7246cb85eebf /src/client/documents/Documents.ts
parent7c1017f15b9c0ad09d3e0185e310733ab7c10c09 (diff)
parentc87024c06941920f1df689d54d82cc309891e3d2 (diff)
Merge branch 'master' into james-azure-image
Diffstat (limited to 'src/client/documents/Documents.ts')
-rw-r--r--src/client/documents/Documents.ts103
1 files changed, 48 insertions, 55 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 2532ef226..f3f645ca2 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -34,7 +34,7 @@ import { ContextMenuProps } from '../views/ContextMenuItem';
import { DFLT_IMAGE_NATIVE_DIM } from '../views/global/globalCssVariables.scss';
import { ActiveArrowEnd, ActiveArrowStart, ActiveDash, ActiveFillColor, ActiveInkBezierApprox, ActiveInkColor, ActiveInkWidth, ActiveIsInkMask, InkingStroke } from '../views/InkingStroke';
import { AudioBox } from '../views/nodes/AudioBox';
-import { FontIconBox } from '../views/nodes/button/FontIconBox';
+import { FontIconBox } from '../views/nodes/FontIconBox/FontIconBox';
import { ColorBox } from '../views/nodes/ColorBox';
import { ComparisonBox } from '../views/nodes/ComparisonBox';
import { DataVizBox } from '../views/nodes/DataVizBox/DataVizBox';
@@ -169,8 +169,8 @@ export class DocumentOptions {
_nativeDimModifiable?: BOOLt = new BoolInfo('native dimensions can be modified using document decoration reizers');
_nativeHeightUnfrozen?: BOOLt = new BoolInfo('native height can be changed independent of width by dragging decoration resizers');
- 'acl-Public'?: string; // public permissions
- '_acl-Public'?: string; // public permissions
+ 'acl-Guest'?: string; // public permissions
+ '_acl-Guest'?: string; // public permissions
type?: DTYPEt = new DTypeInfo('type of document', true);
type_collection?: COLLt = new CTypeInfo('how collection is rendered'); // sub type of a collection
_type_collection?: COLLt = new CTypeInfo('how collection is rendered'); // sub type of a collection
@@ -324,8 +324,9 @@ export class DocumentOptions {
badgeValue?: ScriptField;
//LINEAR VIEW
- linearView_IsExpanded?: BOOLt = new BoolInfo('is linear view expanded');
+ linearView_IsOpen?: BOOLt = new BoolInfo('is linear view open');
linearView_Expandable?: BOOLt = new BoolInfo('can linear view be expanded');
+ linearView_Dropdown?: BOOLt = new BoolInfo('can linear view be opened as a dropdown');
linearView_SubMenu?: BOOLt = new BoolInfo('is doc a sub menu of more linear views');
flexGap?: NUMt = new NumInfo('Linear view flex gap');
flexDirection?: 'unset' | 'row' | 'column' | 'row-reverse' | 'column-reverse';
@@ -395,6 +396,7 @@ export class DocumentOptions {
sidebar_color?: string; // background color of text sidebar
sidebar_collectionType?: string; // collection type of text sidebar
+ data_dashboards?: List<any>; // list of dashboards used in shareddocs;
text?: string;
textTransform?: string;
letterSpacing?: string;
@@ -406,6 +408,7 @@ export class DocumentOptions {
clipboard?: Doc;
hoverBackgroundColor?: string; // background color of a label when hovered
+ userBackgroundColor?: STRt = new StrInfo('background color associated with a Dash user (seen in header fields of shared documents)');
userColor?: STRt = new StrInfo('color associated with a Dash user (seen in header fields of shared documents)');
}
export namespace Docs {
@@ -438,6 +441,7 @@ export namespace Docs {
nativeHeightUnfrozen: true,
layout_forceReflow: true,
defaultDoubleClick: 'ignore',
+ systemIcon: 'BsFileEarmarkTextFill',
},
},
],
@@ -459,21 +463,21 @@ export namespace Docs {
DocumentType.IMG,
{
layout: { view: ImageBox, dataField: defaultDataKey },
- options: { freeform: '' },
+ options: { freeform: '', systemIcon: 'BsFileEarmarkImageFill' },
},
],
[
DocumentType.WEB,
{
layout: { view: WebBox, dataField: defaultDataKey },
- options: { _height: 300, _layout_fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true, waitForDoubleClickToClick: 'always' },
+ options: { _height: 300, _layout_fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true, waitForDoubleClickToClick: 'always', systemIcon: 'BsGlobe' },
},
],
[
DocumentType.COL,
{
layout: { view: CollectionView, dataField: defaultDataKey },
- options: { _layout_fitWidth: true, freeform: '', _freeform_panX: 0, _freeform_panY: 0, _freeform_scale: 1 },
+ options: { _layout_fitWidth: true, freeform: '', _freeform_panX: 0, _freeform_panY: 0, _freeform_scale: 1, systemIcon: 'BsFillCollectionFill' },
},
],
[
@@ -487,35 +491,35 @@ export namespace Docs {
DocumentType.VID,
{
layout: { view: VideoBox, dataField: defaultDataKey },
- options: { _layout_currentTimecode: 0 },
+ options: { _layout_currentTimecode: 0, systemIcon: 'BsFileEarmarkPlayFill' },
},
],
[
DocumentType.AUDIO,
{
layout: { view: AudioBox, dataField: defaultDataKey },
- options: { _height: 100, layout_fitWidth: true, layout_forceReflow: true, nativeDimModifiable: true },
+ options: { _height: 100, layout_fitWidth: true, layout_forceReflow: true, nativeDimModifiable: true, systemIcon: 'BsFillVolumeUpFill' },
},
],
[
DocumentType.REC,
{
layout: { view: VideoBox, dataField: defaultDataKey },
- options: { _height: 100, backgroundColor: 'pink' },
+ options: { _height: 100, backgroundColor: 'pink', systemIcon: 'BsFillMicFill' },
},
],
[
DocumentType.PDF,
{
layout: { view: PDFBox, dataField: defaultDataKey },
- options: { _layout_curPage: 1, _layout_fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true },
+ options: { _layout_curPage: 1, _layout_fitWidth: true, nativeDimModifiable: true, nativeHeightUnfrozen: true, systemIcon: 'BsFileEarmarkPdfFill' },
},
],
[
DocumentType.MAP,
{
layout: { view: MapBox, dataField: defaultDataKey },
- options: { _height: 600, _width: 800, nativeDimModifiable: true },
+ options: { _height: 600, _width: 800, nativeDimModifiable: true, systemIcon: 'BsFillPinMapFill' },
},
],
[
@@ -543,14 +547,6 @@ export namespace Docs {
},
],
[
- DocumentType.LINKDB,
- {
- data: new List<Doc>(),
- layout: { view: EmptyBox, dataField: defaultDataKey },
- options: { title: 'Global Link Database' },
- },
- ],
- [
DocumentType.SCRIPTDB,
{
data: new List<Doc>(),
@@ -562,7 +558,7 @@ export namespace Docs {
DocumentType.SCRIPTING,
{
layout: { view: ScriptingBox, dataField: defaultDataKey },
- options: {},
+ options: { systemIcon: 'BsFileEarmarkCodeFill' },
},
],
[
@@ -582,7 +578,7 @@ export namespace Docs {
DocumentType.EQUATION,
{
layout: { view: EquationBox, dataField: 'text' },
- options: { nativeDimModifiable: true, fontSize: '14px', layout_hideResizeHandles: true, layout_hideDecorationTitle: true },
+ options: { nativeDimModifiable: true, fontSize: '14px', layout_hideResizeHandles: true, layout_hideDecorationTitle: true, systemIcon: 'BsCalculatorFill' }, ///systemIcon: 'BsSuperscript' + BsSubscript
},
],
[
@@ -624,7 +620,7 @@ export namespace Docs {
DocumentType.WEBCAM,
{
layout: { view: RecordingBox, dataField: defaultDataKey },
- options: {},
+ options: { systemIcon: 'BsFillCameraVideoFill' },
},
],
[
@@ -646,14 +642,14 @@ export namespace Docs {
{
// NOTE: this is unused!! ink fields are filled in directly within the InkDocument() method
layout: { view: InkingStroke, dataField: 'stroke' },
- options: {},
+ options: { systemIcon: 'BsFillPencilFill' },
},
],
[
DocumentType.SCREENSHOT,
{
layout: { view: ScreenshotBox, dataField: defaultDataKey },
- options: { nativeDimModifiable: true, nativeHeightUnfrozen: true },
+ options: { nativeDimModifiable: true, nativeHeightUnfrozen: true, systemIcon: 'BsCameraFill' },
},
],
[
@@ -661,13 +657,12 @@ export namespace Docs {
{
data: '',
layout: { view: ComparisonBox, dataField: defaultDataKey },
- options: { backgroundColor: 'gray', dropAction: 'move', waitForDoubleClickToClick: 'always' },
+ options: { backgroundColor: 'gray', dropAction: 'move', waitForDoubleClickToClick: 'always', systemIcon: 'BsLayoutSplit' },
},
],
[
DocumentType.GROUPDB,
{
- data: new List<Doc>(),
layout: { view: EmptyBox, dataField: defaultDataKey },
options: { title: 'Global Group Database' },
},
@@ -698,7 +693,7 @@ export namespace Docs {
{
data: '',
layout: { view: PhysicsSimulationBox, dataField: defaultDataKey, _width: 1000, _height: 800 },
- options: { _height: 100, layout_forceReflow: true, nativeHeightUnfrozen: true, mass1: '', mass2: '', nativeDimModifiable: true, position: '', acceleration: '', pendulum: '', spring: '', wedge: '', simulation: '', review: '' },
+ options: { _height: 100, layout_forceReflow: true, nativeHeightUnfrozen: true, mass1: '', mass2: '', nativeDimModifiable: true, position: '', acceleration: '', pendulum: '', spring: '', wedge: '', simulation: '', review: '', systemIcon: 'BsShareFill' },
},
],
]);
@@ -722,7 +717,7 @@ export namespace Docs {
.filter(type => type !== DocumentType.NONE)
.map(type => type + suffix);
// fetch the actual prototype documents from the server
- const actualProtos = Docs.newAccount ? {} : await DocServer.GetRefFields(prototypeIds);
+ const actualProtos = await DocServer.GetRefFields(prototypeIds);
// update this object to include any default values: DocumentOptions for all prototypes
prototypeIds.map(id => {
const existing = actualProtos[id] as Doc;
@@ -747,13 +742,6 @@ export namespace Docs {
}
/**
- * A collection of all links in the database. Ideally, this would be a search, but for now all links are cached here.
- */
- export function MainLinkDocument() {
- return Prototypes.get(DocumentType.LINKDB);
- }
-
- /**
* A collection of all scripts in the database
*/
export function MainScriptDocument() {
@@ -800,6 +788,7 @@ export namespace Docs {
x: 0,
y: 0,
_width: 300,
+ 'acl-Guest': SharingPermissions.View,
...(template.options || {}),
layout: layout.view?.LayoutString(layout.dataField),
data: template.data,
@@ -841,8 +830,7 @@ export namespace Docs {
const { omit: dataProps, extract: viewProps } = OmitKeys(options, viewKeys, '^_');
// dataProps['acl-Override'] = SharingPermissions.Unset;
- dataProps['acl-Public'] = options['acl-Public'] ? options['acl-Public'] : Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.Augment;
-
+ dataProps['acl-Guest'] = options['acl-Guest'] ?? (Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View);
dataProps.isSystem = viewProps.isSystem;
dataProps.isDataDoc = true;
dataProps.author = Doc.CurrentUserEmail;
@@ -864,16 +852,17 @@ export namespace Docs {
dataDoc.proto = proto;
}
- const viewFirstProps: { [id: string]: any } = {};
- viewFirstProps['acl-Public'] = options['_acl-Public'] ? options['_acl-Public'] : Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.Augment;
- // viewFirstProps['acl-Override'] = SharingPermissions.Unset;
- viewFirstProps.author = Doc.CurrentUserEmail;
+ const viewFirstProps: { [id: string]: any } = { author: Doc.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
if (placeholderDoc) {
placeholderDoc._height = options._height !== undefined ? Number(options._height) : undefined;
placeholderDoc._width = options._width !== undefined ? Number(options._width) : undefined;
viewDoc = Doc.assign(placeholderDoc, viewFirstProps, true, true);
+ Array.from(Object.keys(placeholderDoc))
+ .filter(key => key.startsWith('acl'))
+ .forEach(key => (dataDoc[key] = viewDoc[key] = placeholderDoc[key]));
} else {
viewDoc = Doc.assign(Doc.MakeDelegate(dataDoc, delegId), viewFirstProps, true, true);
}
@@ -1013,10 +1002,11 @@ export namespace Docs {
I.rotation = 0;
I.defaultDoubleClick = 'click';
I.author_date = new DateField();
- I['acl-Public'] = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.Augment;
+ I['acl-Guest'] = Doc.defaultAclPrivate ? SharingPermissions.None : SharingPermissions.View;
//I['acl-Override'] = SharingPermissions.Unset;
I[Initializing] = false;
- return I;
+
+ return InstanceFromProto(I, '', options);
}
export function PdfDocument(url: string, options: DocumentOptions = {}, overwriteDoc?: Doc) {
@@ -1052,7 +1042,7 @@ export namespace Docs {
export function FreeformDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
const inst = InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _xPadding: 20, _yPadding: 20, ...options, _type_collection: CollectionViewType.Freeform }, id);
- documents.forEach(d => (d.embedContainer = inst));
+ documents.forEach(d => Doc.SetContainer(d, inst));
return inst;
}
@@ -1125,8 +1115,8 @@ export namespace Docs {
return InstanceFromProto(Prototypes.get(DocumentType.LABEL), undefined, { ...(options || {}) });
}
- export function EquationDocument(options?: DocumentOptions) {
- return InstanceFromProto(Prototypes.get(DocumentType.EQUATION), undefined, { ...(options || {}) }, undefined, 'text');
+ export function EquationDocument(text?: string, options?: DocumentOptions) {
+ return InstanceFromProto(Prototypes.get(DocumentType.EQUATION), text, { ...(options || {}) }, undefined, 'text');
}
export function FunctionPlotDocument(documents: Array<Doc>, options?: DocumentOptions) {
@@ -1157,7 +1147,9 @@ export namespace Docs {
}
export function DockDocument(documents: Array<Doc>, config: string, options: DocumentOptions, id?: string) {
- return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { treeViewFreezeChildren: 'remove|add', ...options, type_collection: CollectionViewType.Docking, dockingConfig: config }, id);
+ const ret = InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { treeViewFreezeChildren: 'remove|add', ...options, type_collection: CollectionViewType.Docking, dockingConfig: config }, id);
+ documents.map(c => Doc.SetContainer(c, ret));
+ return ret;
}
export function DirectoryImportDocument(options: DocumentOptions = {}) {
@@ -1182,10 +1174,13 @@ export namespace Docs {
const doc = DockDocument(
configs.map(c => c.doc),
JSON.stringify(layoutConfig),
- options,
+ Doc.CurrentUserEmail === 'guest' ? options : { 'acl-Guest': SharingPermissions.View, ...options },
id
);
- configs.map(c => (c.doc.embedContainer = doc));
+ configs.map(c => {
+ Doc.SetContainer(c.doc, doc);
+ inheritParentAcls(doc, c.doc, false);
+ });
return doc;
}
@@ -1276,7 +1271,7 @@ export namespace DocUtils {
if (!satisfiesUnsetsFacets || !satisfiesExistsFacets || !satisfiesCheckFacets || failsNotEqualFacets || (matches.length && !satisfiesMatchFacets)) return false;
}
}
- return (parentCollection?.currentFilter as Doc)?.childFilters_boolean === 'OR' ? false : true;
+ return parentCollection?.childFilters_boolean === 'OR' ? false : true;
})
: childDocs;
const rangeFilteredDocs = filteredDocs.filter(d => {
@@ -1345,8 +1340,8 @@ export namespace DocUtils {
source,
target,
{
- 'acl-Public': SharingPermissions.Augment,
- '_acl-Public': SharingPermissions.Augment,
+ 'acl-Guest': SharingPermissions.Augment,
+ '_acl-Guest': SharingPermissions.Augment,
title: ComputedField.MakeFunction('generateLinkTitle(self)') as any,
link_anchor_1_useSmallAnchor: source.useSmallAnchor ? true : undefined,
link_anchor_2_useSmallAnchor: target.useSmallAnchor ? true : undefined,
@@ -1867,8 +1862,6 @@ export namespace DocUtils {
Doc.SetInPlace(ndoc, 'title', ndoc.title + ' ' + NumCast(dragFactory['dragFactory_count']).toString(), true);
}
- if (ndoc && Doc.ActiveDashboard) inheritParentAcls(Doc.ActiveDashboard, ndoc);
-
return ndoc;
}
export function delegateDragFactory(dragFactory: Doc) {