summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Steinmetz <richard@steinmetz.cloud>2023-10-11 13:54:24 +0200
committerGitHub <noreply@github.com>2023-10-11 13:54:24 +0200
commit106bd3bf5ce055160ca2087d09aed48c5bdae83f (patch)
treec85c4ff9d1c9bdfc98dac26a8083eca557f0faaa
parent9854dd89cc575ebd23206831ceed3e31c36038d3 (diff)
parent503ae11e1f23c5d77c7e704cb65f813b43327066 (diff)
Merge pull request #3653 from nextcloud/bug/3651/update-matching-score
fix: improve matching for tel type parameter
-rw-r--r--src/components/ContactDetails/ContactDetailsProperty.vue15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/components/ContactDetails/ContactDetailsProperty.vue b/src/components/ContactDetails/ContactDetailsProperty.vue
index 353319bd..552629cf 100644
--- a/src/components/ContactDetails/ContactDetailsProperty.vue
+++ b/src/components/ContactDetails/ContactDetailsProperty.vue
@@ -251,11 +251,18 @@ export default {
// https://jsperf.com/array-map-and-intersection-perf
const matchingTypes = this.propModel.options
.map(type => {
- return {
- type,
- // "WORK,HOME" => ['WORK', 'HOME']
- score: type.id.split(',').filter(value => selectedType.indexOf(value) !== -1).length,
+ let score = 0
+ const types = type.id.split(',') // "WORK,HOME" => ['WORK', 'HOME']
+
+ if (types.length === selectedType.length) {
+ // additional point for same length
+ score++
}
+
+ const intersection = types.filter(value => selectedType.includes(value))
+ score = score + intersection.length
+
+ return { type, score }
})
// Sort by score, filtering out the null score and selecting the first match