aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionNoteTakingView.tsx22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/client/views/collections/CollectionNoteTakingView.tsx b/src/client/views/collections/CollectionNoteTakingView.tsx
index 302e7c890..dfee1b173 100644
--- a/src/client/views/collections/CollectionNoteTakingView.tsx
+++ b/src/client/views/collections/CollectionNoteTakingView.tsx
@@ -363,11 +363,11 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
pos0 = pos1
})
// we alter the pivot fields of the docs in case they are moved to a new column.
- // const colIndex = this.getColumnFromXCoord(xCoord)
- // const colHeader = StrCast(this.columnHeaders[colIndex].heading)
- // DragManager.docsBeingDragged.forEach(d => d[this.pivotField] = colHeader)
+ const colIndex = this.getColumnFromXCoord(xCoord)
+ const colHeader = StrCast(this.columnHeaders[colIndex].heading)
+ DragManager.docsBeingDragged.forEach(d => d[this.pivotField] = colHeader)
// used to notify sections to re-render
- console.log([dropInd, this.getColumnFromXCoord(xCoord)])
+ // console.log([dropInd, this.getColumnFromXCoord(xCoord)])
this.docsDraggedRowCol = [dropInd, this.getColumnFromXCoord(xCoord)]
}
}
@@ -375,8 +375,8 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
// returns the column index for a given x-coordinate
getColumnFromXCoord = (xCoord: number): number => {
const numColumns = this.columnHeaders.length
- const coords = this.columnStartXCoords
- coords.push(this.props.PanelWidth())
+ const coords = this.columnStartXCoords.slice()
+ coords.push(this.PanelWidth)
let colIndex = 0
for (let i = 0; i < numColumns; i++) {
if (xCoord > coords[i] && xCoord < coords[i + 1]) {
@@ -412,7 +412,7 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
if (de.complete.docDragData) {
if (super.onInternalDrop(e, de)) {
DragManager.docsBeingDragged = []
- this.docsDraggedRowCol = []
+ // this.docsDraggedRowCol = []
// filter out the currently dragged docs from the child docs, since we will insert them later
const rowCol = this.docsDraggedRowCol
const droppedDocs = this.childDocs.slice().filter((d: Doc, ind: number) => ind >= this.childDocs.length); // if the drop operation adds something to the end of the list, then use that as the new document (may be different than what was dropped e.g., in the case of a button which is dropped but which creates say, a note).
@@ -422,14 +422,14 @@ export class CollectionNoteTakingView extends CollectionSubView<Partial<collecti
if (docs && newDocs.length) {
// remove the dragged documents from the childDocList
newDocs.filter(d => docs.indexOf(d) !== -1).forEach(d => docs.splice(docs.indexOf(d), 1))
- // if the doc starts a columnm (or the drop index is undefined), we can just push it to the back. Otherwise we need to add it to the column properly
+ // if the doc starts a columnm (or the drop index is undefined), we can just push it to the front. Otherwise we need to add it to the column properly
+ //TODO: you need to update childDocList instead. It seems that childDocs is a copy of the actual array we want to modify
if (rowCol[0] <= 0) {
- docs.splice(docs.length - 1, 0, ...newDocs)
+ docs.unshift(...newDocs)
} else {
const colDocs = this.getDocsFromXCoord(de.x)
const previousDoc = colDocs[rowCol[0] - 1]
- const previousDocIndex = this.childDocs.findIndex(d => {d[Id] == previousDoc[Id]})
- //TODO: removing the doc instead of doing what we expect it to do
+ const previousDocIndex = docs.indexOf(previousDoc)
docs.splice(previousDocIndex, 0, ...newDocs)
}
}