From a6347f9741d0c5c23e1ab581bc0dc43c6b0ecf52 Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Thu, 1 Apr 2021 10:24:04 -0700 Subject: [PATCH] Handle select properties in search --- webapp/src/viewModel/boardTree.ts | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/webapp/src/viewModel/boardTree.ts b/webapp/src/viewModel/boardTree.ts index 0ccd86d55..1b2eb337d 100644 --- a/webapp/src/viewModel/boardTree.ts +++ b/webapp/src/viewModel/boardTree.ts @@ -203,14 +203,25 @@ class MutableBoardTree implements BoardTree { if (searchTextInCardTitle) { return true } - for (const property in card.properties) { - if ( - Object.prototype.hasOwnProperty.call(card.properties, property) && - card.properties[property].toLowerCase().includes(searchText) - ) { - return true + + // Search for text in properties + const {board} = this + for (const [propertyId, propertyValue] of Object.entries(card.properties)) { + // TODO: Refactor to a shared function that returns the display value of a property + const propertyTemplate = board.cardProperties.find((o) => o.id === propertyId) + if (propertyTemplate) { + if (propertyTemplate.type === 'select') { + // Look up the value of the select option + const option = propertyTemplate.options.find((o) => o.id === propertyValue) + if (option?.value.toLowerCase().includes(searchText)) { + return true + } + } else if (propertyValue.toLowerCase().includes(searchText)) { + return true + } } } + return false }) }