Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable5.4] fix: improve matching for tel type parameter #3655

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/components/ContactDetails/ContactDetailsProperty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,18 @@
// 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))

Check warning on line 262 in src/components/ContactDetails/ContactDetailsProperty.vue

View check run for this annotation

Codecov / codecov/patch

src/components/ContactDetails/ContactDetailsProperty.vue#L261-L262

Added lines #L261 - L262 were not covered by tests
score = score + intersection.length

return { type, score }
})

// Sort by score, filtering out the null score and selecting the first match
Expand Down
Loading