aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/collections/collectionSchema
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/collections/collectionSchema')
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.scss41
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx14
-rw-r--r--src/client/views/collections/collectionSchema/SchemaCellField.tsx4
-rw-r--r--src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx80
-rw-r--r--src/client/views/collections/collectionSchema/SchemaRowBox.tsx12
-rw-r--r--src/client/views/collections/collectionSchema/SchemaTableCell.tsx10
6 files changed, 82 insertions, 79 deletions
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
index c32661214..0bf78f57c 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
@@ -1,4 +1,4 @@
-@import '../../global/globalCssVariables.module.scss';
+@use '../../global/globalCssVariables.module.scss' as global;
.collectionSchemaView {
cursor: default;
@@ -7,7 +7,7 @@
flex-direction: row;
.schema-table {
- background-color: $white;
+ background-color: global.$white;
cursor: grab;
width: 100%;
@@ -49,10 +49,10 @@
.schema-column-menu,
.schema-filter-menu {
- background: $light-gray;
+ background: global.$light-gray;
position: absolute;
- border: 1px solid $medium-gray;
- border-bottom: 2px solid $medium-gray;
+ border: 1px solid global.$medium-gray;
+ border-bottom: 2px solid global.$medium-gray;
max-height: 201px;
display: flex;
overflow: hidden;
@@ -66,7 +66,7 @@
width: 100%;
&:hover {
- background-color: $medium-gray;
+ background-color: global.$medium-gray;
}
.schema-search-result-type {
font-family: 'Courier New', Courier, monospace;
@@ -74,8 +74,8 @@
.schema-search-result-type,
.schema-search-result-desc {
- color: $dark-gray;
- font-size: $body-text;
+ color: global.$dark-gray;
+ font-size: global.$body-text;
}
.schema-search-result-desc {
font-style: italic;
@@ -120,9 +120,9 @@
.schema-column-menu-button {
cursor: pointer;
padding: 2px 5px;
- background: $medium-blue;
+ background: global.$medium-blue;
border-radius: 9999px;
- color: $white;
+ color: global.$white;
width: fit-content;
margin: 5px;
align-self: center;
@@ -141,7 +141,7 @@
}
.schema-column-header {
- background-color: $light-gray;
+ background-color: global.$light-gray;
font-weight: bold;
display: flex;
flex-direction: row;
@@ -149,7 +149,7 @@
align-items: center;
padding: 0;
z-index: 1;
- border: 1px solid $medium-gray;
+ border: 1px solid global.$medium-gray;
.schema-column-title {
flex-grow: 2;
@@ -175,7 +175,7 @@
cursor: ew-resize;
&:hover {
- background-color: $light-blue;
+ background-color: global.$light-blue;
}
}
@@ -188,7 +188,7 @@
min-width: 5px;
transform: translate(-3px, 0px);
align-self: flex-start;
- background-color: $medium-gray;
+ background-color: global.$medium-gray;
}*/ // creates awkward thick gray borders between colheaders
}
@@ -202,7 +202,7 @@
}
.schema-header-row {
- background-color: $light-gray;
+ background-color: global.$light-gray;
overflow: hidden;
}
@@ -226,7 +226,7 @@
.schema-table-cell,
.row-menu {
- border: 1px solid $medium-gray;
+ border: 1px solid global.$medium-gray;
overflow-x: hidden;
overflow-y: auto;
display: inline-flex;
@@ -264,7 +264,7 @@
.row-menu-infos {
position: absolute;
top: 3;
- left: 3;
+ left: 3;
z-index: 1;
display: flex;
justify-content: flex-end;
@@ -278,7 +278,7 @@
.schema-row-button,
.schema-header-button {
- color: $dark-gray;
+ color: global.$dark-gray;
margin: 3px;
cursor: pointer;
display: flex;
@@ -294,7 +294,7 @@
width: 17px;
height: 17px;
border-radius: 30%;
- background-color: $dark-gray;
+ background-color: global.$dark-gray;
color: white;
margin: 3px;
cursor: pointer;
@@ -309,6 +309,5 @@
.schemaField-editing {
outline: none;
+ height: 100%;
}
-
-
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index aef97e723..8e9e8e1cc 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -1,5 +1,5 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { IconButton, Size } from 'browndash-components';
+import { IconButton, Size } from '@dash/components';
import { IReactionDisposer, Lambda, ObservableMap, action, computed, makeObservable, observable, observe, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
@@ -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'];
diff --git a/src/client/views/collections/collectionSchema/SchemaCellField.tsx b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
index 5a64ecc62..e6acff061 100644
--- a/src/client/views/collections/collectionSchema/SchemaCellField.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaCellField.tsx
@@ -21,7 +21,7 @@ import DOMPurify from 'dompurify';
*/
export interface SchemaCellFieldProps {
- contents: FieldType;
+ contents: FieldType | undefined;
fieldContents?: FieldViewProps;
editing?: boolean;
oneLine?: boolean;
@@ -107,7 +107,6 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
this._disposers.fieldUpdate = reaction(
() => this._props.GetValue(),
fieldVal => {
- console.log('Update: ' + this._props.Document.title, this._props.fieldKey, fieldVal);
this._unrenderedContent = fieldVal ?? '';
this.finalizeEdit(false, false, false);
}
@@ -127,7 +126,6 @@ export class SchemaCellField extends ObservableReactComponent<SchemaCellFieldPro
_unmounted = false;
componentWillUnmount(): void {
this._unmounted = true;
- console.log('Unmount: ' + this._props.Document.title, this._props.fieldKey);
this._overlayDisposer?.();
Object.values(this._disposers).forEach(disposer => disposer?.());
this.finalizeEdit(false, true, false);
diff --git a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
index 9ffdd812f..81a2d8e64 100644
--- a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
@@ -17,7 +17,7 @@ import { DocCast } from '../../../../fields/Types';
import { computedFn } from 'mobx-utils';
import { CollectionSchemaView } from './CollectionSchemaView';
import { undoable } from '../../../util/UndoManager';
-import { IconButton, Size } from 'browndash-components';
+import { IconButton, Size } from '@dash/components';
export enum SchemaFieldType {
Header,
@@ -122,45 +122,53 @@ export class SchemaColumnHeader extends ObservableReactComponent<SchemaColumnHea
@computed get editableView() {
const { color, fieldProps, pointerEvents } = this.renderProps(this._props);
- return <div className='schema-column-edit-wrapper' onPointerUp={() => {
- SchemaColumnHeader.isDefaultField(this.fieldKey) && this.openKeyDropdown();
- this._props.schemaView.deselectAllCells();
- }}
- style={{
- color,
- width: '100%',
- pointerEvents,
- }}>
- <EditableView
- ref={r => {this._inputRef = r; this._props.autoFocus && r?.setIsFocused(true)}}
- oneLine={true}
- allowCRs={false}
- contents={''}
- onClick={this.openKeyDropdown}
- fieldContents={fieldProps}
- editing={undefined}
- placeholder={'Add key'}
- updateAlt={this.updateAlt} // alternate title to display
- updateSearch={this.updateKeyDropdown}
- inputString={true}
- inputStringPlaceholder={'Add key'}
- GetValue={() => {
- if (SchemaColumnHeader.isDefaultField(this.fieldKey)) return '';
- else if (this._altTitle) return this._altTitle;
- else return this.fieldKey;
+ return (
+ <div
+ className="schema-column-edit-wrapper"
+ onPointerUp={() => {
+ SchemaColumnHeader.isDefaultField(this.fieldKey) && this.openKeyDropdown();
+ this._props.schemaView.deselectAllCells();
}}
- SetValue={undoable((value: string, shiftKey?: boolean, enterKey?: boolean) => {
- if (enterKey) {
- // if shift & enter, set value of each cell in column
- this.setColumnValues(value, '');
- this._altTitle = undefined;
+ style={{
+ color,
+ width: '100%',
+ pointerEvents,
+ }}>
+ <EditableView
+ ref={r => {
+ this._inputRef = r;
+ this._props.autoFocus && r?.setIsFocused(true);
+ }}
+ oneLine={true}
+ allowCRs={false}
+ contents={''}
+ onClick={this.openKeyDropdown}
+ fieldContents={fieldProps}
+ editing={undefined}
+ placeholder={'Add key'}
+ updateAlt={this.updateAlt} // alternate title to display
+ updateSearch={this.updateKeyDropdown}
+ inputString={true}
+ inputStringPlaceholder={'Add key'}
+ GetValue={() => {
+ if (SchemaColumnHeader.isDefaultField(this.fieldKey)) return '';
+ else if (this._altTitle) return this._altTitle;
+ else return this.fieldKey;
+ }}
+ SetValue={undoable((value: string, shiftKey?: boolean, enterKey?: boolean) => {
+ if (enterKey) {
+ // if shift & enter, set value of each cell in column
+ this.setColumnValues(value, '');
+ this._altTitle = undefined;
+ this._props.finishEdit?.();
+ return true;
+ }
this._props.finishEdit?.();
return true;
- }
- this._props.finishEdit?.();
- return true;
- }, 'edit column header')}/>
+ }, 'edit column header')}
+ />
</div>
+ );
}
public static isDefaultField = (key: string) => {
diff --git a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
index 6ffb0865a..da203abfa 100644
--- a/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaRowBox.tsx
@@ -1,4 +1,4 @@
-import { IconButton, Size } from 'browndash-components';
+import { IconButton, Size } from '@dash/components';
import { computed, makeObservable, observable } from 'mobx';
import { observer } from 'mobx-react';
import { computedFn } from 'mobx-utils';
@@ -100,9 +100,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
return infos;
}
- isolatedSelection = (doc: Doc) => {
- return this.schemaView?.selectionOverlap(doc);
- };
+ isolatedSelection = (doc: Doc) => this.schemaView?.selectionOverlap(doc);
setCursorIndex = (mouseY: number) => this.schemaView?.setRelCursorIndex(mouseY);
selectedCol = () => this.schemaView._selectedCol;
getFinfo = computedFn((fieldKey: string) => this.schemaView?.fieldInfos.get(fieldKey));
@@ -113,9 +111,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
columnWidth = computedFn((index: number) => () => this.schemaView?.displayColumnWidths[index] ?? CollectionSchemaView._minColWidth);
computeRowIndex = () => this.schemaView?.rowIndex(this.Document);
highlightCells = (text: string) => this.schemaView?.highlightCells(text);
- selectReference = (doc: Doc, col: number) => {
- this.schemaView.selectReference(doc, col);
- };
+ selectReference = (doc: Doc, col: number) => this.schemaView.selectReference(doc, col);
eqHighlightFunc = (text: string) => {
const info = this.schemaView.findCellRefs(text);
const cells: HTMLDivElement[] = [];
@@ -188,7 +184,7 @@ export class SchemaRowBox extends ViewBoxBaseComponent<SchemaRowBoxProps>() {
selectedCells={this.selectedCells}
selectedCol={this.selectedCol}
setColumnValues={this.setColumnValues}
- oneLine={BoolCast(this.schemaDoc?._singleLine)}
+ oneLine={BoolCast(this.schemaDoc?._schema_singleLine)}
menuTarget={this.schemaView.MenuTarget}
transform={() => {
const ind = index === this.schemaView.columnKeys.length - 1 ? this.schemaView.columnKeys.length - 3 : index;
diff --git a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
index f036ff843..d404378eb 100644
--- a/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaTableCell.tsx
@@ -1,6 +1,6 @@
/* eslint-disable no-use-before-define */
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { Popup, Size, Type } from 'browndash-components';
+import { Popup, Size, Type } from '@dash/components';
import { action, computed, makeObservable, observable } from 'mobx';
import { observer } from 'mobx-react';
import { extname } from 'path';
@@ -136,7 +136,7 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
PanelHeight: props.rowHeight,
rootSelected: props.rootSelected,
};
- const readOnly = getFinfo(fieldKey)?.readOnly ?? false;
+ const readOnly = false; // getFinfo(fieldKey)?.readOnly ?? false;
const cursor = !readOnly ? 'text' : 'default';
const pointerEvents: 'all' | 'none' = !readOnly && isRowActive() ? 'all' : 'none';
return { color, textDecoration, fieldProps, cursor, pointerEvents };
@@ -232,9 +232,8 @@ export class SchemaTableCell extends ObservableReactComponent<SchemaTableCellPro
if (typeof cellValue === 'number') return ColumnType.Any;
if (typeof cellValue === 'string' && columnTypeStr !== FInfoFieldType.enumeration) return ColumnType.Any;
if (typeof cellValue === 'boolean') return ColumnType.Boolean;
- if (columnTypeStr && columnTypeStr in FInfotoColType) return FInfotoColType[columnTypeStr];
- return ColumnType.Any;
+ return columnTypeStr ? FInfotoColType[columnTypeStr] : ColumnType.Any;
}
get content() {
@@ -402,7 +401,7 @@ export class SchemaDateCell extends ObservableReactComponent<SchemaTableCellProp
</div>
{pointerEvents === 'none' ? null : (
<Popup
- icon={<FontAwesomeIcon size="sm" icon="caret-down" />}
+ icon={<FontAwesomeIcon size="xs" icon="caret-down" />}
size={Size.XSMALL}
type={Type.TERT}
color={SnappingManager.userColor}
@@ -449,6 +448,7 @@ export class SchemaBoolCell extends ObservableReactComponent<SchemaTableCellProp
return (
<div className="schemaBoolCell" style={{ display: 'flex', color, textDecoration, cursor, pointerEvents }}>
<input
+ onPointerDown={e => e.stopPropagation()}
style={{ marginRight: 4 }}
type="checkbox"
checked={BoolCast(this._props.Document[this._props.fieldKey])}