When nothing entered, delete entry
This commit is contained in:
@@ -5,7 +5,6 @@ import {
|
||||
ScrollView
|
||||
} from 'react-native'
|
||||
import styles from '../../../styles'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import { bleeding } from '../../../i18n/en/cycle-day'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
import SelectTabGroup from '../select-tab-group'
|
||||
@@ -23,8 +22,14 @@ export default class Bleeding extends SymptomView {
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
saveSymptom('bleeding', this.props.date, {
|
||||
symptomName = 'bleeding'
|
||||
|
||||
onBackButtonPress() {
|
||||
if (typeof this.state.currentValue != 'number') {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
this.saveSymptomEntry({
|
||||
value: this.state.currentValue,
|
||||
exclude: this.state.exclude
|
||||
})
|
||||
|
||||
@@ -14,14 +14,22 @@ import SymptomView from './symptom-view'
|
||||
|
||||
export default class Cervix extends SymptomView {
|
||||
constructor(props) {
|
||||
super()
|
||||
super(props)
|
||||
const cycleDay = props.cycleDay
|
||||
this.cervix = cycleDay && cycleDay.cervix
|
||||
this.state = this.cervix ? this.cervix : {}
|
||||
}
|
||||
|
||||
save() {
|
||||
saveSymptom('cervix', this.props.date, {
|
||||
symptomName = 'cervix'
|
||||
|
||||
onBackButtonPress() {
|
||||
const nothingEntered = ['opening', 'firmness', 'position'].every(val => typeof this.state[val] != 'number')
|
||||
if (nothingEntered) {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
|
||||
this.saveSymptomEntry({
|
||||
opening: this.state.opening,
|
||||
firmness: this.state.firmness,
|
||||
position: this.state.position,
|
||||
@@ -95,14 +103,6 @@ export default class Cervix extends SymptomView {
|
||||
symptom='cervix'
|
||||
date={this.props.date}
|
||||
currentSymptomValue={this.cervix}
|
||||
saveAction={() => {
|
||||
saveSymptom('cervix', this.props.date, {
|
||||
opening: this.state.opening,
|
||||
firmness: this.state.firmness,
|
||||
position: this.state.position,
|
||||
exclude: Boolean(this.state.exclude)
|
||||
})
|
||||
}}
|
||||
navigate={this.props.navigate}
|
||||
/>
|
||||
</View>
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
ScrollView
|
||||
} from 'react-native'
|
||||
import styles from '../../../styles'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import { intensity, desire } from '../../../i18n/en/cycle-day'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
import SelectTabGroup from '../select-tab-group'
|
||||
@@ -13,15 +12,21 @@ import SymptomView from './symptom-view'
|
||||
|
||||
export default class Desire extends SymptomView {
|
||||
constructor(props) {
|
||||
super()
|
||||
super(props)
|
||||
const cycleDay = props.cycleDay
|
||||
this.desire = cycleDay && cycleDay.desire
|
||||
const desireValue = this.desire && this.desire.value
|
||||
this.state = { currentValue: desireValue }
|
||||
}
|
||||
|
||||
save() {
|
||||
saveSymptom('desire', this.props.date, { value: this.state.currentValue })
|
||||
symptomName = 'desire'
|
||||
|
||||
onBackButtonPress() {
|
||||
if (!this.state.currentValue) {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
this.saveSymptomEntry({ value: this.state.currentValue })
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
TextInput,
|
||||
View
|
||||
} from 'react-native'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import { mood as labels } from '../../../i18n/en/cycle-day'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
import SelectBoxGroup from '../select-box-group'
|
||||
@@ -14,7 +13,7 @@ import SymptomView from './symptom-view'
|
||||
|
||||
export default class Mood extends SymptomView {
|
||||
constructor(props) {
|
||||
super()
|
||||
super(props)
|
||||
const cycleDay = props.cycleDay
|
||||
if (cycleDay && cycleDay.mood) {
|
||||
this.state = Object.assign({}, cycleDay.mood)
|
||||
@@ -26,12 +25,19 @@ export default class Mood extends SymptomView {
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
symptomName = "mood"
|
||||
|
||||
onBackButtonPress() {
|
||||
const nothingEntered = Object.values(this.state).every(val => !val)
|
||||
if (nothingEntered) {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
const copyOfState = Object.assign({}, this.state)
|
||||
if (!copyOfState.other) {
|
||||
copyOfState.note = null
|
||||
}
|
||||
saveSymptom('mood', this.props.date, copyOfState)
|
||||
this.saveSymptomEntry(copyOfState)
|
||||
}
|
||||
|
||||
toggleState = (key) => {
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
ScrollView
|
||||
} from 'react-native'
|
||||
import styles from '../../../styles'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import { mucus as labels } from '../../../i18n/en/cycle-day'
|
||||
import computeNfpValue from '../../../lib/nfp-mucus'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
@@ -15,16 +14,24 @@ import SymptomView from './symptom-view'
|
||||
|
||||
export default class Mucus extends SymptomView {
|
||||
constructor(props) {
|
||||
super()
|
||||
super(props)
|
||||
const cycleDay = props.cycleDay
|
||||
this.mucus = cycleDay && cycleDay.mucus
|
||||
this.state = this.mucus ? this.mucus : {}
|
||||
}
|
||||
|
||||
save() {
|
||||
symptomName = 'mucus'
|
||||
|
||||
onBackButtonPress() {
|
||||
const nothingEntered = ['feeling', 'texture'].every(val => typeof this.state[val] != 'number')
|
||||
if (nothingEntered) {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
|
||||
const feeling = this.state.feeling
|
||||
const texture = this.state.texture
|
||||
saveSymptom('mucus', this.props.date, {
|
||||
this.saveSymptomEntry({
|
||||
feeling,
|
||||
texture,
|
||||
value: computeNfpValue(feeling, texture),
|
||||
|
||||
@@ -24,8 +24,14 @@ export default class Note extends SymptomView {
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
saveSymptom('note', this.props.date, {
|
||||
symptomName = 'note'
|
||||
|
||||
onBackButtonPress() {
|
||||
if (!this.state.currentValue) {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
this.saveSymptomEntry({
|
||||
value: this.state.currentValue
|
||||
})
|
||||
}
|
||||
|
||||
@@ -27,12 +27,20 @@ export default class Pain extends SymptomView {
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
symptomName = 'pain'
|
||||
|
||||
onBackButtonPress() {
|
||||
const nothingEntered = Object.values(this.state).every(val => !val)
|
||||
if (nothingEntered) {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
|
||||
const copyOfState = Object.assign({}, this.state)
|
||||
if (!copyOfState.other) {
|
||||
copyOfState.note = null
|
||||
}
|
||||
saveSymptom('pain', this.props.date, copyOfState)
|
||||
this.saveSymptomEntry(copyOfState)
|
||||
}
|
||||
|
||||
toggleState = (key) => {
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
ScrollView
|
||||
} from 'react-native'
|
||||
import styles from '../../../styles'
|
||||
import { saveSymptom } from '../../../db'
|
||||
import { sex as sexLabels, contraceptives as contraceptivesLabels } from '../../../i18n/en/cycle-day'
|
||||
import { shared as sharedLabels } from '../../../i18n/en/labels'
|
||||
import ActionButtonFooter from './action-button-footer'
|
||||
@@ -27,12 +26,20 @@ export default class Sex extends SymptomView {
|
||||
if (this.state.note) this.state.other = true
|
||||
}
|
||||
|
||||
save() {
|
||||
symptomName = "sex"
|
||||
|
||||
onBackButtonPress() {
|
||||
const nothingEntered = Object.values(this.state).every(val => !val)
|
||||
if (nothingEntered) {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
|
||||
const copyOfState = Object.assign({}, this.state)
|
||||
if (!copyOfState.other) {
|
||||
copyOfState.note = null
|
||||
}
|
||||
saveSymptom('sex', this.props.date, copyOfState)
|
||||
this.saveSymptomEntry(copyOfState)
|
||||
}
|
||||
|
||||
toggleState = (key) => {
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
import { Component } from 'react'
|
||||
import { BackHandler } from 'react-native'
|
||||
import { saveSymptom } from '../../../db'
|
||||
|
||||
export default class SymptomView extends Component {
|
||||
constructor() {
|
||||
constructor(props) {
|
||||
super()
|
||||
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.save.bind(this))
|
||||
this.backHandler = BackHandler.addEventListener('hardwareBackPress', this.onBackButtonPress.bind(this))
|
||||
this.symptomName = props.symptomName
|
||||
this.date = props.date
|
||||
}
|
||||
|
||||
saveSymptomEntry(entry) {
|
||||
saveSymptom(this.symptomName, this.date, entry)
|
||||
}
|
||||
|
||||
deleteSymptomEntry() {
|
||||
saveSymptom(this.symptomName, this.date)
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
import DateTimePicker from 'react-native-modal-datetime-picker-nevo'
|
||||
import padWithZeros from '../../helpers/pad-time-with-zeros'
|
||||
|
||||
import { getPreviousTemperature, saveSymptom } from '../../../db'
|
||||
import { getPreviousTemperature } from '../../../db'
|
||||
import styles from '../../../styles'
|
||||
import { LocalTime, ChronoUnit } from 'js-joda'
|
||||
import { temperature as labels } from '../../../i18n/en/cycle-day'
|
||||
@@ -54,7 +54,14 @@ export default class Temp extends SymptomView {
|
||||
}
|
||||
}
|
||||
|
||||
save() {
|
||||
symptomName = 'temperature'
|
||||
|
||||
onBackButtonPress() {
|
||||
if (this.state.temperature === '') {
|
||||
this.deleteSymptomEntry()
|
||||
return
|
||||
}
|
||||
|
||||
this.checkRangeAndSave()
|
||||
}
|
||||
|
||||
@@ -65,8 +72,8 @@ export default class Temp extends SymptomView {
|
||||
time: this.state.time,
|
||||
note: this.state.note
|
||||
}
|
||||
saveSymptom('temperature', this.props.date, dataToSave)
|
||||
this.props.navigate('CycleDay', {date: this.props.date})
|
||||
|
||||
this.saveSymptomEntry(dataToSave)
|
||||
}
|
||||
|
||||
checkRangeAndSave = () => {
|
||||
|
||||
Reference in New Issue
Block a user