-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatter before chip insertion. Effects to insertion and duplicated-checking. fix #1288
- Loading branch information
Showing
3 changed files
with
84 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<div> | ||
<md-chips class="md-primary" v-model="clubs" md-placeholder="Add club..." :md-format="toUppercase"> | ||
<label>La Liga Clubs</label> | ||
<div class="md-helper-text">Three uppercase letters</div> | ||
</md-chips> | ||
<md-chips class="md-primary" v-model="artists" md-placeholder="Add artist..." :md-format="formatName"> | ||
<label>Artists</label> | ||
<div class="md-helper-text">Try insert `Eugène Ysaÿe` twice. The formatter will remove diacritics.</div> | ||
</md-chips> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'DuplicatedFeedback', | ||
data: () => ({ | ||
clubs: [ | ||
'FCB', | ||
'MAD' | ||
], | ||
artists: [ | ||
'Claude Debussy', | ||
'Jules Massenet', | ||
'Gabriel Dupont', | ||
'Emma Bardac', | ||
'Mary Garden' | ||
] | ||
}), | ||
methods: { | ||
toUppercase (str) { | ||
str = str.replace(/\s/g, '').toUpperCase() | ||
if (str.length !== 3) return false | ||
return str | ||
}, | ||
formatName (str) { | ||
let words = str.split(' ').filter(str => str !== '') | ||
// remove accents / diacritics | ||
words = words.map(str => str.normalize('NFD').replace(/[\u0300-\u036f]/g, '')) | ||
// capitalize | ||
words = words.map(str => str[0].toUpperCase() + str.slice(1)) | ||
let result = words.join(' ') | ||
return result | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters