Ensure single stat threshold values are unique

pull/10616/head
Alex P 2017-12-08 15:02:03 -08:00
parent dadd133459
commit f11f727997
1 changed files with 6 additions and 5 deletions

View File

@ -140,12 +140,14 @@ class CellEditorOverlay extends Component {
handleValidateColorValue = (threshold, e) => {
const {colors, cellWorkingType} = this.state
if (cellWorkingType === 'single-stat') {
// If type is single-stat then validation doesn't matter
return true
}
const sortedColors = _.sortBy(colors, color => Number(color.value))
const targetValueNumber = Number(e.target.value)
let allowedToUpdate = false
if (cellWorkingType === 'single-stat') {
// If type is single-stat then value only has to be unique
return !sortedColors.some(color => color.value === e.target.value)
}
const maxValue = Number(
colors.find(color => color.type === COLOR_TYPE_MAX).value
@ -154,7 +156,6 @@ class CellEditorOverlay extends Component {
colors.find(color => color.type === COLOR_TYPE_MIN).value
)
let allowedToUpdate = false
// If type === min, make sure it is less than the next threshold
if (threshold.type === COLOR_TYPE_MIN) {