Created
August 9, 2018 00:58
-
-
Save Jantho1990/a9acc5502d74ca53a0474c49b493cbb6 to your computer and use it in GitHub Desktop.
StarRating Vue -- 9b
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
<script> | |
import inputIsValid from '../lib/validate' | |
export default { | |
// ... | |
methods: { | |
anyAreEmpty (...values) { | |
return values.filter(value => value === '').length > 0 | |
}, | |
handleRating () { | |
let { | |
rating_, | |
minRating_, | |
maxRating_, | |
starRatio_, | |
limit_ | |
} = this | |
if (this.anyAreEmpty(rating_, minRating_, maxRating_, starRatio_)) return | |
rating_ = Number(rating_) | |
minRating_ = Number(minRating_) | |
maxRating_ = Number(maxRating_) | |
starRatio_ = Number(starRatio_) | |
if (inputIsValid(rating_, minRating_, maxRating_, starRatio_, limit_)) { | |
this.$emit('rating-update', { | |
rating: rating_, | |
minRating: minRating_, | |
maxRating: maxRating_, | |
starRatio: starRatio_ | |
}) | |
} | |
} | |
}, | |
// ... | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment