From 95164e0cf00dadfba73a5288e91e1d32b751cdfa Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Wed, 11 Nov 2020 09:33:34 -0800 Subject: [PATCH] cleanup addCardTemplate --- webapp/src/components/boardComponent.tsx | 27 ++++++++++-------------- webapp/src/components/tableComponent.tsx | 5 +++-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/webapp/src/components/boardComponent.tsx b/webapp/src/components/boardComponent.tsx index d7b8f7bb6..729f7eaca 100644 --- a/webapp/src/components/boardComponent.tsx +++ b/webapp/src/components/boardComponent.tsx @@ -155,7 +155,7 @@ class BoardComponent extends React.Component { 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 { ) } - private async addCardTemplate(groupByOptionId?: string): Promise { + 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) => { diff --git a/webapp/src/components/tableComponent.tsx b/webapp/src/components/tableComponent.tsx index e0eb5cdd7..08f31de88 100644 --- a/webapp/src/components/tableComponent.tsx +++ b/webapp/src/components/tableComponent.tsx @@ -351,12 +351,13 @@ class TableComponent extends React.Component { 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}) }, ) }