Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSLogic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
VIPS
VIPSLogic
Commits
dc470ef5
Commit
dc470ef5
authored
1 month ago
by
Lene Wasskog
Browse files
Options
Downloads
Patches
Plain Diff
feat: Make crop/pest dropdowns for timeseries behave similar to app
parent
43815afd
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
src/main/webapp/templates/observationTimeSeriesForm.ftl
+22
-39
22 additions, 39 deletions
src/main/webapp/templates/observationTimeSeriesForm.ftl
with
22 additions
and
39 deletions
src/main/webapp/templates/observationTimeSeriesForm.ftl
+
22
−
39
View file @
dc470ef5
...
@@ -108,7 +108,7 @@
...
@@ -108,7 +108,7 @@
function showCorrectMap()
{
function showCorrectMap()
{
let
locationList
=
document
.getElementById
(
"locationPointOfInterestId"
)
;
let
locationList
=
document
.getElementById
(
"locationPointOfInterestId"
)
;
if
(
locationList
.options
[
locationList
.options.selectedIndex
]
.value
==
"-1"
)
{
if
(
locationList
.options
[
locationList
.options.selectedIndex
]
.value
==
=
"-1"
)
{
document
.getElementById
(
"poiFormMap"
)
.style.display
=
"block"
;
document
.getElementById
(
"poiFormMap"
)
.style.display
=
"block"
;
initLocationMap
(
null
)
;
initLocationMap
(
null
)
;
}
else
{
}
else
{
...
@@ -122,7 +122,6 @@
...
@@ -122,7 +122,6 @@
*
form elements in these cases, and rather display the values statically.
*
form elements in these cases, and rather display the values statically.
*
/
*
/
function displayObservationTimeSeriesInfo(cropOrganismId, organismId, locationPointOfInterestId)
{
function displayObservationTimeSeriesInfo(cropOrganismId, organismId, locationPointOfInterestId)
{
console
.log
(
"Display info!"
)
document
.getElementById
(
"cropDisplayName"
)
.innerHTML
=
nameForCropOrganismId
(
cropOrganismId
)
;
document
.getElementById
(
"cropDisplayName"
)
.innerHTML
=
nameForCropOrganismId
(
cropOrganismId
)
;
document
.getElementById
(
"pestDisplayName"
)
.innerHTML
=
nameForOrganismId
(
organismId
)
;
document
.getElementById
(
"pestDisplayName"
)
.innerHTML
=
nameForOrganismId
(
organismId
)
;
fetchPOIs
(
function
(
allPois
)
{
fetchPOIs
(
function
(
allPois
)
{
...
@@ -162,7 +161,6 @@
...
@@ -162,7 +161,6 @@
function renderCropCategories()
{
function renderCropCategories()
{
let
cropCategoryIdList
=
document
.getElementById
(
"cropCategoryIdList"
)
;
let
cropCategoryIdList
=
document
.getElementById
(
"cropCategoryIdList"
)
;
console
.info
(
"renderCropCategories"
,
cropCategories
)
for
(
let
i
in
cropCategories
)
{
for
(
let
i
in
cropCategories
)
{
let
cropCategory
=
cropCategories
[
i
];
let
cropCategory
=
cropCategories
[
i
];
//
B
est
effort
getting
name
for
crop
category
//
B
est
effort
getting
name
for
crop
category
...
@@ -173,8 +171,7 @@
...
@@ -173,8 +171,7 @@
catName
=
cLocal
.localName
;
catName
=
cLocal
.localName
;
}
}
}
}
let
cOption
=
new
O
ption
(
catName
,
cropCategory
.cropCategoryId
)
;
cropCategoryIdList
.options
[
cropCategoryIdList
.options.length
]
=
new
O
ption
(
catName
,
cropCategory
.cropCategoryId
)
;
cropCategoryIdList
.options
[
cropCategoryIdList
.options.length
]
=
cOption
;
}
}
}
}
...
@@ -222,22 +219,18 @@
...
@@ -222,22 +219,18 @@
}
}
function renderCropList(matchingCropOrganismOptions, theRest)
{
function renderCropList(matchingCropOrganismOptions, theRest)
{
var
cropOrganismIdList
=
document
.getElementById
(
"cropOrganismIdList"
)
;
let
cropOrganismIdList
=
document
.getElementById
(
"cropOrganismIdList"
)
;
if
(
!
cropOrganismIdList
)
{
if
(
!
cropOrganismIdList
)
{
//
HTML
element
does
not
exist
for
observations
in
time
series
//
HTML
element
does
not
exist
for
observations
in
time
series
return
;
return
;
}
}
cropOrganismIdList
.options.length
=
1
;
cropOrganismIdList
.options.length
=
1
;
for
(
var
i
in
matchingCropOrganismOptions
)
{
for
(
let
i
in
matchingCropOrganismOptions
)
{
cropOrganismIdList
.options
[
cropOrganismIdList
.options.length
]
=
matchingCropOrganismOptions
[
i
];
cropOrganismIdList
.options
[
cropOrganismIdList
.options.length
]
=
matchingCropOrganismOptions
[
i
];
}
}
cropOrganismIdList
.options
[
cropOrganismIdList
.options.length
]
=
new
O
ption
(
"----"
,
-1
)
;
for
(
var
i
in
theRest
)
{
cropOrganismIdList
.options
[
cropOrganismIdList
.options.length
]
=
theRest
[
i
];
}
}
}
var
cropList = [
let
cropList = [
<#if ! observationTimeSeries.observationTimeSeriesId?has_content || user.isSuperUser() || user.isOrganizationAdmin()>
<#if ! observationTimeSeries.observationTimeSeriesId?has_content || user.isSuperUser() || user.isOrganizationAdmin()>
{
organismId
:
-10
,
displayName
:
"${i18nBundle.missingInDatabase}"
,
hierarchyCategoryId
:
-1
}
,
{
organismId
:
-10
,
displayName
:
"${i18nBundle.missingInDatabase}"
,
hierarchyCategoryId
:
-1
}
,
<#list allCrops as cropOrganism>
<#list allCrops as cropOrganism>
...
@@ -260,7 +253,7 @@
...
@@ -260,7 +253,7 @@
</#if>
</#if>
];
];
var
organismList = [
let
organismList = [
<#list allPests as organism>
<#list allPests as organism>
{
{
organismId
:
$
{
organism
.organismId
},
organismId
:
$
{
organism
.organismId
},
...
@@ -268,12 +261,13 @@
...
@@ -268,12 +261,13 @@
}
,
}
,
</#list>
</#list>
];
];
let updateCropPests = function ()
{
let
theForm
=
document
.getElementById
(
'
observationTimeSeriesForm
'
)
;
theForm
[
"organismId"
]
.options.selectedIndex
=
-1
;
var updateCropPests = function ()
{
let
selectedCropId
=
theForm
[
"cropOrganismId"
]
.options
[
theForm
[
"cropOrganismId"
]
.options.selectedIndex
]
.value
;
var
theForm
=
document
.getElementById
(
'
observationTimeSeriesForm
'
)
;
var
selectedCropId
=
theForm
[
"cropOrganismId"
]
.options
[
theForm
[
"cropOrganismId"
]
.options.selectedIndex
]
.value
;
//
I
f
this
is
not
a
new
observation
,
or
the
selected
crop
is
not
in
the
database
,
we
keep
calm
//
I
f
this
is
not
a
new
observation
,
or
the
selected
crop
is
not
in
the
database
,
we
keep
calm
if
(
theForm
[
"observationTimeSeriesId"
]
.value
!==
"-1"
||
selectedCropId
==
"-10"
)
{
if
(
theForm
[
"observationTimeSeriesId"
]
.value
!==
"-1"
||
selectedCropId
==
=
"-10"
)
{
return
;
return
;
}
}
$
.getJSON
(
"/rest/organism/croppest/"
+
selectedCropId
,
function
(
json
)
{
$
.getJSON
(
"/rest/organism/croppest/"
+
selectedCropId
,
function
(
json
)
{
...
@@ -284,40 +278,29 @@
...
@@ -284,40 +278,29 @@
})
;
})
;
}
;
}
;
var
updateCropPestsCallback = function (cropPest)
{
let
updateCropPestsCallback = function (cropPest)
{
var
pestList
=
document
.getElementById
(
'
observationTimeSeriesForm
'
)
[
"organismId"
];
let
pestList
=
document
.getElementById
(
'
observationTimeSeriesForm
'
)
[
"organismId"
];
if
(
cropPest
==
null
)
{
if
(
cropPest
==
null
)
{
//
N
eed
to
reorganize
pests
back
to
default
//
N
eed
to
reorganize
pests
back
to
default
var
allPests
=
[];
let
allPests
=
[];
for
(
var
i
=
2
;
i
<
pestList
.options.length
;
i
++
)
{
for
(
let
i
=
2
;
i
<
pestList
.options.length
;
i
++
)
{
allPests
.push
(
pestList
.options
[
i
]
)
;
allPests
.push
(
pestList
.options
[
i
]
)
;
}
}
allPests
.sort
(
compareSelectListOptions
)
;
allPests
.sort
(
compareSelectListOptions
)
;
pestList
.options.length
=
2
;
//
K
eeping
the
top
two
pestList
.options.length
=
2
;
//
K
eeping
the
top
two
for
(
var
i
=
0
;
i
<
allPests
.length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
allPests
.length
;
i
++
)
{
pestList
.options
[
pestList
.options.length
]
=
allPests
[
i
];
pestList
.options
[
pestList
.options.length
]
=
allPests
[
i
];
}
}
}
else
{
}
else
{
var
prioritatedPests
=
[];
let
prioritizedPests
=
[];
var
unprioritatedPests
=
[]
for
(
let
i
=
2
;
i
<
pestList
.options.length
;
i
++
)
{
for
(
var
i
=
2
;
i
<
pestList
.options.length
;
i
++
)
{
if
(
cropPest
.pestOrganismIds.indexOf
(
parseInt
(
pestList
.options
[
i
]
.value
))
>=
0
)
{
if
(
cropPest
.pestOrganismIds.indexOf
(
parseInt
(
pestList
.options
[
i
]
.value
))
>=
0
)
{
//
console
.log
(
pestList
.options
[
i
]
.value
+
" is prioritated"
)
;
prioritizedPests
.push
(
pestList
.options
[
i
]
)
;
prioritatedPests
.push
(
pestList
.options
[
i
]
)
;
}
else
if
(
pestList
.options
[
i
]
.value
!=
"-1"
)
//
A
voiding
the
"---"
option
{
//
console
.log
(
pestList
.options
[
i
]
.value
+
" is unprioritated"
)
;
unprioritatedPests
.push
(
pestList
.options
[
i
]
)
;
}
}
}
}
pestList
.options.length
=
2
;
//
K
eeping
the
top
two
pestList
.options.length
=
2
;
//
K
eeping
the
top
two
for
(
var
i
=
0
;
i
<
prioritatedPests
.length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
prioritizedPests
.length
;
i
++
)
{
pestList
.options
[
pestList
.options.length
]
=
prioritatedPests
[
i
];
pestList
.options
[
pestList
.options.length
]
=
prioritizedPests
[
i
];
}
pestList
.options
[
pestList
.options.length
]
=
new
O
ption
(
"---"
,
"-1"
)
;
for
(
var
i
=
0
;
i
<
unprioritatedPests
.length
;
i
++
)
{
pestList
.options
[
pestList
.options.length
]
=
unprioritatedPests
[
i
];
}
}
}
}
}
;
}
;
...
@@ -439,7 +422,7 @@
...
@@ -439,7 +422,7 @@
<label for="yearList">$
{
i18nBundle
.year
}
</label>
<label for="yearList">$
{
i18nBundle
.year
}
</label>
<select class="form-control" id="yearList" name="year">
<select class="form-control" id="yearList" name="year">
<#if !observationTimeSeries.observationTimeSeriesId?has_content>
<#if !observationTimeSeries.observationTimeSeriesId?has_content>
<option value="
-1"
>$
{
i18nBundle
.pleaseSelect
}
$
{
i18nBundle
.year
?
lower_case
}
</option>
<option value="
" disabled selected
>$
{
i18nBundle
.pleaseSelect
}
$
{
i18nBundle
.year
?
lower_case
}
</option>
</#if>
</#if>
<#list years as year>
<#list years as year>
<option value="$
{
year
}
" <#if observationTimeSeries.observationTimeSeriesId?has_content && observationTimeSeries.year == year>selected</#if>>$
{
year
}
</option>
<option value="$
{
year
}
" <#if observationTimeSeries.observationTimeSeriesId?has_content && observationTimeSeries.year == year>selected</#if>>$
{
year
}
</option>
...
...
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