mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-26 18:48:15 +02:00
Improve change select property type
This commit is contained in:
parent
e279968793
commit
40b36e7463
@ -144,7 +144,7 @@ class CardDetail extends React.Component<Props, State> {
|
||||
{board.cardProperties.map((propertyTemplate) => {
|
||||
return (
|
||||
<div
|
||||
key={propertyTemplate.id}
|
||||
key={propertyTemplate.id + '-' + propertyTemplate.type}
|
||||
className='octo-propertyrow'
|
||||
>
|
||||
{this.props.readonly && <div className='octo-propertyname'>{propertyTemplate.name}</div>}
|
||||
|
@ -388,6 +388,7 @@ class Mutator {
|
||||
|
||||
const newBoard = new MutableBoard(board)
|
||||
const newTemplate = newBoard.cardProperties.find((o) => o.id === propertyTemplate.id)!
|
||||
newTemplate.options = []
|
||||
newTemplate.type = type
|
||||
|
||||
const oldBlocks: IBlock[] = [board]
|
||||
@ -402,6 +403,7 @@ class Mutator {
|
||||
if (newValue) {
|
||||
newCard.properties[propertyTemplate.id] = newValue
|
||||
} else {
|
||||
// This was an invalid select option, so delete it
|
||||
delete newCard.properties[propertyTemplate.id]
|
||||
}
|
||||
newBlocks.push(newCard)
|
||||
@ -409,17 +411,23 @@ class Mutator {
|
||||
}
|
||||
}
|
||||
} else if (type === 'select') {
|
||||
// Map values to template option IDs
|
||||
// Map values to new template option IDs
|
||||
for (const card of boardTree.allCards) {
|
||||
const oldValue = card.properties[propertyTemplate.id]
|
||||
if (oldValue) {
|
||||
const newValue = propertyTemplate.options.find((o) => o.value === oldValue)?.id
|
||||
const newCard = new MutableCard(card)
|
||||
if (newValue) {
|
||||
newCard.properties[propertyTemplate.id] = newValue
|
||||
} else {
|
||||
delete newCard.properties[propertyTemplate.id]
|
||||
let option = newTemplate.options.find((o) => o.value === oldValue)
|
||||
if (!option) {
|
||||
option = {
|
||||
id: Utils.createGuid(),
|
||||
value: oldValue,
|
||||
color: 'propColorDefault',
|
||||
}
|
||||
newTemplate.options.push(option)
|
||||
}
|
||||
|
||||
const newCard = new MutableCard(card)
|
||||
newCard.properties[propertyTemplate.id] = option.id
|
||||
|
||||
newBlocks.push(newCard)
|
||||
oldBlocks.push(card)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user