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
0f6f28e8
Commit
0f6f28e8
authored
6 years ago
by
emelko
Browse files
Options
Downloads
Patches
Plain Diff
Implementing Julia's suggestion to remove repetition
parent
32c08c8d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/cervix.js
+0
-155
0 additions, 155 deletions
components/cervix.js
components/cycle-day/symptoms/cervix.js
+19
-23
19 additions, 23 deletions
components/cycle-day/symptoms/cervix.js
components/cycle-day/symptoms/mucus.js
+17
-17
17 additions, 17 deletions
components/cycle-day/symptoms/mucus.js
with
36 additions
and
195 deletions
components/cervix.js
deleted
100644 → 0
+
0
−
155
View file @
32c08c8d
import
React
,
{
Component
}
from
'
react
'
import
{
View
,
Button
,
Text
,
Switch
}
from
'
react-native
'
import
RadioForm
from
'
react-native-simple-radio-button
'
import
{
saveCervix
}
from
'
../db
'
import
styles
from
'
../styles/index
'
import
{
cervixPosition
as
positionLabels
,
cervixConsistency
as
consistencyLabels
}
from
'
../labels/labels
'
import
computeSensiplanValue
from
'
../lib/sensiplan-cervix
'
export
default
class
Cervix
extends
Component
{
constructor
(
props
)
{
super
(
props
)
this
.
cycleDay
=
props
.
cycleDay
this
.
showView
=
props
.
showView
let
currentPositionValue
=
this
.
cycleDay
.
cervix
&&
this
.
cycleDay
.
cervix
.
position
if
(
typeof
currentPositionValue
!==
'
number
'
)
{
currentPositionValue
=
-
1
}
let
currentConsistencyValue
=
this
.
cycleDay
.
cervix
&&
this
.
cycleDay
.
cervix
.
consistency
if
(
typeof
currentConsistencyValue
!==
'
number
'
)
{
currentConsistencyValue
=
-
1
}
this
.
state
=
{
currentPositionValue
,
currentConsistencyValue
,
computeSensiplanValue
,
exclude
:
this
.
cycleDay
.
cervix
?
this
.
cycleDay
.
cervix
.
exclude
:
false
}
}
render
()
{
const
cervixPositionRadioProps
=
[
{
label
:
positionLabels
[
0
],
value
:
0
},
{
label
:
positionLabels
[
1
],
value
:
1
},
{
label
:
positionLabels
[
2
],
value
:
2
}
]
const
cervixConsistencyRadioProps
=
[
{
label
:
consistencyLabels
[
0
],
value
:
0
},
{
label
:
consistencyLabels
[
1
],
value
:
1
}
]
return
(
<
View
style
=
{
styles
.
symptomEditView
}
>
<
View
style
=
{
styles
.
symptomEditSplitSymptomsAndLastRowButtons
}
>
<
View
style
=
{
styles
.
symptomEditListedSymptomView
}
>
<
View
style
=
{{
flex
:
1
}}
>
<
Text
style
=
{
styles
.
symptomDayView
}
>
Cervix
<
/Text
>
<
/View
>
<
View
style
=
{{
flex
:
1
}}
>
<
Text
style
=
{
styles
.
symptomDayView
}
>
Position
<
/Text
>
<
/View
>
<
View
style
=
{{
flex
:
1
}}
>
<
RadioForm
radio_props
=
{
cervixPositionRadioProps
}
initial
=
{
this
.
state
.
currentPositionValue
}
formHorizontal
=
{
true
}
labelHorizontal
=
{
false
}
labelStyle
=
{
styles
.
radioButton
}
onPress
=
{(
itemValue
)
=>
{
this
.
setState
({
currentPositionValue
:
itemValue
})
}}
/
>
<
/View
>
<
View
style
=
{{
flex
:
1
}}
>
<
Text
style
=
{
styles
.
symptomDayView
}
>
Consistency
<
/Text
>
<
/View
>
<
View
style
=
{{
flex
:
1
}}
>
<
RadioForm
radio_props
=
{
cervixConsistencyRadioProps
}
initial
=
{
this
.
state
.
currentConsistencyValue
}
formHorizontal
=
{
true
}
labelHorizontal
=
{
false
}
labelStyle
=
{
styles
.
radioButton
}
onPress
=
{(
itemValue
)
=>
{
this
.
setState
({
currentConsistencyValue
:
itemValue
})
}}
/
>
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
itemsInRowSeparatedView
}
>
<
View
style
=
{
styles
.
singleButtonView
}
>
<
Text
style
=
{
styles
.
symptomDayView
}
>
Exclude
<
/Text
>
<
/View
>
<
View
style
=
{
styles
.
singleButtonView
}
>
<
Switch
onValueChange
=
{(
val
)
=>
{
this
.
setState
({
exclude
:
val
})
}}
value
=
{
this
.
state
.
exclude
}
/
>
<
/View
>
<
/View
>
<
/View
>
<
View
style
=
{
styles
.
itemsInRowSeparatedView
}
>
<
View
style
=
{
styles
.
singleButtonView
}
>
<
Button
onPress
=
{()
=>
this
.
showView
(
'
dayView
'
)}
title
=
"
Cancel
"
>
<
/Button
>
<
/View
>
<
View
style
=
{
styles
.
singleButtonView
}
>
<
Button
onPress
=
{()
=>
{
saveCervix
(
this
.
cycleDay
)
this
.
showView
(
'
dayView
'
)
}}
title
=
"
Delete
"
>
<
/Button
>
<
/View
>
<
View
style
=
{
styles
.
singleButtonView
}
>
<
Button
onPress
=
{()
=>
{
saveCervix
(
this
.
cycleDay
,
{
position
:
this
.
state
.
currentPositionValue
,
consistency
:
this
.
state
.
currentConsistencyValue
,
computedNfp
:
computeSensiplanValue
(
this
.
state
.
currentPositionValue
,
this
.
state
.
currentConsistencyValue
),
exclude
:
this
.
state
.
exclude
})
this
.
showView
(
'
dayView
'
)
}}
disabled
=
{
this
.
state
.
currentPositionValue
===
-
1
||
this
.
state
.
currentConsistencyValue
===
-
1
}
title
=
"
Save
"
>
<
/Button
>
<
/View
>
<
/View
>
<
/View
>
)
}
}
This diff is collapsed.
Click to expand it.
components/cycle-day/symptoms/cervix.js
+
19
−
23
View file @
0f6f28e8
...
...
@@ -20,20 +20,16 @@ export default class Cervix extends Component {
this
.
makeActionButtons
=
props
.
makeActionButtons
this
.
state
=
{
exclude
:
this
.
cycleDay
.
cervix
?
this
.
cycleDay
.
cervix
.
exclude
:
false
}
}
;
this
.
state
.
currentOpeningValue
=
this
.
cycleDay
.
cervix
&&
this
.
cycleDay
.
cervix
.
opening
if
(
typeof
this
.
state
.
currentOpeningValue
!==
'
number
'
)
{
this
.
state
.
currentOpeningValue
=
-
1
}
this
.
state
.
currentFirmnessValue
=
this
.
cycleDay
.
cervix
&&
this
.
cycleDay
.
cervix
.
firmness
if
(
typeof
this
.
state
.
currentFirmnessValue
!==
'
number
'
)
{
this
.
state
.
currentFirmnessValue
=
-
1
}
this
.
state
.
currentPositionValue
=
this
.
cycleDay
.
cervix
&&
this
.
cycleDay
.
cervix
.
position
if
(
typeof
this
.
state
.
currentPositionValue
!==
'
number
'
)
{
this
.
state
.
currentPositionValue
=
-
1
}
/* eslint-disable react/no-direct-mutation-state */
[
'
opening
'
,
'
firmness
'
,
'
position
'
].
forEach
(
label
=>
{
this
.
state
[
label
]
=
this
.
cycleDay
.
cervix
&&
this
.
cycleDay
.
cervix
[
label
]
if
(
typeof
this
.
state
[
label
]
!==
'
number
'
)
{
this
.
state
[
label
]
=
-
1
}
})
/* eslint-enable react/no-direct-mutation-state */
}
render
()
{
...
...
@@ -58,12 +54,12 @@ export default class Cervix extends Component {
<
View
style
=
{
styles
.
radioButtonRow
}
>
<
RadioForm
radio_props
=
{
cervixOpeningRadioProps
}
initial
=
{
this
.
state
.
currentO
pening
Value
}
initial
=
{
this
.
state
.
o
pening
}
formHorizontal
=
{
true
}
labelHorizontal
=
{
false
}
labelStyle
=
{
styles
.
radioButton
}
onPress
=
{(
itemValue
)
=>
{
this
.
setState
({
currentO
pening
Value
:
itemValue
})
this
.
setState
({
o
pening
:
itemValue
})
}}
/
>
<
/View
>
...
...
@@ -71,12 +67,12 @@ export default class Cervix extends Component {
<
View
style
=
{
styles
.
radioButtonRow
}
>
<
RadioForm
radio_props
=
{
cervixFirmnessRadioProps
}
initial
=
{
this
.
state
.
currentF
irmness
Value
}
initial
=
{
this
.
state
.
f
irmness
}
formHorizontal
=
{
true
}
labelHorizontal
=
{
false
}
labelStyle
=
{
styles
.
radioButton
}
onPress
=
{(
itemValue
)
=>
{
this
.
setState
({
currentF
irmness
Value
:
itemValue
})
this
.
setState
({
f
irmness
:
itemValue
})
}}
/
>
<
/View
>
...
...
@@ -84,12 +80,12 @@ export default class Cervix extends Component {
<
View
style
=
{
styles
.
radioButtonRow
}
>
<
RadioForm
radio_props
=
{
cervixPositionRadioProps
}
initial
=
{
this
.
state
.
currentP
osition
Value
}
initial
=
{
this
.
state
.
p
osition
}
formHorizontal
=
{
true
}
labelHorizontal
=
{
false
}
labelStyle
=
{
styles
.
radioButton
}
onPress
=
{(
itemValue
)
=>
{
this
.
setState
({
currentP
osition
Value
:
itemValue
})
this
.
setState
({
p
osition
:
itemValue
})
}}
/
>
<
/View
>
...
...
@@ -109,13 +105,13 @@ export default class Cervix extends Component {
cycleDay
:
this
.
cycleDay
,
saveAction
:
()
=>
{
saveSymptom
(
'
cervix
'
,
this
.
cycleDay
,
{
opening
:
this
.
state
.
currentO
pening
Value
,
firmness
:
this
.
state
.
currentF
irmness
Value
,
position
:
this
.
state
.
currentP
osition
Value
,
opening
:
this
.
state
.
o
pening
,
firmness
:
this
.
state
.
f
irmness
,
position
:
this
.
state
.
p
osition
,
exclude
:
this
.
state
.
exclude
})
},
saveDisabled
:
this
.
state
.
currentO
pening
Value
===
-
1
||
this
.
state
.
currentF
irmness
Value
===
-
1
saveDisabled
:
this
.
state
.
o
pening
===
-
1
||
this
.
state
.
f
irmness
===
-
1
}
)}
<
/View
>
...
...
This diff is collapsed.
Click to expand it.
components/cycle-day/symptoms/mucus.js
+
17
−
17
View file @
0f6f28e8
...
...
@@ -21,17 +21,17 @@ export default class Mucus extends Component {
this
.
makeActionButtons
=
props
.
makeActionButtons
this
.
state
=
{
exclude
:
this
.
cycleDay
.
mucus
?
this
.
cycleDay
.
mucus
.
exclude
:
false
}
}
;
this
.
state
.
currentFeelingValue
=
this
.
cycleDay
.
mucus
&&
this
.
cycleDay
.
mucus
.
feeling
if
(
typeof
this
.
state
.
currentFeelingValue
!==
'
number
'
)
{
this
.
state
.
currentFeelingValue
=
-
1
}
/* eslint-disable react/no-direct-mutation-state */
[
'
feeling
'
,
'
texture
'
].
forEach
(
label
=>
{
this
.
state
[
label
]
=
this
.
cycleDay
.
mucus
&&
this
.
cycleDay
.
mucus
[
label
]
if
(
typeof
this
.
state
[
label
]
!==
'
number
'
)
{
this
.
state
[
label
]
=
-
1
}
})
/* eslint-enable react/no-direct-mutation-state */
this
.
state
.
currentTextureValue
=
this
.
cycleDay
.
mucus
&&
this
.
cycleDay
.
mucus
.
texture
if
(
typeof
this
.
state
.
currentTextureValue
!==
'
number
'
)
{
this
.
state
.
currentTextureValue
=
-
1
}
}
render
()
{
...
...
@@ -53,12 +53,12 @@ export default class Mucus extends Component {
<
View
style
=
{
styles
.
radioButtonRow
}
>
<
RadioForm
radio_props
=
{
mucusFeelingRadioProps
}
initial
=
{
this
.
state
.
currentF
eeling
Value
}
initial
=
{
this
.
state
.
f
eeling
}
formHorizontal
=
{
true
}
labelHorizontal
=
{
false
}
labelStyle
=
{
styles
.
radioButton
}
onPress
=
{(
itemValue
)
=>
{
this
.
setState
({
currentF
eeling
Value
:
itemValue
})
this
.
setState
({
f
eeling
:
itemValue
})
}}
/
>
<
/View
>
...
...
@@ -66,12 +66,12 @@ export default class Mucus extends Component {
<
View
style
=
{
styles
.
radioButtonRow
}
>
<
RadioForm
radio_props
=
{
mucusTextureRadioProps
}
initial
=
{
this
.
state
.
currentTextureValu
e
}
initial
=
{
this
.
state
.
textur
e
}
formHorizontal
=
{
true
}
labelHorizontal
=
{
false
}
labelStyle
=
{
styles
.
radioButton
}
onPress
=
{(
itemValue
)
=>
{
this
.
setState
({
currentTextureValu
e
:
itemValue
})
this
.
setState
({
textur
e
:
itemValue
})
}}
/
>
<
/View
>
...
...
@@ -92,13 +92,13 @@ export default class Mucus extends Component {
cycleDay
:
this
.
cycleDay
,
saveAction
:
()
=>
{
saveSymptom
(
'
mucus
'
,
this
.
cycleDay
,
{
feeling
:
this
.
state
.
currentF
eeling
Value
,
texture
:
this
.
state
.
currentTextureValu
e
,
computedNfp
:
computeSensiplanValue
(
this
.
state
.
currentF
eeling
Value
,
this
.
state
.
currentTextureValu
e
),
feeling
:
this
.
state
.
f
eeling
,
texture
:
this
.
state
.
textur
e
,
computedNfp
:
computeSensiplanValue
(
this
.
state
.
f
eeling
,
this
.
state
.
textur
e
),
exclude
:
this
.
state
.
exclude
})
},
saveDisabled
:
this
.
state
.
currentF
eeling
Value
===
-
1
||
this
.
state
.
currentTextureValu
e
===
-
1
saveDisabled
:
this
.
state
.
f
eeling
===
-
1
||
this
.
state
.
textur
e
===
-
1
}
)}
<
/View
>
...
...
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