Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
346d7e6d
Commit
346d7e6d
authored
5 years ago
by
Sofiya Tepikin
Browse files
Options
Downloads
Patches
Plain Diff
Cleanups symptom view
parent
12b8e5c2
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
components/cycle-day/symptoms/symptom-view.js
+11
-38
11 additions, 38 deletions
components/cycle-day/symptoms/symptom-view.js
with
11 additions
and
38 deletions
components/cycle-day/symptoms/symptom-view.js
+
11
−
38
View file @
346d7e6d
...
...
@@ -16,27 +16,30 @@ import { sharedDialogs } from '../../../i18n/en/cycle-day'
import
styles
from
'
../../../styles
'
const
checkIfHasValues
=
data
=>
{
const
isMeaningfulValue
=
value
=>
value
||
value
===
0
return
Object
.
values
(
data
).
some
(
isMeaningfulValue
)
}
class
SymptomView
extends
Component
{
static
propTypes
=
{
symptom
:
PropTypes
.
string
.
isRequired
,
values
:
PropTypes
.
object
,
date
:
PropTypes
.
string
,
handleBackButtonPress
:
PropTypes
.
func
,
children
:
PropTypes
.
node
,
}
constructor
(
props
)
{
super
()
this
.
values
=
props
.
values
this
.
state
=
{
shouldShowDelete
:
this
.
checkIfHasValues
ToDelete
(
)
shouldShowDelete
:
checkIfHasValues
(
props
.
values
)
}
this
.
date
=
props
.
date
this
.
navigate
=
props
.
navigate
}
componentDidUpdate
()
{
this
.
values
=
this
.
props
.
values
const
shouldShowDelete
=
this
.
checkIfHasValuesToDelete
()
const
shouldShowDelete
=
checkIfHasValues
(
this
.
props
.
values
)
if
(
shouldShowDelete
!==
this
.
state
.
shouldShowDelete
)
{
this
.
setState
({
shouldShowDelete
})
}
...
...
@@ -47,17 +50,6 @@ class SymptomView extends Component {
saveSymptom
(
symptom
,
date
,
null
)
}
checkIfHasValuesToDelete
()
{
const
valueHasBeenFilledOut
=
key
=>
{
// is there any meaningful value in the current state?
return
this
.
values
[
key
]
||
this
.
values
[
key
]
===
0
}
const
valuesKeys
=
Object
.
keys
(
this
.
values
)
return
valuesKeys
.
some
(
valueHasBeenFilledOut
)
}
onDeleteConfirmation
=
()
=>
{
this
.
deleteSymptomEntry
()
this
.
props
.
handleBackButtonPress
()
...
...
@@ -82,32 +74,13 @@ class SymptomView extends Component {
)
}
showConfirmationAlert
=
()
=>
{
const
cancelButton
=
{
text
:
sharedDialogs
.
cancel
,
style
:
'
cancel
'
}
const
confirmationButton
=
{
text
:
sharedDialogs
.
reallyDeleteData
,
onPress
:
this
.
onDeleteConfirmation
}
return
Alert
.
alert
(
sharedDialogs
.
areYouSureTitle
,
sharedDialogs
.
areYouSureToDelete
,
[
cancelButton
,
confirmationButton
]
)
}
render
()
{
const
{
symptom
}
=
this
.
props
const
{
symptom
,
date
}
=
this
.
props
return
(
<
View
style
=
{{
flex
:
1
}}
>
<
Header
title
=
{
headerTitles
[
symptom
]}
subtitle
=
{
formatDate
(
this
.
date
)}
subtitle
=
{
formatDate
(
date
)}
handleBack
=
{
this
.
props
.
handleBackButtonPress
}
handleDelete
=
{
this
.
state
.
shouldShowDelete
&&
this
.
showConfirmationAlert
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment