aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.scss2
-rw-r--r--src/client/views/collections/collectionSchema/CollectionSchemaView.tsx29
-rw-r--r--src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx15
4 files changed, 16 insertions, 32 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index c80bafe26..3a8edb1a5 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -1358,7 +1358,7 @@ export class CollectionFreeFormView extends CollectionSubView<Partial<collection
case OpenWhere.inParentFromScreen:
const docContext = DocCast((doc instanceof Doc ? doc : doc?.[0])?.context);
return (
- (this.props.addDocument?.(
+ (this.addDocument?.(
(doc instanceof Doc ? [doc] : doc).map(doc => {
const pt = this.getTransform().transformPoint(NumCast(doc.x), NumCast(doc.y));
doc.x = pt[0];
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
index 287e2b01b..c96773298 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.scss
@@ -115,6 +115,8 @@
.schema-column-title {
flex-grow: 2;
margin: 5px;
+ overflow: hidden;
+ min-width: 20%;
}
.schema-header-menu {
diff --git a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
index b97a2393d..d92ccc344 100644
--- a/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
+++ b/src/client/views/collections/collectionSchema/CollectionSchemaView.tsx
@@ -38,7 +38,7 @@ export enum ColumnType {
Image,
}
-const defaultColumnKeys: string[] = ['title', 'type', 'author', 'creationDate', 'links'];
+const defaultColumnKeys: string[] = ['title', 'type', 'author', 'creationDate', 'text'];
@observer
export class CollectionSchemaView extends CollectionSubView() {
@@ -49,7 +49,7 @@ export class CollectionSchemaView extends CollectionSubView() {
private _makeNewColumn: boolean = false;
public static _rowHeight: number = 40;
- public static _minColWidth: number = 150;
+ public static _minColWidth: number = 25;
public static _rowMenuWidth: number = 100;
public static _previewDividerWidth: number = 4;
@@ -207,16 +207,13 @@ export class CollectionSchemaView extends CollectionSubView() {
this.addNewKey(key, defaultVal);
}
- let currWidths = [...this.storedColumnWidths];
- const newColWidth = this.tableWidth / (currWidths.length + 1);
- currWidths = currWidths.map(w => {
- const proportion = w / (this.tableWidth - CollectionSchemaView._rowMenuWidth);
- return proportion * (this.tableWidth - CollectionSchemaView._rowMenuWidth - newColWidth);
- });
+ const newColWidth = this.tableWidth / (this.storedColumnWidths.length + 1);
+ const currWidths = this.storedColumnWidths.slice();
currWidths.splice(0, 0, newColWidth);
- this.layoutDoc.columnWidths = new List<number>(currWidths);
+ const newDesiredTableWidth = currWidths.reduce((w, cw) => w + cw, 0);
+ this.layoutDoc.columnWidths = new List<number>(currWidths.map(w => (w / newDesiredTableWidth) * (this.tableWidth - CollectionSchemaView._rowMenuWidth)));
- let currKeys = [...this.columnKeys];
+ let currKeys = this.columnKeys.slice();
currKeys.splice(0, 0, key);
this.layoutDoc.columnKeys = new List<string>(currKeys);
};
@@ -230,16 +227,12 @@ export class CollectionSchemaView extends CollectionSubView() {
@action
removeColumn = (index: number) => {
if (this.columnKeys.length === 1) return;
- let currWidths = [...this.storedColumnWidths];
- const removedColWidth = currWidths[index];
- currWidths = currWidths.map(w => {
- const proportion = w / (this.tableWidth - CollectionSchemaView._rowMenuWidth - removedColWidth);
- return proportion * (this.tableWidth - CollectionSchemaView._rowMenuWidth);
- });
+ const currWidths = this.storedColumnWidths.slice();
currWidths.splice(index, 1);
- this.layoutDoc.columnWidths = new List<number>(currWidths);
+ const newDesiredTableWidth = currWidths.reduce((w, cw) => w + cw, 0);
+ this.layoutDoc.columnWidths = new List<number>(currWidths.map(w => (w / newDesiredTableWidth) * (this.tableWidth - CollectionSchemaView._rowMenuWidth)));
- let currKeys = [...this.columnKeys];
+ let currKeys = this.columnKeys.slice();
currKeys.splice(index, 1);
this.layoutDoc.columnKeys = new List<string>(currKeys);
};
diff --git a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
index e648356f4..fffe0f4b4 100644
--- a/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
+++ b/src/client/views/collections/collectionSchema/SchemaColumnHeader.tsx
@@ -1,21 +1,10 @@
import React = require('react');
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, computed, observable } from 'mobx';
+import { action, computed } from 'mobx';
import { observer } from 'mobx-react';
import { emptyFunction, setupMoveUpEvents } from '../../../../Utils';
-import './CollectionSchemaView.scss';
-import { ColumnType } from './CollectionSchemaView';
-import { IconButton } from 'browndash-components';
import { Colors } from '../../global/globalEnums';
-import { ContextMenu } from '../../ContextMenu';
-import { Doc, DocListCast } from '../../../../fields/Doc';
-import { Id } from '../../../../fields/FieldSymbols';
-import { RichTextField } from '../../../../fields/RichTextField';
-import { StrCast } from '../../../../fields/Types';
-import { ImageField } from '../../../../fields/URLField';
-import { DocUtils, Docs } from '../../../documents/Documents';
-import { ContextMenuProps } from '../../ContextMenuItem';
-import { FormattedTextBox } from '../../nodes/formattedText/FormattedTextBox';
+import './CollectionSchemaView.scss';
export interface SchemaColumnHeaderProps {
columnKeys: string[];