Allow no-option column to be reordered.
This commit is contained in:
parent
95955a01f8
commit
c165a2c77f
2 changed files with 56 additions and 7 deletions
|
@ -230,12 +230,41 @@ class BoardComponent extends React.Component<Props, State> {
|
|||
const {boardTree, intl} = this.props
|
||||
const {activeView} = boardTree
|
||||
|
||||
// TODO: Refactor this as a component
|
||||
if (!group.option.id) {
|
||||
// Empty group
|
||||
const ref = React.createRef<HTMLDivElement>()
|
||||
return (
|
||||
<div
|
||||
key='empty'
|
||||
ref={ref}
|
||||
className='octo-board-header-cell'
|
||||
|
||||
draggable={true}
|
||||
onDragStart={() => {
|
||||
this.draggedHeaderOption = group.option
|
||||
}}
|
||||
onDragEnd={() => {
|
||||
this.draggedHeaderOption = undefined
|
||||
}}
|
||||
|
||||
onDragOver={(e) => {
|
||||
ref.current.classList.add('dragover')
|
||||
e.preventDefault()
|
||||
}}
|
||||
onDragEnter={(e) => {
|
||||
ref.current.classList.add('dragover')
|
||||
e.preventDefault()
|
||||
}}
|
||||
onDragLeave={(e) => {
|
||||
ref.current.classList.remove('dragover')
|
||||
e.preventDefault()
|
||||
}}
|
||||
onDrop={(e) => {
|
||||
ref.current.classList.remove('dragover')
|
||||
e.preventDefault()
|
||||
this.onDropToColumn(group.option)
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className='octo-label'
|
||||
|
@ -498,11 +527,15 @@ class BoardComponent extends React.Component<Props, State> {
|
|||
Utils.assertValue(boardTree.groupByProperty)
|
||||
|
||||
// Move option to new index
|
||||
const {board} = boardTree
|
||||
const options = boardTree.groupByProperty.options
|
||||
const destIndex = option ? options.indexOf(option) : 0
|
||||
const visibleOptionIds = boardTree.visibleGroups.map(o => o.option.id)
|
||||
|
||||
await mutator.changePropertyOptionOrder(board, boardTree.groupByProperty, draggedHeaderOption, destIndex)
|
||||
const {activeView} = boardTree
|
||||
const srcIndex = visibleOptionIds.indexOf(draggedHeaderOption.id)
|
||||
const destIndex = visibleOptionIds.indexOf(option.id)
|
||||
|
||||
visibleOptionIds.splice(destIndex, 0, visibleOptionIds.splice(srcIndex, 1)[0])
|
||||
|
||||
await mutator.changeViewVisibleOptionIds(activeView, visibleOptionIds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,16 +371,28 @@ class Mutator {
|
|||
await this.updateBlock(newView, view, 'filter')
|
||||
}
|
||||
|
||||
async changeViewGroupById(view: BoardView, groupById: string): Promise<void> {
|
||||
const newView = new MutableBoardView(view)
|
||||
newView.groupById = groupById
|
||||
await this.updateBlock(newView, view, 'group by')
|
||||
}
|
||||
|
||||
async changeViewVisibleProperties(view: BoardView, visiblePropertyIds: string[], description = 'show / hide property'): Promise<void> {
|
||||
const newView = new MutableBoardView(view)
|
||||
newView.visiblePropertyIds = visiblePropertyIds
|
||||
await this.updateBlock(newView, view, description)
|
||||
}
|
||||
|
||||
async changeViewGroupById(view: BoardView, groupById: string): Promise<void> {
|
||||
async changeViewVisibleOptionIds(view: BoardView, visibleOptionIds: string[], description = 'reorder'): Promise<void> {
|
||||
const newView = new MutableBoardView(view)
|
||||
newView.groupById = groupById
|
||||
await this.updateBlock(newView, view, 'group by')
|
||||
newView.visibleOptionIds = visibleOptionIds
|
||||
await this.updateBlock(newView, view, description)
|
||||
}
|
||||
|
||||
async changeViewHiddenOptionIds(view: BoardView, hiddenOptionIds: string[], description = 'reorder'): Promise<void> {
|
||||
const newView = new MutableBoardView(view)
|
||||
newView.hiddenOptionIds = hiddenOptionIds
|
||||
await this.updateBlock(newView, view, description)
|
||||
}
|
||||
|
||||
async hideViewColumn(view: BoardView, columnOptionId: string): Promise<void> {
|
||||
|
@ -389,6 +401,7 @@ class Mutator {
|
|||
}
|
||||
|
||||
const newView = new MutableBoardView(view)
|
||||
newView.visibleOptionIds = newView.visibleOptionIds.filter(o => o !== columnOptionId)
|
||||
newView.hiddenOptionIds.push(columnOptionId)
|
||||
await this.updateBlock(newView, view, 'hide column')
|
||||
}
|
||||
|
@ -400,6 +413,9 @@ class Mutator {
|
|||
|
||||
const newView = new MutableBoardView(view)
|
||||
newView.hiddenOptionIds = newView.hiddenOptionIds.filter((o) => o !== columnOptionId)
|
||||
// Put the column at the end of the visible list
|
||||
newView.visibleOptionIds = newView.visibleOptionIds.filter(o => o !== columnOptionId)
|
||||
newView.visibleOptionIds.push(columnOptionId)
|
||||
await this.updateBlock(newView, view, 'show column')
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue