aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/views/collections/CollectionNoteTakingView.tsx29
-rw-r--r--src/fields/util.ts9
2 files changed, 21 insertions, 17 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index 302c4eaea..81ca4dd98 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -40,7 +40,7 @@ export type collectionNoteTakingViewProps = {
/**
* CollectionNoteTakingView is a column-based view for displaying documents. In this view, the user can (1)
* add and remove columns (2) change column sizes and (3) move documents within and between columns. This
- * view is reminiscent of Kanban-style web apps like Trello, or the 'Board' view in Notion. Each column is
+ * view is reminiscent of Kanban-style web apps like Trello, or the 'Board' view in Notion. Each column is
* headed by a SchemaHeaderField followed by the column's documents. SchemaHeaderFields are NOT present in
* the rest of Dash, so it may be worthwhile to transition the headers to simple documents.
*/
@@ -51,7 +51,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
_draggerRef = React.createRef<HTMLDivElement>();
@observable docsDraggedRowCol: number[] = [];
@observable _cursor: CursorProperty = 'grab';
- @observable _scroll = 0;
+ @observable _scroll = 0;
@computed get chromeHidden() {
return this.props.chromeHidden || BoolCast(this.layoutDoc.chromeHidden);
}
@@ -96,7 +96,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
@computed get maxColWidth() {
return this.props.PanelWidth() - 2 * this.xMargin;
}
- // availableWidth is the total amount of non-divider width. Since widths are stored relatively,
+ // availableWidth is the total amount of non-divider width. Since widths are stored relatively,
// we use availableWidth to convert from a percentage to a pixel count.
@computed get availableWidth() {
const numDividers = this.columnHeaders.length - 1;
@@ -342,11 +342,11 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
return Math.min(childHeight, maxHeight, panelHeight);
}
- // resizeColumns is called whenever a user adds or removes a column. When removing,
+ // resizeColumns is called whenever a user adds or removes a column. When removing,
// this function renormalizes the column widths to fill the newly available space
// in the panel. When adding, this function renormalizes the existing columns to take up
// (n - 1)/n space, since the new column will be allocated 1/n of the total space.
- // Column widths are relative (portion of available space) and stored in the 'width'
+ // Column widths are relative (portion of available space) and stored in the 'width'
// field of SchemaHeaderFields.
//
// Removing example: column widths are [0.5, 0.30, 0.20] --> user deletes the final column --> column widths are [0.625, 0.375].
@@ -400,7 +400,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
}
};
- // getColumnFromXCoord returns the column index for a given x-coordinate (currently always the client's mouse coordinate).
+ // getColumnFromXCoord returns the column index for a given x-coordinate (currently always the client's mouse coordinate).
// This function is used to know which document a column SHOULD be in while it is being dragged.
getColumnFromXCoord = (xCoord: number): number => {
const numColumns = this.columnHeaders.length;
@@ -479,8 +479,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
}
}
}
- }
- else if (de.complete.linkDragData?.dragDocument.context === this.props.Document && de.complete.linkDragData?.linkDragView?.props.CollectionFreeFormDocumentView?.()) {
+ } else if (de.complete.linkDragData?.dragDocument.context === this.props.Document && de.complete.linkDragData?.linkDragView?.props.CollectionFreeFormDocumentView?.()) {
const source = Docs.Create.TextDocument('', { _width: 200, _height: 75, _fitWidth: true, title: 'dropped annotation' });
this.props.addDocument?.(source);
de.complete.linkDocument = DocUtils.MakeLink({ doc: source }, { doc: de.complete.linkDragData.linkSourceGetAnchor() }, 'doc annotation', ''); // TODODO this is where in text links get passed
@@ -535,7 +534,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
contents: '+ New Column',
});
- // sectionNoteTaking returns a CollectionNoteTakingViewColumn (which is an individual column)
+ // sectionNoteTaking returns a CollectionNoteTakingViewColumn (which is an individual column)
sectionNoteTaking = (heading: SchemaHeaderField | undefined, docList: Doc[]) => {
const type = 'number';
return (
@@ -585,16 +584,16 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
);
};
- // addGroup is called when adding a new columnHeader, adding a SchemaHeaderField to our list of
+ // addGroup is called when adding a new columnHeader, adding a SchemaHeaderField to our list of
// columnHeaders and resizing the existing columns to make room for our new one.
@undoBatch
@action
addGroup = (value: string) => {
for (const header of this.columnHeaders) {
- if (header.heading == value) {
- alert('You cannot use an existing column name. Please try a new column name');
- return 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 newColWidth = 1 / (this.numGroupColumns + 1);
@@ -623,7 +622,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
};
// renderedSections returns a list of all of the JSX elements used (columns and dividers). If the view
- // has more than one column, those columns will be separated by a CollectionNoteTakingViewDivider that
+ // has more than one column, those columns will be separated by a CollectionNoteTakingViewDivider that
// allows the user to adjust the column widths.
@computed get renderedSections() {
TraceMobx();
diff --git a/src/fields/util.ts b/src/fields/util.ts
index d87bb6656..b3cbbe241 100644
--- a/src/fields/util.ts
+++ b/src/fields/util.ts
@@ -445,8 +445,13 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any
undo: action(() => {
// console.log("undo $add: " + prop, diff.items) // bcz: uncomment to log undo
diff.items.forEach((item: any) => {
- const ind = receiver[prop].indexOf(item.value ? item.value() : item);
- ind !== -1 && receiver[prop].splice(ind, 1);
+ if (item instanceof SchemaHeaderField) {
+ const ind = receiver[prop].findIndex((ele: any) => ele instanceof SchemaHeaderField && ele.heading === item.heading);
+ ind !== -1 && receiver[prop].splice(ind, 1);
+ } else {
+ const ind = receiver[prop].indexOf(item.value ? item.value() : item);
+ ind !== -1 && receiver[prop].splice(ind, 1);
+ }
});
lastValue = ObjectField.MakeCopy(receiver[prop]);
}),