You've already forked focalboard
mirror of
https://github.com/mattermost/focalboard.git
synced 2025-07-15 23:54:29 +02:00
cleanup
This commit is contained in:
@ -41,7 +41,6 @@ class Block implements IBlock {
|
|||||||
this.updateAt = block.updateAt || now
|
this.updateAt = block.updateAt || now
|
||||||
this.deleteAt = block.deleteAt || 0
|
this.deleteAt = block.deleteAt || 0
|
||||||
|
|
||||||
// this.properties = block.properties ? block.properties.map((o: IProperty) => ({ ...o })) : [] // Deep clone
|
|
||||||
if (Array.isArray(block.properties)) {
|
if (Array.isArray(block.properties)) {
|
||||||
// HACKHACK: Port from old schema
|
// HACKHACK: Port from old schema
|
||||||
this.properties = {}
|
this.properties = {}
|
||||||
@ -54,29 +53,6 @@ class Block implements IBlock {
|
|||||||
this.properties = { ...block.properties || {} }
|
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 }
|
export { Block }
|
||||||
|
@ -233,7 +233,7 @@ class BoardComponent extends React.Component<Props, State> {
|
|||||||
const properties = CardFilter.propertiesThatMeetFilterGroup(activeView.filter, board.cardProperties)
|
const properties = CardFilter.propertiesThatMeetFilterGroup(activeView.filter, board.cardProperties)
|
||||||
const card = new Block({ type: "card", parentId: boardTree.board.id, properties })
|
const card = new Block({ type: "card", parentId: boardTree.board.id, properties })
|
||||||
if (boardTree.groupByProperty) {
|
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) })
|
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<Props, State> {
|
|||||||
|
|
||||||
if (draggedCard) {
|
if (draggedCard) {
|
||||||
Utils.log(`ondrop. Card: ${draggedCard.title}, column: ${propertyValue}`)
|
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) {
|
if (propertyValue !== oldValue) {
|
||||||
await mutator.changePropertyValue(draggedCard, boardTree.groupByProperty.id, propertyValue, "drag card")
|
await mutator.changePropertyValue(draggedCard, boardTree.groupByProperty.id, propertyValue, "drag card")
|
||||||
}
|
}
|
||||||
|
@ -408,14 +408,14 @@ class Mutator {
|
|||||||
async changePropertyValue(block: IBlock, propertyId: string, value?: string, description: string = "change property") {
|
async changePropertyValue(block: IBlock, propertyId: string, value?: string, description: string = "change property") {
|
||||||
const { octo, undoManager } = this
|
const { octo, undoManager } = this
|
||||||
|
|
||||||
const oldValue = Block.getPropertyValue(block, propertyId)
|
const oldValue = block.properties[propertyId]
|
||||||
await undoManager.perform(
|
await undoManager.perform(
|
||||||
async () => {
|
async () => {
|
||||||
Block.setProperty(block, propertyId, value)
|
block.properties[propertyId] = value
|
||||||
await octo.updateBlock(block)
|
await octo.updateBlock(block)
|
||||||
},
|
},
|
||||||
async () => {
|
async () => {
|
||||||
Block.setProperty(block, propertyId, oldValue)
|
block.properties[propertyId] = oldValue
|
||||||
await octo.updateBlock(block)
|
await octo.updateBlock(block)
|
||||||
},
|
},
|
||||||
description
|
description
|
||||||
|
Reference in New Issue
Block a user