aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/CollectionMenu.tsx
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/views/collections/CollectionMenu.tsx
parent0e975569e5686138e52bdc554b3f0391f42aeead (diff)
parente57584a1be9d428fb40fc789494a7ac0ac14fb84 (diff)
fixed up a bunch of things in face recognition
Diffstat (limited to 'src/client/views/collections/CollectionMenu.tsx')
-rw-r--r--src/client/views/collections/CollectionMenu.tsx75
1 files changed, 32 insertions, 43 deletions
diff --git a/src/client/views/collections/CollectionMenu.tsx b/src/client/views/collections/CollectionMenu.tsx
index 3eb3008c4..dab1298d5 100644
--- a/src/client/views/collections/CollectionMenu.tsx
+++ b/src/client/views/collections/CollectionMenu.tsx
@@ -1,7 +1,3 @@
-/* eslint-disable jsx-a11y/label-has-associated-control */
-/* eslint-disable jsx-a11y/no-static-element-interactions */
-/* eslint-disable jsx-a11y/click-events-have-key-events */
-/* eslint-disable jsx-a11y/control-has-associated-label */
/* eslint-disable react/no-unused-class-component-methods */
/* eslint-disable react/sort-comp */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
@@ -10,20 +6,20 @@ import { Toggle, ToggleType, Type } from 'browndash-components';
import { Lambda, action, computed, makeObservable, observable, reaction, runInAction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
-import { ClientUtils, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue, setupMoveUpEvents } from '../../../ClientUtils';
+import { ClientUtils, returnEmptyFilter, returnFalse, returnTrue, setupMoveUpEvents } from '../../../ClientUtils';
import { emptyFunction } from '../../../Utils';
-import { Doc, DocListCast, Opt } from '../../../fields/Doc';
+import { Doc, DocListCast, Opt, returnEmptyDoclist } from '../../../fields/Doc';
import { DocData } from '../../../fields/DocSymbols';
import { List } from '../../../fields/List';
import { ObjectField } from '../../../fields/ObjectField';
import { RichTextField } from '../../../fields/RichTextField';
-import { BoolCast, Cast, DocCast, NumCast, StrCast } from '../../../fields/Types';
+import { BoolCast, Cast, NumCast, StrCast } from '../../../fields/Types';
import { CollectionViewType, DocumentType } from '../../documents/DocumentTypes';
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';
@@ -47,7 +43,7 @@ export class CollectionMenu extends AntimodeMenu<CollectionMenuProps> {
private _docBtnRef = React.createRef<HTMLDivElement>();
- constructor(props: any) {
+ constructor(props: CollectionMenuProps) {
super(props);
makeObservable(this);
CollectionMenu.Instance = this;
@@ -185,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);
@@ -200,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 = {
@@ -229,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;
@@ -253,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 = {
@@ -272,15 +268,15 @@ 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) {
- button.target_childFilters = (Doc.MySearcher._childFilters || activeDash._childFilters) instanceof ObjectField ? ObjectField.MakeCopy((Doc.MySearcher._childFilters || activeDash._childFilters) as any as ObjectField) : undefined;
- button.target_searchFilterDocs = activeDash._searchFilterDocs instanceof ObjectField ? ObjectField.MakeCopy(activeDash._searchFilterDocs as any as ObjectField) : undefined;
+ button.target_childFilters = (Doc.MySearcher._childFilters || activeDash._childFilters) instanceof ObjectField ? ObjectField.MakeCopy((Doc.MySearcher._childFilters || activeDash._childFilters) as ObjectField) : undefined;
+ button.target_searchFilterDocs = activeDash._searchFilterDocs instanceof ObjectField ? ObjectField.MakeCopy(activeDash._searchFilterDocs) : undefined;
}
},
};
@@ -338,15 +334,9 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewMenu
this._currentKey = this._currentKey || (this._buttonizableCommands?.length ? this._buttonizableCommands[0]?.title : '');
});
- @undoBatch
- viewChanged = (e: React.ChangeEvent) => {
- const target = this.document !== Doc.MyLeftSidebarPanel ? this.document : DocCast(this.document.proto);
- target._type_collection = (e.target as any).selectedOptions[0].value;
- };
-
- commandChanged = (e: React.ChangeEvent) => {
+ commandChanged = (e: React.ChangeEvent<HTMLSelectElement>) => {
runInAction(() => {
- this._currentKey = (e.target as any).selectedOptions[0].value;
+ this._currentKey = e.target.selectedOptions[0].value;
});
};
@@ -485,7 +475,7 @@ export class CollectionNoteTakingViewChrome extends React.Component<CollectionVi
};
@action
- onKeyChange = (e: React.ChangeEvent, { newValue }: { newValue: string }) => {
+ onKeyChange = (e: React.FormEvent<Element>, { newValue }: { newValue: string }) => {
this._currentKey = newValue;
};
@@ -538,7 +528,6 @@ export class CollectionNoteTakingViewChrome extends React.Component<CollectionVi
autosuggestProps: {
inputProps: {
value: this._currentKey,
- // @ts-ignore
onChange: this.onKeyChange,
},
getSuggestionValue: this.getSuggestionValue,
@@ -605,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;
- })();
+ }, '')();
};
/**
@@ -636,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;
};
@@ -649,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;
@@ -733,7 +722,7 @@ export class CollectionGridViewChrome extends React.Component<CollectionViewMenu
onChange={this.changeCompactType}
value={StrCast(this.document.gridStartCompaction, StrCast(this.document.gridCompaction))}>
{['vertical', 'horizontal', 'none'].map(type => (
- <option className="collectionGridViewChrome-viewOption" onPointerDown={stopPropagation} value={type}>
+ <option key={type} className="collectionGridViewChrome-viewOption" onPointerDown={stopPropagation} value={type}>
{this.resize ? type[0].toUpperCase() + type.substring(1) : 'Compact: ' + type}
</option>
))}