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
74c0a476
Commit
74c0a476
authored
8 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Adding max_hierarchy_category_id to the sorting/filtering of crops
parent
b33f8b60
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/no/nibio/vips/logic/entity/CropCategory.java
+16
-0
16 additions, 0 deletions
src/main/java/no/nibio/vips/logic/entity/CropCategory.java
src/main/webapp/templates/observationForm.ftl
+53
-31
53 additions, 31 deletions
src/main/webapp/templates/observationForm.ftl
with
69 additions
and
31 deletions
src/main/java/no/nibio/vips/logic/entity/CropCategory.java
+
16
−
0
View file @
74c0a476
...
...
@@ -76,6 +76,8 @@ public class CropCategory implements Serializable {
private
Integer
[]
cropOrganismIds
;
@Column
(
name
=
"organization_id"
)
private
Integer
organizationId
;
@Column
(
name
=
"max_hierarchy_category_id"
)
private
Integer
maxHierarchyCategoryId
;
public
CropCategory
()
{
}
...
...
@@ -216,4 +218,18 @@ public class CropCategory implements Serializable {
this
.
setCropOrganismIds
(
cropSet
.
toArray
(
new
Integer
[
cropSet
.
size
()]));
}
}
/**
* @return the maxHierarchyCategoryId
*/
public
Integer
getMaxHierarchyCategoryId
()
{
return
maxHierarchyCategoryId
;
}
/**
* @param maxHierarchyCategoryId the maxHierarchyCategoryId to set
*/
public
void
setMaxHierarchyCategoryId
(
Integer
maxHierarchyCategoryId
)
{
this
.
maxHierarchyCategoryId
=
maxHierarchyCategoryId
;
}
}
This diff is collapsed.
Click to expand it.
src/main/webapp/templates/observationForm.ftl
+
53
−
31
View file @
74c0a476
...
...
@@ -96,6 +96,9 @@
</#
if
>
//
A
ctivating
chosen
plugin
$
(
".chosen-select"
)
.chosen
()
;
//
S
how
all
available
crops
filterCrops
(
-1
)
;
}
);
// Adding selected file name to a box
...
...
@@ -342,32 +345,51 @@
cropCategoryIdList
.options
[
cropCategoryIdList
.options.length
]
=
cOption
;
}
}
function filterCrops(selectedCropCategoryId)
{
//
S
earching
for
selected
crop
category
for
(
var
i
in
cropCategories
)
if
(
selectedCropCategoryId
<
0
)
{
var
cropCategory
=
cropCategories
[
i
];
if
(
cropCategory
.cropCategoryId
==
parseInt
(
selectedCropCategoryId
))
var
cropOptions
=
[];
for
(
var
j
=
0
;
j
<
cropList
.length
;
j
++
)
{
//
var
cropOption
=
cropOrganismIdList
.options
[
j
];
var
crop
=
cropList
[
j
];
var
cropOption
=
new
O
ption
(
crop
.displayName
,
crop
.organismId
)
;
cropOptions
.push
(
cropOption
)
;
}
renderCropList
(
cropOptions
,
[]
)
;
}
else
{
//
S
earching
for
selected
crop
category
for
(
var
i
in
cropCategories
)
{
//
F
ilter
based
on
match
var
matchingCropOrganismOptions
=
[];
var
theRest
=
[];
var
cropOrganismIdList
=
document
.getElementById
(
"cropOrganismIdList"
)
;
for
(
var
j
=
0
;
j
<
cropOrganismIdList
.length
;
j
++
)
var
cropCategory
=
cropCategories
[
i
];
if
(
cropCategory
.cropCategoryId
==
parseInt
(
selectedCropCategoryId
))
{
var
cropOption
=
cropOrganismIdList
.options
[
j
];
if
(
cropCategory
.cropOrganismIds.indexOf
(
parseInt
(
cropOption
.value
))
>=
0
)
//
F
ilter
based
on
match
var
matchingCropOrganismOptions
=
[];
var
theRest
=
[];
//
var
cropOrganismIdList
=
document
.getElementById
(
"cropOrganismIdList"
)
;
for
(
var
j
=
0
;
j
<
cropList
.length
;
j
++
)
{
matchingCropOrganismOptions
.push
(
cropOption
)
;
}
else
if
(
parseInt
(
cropOption
.value
)
>
0
)
{
theRest
.push
(
cropOption
)
;
//
var
cropOption
=
cropOrganismIdList
.options
[
j
];
var
crop
=
cropList
[
j
];
var
cropOption
=
new
O
ption
(
crop
.displayName
,
crop
.organismId
)
;
if
(
cropCategory
.cropOrganismIds.indexOf
(
crop
.organismId
)
>=
0
&&
cropCategory
.maxHierarchyCategoryId
>=
crop
.hierarchyCategoryId
)
{
matchingCropOrganismOptions
.push
(
cropOption
)
;
}
else
if
(
crop
.organismId
>
0
)
{
theRest
.push
(
cropOption
)
;
}
}
renderCropList
(
matchingCropOrganismOptions
,
theRest
)
;
}
renderCropList
(
matchingCropOrganismOptions
,
theRest
)
;
}
}
}
...
...
@@ -398,6 +420,19 @@
document
.getElementById
(
"observationText"
)
.value
=
registrationOfText
;
}
</#if>
var cropList = [
<#if ! observation.observationId?has_content || user.isSuperUser() || user.isOrganizationAdmin()>
<#list allCrops as cropOrganism>
{
organismId
:
$
{
cropOrganism
.organismId
},
displayName
:
"${cropOrganism.getLocalName(currentLocale.language)!""} (${cropOrganism.latinName!""}) ${hierarchyCategories.getName(cropOrganism.hierarchyCategoryId)?upper_case}"
,
hierarchyCategoryId
:
$
{
cropOrganism
.hierarchyCategoryId
}}
<#sep>,
</#list>
<#else>
<#list allCrops as cropOrganism>
<#if (observation.cropOrganism?has_content && observation.cropOrganism.organismId == cropOrganism.organismId)>
{
organismId
:
$
{
cropOrganism
.organismId
},
displayName
:
"${cropOrganism.getLocalName(currentLocale.language)!""} (${cropOrganism.latinName!""}) ${hierarchyCategories.getName(cropOrganism.hierarchyCategoryId)?upper_case}"
,
hierarchyCategoryId
:
$
{
cropOrganism
.hierarchyCategoryId
}}
</#if>
</#list>
</#if>
];
</script>
</#
macro
>
<#
macro
page_contents>
...
...
@@ -435,19 +470,6 @@
<#if ! observation.observationId?has_content || user.isSuperUser() || user.isOrganizationAdmin()>
<option value="-1">$
{
i18nBundle
.pleaseSelect
}
$
{
i18nBundle
.cropOrganismId
?
lower_case
}
</option>
<option value="-10"<#if (observation.cropOrganism?has_content && observation.cropOrganism.organismId == -10)>selected="selected"</#if>>$
{
i18nBundle
.missingInDatabase
}
</option>
<#list allCrops as cropOrganism>
<#if cropOrganism.hierarchyCategoryId <= 121>
<option value="$
{
cropOrganism
.organismId
}
"
<#if (observation.cropOrganism?has_content && observation.cropOrganism.organismId == cropOrganism.organismId)>selected="selected"</#if>
>$
{
cropOrganism
.getLocalName
(
currentLocale
.language
)
!
""
}
($
{
cropOrganism
.latinName
!
""
}
) $
{
hierarchyCategories
.getName
(
cropOrganism
.hierarchyCategoryId
)
?
upper_case
}
</option>
</#if>
</#list>
<#else>
<#list allCrops as cropOrganism>
<#if (observation.cropOrganism?has_content && observation.cropOrganism.organismId == cropOrganism.organismId)>
<option value="$
{
cropOrganism
.organismId
}
" selected="selected">$
{
cropOrganism
.getLocalName
(
currentLocale
.language
)
!
""
}
($
{
cropOrganism
.latinName
!
""
}
) $
{
hierarchyCategories
.getName
(
cropOrganism
.hierarchyCategoryId
)
?
upper_case
}
</option>
</#if>
</#list>
</#if>
</select>
<span class="help-block" id="$
{
formId
}
_cropOrganismId_validation"></span>
...
...
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