diff options
author | Daniel Kesselberg <mail@danielkesselberg.de> | 2023-10-10 20:20:07 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-10-11 11:54:44 +0000 |
commit | 912ac3a192b64fd571d67c7d8b387eb7b903cb01 (patch) | |
tree | c4b5af97734b08be47136d62da8879222d1651c6 /src/components/ContactDetails/ContactDetailsProperty.vue | |
parent | 894c11c1b6c2288e89c684ed883d77a33e077076 (diff) |
fix: improve matching for tel type parameter
The old implementation assigns the same score for HOME,VOICE and VOICE for a tel property with parameter voice.
This pull requests adds an aditional point for the items with the same length.
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'src/components/ContactDetails/ContactDetailsProperty.vue')
-rw-r--r-- | src/components/ContactDetails/ContactDetailsProperty.vue | 15 |
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 |