aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections')
-rw-r--r--src/client/views/collections/CollectionCarouselView.tsx3
-rw-r--r--src/client/views/collections/CollectionMenu.tsx44
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx4
-rw-r--r--src/client/views/collections/CollectionView.tsx12
4 files changed, 31 insertions, 32 deletions
diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx
index c969c39e5..4bec2d963 100644
--- a/src/client/views/collections/CollectionCarouselView.tsx
+++ b/src/client/views/collections/CollectionCarouselView.tsx
@@ -10,7 +10,6 @@ import { DocCast, NumCast, ScriptCast, StrCast } from '../../../fields/Types';
import { DocumentType } from '../../documents/DocumentTypes';
import { DragManager } from '../../util/DragManager';
import { ContextMenu } from '../ContextMenu';
-import { ContextMenuProps } from '../ContextMenuItem';
import { StyleProp } from '../StyleProp';
import { DocumentView } from '../nodes/DocumentView';
import { FieldViewProps } from '../nodes/FieldView';
@@ -135,7 +134,7 @@ export class CollectionCarouselView extends CollectionSubView() {
const cm = ContextMenu.Instance;
const revealOptions = cm.findByDescription('Filter Flashcards');
- const revealItems: ContextMenuProps[] = revealOptions && 'subitems' in revealOptions ? revealOptions.subitems : [];
+ const revealItems = revealOptions?.subitems ?? [];
revealItems.push({description: 'All', event: () => {this.layoutDoc.filterOp = undefined;}, icon: 'layer-group',}); // prettier-ignore
revealItems.push({description: 'Star', event: () => {this.layoutDoc.filterOp = cardMode.STAR;}, icon: 'star',}); // prettier-ignore
revealItems.push({description: 'Practice Mode', event: () => {this.layoutDoc.filterOp = cardMode.PRACTICE;}, icon: 'check',}); // prettier-ignore
diff --git a/src/client/views/collections/CollectionMenu.tsx b/src/client/views/collections/CollectionMenu.tsx
index 7b9475590..f1b5e4db2 100644
--- a/src/client/views/collections/CollectionMenu.tsx
+++ b/src/client/views/collections/CollectionMenu.tsx
@@ -19,7 +19,7 @@ import { DragManager } from '../../util/DragManager';
import { dropActionType } from '../../util/DropActionTypes';
import { SnappingManager } from '../../util/SnappingManager';
import { Transform } from '../../util/Transform';
-import { undoBatch } from '../../util/UndoManager';
+import { undoBatch, undoable } from '../../util/UndoManager';
import { AntimodeMenu } from '../AntimodeMenu';
import { EditableView } from '../EditableView';
import { DefaultStyleProvider, returnEmptyDocViewList } from '../StyleProvider';
@@ -181,7 +181,7 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewMenu
params: ['target', 'source'],
title: 'item view',
script: 'this.target.childLayoutTemplate = getDocTemplate(this.source?.[0])',
- immediate: undoBatch((source: Doc[]) => {
+ immediate: undoable((source: Doc[]) => {
let formatStr = source.length && Cast(source[0].text, RichTextField, null)?.Text;
try {
formatStr && JSON.parse(formatStr);
@@ -196,25 +196,25 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewMenu
Doc.SetInPlace(this.target, 'childLayoutString', undefined, true);
Doc.SetInPlace(this.target, 'childLayoutTemplate', undefined, true);
}
- }),
+ }, ''),
initialize: emptyFunction,
};
_narrativeCommand = {
params: ['target', 'source'],
title: 'child click view',
script: 'this.target.childClickedOpenTemplateView = getDocTemplate(this.source?.[0])',
- immediate: undoBatch((source: Doc[]) => {
+ immediate: undoable((source: Doc[]) => {
source.length && (this.target.childClickedOpenTemplateView = Doc.getDocTemplate(source?.[0]));
- }),
+ }, 'narrative command'),
initialize: emptyFunction,
};
_contentCommand = {
params: ['target', 'source'],
title: 'set content',
script: 'getProto(this.target).data = copyField(this.source);',
- immediate: undoBatch((source: Doc[]) => {
+ immediate: undoable((source: Doc[]) => {
this.target[DocData].data = new List<Doc>(source);
- }),
+ }, ''),
initialize: emptyFunction,
};
_onClickCommand = {
@@ -225,19 +225,19 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewMenu
getProto(this.proxy[0]).target = this.target.target;
getProto(this.proxy[0]).source = copyField(this.target.source);
}}`,
- immediate: undoBatch(() => {}),
+ immediate: undoable(() => {}, ''),
initialize: emptyFunction,
};
_viewCommand = {
params: ['target'],
title: 'bookmark view',
script: "this.target._freeform_panX = this.target_freeform_panX; this.target._freeform_panY = this['target-freeform_panY']; this.target._freeform_scale = this['target_freeform_scale']; gotoFrame(this.target, this['target-currentFrame']);",
- immediate: undoBatch(() => {
+ immediate: undoable(() => {
this.target._freeform_panX = 0;
this.target._freeform_panY = 0;
this.target._freeform_scale = 1;
this.target._currentFrame = this.target._currentFrame === undefined ? undefined : 0;
- }),
+ }, ''),
initialize: (button: Doc) => {
button['target-panX'] = this.target._freeform_panX;
button['target-panY'] = this.target._freeform_panY;
@@ -249,18 +249,18 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewMenu
params: ['target'],
title: 'fit content',
script: 'this.target._freeform_fitContentsToBox = !this.target._freeform_fitContentsToBox;',
- immediate: undoBatch(() => {
+ immediate: undoable(() => {
this.target._freeform_fitContentsToBox = !this.target._freeform_fitContentsToBox;
- }),
+ }, ''),
initialize: emptyFunction,
};
_fitContentCommand = {
params: ['target'],
title: 'toggle clusters',
script: 'this.target._freeform_useClusters = !this.target._freeform_useClusters;',
- immediate: undoBatch(() => {
+ immediate: undoable(() => {
this.target._freeform_useClusters = !this.target._freeform_useClusters;
- }),
+ }, ''),
initialize: emptyFunction,
};
_saveFilterCommand = {
@@ -268,10 +268,10 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewMenu
title: 'save filter',
script: `this.target._childFilters = compareLists(this.target_childFilters,this.target._childFilters) ? undefined : copyField(this.target_childFilters);
this.target._searchFilterDocs = compareLists(this.target_searchFilterDocs,this.target._searchFilterDocs) ? undefined: copyField(this.target_searchFilterDocs);`,
- immediate: undoBatch(() => {
+ immediate: undoable(() => {
this.target._childFilters = undefined;
this.target._searchFilterDocs = undefined;
- }),
+ }, ''),
initialize: (button: Doc) => {
const activeDash = Doc.ActiveDashboard;
if (activeDash) {
@@ -594,9 +594,9 @@ export class CollectionGridViewChrome extends React.Component<CollectionViewMenu
*/
onNumColsChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.currentTarget.valueAsNumber > 0)
- undoBatch(() => {
+ undoable(() => {
this.document.gridNumCols = e.currentTarget.valueAsNumber;
- })();
+ }, '')();
};
/**
@@ -625,9 +625,9 @@ export class CollectionGridViewChrome extends React.Component<CollectionViewMenu
onIncrementButtonClick = () => {
this.clicked = true;
this.entered && (this.document.gridNumCols as number)--;
- undoBatch(() => {
+ undoable(() => {
this.document.gridNumCols = this.numCols + 1;
- })();
+ }, '')();
this.entered = false;
};
@@ -638,9 +638,9 @@ export class CollectionGridViewChrome extends React.Component<CollectionViewMenu
this.clicked = true;
if (this.numCols > 1 && !this.decrementLimitReached) {
this.entered && (this.document.gridNumCols as number)++;
- undoBatch(() => {
+ undoable(() => {
this.document.gridNumCols = this.numCols - 1;
- })();
+ }, '')();
if (this.numCols === 1) this.decrementLimitReached = true;
}
this.entered = false;
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index ff316cfbd..0557a9102 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -213,7 +213,7 @@ export class CollectionTreeView extends CollectionSubView<Partial<collectionTree
ContextMenu.Instance.addItem({ description: 'Options...', subitems: layoutItems, icon: 'eye' });
if (!Doc.noviceMode) {
const existingOnClick = ContextMenu.Instance.findByDescription('OnClick...');
- const onClicks: ContextMenuProps[] = existingOnClick.subitems ?? [];
+ const onClicks: ContextMenuProps[] = existingOnClick?.subitems ?? [];
onClicks.push({ description: 'Edit onChecked Script', event: () => UndoManager.RunInBatch(() => DocUtils.makeCustomViewClicked(this.Document, undefined, 'onCheckedClick'), 'edit onCheckedClick'), icon: 'edit' });
!existingOnClick && ContextMenu.Instance.addItem({ description: 'OnClick...', noexpand: true, subitems: onClicks, icon: 'mouse-pointer' });
}
@@ -226,7 +226,7 @@ export class CollectionTreeView extends CollectionSubView<Partial<collectionTree
get editableTitle() {
return (
<EditableView
- contents={this.dataDoc.title}
+ contents={StrCast(this.dataDoc.title)}
display="block"
maxHeight={72}
height="auto"
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 5c304b4a9..c9ab5f661 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -48,7 +48,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<CollectionViewPr
private reactionDisposer: IReactionDisposer | undefined;
@observable _isContentActive: boolean | undefined = undefined;
- constructor(props: any) {
+ constructor(props: CollectionViewProps) {
super(props);
makeObservable(this);
this._annotationKeySuffix = returnEmptyString;
@@ -72,7 +72,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<CollectionViewPr
}
get collectionViewType(): CollectionViewType | undefined {
- const viewField = StrCast(this.layoutDoc._type_collection) as any as CollectionViewType;
+ const viewField = StrCast(this.layoutDoc._type_collection) as CollectionViewType;
if (CollectionView._safeMode) {
switch (viewField) {
case CollectionViewType.Freeform:
@@ -132,7 +132,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<CollectionViewPr
];
const existingVm = ContextMenu.Instance.findByDescription(category);
- const catItems = existingVm && 'subitems' in existingVm ? existingVm.subitems : [];
+ const catItems = existingVm?.subitems ?? [];
catItems.push({ description: 'Add a Perspective...', addDivider: true, noexpand: true, subitems: subItems, icon: 'eye' });
!existingVm && ContextMenu.Instance.addItem({ description: category, subitems: catItems, icon: 'eye' });
}
@@ -151,7 +151,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<CollectionViewPr
});
const options = cm.findByDescription('Options...');
- const optionItems = options && 'subitems' in options ? options.subitems : [];
+ const optionItems = options?.subitems ?? [];
!Doc.noviceMode ? optionItems.splice(0, 0, { description: `${this.Document.forceActive ? 'Select' : 'Force'} Contents Active`, event: () => {this.Document.forceActive = !this.Document.forceActive}, icon: 'project-diagram' }) : null; // prettier-ignore
if (this.Document.childLayout instanceof Doc) {
optionItems.push({ description: 'View Child Layout', event: () => this._props.addDocTab(this.Document.childLayout as Doc, OpenWhere.addRight), icon: 'project-diagram' });
@@ -165,7 +165,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<CollectionViewPr
if (!Doc.noviceMode && !this.Document.annotationOn && !this._props.hideClickBehaviors) {
const existingOnClick = cm.findByDescription('OnClick...');
- const onClicks = existingOnClick && 'subitems' in existingOnClick ? existingOnClick.subitems : [];
+ const onClicks = existingOnClick?.subitems ?? [];
const funcs = [
{ key: 'onChildClick', name: 'On Child Clicked' },
{ key: 'onChildDoubleClick', name: 'On Child Double Clicked' },
@@ -195,7 +195,7 @@ export class CollectionView extends ViewBoxAnnotatableComponent<CollectionViewPr
if (!Doc.noviceMode) {
const more = cm.findByDescription('More...');
- const moreItems = more && 'subitems' in more ? more.subitems : [];
+ const moreItems = more?.subitems ?? [];
moreItems.push({ description: 'Export Image Hierarchy', icon: 'columns', event: () => ImageUtils.ExportHierarchyToFileSystem(this.Document) });
!more && cm.addItem({ description: 'More...', subitems: moreItems, icon: 'hand-point-right' });
}