Don't set unselected values to -1
This commit is contained in:
@@ -122,14 +122,14 @@ export default class CycleDayOverView extends Component {
|
|||||||
function getLabel(symptomName, symptom) {
|
function getLabel(symptomName, symptom) {
|
||||||
const l = {
|
const l = {
|
||||||
bleeding: bleeding => {
|
bleeding: bleeding => {
|
||||||
if (typeof bleeding.value === 'number') {
|
if (isNumber(bleeding.value)) {
|
||||||
let bleedingLabel = `${bleedingLabels[bleeding.value]}`
|
let bleedingLabel = `${bleedingLabels[bleeding.value]}`
|
||||||
if (bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
|
if (bleeding.exclude) bleedingLabel = "( " + bleedingLabel + " )"
|
||||||
return bleedingLabel
|
return bleedingLabel
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
temperature: temperature => {
|
temperature: temperature => {
|
||||||
if (typeof temperature.value === 'number') {
|
if (isNumber(temperature.value)) {
|
||||||
let temperatureLabel = `${temperature.value} °C - ${temperature.time}`
|
let temperatureLabel = `${temperature.value} °C - ${temperature.time}`
|
||||||
if (temperature.exclude) {
|
if (temperature.exclude) {
|
||||||
temperatureLabel = "( " + temperatureLabel + " )"
|
temperatureLabel = "( " + temperatureLabel + " )"
|
||||||
@@ -139,7 +139,7 @@ function getLabel(symptomName, symptom) {
|
|||||||
},
|
},
|
||||||
mucus: mucus => {
|
mucus: mucus => {
|
||||||
const categories = ['feeling', 'texture', 'value']
|
const categories = ['feeling', 'texture', 'value']
|
||||||
if (categories.every(c => typeof mucus[c] === 'number')) {
|
if (categories.every(c => isNumber(mucus[c]))) {
|
||||||
let mucusLabel = [feelingLabels[mucus.feeling], textureLabels[mucus.texture]].join(', ')
|
let mucusLabel = [feelingLabels[mucus.feeling], textureLabels[mucus.texture]].join(', ')
|
||||||
mucusLabel += `\n${labels.mucusNFP[mucus.value]}`
|
mucusLabel += `\n${labels.mucusNFP[mucus.value]}`
|
||||||
if (mucus.exclude) mucusLabel = `(${mucusLabel})`
|
if (mucus.exclude) mucusLabel = `(${mucusLabel})`
|
||||||
@@ -148,12 +148,12 @@ function getLabel(symptomName, symptom) {
|
|||||||
},
|
},
|
||||||
cervix: cervix => {
|
cervix: cervix => {
|
||||||
let cervixLabel = []
|
let cervixLabel = []
|
||||||
if (cervix.opening > -1 && cervix.firmness > -1) {
|
if (isNumber(cervix.opening) && isNumber(cervix.firmness)) {
|
||||||
cervixLabel.push(
|
cervixLabel.push(
|
||||||
openingLabels[cervix.opening],
|
openingLabels[cervix.opening],
|
||||||
firmnessLabels[cervix.firmness]
|
firmnessLabels[cervix.firmness]
|
||||||
)
|
)
|
||||||
if (cervix.position > -1) {
|
if (isNumber(cervix.position)) {
|
||||||
cervixLabel.push(positionLabels[cervix.position])
|
cervixLabel.push(positionLabels[cervix.position])
|
||||||
}
|
}
|
||||||
cervixLabel = cervixLabel.join(', ')
|
cervixLabel = cervixLabel.join(', ')
|
||||||
@@ -165,7 +165,7 @@ function getLabel(symptomName, symptom) {
|
|||||||
return note.value
|
return note.value
|
||||||
},
|
},
|
||||||
desire: desire => {
|
desire: desire => {
|
||||||
if (typeof desire.value === 'number') {
|
if (isNumber(desire.value)) {
|
||||||
const desireLabel = `${intensityLabels[desire.value]}`
|
const desireLabel = `${intensityLabels[desire.value]}`
|
||||||
return desireLabel
|
return desireLabel
|
||||||
}
|
}
|
||||||
@@ -266,3 +266,7 @@ class FillerBoxes extends Component {
|
|||||||
return fillerBoxes
|
return fillerBoxes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isNumber(val) {
|
||||||
|
return typeof val === 'number'
|
||||||
|
}
|
||||||
@@ -16,12 +16,8 @@ export default class Bleeding extends Component {
|
|||||||
super(props)
|
super(props)
|
||||||
this.cycleDay = props.cycleDay
|
this.cycleDay = props.cycleDay
|
||||||
this.makeActionButtons = props.makeActionButtons
|
this.makeActionButtons = props.makeActionButtons
|
||||||
let bleedingValue = this.cycleDay.bleeding && this.cycleDay.bleeding.value
|
|
||||||
if (!(typeof bleedingValue === 'number')) {
|
|
||||||
bleedingValue = -1
|
|
||||||
}
|
|
||||||
this.state = {
|
this.state = {
|
||||||
currentValue: bleedingValue,
|
currentValue: this.cycleDay.bleeding && this.cycleDay.bleeding.value,
|
||||||
exclude: this.cycleDay.bleeding ? this.cycleDay.bleeding.exclude : false
|
exclude: this.cycleDay.bleeding ? this.cycleDay.bleeding.exclude : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,7 +64,7 @@ export default class Bleeding extends Component {
|
|||||||
exclude: this.state.exclude
|
exclude: this.state.exclude
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
saveDisabled={this.state.currentValue === -1}
|
saveDisabled={typeof this.state.currentValue != 'number'}
|
||||||
navigate={this.props.navigate}
|
navigate={this.props.navigate}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -17,17 +17,11 @@ export default class Cervix extends Component {
|
|||||||
this.cycleDay = props.cycleDay
|
this.cycleDay = props.cycleDay
|
||||||
this.makeActionButtons = props.makeActionButtons
|
this.makeActionButtons = props.makeActionButtons
|
||||||
this.state = {
|
this.state = {
|
||||||
exclude: this.cycleDay.cervix ? this.cycleDay.cervix.exclude : false
|
exclude: this.cycleDay.cervix ? this.cycleDay.cervix.exclude : false,
|
||||||
};
|
opening: this.cycleDay.cervix ? this.cycleDay.cervix.opening : null,
|
||||||
|
firmness: this.cycleDay.cervix ? this.cycleDay.cervix.firmness : null,
|
||||||
/* eslint-disable react/no-direct-mutation-state */
|
position: this.cycleDay.cervix ? this.cycleDay.cervix.position : null
|
||||||
['opening', 'firmness', 'position'].forEach(label => {
|
}
|
||||||
this.state[label] = this.cycleDay.cervix && this.cycleDay.cervix[label]
|
|
||||||
if (typeof this.state[label] !== 'number') {
|
|
||||||
this.state[label] = -1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
/* eslint-enable react/no-direct-mutation-state */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -102,7 +96,7 @@ export default class Cervix extends Component {
|
|||||||
exclude: this.state.exclude
|
exclude: this.state.exclude
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
saveDisabled={this.state.opening === -1 || this.state.firmness === -1}
|
saveDisabled={typeof this.state.opening != 'number' || typeof this.state.firmness != 'number'}
|
||||||
navigate={this.props.navigate}
|
navigate={this.props.navigate}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -15,10 +15,7 @@ export default class Desire extends Component {
|
|||||||
super(props)
|
super(props)
|
||||||
this.cycleDay = props.cycleDay
|
this.cycleDay = props.cycleDay
|
||||||
this.makeActionButtons = props.makeActionButtons
|
this.makeActionButtons = props.makeActionButtons
|
||||||
let desireValue = this.cycleDay.desire && this.cycleDay.desire.value
|
const desireValue = this.cycleDay.desire && this.cycleDay.desire.value
|
||||||
if (!(typeof desireValue === 'number')) {
|
|
||||||
desireValue = -1
|
|
||||||
}
|
|
||||||
this.state = { currentValue: desireValue }
|
this.state = { currentValue: desireValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +45,7 @@ export default class Desire extends Component {
|
|||||||
saveAction={() => {
|
saveAction={() => {
|
||||||
saveSymptom('desire', this.cycleDay, { value: this.state.currentValue })
|
saveSymptom('desire', this.cycleDay, { value: this.state.currentValue })
|
||||||
}}
|
}}
|
||||||
saveDisabled={this.state.currentValue === -1}
|
saveDisabled={typeof this.state.currentValue != 'number'}
|
||||||
navigate={this.props.navigate}
|
navigate={this.props.navigate}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -19,17 +19,10 @@ export default class Mucus extends Component {
|
|||||||
this.cycleDay = props.cycleDay
|
this.cycleDay = props.cycleDay
|
||||||
this.makeActionButtons = props.makeActionButtons
|
this.makeActionButtons = props.makeActionButtons
|
||||||
this.state = {
|
this.state = {
|
||||||
exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false
|
exclude: this.cycleDay.mucus ? this.cycleDay.mucus.exclude : false,
|
||||||
};
|
feeling: this.cycleDay.mucus ? this.cycleDay.mucus.feeling : null,
|
||||||
|
texture: this.cycleDay.mucus ? this.cycleDay.mucus.texture : null
|
||||||
/* eslint-disable react/no-direct-mutation-state */
|
}
|
||||||
['feeling', 'texture'].forEach(label => {
|
|
||||||
this.state[label] = this.cycleDay.mucus && this.cycleDay.mucus[label]
|
|
||||||
if (typeof this.state[label] !== 'number') {
|
|
||||||
this.state[label] = -1
|
|
||||||
}
|
|
||||||
})
|
|
||||||
/* eslint-enable react/no-direct-mutation-state */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -93,7 +86,7 @@ export default class Mucus extends Component {
|
|||||||
exclude: this.state.exclude
|
exclude: this.state.exclude
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
saveDisabled={this.state.feeling === -1 || this.state.texture === -1}
|
saveDisabled={typeof this.state.feeling != 'number' || typeof this.state.texture != 'number'}
|
||||||
navigate={this.props.navigate}
|
navigate={this.props.navigate}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user