From 4db40c310e3e151ebdde70818f5652986c58198e Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Tue, 13 Oct 2020 21:26:48 -0700 Subject: [PATCH] cleanup --- src/client/block.ts | 24 ------------------------ src/client/components/boardComponent.tsx | 4 ++-- src/client/mutator.ts | 6 +++--- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/src/client/block.ts b/src/client/block.ts index 421469e2b..10258cfa6 100644 --- a/src/client/block.ts +++ b/src/client/block.ts @@ -41,7 +41,6 @@ class Block implements IBlock { this.updateAt = block.updateAt || now this.deleteAt = block.deleteAt || 0 - // this.properties = block.properties ? block.properties.map((o: IProperty) => ({ ...o })) : [] // Deep clone if (Array.isArray(block.properties)) { // HACKHACK: Port from old schema this.properties = {} @@ -54,29 +53,6 @@ class Block implements IBlock { this.properties = { ...block.properties || {} } } } - - static getPropertyValue(block: IBlock, id: string): string | undefined { - if (!block.properties) { return undefined } - return block.properties[id] - } - - static setProperty(block: IBlock, id: string, value?: string) { - block.properties[id] = value - // if (!block.properties) { block.properties = [] } - // if (!value) { - // // Remove property - // block.properties = block.properties.filter(o => o.id !== id) - // return - // } - - // const property = block.properties.find(o => o.id === id) - // if (property) { - // property.value = value - // } else { - // const newProperty: IProperty = { id, value } - // block.properties.push(newProperty) - // } - } } export { Block } diff --git a/src/client/components/boardComponent.tsx b/src/client/components/boardComponent.tsx index 885953c1e..8932c5ba5 100644 --- a/src/client/components/boardComponent.tsx +++ b/src/client/components/boardComponent.tsx @@ -233,7 +233,7 @@ class BoardComponent extends React.Component { const properties = CardFilter.propertiesThatMeetFilterGroup(activeView.filter, board.cardProperties) const card = new Block({ type: "card", parentId: boardTree.board.id, properties }) if (boardTree.groupByProperty) { - Block.setProperty(card, boardTree.groupByProperty.id, groupByValue) + card.properties[boardTree.groupByProperty.id] = groupByValue } await mutator.insertBlock(card, "add card", async () => { await this.showCard(card) }, async () => { await this.showCard(undefined) }) } @@ -354,7 +354,7 @@ class BoardComponent extends React.Component { if (draggedCard) { Utils.log(`ondrop. Card: ${draggedCard.title}, column: ${propertyValue}`) - const oldValue = Block.getPropertyValue(draggedCard, boardTree.groupByProperty.id) + const oldValue = draggedCard.properties[boardTree.groupByProperty.id] if (propertyValue !== oldValue) { await mutator.changePropertyValue(draggedCard, boardTree.groupByProperty.id, propertyValue, "drag card") } diff --git a/src/client/mutator.ts b/src/client/mutator.ts index 18c062e7b..ef77bc346 100644 --- a/src/client/mutator.ts +++ b/src/client/mutator.ts @@ -408,14 +408,14 @@ class Mutator { async changePropertyValue(block: IBlock, propertyId: string, value?: string, description: string = "change property") { const { octo, undoManager } = this - const oldValue = Block.getPropertyValue(block, propertyId) + const oldValue = block.properties[propertyId] await undoManager.perform( async () => { - Block.setProperty(block, propertyId, value) + block.properties[propertyId] = value await octo.updateBlock(block) }, async () => { - Block.setProperty(block, propertyId, oldValue) + block.properties[propertyId] = oldValue await octo.updateBlock(block) }, description