For temperature, only show delete button when certain fields active

This commit is contained in:
Julia Friesel
2019-05-17 16:47:31 +02:00
parent 0f7ab6c803
commit a557733d30
+5 -7
View File
@@ -47,7 +47,7 @@ export default class Temp extends SymptomView {
} else {
const prevTemp = getPreviousTemperature(props.date)
if (prevTemp) {
this.state.temperature = prevTemp.toString()
this.state.suggestedTemperature = prevTemp.toString()
this.state.isSuggestion = true
}
}
@@ -56,10 +56,9 @@ export default class Temp extends SymptomView {
symptomName = 'temperature'
isDeleteIconActive() {
return Object.keys(this.state).some(key => {
// the time is always prefilled, so it's not relevant for setting
// the delete button active
if (key === 'time') return
return ['temperature', 'note', 'exclude'].some(key => {
// the time is always and the suggested temp sometimes prefilled, so they're not relevant for setting
// the delete button active.
return this.state[key] || this.state[key] === 0
})
}
@@ -151,8 +150,7 @@ export default class Temp extends SymptomView {
<AppTextInput
style={[inputStyle]}
autoFocus={true}
placeholder={this.state.temperature}
value={this.state.temperature}
value={this.state.temperature || this.state.suggestedTemperature}
onChangeText={this.setTemperature}
keyboardType='numeric'
maxLength={5}