Ask before deleting entry
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import {
|
import {
|
||||||
View, TouchableOpacity, Text, Alert} from 'react-native'
|
View, TouchableOpacity, Text} from 'react-native'
|
||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
||||||
import { saveSymptom } from '../../../db'
|
|
||||||
import styles, {iconStyles} from '../../../styles'
|
import styles, {iconStyles} from '../../../styles'
|
||||||
import {sharedDialogs as labels} from '../../../i18n/en/cycle-day'
|
import {sharedDialogs as labels} from '../../../i18n/en/cycle-day'
|
||||||
|
|
||||||
@@ -10,31 +9,13 @@ import {sharedDialogs as labels} from '../../../i18n/en/cycle-day'
|
|||||||
export default class ActionButtonFooter extends Component {
|
export default class ActionButtonFooter extends Component {
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
symptom,
|
|
||||||
currentSymptomValue,
|
currentSymptomValue,
|
||||||
date,
|
|
||||||
navigate,
|
|
||||||
}
|
}
|
||||||
= this.props
|
= this.props
|
||||||
const navigateToOverView = () => navigate('CycleDay', {date})
|
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
title: labels.delete,
|
title: labels.delete,
|
||||||
action: () => {
|
action: () => {
|
||||||
Alert.alert(
|
|
||||||
labels.areYouSureTitle,
|
|
||||||
labels.areYouSureToDelete,
|
|
||||||
[{
|
|
||||||
text: labels.cancel,
|
|
||||||
style: 'cancel'
|
|
||||||
}, {
|
|
||||||
text: labels.reallyDeleteData,
|
|
||||||
onPress: () => {
|
|
||||||
saveSymptom(symptom, date)
|
|
||||||
navigateToOverView()
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
disabledCondition: (!currentSymptomValue ||
|
disabledCondition: (!currentSymptomValue ||
|
||||||
(Object.keys(currentSymptomValue).length === 0 && currentSymptomValue.constructor === Object) ||
|
(Object.keys(currentSymptomValue).length === 0 && currentSymptomValue.constructor === Object) ||
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { BackHandler, View } from 'react-native'
|
import { BackHandler, View, Alert } from 'react-native'
|
||||||
import { saveSymptom } from '../../../db'
|
import { saveSymptom } from '../../../db'
|
||||||
import Header from '../../header/symptom-view'
|
import Header from '../../header/symptom-view'
|
||||||
import { headerTitles } from '../../../i18n/en/labels'
|
import { headerTitles } from '../../../i18n/en/labels'
|
||||||
|
import { sharedDialogs } from '../../../i18n/en/cycle-day'
|
||||||
|
|
||||||
export default class SymptomView extends Component {
|
export default class SymptomView extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@@ -41,8 +42,20 @@ export default class SymptomView extends Component {
|
|||||||
date={this.date}
|
date={this.date}
|
||||||
goBack={this.handleBackButtonPressOnSymptomView.bind(this)}
|
goBack={this.handleBackButtonPressOnSymptomView.bind(this)}
|
||||||
deleteEntry={() => {
|
deleteEntry={() => {
|
||||||
this.deleteSymptomEntry()
|
Alert.alert(
|
||||||
this.globalBackhandler()
|
sharedDialogs.areYouSureTitle,
|
||||||
|
sharedDialogs.areYouSureToDelete,
|
||||||
|
[{
|
||||||
|
text: sharedDialogs.cancel,
|
||||||
|
style: 'cancel'
|
||||||
|
}, {
|
||||||
|
text: sharedDialogs.reallyDeleteData,
|
||||||
|
onPress: () => {
|
||||||
|
this.deleteSymptomEntry()
|
||||||
|
this.globalBackhandler()
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{this.renderContent()}
|
{this.renderContent()}
|
||||||
|
|||||||
Reference in New Issue
Block a user