1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-10-31 00:17:42 +02:00

Add selected cards duplication with CTRL+D

This commit is contained in:
Jesús Espino
2021-03-31 16:03:31 +02:00
parent 8af37617ee
commit 16256a41d0
2 changed files with 28 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ This changelog summarizes updates to our open source project. You can also find
* Add docker-compose to run the whole service in containers. [#105](https://github.com/mattermost/focalboard/pull/105) Thanks @jbutler992!
* Added Gallery view.
* Added Checkbox content type.
* Added Selected cards duplication with CTRL+D.
* Requested Contributions
* Add more frontend unit test coverage. [#126](https://github.com/mattermost/focalboard/pull/126) Thanks @renjithgr!
* [GH-40](https://github.com/mattermost/focalboard/issues/40) - Add property type email [#84](https://github.com/mattermost/focalboard/pull/84). Thanks @renjithgr!

View File

@@ -55,6 +55,13 @@ class CenterPanel extends React.Component<Props, State> {
this.deleteSelectedCards()
e.stopPropagation()
}
if ((e.ctrlKey || e.metaKey) && !e.altKey && !e.shiftKey && e.keyCode === 68 && this.state.selectedCardIds.length > 0) {
// CTRL+D: Duplicate selected cards
this.duplicateSelectedCards()
e.stopPropagation()
e.preventDefault()
}
}
componentDidMount(): void {
@@ -309,6 +316,26 @@ class CenterPanel extends React.Component<Props, State> {
this.setState({selectedCardIds: []})
}
private async duplicateSelectedCards() {
const {selectedCardIds} = this.state
if (selectedCardIds.length < 1) {
return
}
mutator.performAsUndoGroup(async () => {
for (const cardId of selectedCardIds) {
const card = this.props.boardTree.allCards.find((o) => o.id === cardId)
if (card) {
mutator.duplicateCard(cardId)
} else {
Utils.assertFailure(`Selected card not found: ${cardId}`)
}
}
})
this.setState({selectedCardIds: []})
}
}
export default injectIntl(CenterPanel)