aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionNoteTakingView.scss20
-rw-r--r--src/client/views/collections/CollectionNoteTakingView.tsx35
-rw-r--r--src/client/views/collections/CollectionNoteTakingViewColumn.tsx61
3 files changed, 58 insertions, 58 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.scss b/src/client/views/collections/CollectionNoteTakingView.scss
index 4d1f18e54..be1800d81 100644
--- a/src/client/views/collections/CollectionNoteTakingView.scss
+++ b/src/client/views/collections/CollectionNoteTakingView.scss
@@ -51,10 +51,6 @@
display: flex;
}
-.collectionNoteTakingViewFieldColumn {
- display: flex;
- overflow: auto;
-}
.collectionNoteTakingViewFieldColumn:hover {
.collectionNoteTakingView-DocumentButtons {
display: flex;
@@ -98,6 +94,11 @@
position: relative;
display: block;
}
+ .collectionNoteTakingViewFieldColumn {
+ overflow: auto;
+ display: flex;
+ flex-direction: column;
+ }
.collectionSchemaView-previewDoc {
height: 100%;
@@ -111,14 +112,19 @@
height: auto;
}
+ .collectionNoteTakingView-columnStackContainer {
+ height: 100%;
+ overflow: auto;
+ width: 100%;
+ display: flex;
+ }
.collectionNoteTakingView-columnStack {
height: 100%;
width: 100%;
- display: inline-block;
+ display: table-cell;
}
.collectionNoteTakingView-Nodes {
width: 100%;
- height: 100%;
position: absolute;
display: flex;
flex-direction: column;
@@ -128,7 +134,6 @@
width: 100%;
position: absolute;
margin: auto;
- width: max-content;
height: max-content;
position: relative;
grid-auto-rows: 0px;
@@ -165,6 +170,7 @@
// Documents in NoteTaking view
.collectionNoteTakingView-columnDoc {
display: flex;
+ width: 100%;
// margin: auto; // Removed auto so that it is no longer center aligned - this could be something we change
position: relative;
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index 26c73438c..edd5ba96c 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -217,6 +217,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
isContentActive = () => this.props.isSelected() || this.props.isContentActive();
+ blockPointerEventsWhenDragging = () => (this.docsDraggedRowCol.length ? 'none' : undefined);
// getDisplayDoc returns the rules for displaying a document in this view (ie. DocumentView)
getDisplayDoc(doc: Doc, width: () => number) {
const dataDoc = !doc.isTemplateDoc && !doc.isTemplateForField && !doc.PARAMS ? undefined : this.props.DataDoc;
@@ -227,6 +228,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
<DocumentView
ref={r => (dref = r || undefined)}
Document={doc}
+ pointerEvents={this.blockPointerEventsWhenDragging}
DataDoc={dataDoc || (!Doc.AreProtosEqual(doc[DataSym], doc) && doc[DataSym])}
renderDepth={this.props.renderDepth + 1}
PanelWidth={width}
@@ -276,7 +278,7 @@ export class CollectionNoteTakingView extends CollectionSubView() {
// getDocTransform is used to get the coordinates of a document when we go from a view like freeform to columns
getDocTransform(doc: Doc, dref?: DocumentView) {
const y = this._scroll; // required for document decorations to update when the text box container is scrolled
- const { scale, translateX, translateY } = Utils.GetScreenTransform(dref?.ContentDiv || undefined);
+ const { translateX, translateY } = Utils.GetScreenTransform(dref?.ContentDiv || undefined);
// the document view may center its contents and if so, will prepend that onto the screenToLocalTansform. so we have to subtract that off
return new Transform(-translateX + (dref?.centeringX || 0), -translateY + (dref?.centeringY || 0), 1).scale(this.props.ScreenToLocalTransform().Scale);
}
@@ -319,18 +321,16 @@ export class CollectionNoteTakingView extends CollectionSubView() {
// Removing example: column widths are [0.5, 0.30, 0.20] --> user deletes the final column --> column widths are [0.625, 0.375].
// Adding example: column widths are [0.6, 0.4] --> user adds column at end --> column widths are [0.4, 0.267, 0.33]
@action
- resizeColumns = (isAdd: boolean, colWidth: number, colIndex: number) => {
- const n = this.columnHeaders.length;
- if (n == 1) {
- this.columnHeaders[0].setWidth(1);
- return true;
- }
- const scaleFactor = isAdd ? 1 - colWidth : 1 / (1 - colWidth);
- this.columnHeaders.forEach((h, i) => {
- if (!(isAdd && i == colIndex)) {
- h.width < 0 ? h.setWidth(1 / n) : h.setWidth(h.width * scaleFactor);
- }
- });
+ resizeColumns = (isAdd: boolean, headers: SchemaHeaderField[], colIndex: number) => {
+ const n = headers.length;
+ const curWidths = headers.reduce((sum, hdr) => sum + Math.abs(hdr.width), 0);
+ const scaleFactor = 1 / curWidths;
+ this.dataDoc.columnHeaders = new List<SchemaHeaderField>(
+ headers.map(h => {
+ h.setWidth(Math.abs(h.width) * scaleFactor);
+ return h;
+ })
+ );
return true;
};
@@ -533,7 +533,6 @@ export class CollectionNoteTakingView extends CollectionSubView() {
dividerWidth={this.DividerWidth}
maxColWidth={this.maxColWidth}
availableWidth={this.availableWidth}
- PanelWidth={this.PanelWidth}
key={heading?.heading ?? 'unset'}
headings={this.headings}
heading={heading?.heading ?? 'unset'}
@@ -555,16 +554,16 @@ export class CollectionNoteTakingView extends CollectionSubView() {
addGroup = (value: string) => {
if (this.columnHeaders) {
for (const header of this.columnHeaders) {
- if (header.heading == value) {
+ if (header.heading === value) {
alert('You cannot use an existing column name. Please try a new column name');
return value;
}
}
}
- const columnHeaders = Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null);
+ const columnHeaders = Array.from(Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null));
const newColWidth = 1 / (this.numGroupColumns + 1);
- value && columnHeaders?.push(new SchemaHeaderField(value, undefined, undefined, newColWidth)) && this.resizeColumns(true, newColWidth, this.columnHeaders.length - 1);
- this.dataDoc.columnHeaders = new List<SchemaHeaderField>(columnHeaders.map(header => header[Copy]()));
+ columnHeaders.push(new SchemaHeaderField(value, undefined, undefined, newColWidth));
+ value && this.resizeColumns(true, columnHeaders, this.columnHeaders.length - 1);
return true;
};
diff --git a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
index 84d1c0205..ec6a2bec8 100644
--- a/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewColumn.tsx
@@ -44,8 +44,7 @@ interface CSVFieldColumnProps {
observeHeight: (myref: any) => void;
unobserveHeight: (myref: any) => void;
editableViewProps: () => any;
- resizeColumns: (isAdd: boolean, colWidth: number, colIndex: number) => boolean;
- PanelWidth: number;
+ resizeColumns: (isAdd: boolean, headers: SchemaHeaderField[], colIndex: number) => boolean;
maxColWidth: number;
dividerWidth: number;
availableWidth: number;
@@ -141,18 +140,12 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
@undoBatch
@action
deleteColumn = () => {
- const acolumnHeaders = Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null);
- if (acolumnHeaders && this.props.headingObject) {
- const index = acolumnHeaders.indexOf(this.props.headingObject);
- const columnHeaders = acolumnHeaders; // new List<SchemaHeaderField>(acolumnHeaders.map(header => header[Copy]())); // needed for undo to work properly. otherwise we end up changing field values in the undo stack since they are shared by reference
- const newColIndex = index > 0 ? index - 1 : 1;
- const newColHeader = this.props.columnHeaders ? this.props.columnHeaders[newColIndex] : undefined;
- const newHeading = newColHeader ? newColHeader.heading : 'unset';
- this.props.docList.forEach(d => (d[this.props.pivotField] = newHeading));
- const colWidth = this.props.columnHeaders ? this.props.columnHeaders[index].width : 0;
+ const columnHeaders = Array.from(Cast(this.props.Document.columnHeaders, listSpec(SchemaHeaderField), null));
+ if (this.props.headingObject) {
+ const index = columnHeaders.indexOf(this.props.headingObject);
+ this.props.docList.forEach(d => (d[this.props.pivotField] = undefined));
columnHeaders.splice(index, 1);
- //Doc.GetProto(this.props.Document).columnHeaders = columnHeaders;
- this.props.resizeColumns(false, colWidth, index);
+ this.props.resizeColumns(false, columnHeaders, index);
}
};
@@ -262,28 +255,30 @@ export class CollectionNoteTakingViewColumn extends React.Component<CSVFieldColu
return (
<>
{headingView}
- <div className="collectionNoteTakingView-columnStack">
- <div
- key={`${heading}-stack`}
- className={`collectionNoteTakingView-Nodes`}
- style={{
- padding: `${columnYMargin}px ${0}px ${this.props.yMargin}px ${0}px`,
- gridGap: this.props.gridGap,
- gridTemplateColumns: templatecols,
- }}>
- {this.props.renderChildren(this.props.docList)}
- </div>
+ <div className="collectionNoteTakingView-columnStackContainer">
+ <div className="collectionNoteTakingView-columnStack">
+ <div
+ key={`${heading}-stack`}
+ className={`collectionNoteTakingView-Nodes`}
+ style={{
+ padding: `${columnYMargin}px ${0}px ${this.props.yMargin}px ${0}px`,
+ gridGap: this.props.gridGap,
+ gridTemplateColumns: templatecols,
+ }}>
+ {this.props.renderChildren(this.props.docList)}
+ </div>
- {!this.props.chromeHidden && type !== DocumentType.PRES ? (
- <div className="collectionNoteTakingView-DocumentButtons" style={{ marginBottom: 10 }}>
- <div key={`${heading}-add-document`} className="collectionNoteTakingView-addDocumentButton">
- <EditableView GetValue={returnEmptyString} SetValue={this.addNewTextDoc} textCallback={this.textCallback} placeholder={"Type ':' for commands"} contents={'+ New Node'} menuCallback={this.menuCallback} />
- </div>
- <div key={`${this.props.Document[Id]}-addGroup`} className="collectionNoteTakingView-addDocumentButton">
- <EditableView {...this.props.editableViewProps()} />
+ {!this.props.chromeHidden && type !== DocumentType.PRES ? (
+ <div className="collectionNoteTakingView-DocumentButtons" style={{ marginBottom: 10 }}>
+ <div key={`${heading}-add-document`} className="collectionNoteTakingView-addDocumentButton">
+ <EditableView GetValue={returnEmptyString} SetValue={this.addNewTextDoc} textCallback={this.textCallback} placeholder={"Type ':' for commands"} contents={'+ New Node'} menuCallback={this.menuCallback} />
+ </div>
+ <div key={`${this.props.Document[Id]}-addGroup`} className="collectionNoteTakingView-addDocumentButton">
+ <EditableView {...this.props.editableViewProps()} />
+ </div>
</div>
- </div>
- ) : null}
+ ) : null}
+ </div>
</div>
</>
);