Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
waterdataui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository 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
Water Mission Area
Internet of Water
waterdataui
Commits
caa16197
Commit
caa16197
authored
7 years ago
by
Yan, Andrew N.
Browse files
Options
Downloads
Patches
Plain Diff
simplify last year checkbox controller
parent
1d150383
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
assets/src/scripts/components/hydrograph/index.js
+13
-14
13 additions, 14 deletions
assets/src/scripts/components/hydrograph/index.js
with
13 additions
and
14 deletions
assets/src/scripts/components/hydrograph/index.js
+
13
−
14
View file @
caa16197
...
...
@@ -269,30 +269,29 @@ const plotSROnlyTable = function (elem, {tsKey, variable, methods, visible, data
}
};
const
controlLastYearSelect
=
function
(
elem
,
{
variable
,
availableTimeseries
})
{
/**
* Determine if the last year checkbox should be enabled or disabled
*
* @param elem
* @param compareTimeseries
*/
const
controlLastYearSelect
=
function
(
elem
,
{
compareTimeseries
})
{
const
comparePoints
=
compareTimeseries
[
Object
.
keys
(
compareTimeseries
)[
0
]]
?
compareTimeseries
[
Object
.
keys
(
compareTimeseries
)[
0
]].
points
:
[];
let
checkbox
=
elem
.
select
(
'
.hydrograph-last-year-input
'
);
if
(
variable
===
null
||
!
availableTimeseries
.
length
)
{
return
;
}
const
variableParmCd
=
variable
.
variableCode
.
value
;
const
availableVariableTimeseries
=
availableTimeseries
.
filter
(
x
=>
x
[
0
]
===
variableParmCd
);
// an array of arrays
const
variableTimeseries
=
availableVariableTimeseries
.
map
(
x
=>
x
.
slice
(
1
));
const
compareTimeseriesCountVals
=
variableTimeseries
.
map
(
x
=>
x
.
map
(
y
=>
y
.
compareTimeseriesCount
));
if
(
compareTimeseriesCountVals
.
reduce
((
a
,
b
)
=>
Number
(
a
)
+
Number
(
b
),
0
)
===
0
)
{
if
(
comparePoints
.
length
>
0
)
{
checkbox
.
property
(
'
disabled
'
,
false
);
}
else
{
checkbox
.
property
(
'
disabled
'
,
true
)
.
property
(
'
checked
'
,
false
)
.
dispatch
(
'
change
'
);
// trigger a change event
}
else
{
checkbox
.
property
(
'
disabled
'
,
null
);
.
dispatch
(
'
change
'
);
}
};
const
timeSeriesGraph
=
function
(
elem
)
{
elem
.
call
(
link
(
controlLastYearSelect
,
createStructuredSelector
({
variable
:
currentVariableSelector
,
availableTimeseries
:
availableTimeseriesSelector
compareTimeseries
:
currentVariableTimeSeriesSelector
(
'
compare
'
)
}))).
append
(
'
div
'
)
.
attr
(
'
class
'
,
'
hydrograph-container
'
)
.
append
(
'
svg
'
)
...
...
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