From 18ef731f66340c759f6818c923e1032bd5b84c7a Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Thu, 21 Mar 2019 01:50:48 -0400 Subject: fixed selections within schema. fixed image double-tap. fixed Open Full Screen --- .../views/collections/CollectionDockingView.tsx | 2 + .../views/collections/CollectionSchemaView.tsx | 151 +++++++-------------- src/client/views/nodes/ImageBox.tsx | 4 +- 3 files changed, 53 insertions(+), 104 deletions(-) (limited to 'src') diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx index 0f0276929..fd0810242 100644 --- a/src/client/views/collections/CollectionDockingView.tsx +++ b/src/client/views/collections/CollectionDockingView.tsx @@ -61,6 +61,7 @@ export class CollectionDockingView extends React.Component - this.key && this.props.toggle(this.key)} /> {this.key.Name} + this.key && this.props.toggle(this.key)} /> + {this.key.Name} ) - } else { - return
} + return (null); } } @observer export class CollectionSchemaView extends CollectionViewBase { private _mainCont = React.createRef(); + private _startSplitPercent = 0; private DIVIDER_WIDTH = 4; @observable _columns: Array = [KeyStore.Title, KeyStore.Data, KeyStore.Author]; @@ -64,6 +65,8 @@ export class CollectionSchemaView extends CollectionViewBase { @observable _panelHeight = 0; @observable _selectedIndex = 0; @observable _columnsPercentage = 0; + @observable _keys: Key[] = []; + @computed get splitPercentage() { return this.props.Document.GetNumber(KeyStore.SchemaSplitPercentage, 0); } @@ -124,9 +127,8 @@ export class CollectionSchemaView extends CollectionViewBase { } return { onClick: action((e: React.MouseEvent, handleOriginal: Function) => { + that.props.select(e.ctrlKey); that._selectedIndex = rowInfo.index; - // bcz - ugh - needed to force Measure to do its thing and call onResize - this.props.Document.SetNumber(KeyStore.SchemaSplitPercentage, this.splitPercentage - 0.05) if (handleOriginal) { handleOriginal() @@ -165,27 +167,14 @@ export class CollectionSchemaView extends CollectionViewBase { this.props.Document.SetNumber(KeyStore.SchemaSplitPercentage, this.splitPercentage == 0 ? 33 : 0); } } - - @observable keys: Key[] = []; - findAllDocumentKeys = (): { [id: string]: boolean } => { const docs = this.props.Document.GetList(this.props.fieldKey, []); let keys: { [id: string]: boolean } = {} - docs.forEach(doc => { - let protos = doc.GetAllPrototypes(); - for (const proto of protos) { - proto._proxies.forEach((val: any, key: string) => { - keys[key] = false - }) - } - }) - this.columns.forEach(key => { - keys[key.Id] = true; - }) + docs.map(doc => doc.GetAllPrototypes().map(proto => proto._proxies.forEach((val: any, key: string) => keys[key] = false))); + this.columns.forEach(key => keys[key.Id] = true) return keys; } - _startSplitPercent = 0; @action onDividerMove = (e: PointerEvent): void => { let nativeWidth = this._mainCont.current!.getBoundingClientRect(); @@ -207,51 +196,11 @@ export class CollectionSchemaView extends CollectionViewBase { document.addEventListener('pointerup', this.onDividerUp); } - + @observable _tableWidth = 0; @action - onColDividerMove = (e: PointerEvent): void => { - let nativeWidth = this._mainCont.current!.getBoundingClientRect(); - this._columnsPercentage = 100 - (e.clientY - nativeWidth.top) / nativeWidth.height * 100; + setTableDimensions = (r: any) => { + this._tableWidth = r.entry.width; } - @action - onColDividerUp = (e: PointerEvent): void => { - document.removeEventListener("pointermove", this.onColDividerMove); - document.removeEventListener('pointerup', this.onColDividerUp); - } - onColDividerDown = (e: React.PointerEvent) => { - e.stopPropagation(); - e.preventDefault(); - document.addEventListener("pointermove", this.onColDividerMove); - document.addEventListener('pointerup', this.onColDividerUp); - } - - @action - onExpanderMove = (e: PointerEvent): void => { - e.stopPropagation(); - e.preventDefault(); - } - - @action - onColumnsMove = (e: PointerEvent): void => { - e.stopPropagation(); - e.preventDefault(); - } - @action - onColumnsUp = (e: PointerEvent): void => { - e.stopPropagation(); - e.preventDefault(); - document.removeEventListener("pointermove", this.onColumnsMove); - document.removeEventListener('pointerup', this.onColumnsUp); - this._columnsPercentage = this._columnsPercentage ? 0 : 50; - } - onColumnsDown = (e: React.PointerEvent) => { - this._startSplitPercent = this.splitPercentage; - e.stopPropagation(); - e.preventDefault(); - document.addEventListener("pointermove", this.onColumnsMove); - document.addEventListener('pointerup', this.onColumnsUp); - } - @action setScaling = (r: any) => { const children = this.props.Document.GetList(this.props.fieldKey, []); @@ -267,11 +216,16 @@ export class CollectionSchemaView extends CollectionViewBase { getTransform = (): Transform => { return this.props.ScreenToLocalTransform().translate(- COLLECTION_BORDER_WIDTH - this.DIVIDER_WIDTH - this._dividerX, - COLLECTION_BORDER_WIDTH).scale(1 / this._contentScaling); } + getPreviewTransform = (): Transform => { + return this.props.ScreenToLocalTransform().translate(- COLLECTION_BORDER_WIDTH - this.DIVIDER_WIDTH - this._dividerX - this._tableWidth, - COLLECTION_BORDER_WIDTH).scale(1 / this._contentScaling); + } focusDocument = (doc: Document) => { } onPointerDown = (e: React.PointerEvent): void => { - // + if (this.props.isSelected()) { + e.stopPropagation(); + } } render() { @@ -289,7 +243,7 @@ export class CollectionSchemaView extends CollectionViewBase { AddDocument={this.props.addDocument} RemoveDocument={this.props.removeDocument} isTopMost={false} SelectOnLoad={false} - ScreenToLocalTransform={this.getTransform} + ScreenToLocalTransform={this.getPreviewTransform} ContentScaling={this.getContentScaling} PanelWidth={this.getPanelWidth} PanelHeight={this.getPanelHeight} @@ -326,34 +280,27 @@ export class CollectionSchemaView extends CollectionViewBase { return (
this.onDrop(e, {})} ref={this.createDropTarget}> - { - this._dividerX = r.entry.width; - this._panelHeight = r.entry.height; - })}> + {({ measureRef }) => -
-
- ({ - Header: col.Name, - accessor: (doc: Document) => [doc, col], - id: col.Id - }))} - column={{ - ...ReactTableDefaults.column, - Cell: this.renderCell, +
+ ({ + Header: col.Name, + accessor: (doc: Document) => [doc, col], + id: col.Id + }))} + column={{ + ...ReactTableDefaults.column, + Cell: this.renderCell, - }} - getTrProps={this.getTrProps} - /> -
-
- } + }} + getTrProps={this.getTrProps} + /> +
}
{dividerDragger}
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx index 2db0cc4e2..60d1f7214 100644 --- a/src/client/views/nodes/ImageBox.tsx +++ b/src/client/views/nodes/ImageBox.tsx @@ -50,7 +50,7 @@ export class ImageBox extends React.Component { onPointerDown = (e: React.PointerEvent): void => { if (Date.now() - this._lastTap < 300) { - if (e.buttons === 1 && this.props.isSelected()) { + if (e.buttons === 1) { e.stopPropagation(); this._downX = e.clientX; this._downY = e.clientY; @@ -72,7 +72,7 @@ export class ImageBox extends React.Component { lightbox = (path: string) => { const images = [path]; - if (this._isOpen && this.props.isSelected()) { + if (this._isOpen) { return (