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 { } else {
const prevTemp = getPreviousTemperature(props.date) const prevTemp = getPreviousTemperature(props.date)
if (prevTemp) { if (prevTemp) {
this.state.temperature = prevTemp.toString() this.state.suggestedTemperature = prevTemp.toString()
this.state.isSuggestion = true this.state.isSuggestion = true
} }
} }
@@ -56,10 +56,9 @@ export default class Temp extends SymptomView {
symptomName = 'temperature' symptomName = 'temperature'
isDeleteIconActive() { isDeleteIconActive() {
return Object.keys(this.state).some(key => { return ['temperature', 'note', 'exclude'].some(key => {
// the time is always prefilled, so it's not relevant for setting // the time is always and the suggested temp sometimes prefilled, so they're not relevant for setting
// the delete button active // the delete button active.
if (key === 'time') return
return this.state[key] || this.state[key] === 0 return this.state[key] || this.state[key] === 0
}) })
} }
@@ -151,8 +150,7 @@ export default class Temp extends SymptomView {
<AppTextInput <AppTextInput
style={[inputStyle]} style={[inputStyle]}
autoFocus={true} autoFocus={true}
placeholder={this.state.temperature} value={this.state.temperature || this.state.suggestedTemperature}
value={this.state.temperature}
onChangeText={this.setTemperature} onChangeText={this.setTemperature}
keyboardType='numeric' keyboardType='numeric'
maxLength={5} maxLength={5}