From a722aab6a65ad8d222ec3d576497ce9687cac966 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 8 Oct 2020 00:44:43 -0400 Subject: fixed adding/removing schema columns. fixed showing text/ink tools in menu at right time. cleaned up schema view a bit and fixed drag bar from disappearing when shown in full tab. --- src/client/views/collections/CollectionMenu.tsx | 4 +- .../views/collections/CollectionSchemaView.scss | 5 +- .../views/collections/CollectionSchemaView.tsx | 148 +++++++-------------- src/client/views/collections/SchemaTable.tsx | 6 +- src/client/views/globalCssVariables.scss | 2 + src/client/views/globalCssVariables.scss.d.ts | 1 + .../views/nodes/formattedText/FormattedTextBox.tsx | 1 + .../views/nodes/formattedText/RichTextMenu.tsx | 4 +- src/server/websocket.ts | 4 +- 9 files changed, 63 insertions(+), 112 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionMenu.tsx b/src/client/views/collections/CollectionMenu.tsx index 4bdb233c9..429764154 100644 --- a/src/client/views/collections/CollectionMenu.tsx +++ b/src/client/views/collections/CollectionMenu.tsx @@ -528,9 +528,7 @@ export class CollectionFreeFormViewChrome extends React.Component = new Map([ @observer export class CollectionSchemaView extends CollectionSubView(doc => doc) { private _previewCont?: HTMLDivElement; - private DIVIDER_WIDTH = 4; - - @observable previewDoc: Doc | undefined = undefined; - @observable private _focusedTable: Doc = this.props.Document; - - @computed get previewWidth() { return () => NumCast(this.props.Document.schemaPreviewWidth); } - @computed get previewHeight() { return () => this.props.PanelHeight() - 2 * this.borderWidth; } - @computed get tableWidth() { return this.props.PanelWidth() - 2 * this.borderWidth - this.DIVIDER_WIDTH - this.previewWidth(); } - @computed get borderWidth() { return Number(COLLECTION_BORDER_WIDTH); } + @observable _previewDoc: Doc | undefined = undefined; + @observable _focusedTable: Doc = this.props.Document; + @observable _col: any = ""; @observable _menuWidth = 0; @observable _headerOpen = false; @observable _headerIsEditing = false; - @observable _col: any = ""; @observable _menuHeight = 0; @observable _pointerX = 0; @observable _pointerY = 0; @observable _openTypes: boolean = false; + + @computed get previewWidth() { return () => NumCast(this.props.Document.schemaPreviewWidth); } + @computed get previewHeight() { return () => this.props.PanelHeight() - 2 * this.borderWidth; } + @computed get tableWidth() { return this.props.PanelWidth() - 2 * this.borderWidth - Number(SCHEMA_DIVIDER_WIDTH) - this.previewWidth(); } + @computed get borderWidth() { return Number(COLLECTION_BORDER_WIDTH); } + @computed get scale() { return this.props.ScreenToLocalTransform().Scale; } + @computed get columns() { return Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []); } + set columns(columns: SchemaHeaderField[]) { this.props.Document._schemaHeaders = new List(columns); } + @computed get menuCoordinates() { let searchx = 0; let searchy = 0; @@ -81,15 +83,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { return this.props.ScreenToLocalTransform().transformPoint(x, y); } - @computed get scale() { return this.props.ScreenToLocalTransform().Scale; } - - @computed get columns() { - return Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []); - } - set columns(columns: SchemaHeaderField[]) { - this.props.Document._schemaHeaders = new List(columns); - } - get documentKeys() { const docs = this.childDocs; const keys: { [key: string]: boolean } = {}; @@ -104,27 +97,12 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { this.columns.forEach(key => keys[key.heading] = true); return Array.from(Object.keys(keys)); } - @computed get possibleKeys() { return this.documentKeys.filter(key => this.columns.findIndex(existingKey => existingKey.heading.toUpperCase() === key.toUpperCase()) === -1); } @action setHeaderIsEditing = (isEditing: boolean) => this._headerIsEditing = isEditing; - - @action - changeColumnType = (type: ColumnType, col: any): void => { - this._openTypes = false; - this.setColumnType(col, type); - } - - changeColumnSort = (desc: boolean | undefined, col: any): void => { - this.setColumnSort(col, desc); - } - - changeColumnColor = (color: string, col: any): void => { - this.setColumnColor(col, color); - } - @undoBatch setColumnType = (columnField: SchemaHeaderField, type: ColumnType): void => { + this._openTypes = false; if (columnTypes.get(columnField.heading)) return; const columns = this.columns; @@ -165,42 +143,42 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { const type = col.type; - const anyType =
this.changeColumnType(ColumnType.Any, col)}> + const anyType =
this.setColumnType(col, ColumnType.Any)}> Any
; - const numType =
this.changeColumnType(ColumnType.Number, col)}> + const numType =
this.setColumnType(col, ColumnType.Number)}> Number
; - const textType =
this.changeColumnType(ColumnType.String, col)}> + const textType =
this.setColumnType(col, ColumnType.String)}> Text
; - const boolType =
this.changeColumnType(ColumnType.Boolean, col)}> + const boolType =
this.setColumnType(col, ColumnType.Boolean)}> Checkbox
; - const listType =
this.changeColumnType(ColumnType.List, col)}> + const listType =
this.setColumnType(col, ColumnType.List)}> List
; - const docType =
this.changeColumnType(ColumnType.Doc, col)}> + const docType =
this.setColumnType(col, ColumnType.Doc)}> Document
; - const imageType =
this.changeColumnType(ColumnType.Image, col)}> + const imageType =
this.setColumnType(col, ColumnType.Image)}> Image
; - const dateType =
this.changeColumnType(ColumnType.Date, col)}> + const dateType =
this.setColumnType(col, ColumnType.Date)}> Date
; @@ -239,15 +217,15 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
-
this.changeColumnSort(true, col)}> +
this.setColumnSort(col, true)}> Sort descending
-
this.changeColumnSort(false, col)}> +
this.setColumnSort(col, false)}> Sort ascending
-
this.changeColumnSort(undefined, col)}> +
this.setColumnSort(col, undefined)}> Clear sorting
@@ -270,12 +248,12 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
-
this.changeColumnColor(pink!, col)}>
-
this.changeColumnColor(purple!, col)}>
-
this.changeColumnColor(blue!, col)}>
-
this.changeColumnColor(yellow!, col)}>
-
this.changeColumnColor(red!, col)}>
-
this.changeColumnColor(gray, col)}>
+
this.setColumnColor(col, pink!)}>
+
this.setColumnColor(col, purple!)}>
+
this.setColumnColor(col, blue!)}>
+
this.setColumnColor(col, yellow!)}>
+
this.setColumnColor(col, red!)}>
+
this.setColumnColor(col, gray)}>
); @@ -320,8 +298,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { @action closeHeader = () => { this._headerOpen = false; } - - @undoBatch @action deleteColumn = (key: string) => { @@ -351,15 +327,12 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) { onWheel(e: React.WheelEvent) { const scale = this.props.ScreenToLocalTransform().Scale; this.props.active(true) && e.stopPropagation(); - //this.menuCoordinates[0] -= e.screenX / scale; - //this.menuCoordinates[1] -= e.screenY / scale; } @computed get renderMenuContent() { TraceMobx(); return
{this.renderTypes(this._col)} - {/* {this.renderSorting(this._col)} */} {this.renderColors(this._col)}