1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-30 14:00:07 +02:00

cleanup addCardTemplate

This commit is contained in:
Chen-I Lim 2020-11-11 09:33:34 -08:00
parent 57d7eb35bd
commit 95164e0cf0
2 changed files with 14 additions and 18 deletions

View File

@ -155,7 +155,7 @@ class BoardComponent extends React.Component<Props, State> {
setSearchText={this.props.setSearchText}
addCard={() => this.addCard()}
addCardFromTemplate={this.addCardFromTemplate}
addCardTemplate={() => this.addCardTemplate()}
addCardTemplate={this.addCardTemplate}
editCardTemplate={this.editCardTemplate}
withGroupBy={true}
/>
@ -526,26 +526,21 @@ class BoardComponent extends React.Component<Props, State> {
)
}
private async addCardTemplate(groupByOptionId?: string): Promise<void> {
private addCardTemplate = async () => {
const {boardTree} = this.props
const {activeView, board} = boardTree
const cardTemplate = new MutableCard()
cardTemplate.isTemplate = true
cardTemplate.parentId = boardTree.board.id
cardTemplate.properties = CardFilter.propertiesThatMeetFilterGroup(activeView.filter, board.cardProperties)
if (boardTree.groupByProperty) {
if (groupByOptionId) {
cardTemplate.properties[boardTree.groupByProperty.id] = groupByOptionId
} else {
delete cardTemplate.properties[boardTree.groupByProperty.id]
}
}
await mutator.insertBlock(cardTemplate, 'add card template', async () => {
this.setState({shownCardId: cardTemplate.id})
}, async () => {
this.setState({shownCardId: undefined})
})
await mutator.insertBlock(
cardTemplate,
'add card template',
async () => {
this.setState({shownCardId: cardTemplate.id})
}, async () => {
this.setState({shownCardId: undefined})
},
)
}
private editCardTemplate = (cardTemplateId: string) => {

View File

@ -351,12 +351,13 @@ class TableComponent extends React.Component<Props, State> {
const cardTemplate = new MutableCard()
cardTemplate.isTemplate = true
cardTemplate.parentId = boardTree.board.id
cardTemplate.icon = BlockIcons.shared.randomIcon()
await mutator.insertBlock(
cardTemplate,
'add card',
'add card template',
async () => {
this.setState({shownCardId: cardTemplate.id})
}, async () => {
this.setState({shownCardId: undefined})
},
)
}