aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2025-05-05 12:37:09 -0400
committerbobzel <zzzman@gmail.com>2025-05-05 12:37:09 -0400
commit3a733aa0fd24517e83649824dec0fc8bcc0bde43 (patch)
treeac01848cdab3b83582c0b7ab6f3d2b1c8187a24f /src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
parente058d227ccbce47c86b0fa558adb01dfccaf4d60 (diff)
parentd4659e2bd3ddb947683948083232c26fb1227f39 (diff)
Merge branch 'master' into joanne-tutorialagent
Diffstat (limited to 'src/client/views/collections/collectionSchema/CollectionSchemaView.tsx')
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index 5a5cc3622..c06391f35 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -12,7 +12,7 @@ import { List } from '../../../../fields/List';
import { ColumnType } from '../../../../fields/SchemaHeaderField';
import { BoolCast, NumCast, StrCast } from '../../../../fields/Types';
import { DocUtils } from '../../../documents/DocUtils';
-import { Docs, DocumentOptions, FInfo } from '../../../documents/Documents';
+import { Docs, DocumentOptions, FInfo, FInfoFieldType } from '../../../documents/Documents';
import { DocumentManager } from '../../../util/DocumentManager';
import { DragManager } from '../../../util/DragManager';
import { dropActionType } from '../../../util/DropActionTypes';
@@ -49,14 +49,16 @@ import { SchemaRowBox } from './SchemaRowBox';
// eslint-disable-next-line @typescript-eslint/no-require-imports
const { SCHEMA_NEW_NODE_HEIGHT } = require('../../global/globalCssVariables.module.scss'); // prettier-ignore
-export const FInfotoColType: { [key: string]: ColumnType } = {
+export const FInfotoColType: { [key in FInfoFieldType]: ColumnType } = {
string: ColumnType.String,
number: ColumnType.Number,
boolean: ColumnType.Boolean,
date: ColumnType.Date,
- image: ColumnType.Image,
- rtf: ColumnType.RTF,
- enumeration: ColumnType.Enumeration,
+ richtext: ColumnType.RTF,
+ enum: ColumnType.Enumeration,
+ Doc: ColumnType.Any,
+ list: ColumnType.Any,
+ map: ColumnType.Any,
};
const defaultColumnKeys: string[] = ['title', 'type', 'author', 'author_date', 'text'];
@@ -198,7 +200,7 @@ export class CollectionSchemaView extends CollectionSubView() {
this._props.setContentViewBox?.(this);
document.addEventListener('keydown', this.onKeyDown);
- Object.entries(this._documentOptions).forEach((pair: [string, FInfo]) => this.fieldInfos.set(pair[0], pair[1]));
+ Object.entries(this._documentOptions).forEach(pair => this.fieldInfos.set(pair[0], pair[1] as FInfo));
this._keysDisposer = observe(
this.dataDoc[this.fieldKey ?? 'data'] as List<Doc>,
change => {
@@ -250,7 +252,8 @@ export class CollectionSchemaView extends CollectionSubView() {
@action
onKeyDown = (e: KeyboardEvent) => {
if (this._selectedDocs.length > 0) {
- switch (e.key) {
+ switch (e.key + (e.shiftKey ? 'Shift' : '')) {
+ case 'Enter':
case 'ArrowDown':
{
const lastDoc = this._selectedDocs.lastElement();
@@ -270,6 +273,7 @@ export class CollectionSchemaView extends CollectionSubView() {
e.preventDefault();
}
break;
+ case 'EnterShift':
case 'ArrowUp':
{
const firstDoc = this._selectedDocs.lastElement();
@@ -289,6 +293,7 @@ export class CollectionSchemaView extends CollectionSubView() {
e.preventDefault();
}
break;
+ case 'Tab':
case 'ArrowRight':
if (this._selectedCells) {
this._selectedCol = Math.min(this._colEles.length - 1, this._selectedCol + 1);
@@ -296,6 +301,7 @@ export class CollectionSchemaView extends CollectionSubView() {
this.selectCell(this._selectedDocs[0], 0, false, false);
}
break;
+ case 'TabShift':
case 'ArrowLeft':
if (this._selectedCells) {
this._selectedCol = Math.max(0, this._selectedCol - 1);
@@ -1187,7 +1193,7 @@ export class CollectionSchemaView extends CollectionSubView() {
let notFiltered = d.z || Doc.IsSystem(d) || DocUtils.FilterDocs([d], this.unrecursiveDocFilters(), childFiltersByRanges, this.Document).length > 0;
if (notFiltered) {
notFiltered = (!searchDocs.length || searchDocs.includes(d)) && DocUtils.FilterDocs([d], childDocFilters, childFiltersByRanges, this.Document).length > 0;
- const fieldKey = Doc.LayoutFieldKey(d);
+ const fieldKey = Doc.LayoutDataKey(d);
const isAnnotatableDoc = d[fieldKey] instanceof List && !(d[fieldKey] as List<Doc>)?.some(ele => !(ele instanceof Doc));
const docChildDocs = d[isAnnotatableDoc ? fieldKey + '_annotations' : fieldKey];
const sidebarDocs = isAnnotatableDoc && d[fieldKey + '_sidebar'];
@@ -1200,7 +1206,7 @@ export class CollectionSchemaView extends CollectionSubView() {
newarray = [];
// eslint-disable-next-line no-loop-func
subDocs.forEach(t => {
- const docFieldKey = Doc.LayoutFieldKey(t);
+ const docFieldKey = Doc.LayoutDataKey(t);
const isSubDocAnnotatable = t[docFieldKey] instanceof List && !(t[docFieldKey] as List<Doc>)?.some(ele => !(ele instanceof Doc));
notFiltered = notFiltered || ((!searchDocs.length || searchDocs.includes(t)) && ((!childDocFilters.length && !childFiltersByRanges.length) || DocUtils.FilterDocs([t], childDocFilters, childFiltersByRanges, d).length));
DocListCast(t[isSubDocAnnotatable ? docFieldKey + '_annotations' : docFieldKey]).forEach(newdoc => newarray.push(newdoc));
@@ -1287,7 +1293,6 @@ export class CollectionSchemaView extends CollectionSubView() {
isContentActive = () => this._props.isSelected() || this._props.isContentActive();
screenToLocal = () => this.ScreenToLocalBoxXf().translate(-this.tableWidth, 0);
previewWidthFunc = () => this.previewWidth;
- onPassiveWheel = (e: WheelEvent) => e.stopPropagation();
displayedDocsFunc = () => this.docsWithDrag.docs;
render() {
return (
@@ -1301,15 +1306,7 @@ export class CollectionSchemaView extends CollectionSubView() {
this.setColDrag(false);
}}>
<div ref={this._menuTarget} style={{ background: 'red', top: 0, left: 0, position: 'absolute', zIndex: 10000 }} />
- <div
- className="schema-table"
- style={{ width: `calc(100% - ${this.previewWidth}px)` }}
- onWheel={e => this._props.isContentActive() && e.stopPropagation()}
- ref={ele => {
- // prevent wheel events from passively propagating up through containers and prevents containers from preventDefault which would block scrolling
- this._oldWheel?.removeEventListener('wheel', this.onPassiveWheel);
- (this._oldWheel = ele)?.addEventListener('wheel', this.onPassiveWheel, { passive: false });
- }}>
+ <div className="schema-table" style={{ width: `calc(100% - ${this.previewWidth}px)` }} onWheel={e => this._props.isContentActive() && e.stopPropagation()} ref={ele => this.fixWheelEvents(ele, this._props.isContentActive)}>
<div className="schema-header-row" style={{ height: this.rowHeightFunc() }}>
<div className="row-menu" style={{ width: CollectionSchemaView._rowMenuWidth }}>
<IconButton