Let symptom views overwrite isDeleteIconActive method
This commit is contained in:
@@ -34,6 +34,13 @@ export default class SymptomView extends Component {
|
|||||||
this.backHandler.remove()
|
this.backHandler.remove()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDeleteIconActive() {
|
||||||
|
return Object.values(this.state).some(value => {
|
||||||
|
// is there any meaningful value in the current state?
|
||||||
|
return value || value === 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<View style={{flex: 1}}>
|
<View style={{flex: 1}}>
|
||||||
@@ -41,10 +48,7 @@ export default class SymptomView extends Component {
|
|||||||
title={headerTitles[this.symptomName].toLowerCase()}
|
title={headerTitles[this.symptomName].toLowerCase()}
|
||||||
date={this.date}
|
date={this.date}
|
||||||
goBack={this.handleBackButtonPressOnSymptomView.bind(this)}
|
goBack={this.handleBackButtonPressOnSymptomView.bind(this)}
|
||||||
deleteIconActive={Object.values(this.state).some(x => {
|
deleteIconActive={this.isDeleteIconActive()}
|
||||||
// is there any meaningful value in the current state?
|
|
||||||
return x || x === 0
|
|
||||||
})}
|
|
||||||
deleteEntry={() => {
|
deleteEntry={() => {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
sharedDialogs.areYouSureTitle,
|
sharedDialogs.areYouSureTitle,
|
||||||
|
|||||||
@@ -55,6 +55,15 @@ export default class Temp extends SymptomView {
|
|||||||
|
|
||||||
symptomName = 'temperature'
|
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 this.state[key] || this.state[key] === 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async onBackButtonPress() {
|
async onBackButtonPress() {
|
||||||
if (typeof this.state.temperature != 'string' || this.state.temperature === '') {
|
if (typeof this.state.temperature != 'string' || this.state.temperature === '') {
|
||||||
this.deleteSymptomEntry()
|
this.deleteSymptomEntry()
|
||||||
|
|||||||
Reference in New Issue
Block a user