-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 470 refine state selection #476
Conversation
I've created a screen capture which can be downloaded |
Thanks @alexhuang091, that looks really good! I have one question about the states & territories drop-down (haven't run the PR myself) - when there is no country selected, does it still show every state/territory (same as current implementation)? |
@@ -659,6 +659,32 @@ class WebServicesService { | |||
dataQualityCodes | |||
} | |||
|
|||
// maps from country name to iso code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add proper Javadoc - /** Foo */
so IDE can display info about method from the controller code, etc...
Hi Nick,
Yes when
1. Page initially loaded
2. User selects the first option C select a country C
All original states will be populated. (those states get from solr)
There's a small issue though, if you select 'Australia' + 'ACT' and submit, you go to biocache-hubs page. Then you navigate back, the country will be restored to Australia, the state list is correctly populated, but the previously selected state is not selected. (extra code needed to remember previous state because states list is constructed dynamically, I don't bother to do it now)
Thanks
发件人: Nick dos Remedios ***@***.***>
日期: 星期三, 2021年8月11日 下午12:53
收件人: AtlasOfLivingAustralia/biocache-hubs ***@***.***>
抄送: HUANG, Alex (NCMI, Black Mountain) ***@***.***>, Mention ***@***.***>
主题: Re: [AtlasOfLivingAustralia/biocache-hubs] Issue 470 refine state selection (#476)
Thanks @alexhuang091<https://github.com/alexhuang091>, that looks really good!
I have one question about the states & territories drop-down (haven't run the PR myself) - when there is no country selected, does it still show every state/territory (same as current implementation)?
―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#476 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AOWSDI2IFZVOLJ4GSE4UMY3T4HQZRANCNFSM5B5E7WEA>.
|
return states.findAll { it -> beAValidCountryOrState(it) }.collect { it -> (String)it.get("name") } | ||
} | ||
} | ||
[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference is for a single return statement, when it is practical (you have 2 in this method) - as it makes the code easier to read. E.g.
List<String> getStates(String countryName) {
List<String> matchingStates = []
if (countryNameMap?.containsKey(countryName)) {
def states = getJsonElements("${grailsApplication.config.userdetails.baseUrl}/ws/registration/states.json?country=" + countryNameMap.get(countryName))
if (states) {
// only return valid states
matchingStates = states.findAll { it -> beAValidCountryOrState(it) }.collect { it -> (String)it.get("name") }
}
}
matchingStates
}
Seeing []
as last statement is not ideal as it makes me think this is the "intended" output when its really the "exception" to the output.
Map countryNameMap = grailsApplication.mainContext.getBean('webServicesService').getCountryNameMap() | ||
// if a known country name | ||
if (countryNameMap?.containsKey(countryName)) { | ||
def states = getJsonElements("${grailsApplication.config.userdetails.baseUrl}/ws/registration/states.json?country=" + countryNameMap.get(countryName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking if this needs to be (exception) caught? What happens if the service throws an error? Does the user (or ALA staff) have anyway to know that its not working or will it silently fail and be an empty list (that you could interpret as "we don't have any states for this country")?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Nick, for frontend, only when request is successful will be state list be re-constructed.
$.getJSON(url, function(data)
- If not empty, populate it
- If empty (no matter because originally empty or backend error), populate with the original list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the backend.
def getCountryNameMap() {
def countryUrl = "${grailsApplication.config.userdetails.baseUrl}/ws/registration/countries.json"
def countries = getJsonElements(countryUrl)
getJsonElements
might throw an exception, why it doesn't have a throws in definition
JSONElement getJsonElements(String url, String apiKey = null) {
I should catch it I think. So frontend always get 200
, in case of error we return an empty list.
* #379 Records from DigiVol don't show "Flag an issue" button * updated version to 3.0.3-SNAPSHOT for next iteration * Feature/duplicate record (#429) Add duplicate assertion type to flag an issue * enhanced duplicate record flag (#431) * release 3.0.3 (#432) * version to 3.0.4-SNAPSHOT * #434 fix duplicate record facet labels Code formatting * Feature my annotation (#435) * allow user to subscribe to 'my annotation' alert when flagging an issue * Fix jquery.i18n load errors * $.param() doesn't format object correctly (#438) * Release/3.0.4 (#442) * 3.0.5-SNAPSHOT * #443 fixes for flash.message exposing apiKey * Revert "Fix jquery.i18n load errors" * Translation of Map legend button and pagination next and previous button * release 3.0.5 (#449) * 3.0.6-SNAPSHOT * AtlasOfLivingAustralia/la-pipelines#372 hide passed assertions by default * i18n en differentiate between duplicate_status and duplicate_type * Bugfix/la pipelines 445 dq profile category dialog display (#456) * AtlasOfLivingAustralia/la-pipelines#445 process array of filters rather then combined filter * AtlasOfLivingAustralia/la-pipelines#445 increase width of DQ profile modal * AtlasOfLivingAustralia/la-pipelines#372 removed test for data quality assertion code `1` * Fix for AtlasOfLivingAustralia/la-pipelines/issues/467 Fix for incorrect sort param for subsequent (paginated) calls for the species list column in EYA. * update biocache-hubs since backend now returns 404 when no record found. * Update README.md * fixed an issue in reading local json files * border-radius for active filters (#462) * wrap taxon name with "" * removed log code * clean log * AtlasOfLivingAustralia/la-pipelines#419 (#465) pass filters and descriptions as JSON array standardise display of filters for DQ profile and category * Release/3.0.6 (#468) * 3.0.7-SNAPSHOT * no strip . in taxon (#469) * handle the case where taxa query returns empty JSON object (404) (#472) * make 'disableAll' and 'expand' configurable (#473) * make 'disableAll' and 'expand' configurable * when 'quality profile' is changed, update drop-down immediately (#474) * use 'fa' for font-awesome 4.x * Issue 470 refine state selection (#476) advanced search UI refine: state list be populated per country selected * style changes to admin page for dq admin link (#477) * fixed a type in flag an issue error message (#478) * added sound file metadata and sound file link to record detail page. (#479) * explicitly set 'user_facets' as String in cookie (#480) * updated css style for #occurrenceSounds * updated message.properties * location display logic updated (#485) * Avh issue120 avh styling (#487) * remove some inline styles * updated left side panel dq filters display * fix the 'view excluded records' on left side panel doesn't work issue. * fix the 'filter details' not shown on left side panel issue * style change, left side panel dq spin * Issue 334 update ehcache (#488) updated to ehcache 3.0 * updated getJsonElements to handle JSON error better (#490) * removed persistence settings * release 3.0.7 Co-authored-by: Rita Chen <[email protected]> Co-authored-by: Nick dos Remedios <[email protected]> Co-authored-by: vjrj <[email protected]> Co-authored-by: alice.ainsa <[email protected]> Co-authored-by: Dave Martin <[email protected]> Co-authored-by: Bruce Hyslop <[email protected]> Co-authored-by: adam-collins <[email protected]>
* #379 Records from DigiVol don't show "Flag an issue" button * updated version to 3.0.3-SNAPSHOT for next iteration * Feature/duplicate record (#429) Add duplicate assertion type to flag an issue * enhanced duplicate record flag (#431) * release 3.0.3 (#432) * version to 3.0.4-SNAPSHOT * #434 fix duplicate record facet labels Code formatting * Feature my annotation (#435) * allow user to subscribe to 'my annotation' alert when flagging an issue * Fix jquery.i18n load errors * $.param() doesn't format object correctly (#438) * Release/3.0.4 (#442) * 3.0.5-SNAPSHOT * #443 fixes for flash.message exposing apiKey * Revert "Fix jquery.i18n load errors" * Translation of Map legend button and pagination next and previous button * release 3.0.5 (#449) * 3.0.6-SNAPSHOT * AtlasOfLivingAustralia/la-pipelines#372 hide passed assertions by default * i18n en differentiate between duplicate_status and duplicate_type * Bugfix/la pipelines 445 dq profile category dialog display (#456) * AtlasOfLivingAustralia/la-pipelines#445 process array of filters rather then combined filter * AtlasOfLivingAustralia/la-pipelines#445 increase width of DQ profile modal * AtlasOfLivingAustralia/la-pipelines#372 removed test for data quality assertion code `1` * Fix for AtlasOfLivingAustralia/la-pipelines/issues/467 Fix for incorrect sort param for subsequent (paginated) calls for the species list column in EYA. * update biocache-hubs since backend now returns 404 when no record found. * Update README.md * fixed an issue in reading local json files * border-radius for active filters (#462) * wrap taxon name with "" * removed log code * clean log * AtlasOfLivingAustralia/la-pipelines#419 (#465) pass filters and descriptions as JSON array standardise display of filters for DQ profile and category * Release/3.0.6 (#468) * 3.0.7-SNAPSHOT * no strip . in taxon (#469) * handle the case where taxa query returns empty JSON object (404) (#472) * make 'disableAll' and 'expand' configurable (#473) * make 'disableAll' and 'expand' configurable * when 'quality profile' is changed, update drop-down immediately (#474) * use 'fa' for font-awesome 4.x * Issue 470 refine state selection (#476) advanced search UI refine: state list be populated per country selected * style changes to admin page for dq admin link (#477) * fixed a type in flag an issue error message (#478) * added sound file metadata and sound file link to record detail page. (#479) * explicitly set 'user_facets' as String in cookie (#480) * updated css style for #occurrenceSounds * updated message.properties * location display logic updated (#485) * Avh issue120 avh styling (#487) * remove some inline styles * updated left side panel dq filters display * fix the 'view excluded records' on left side panel doesn't work issue. * fix the 'filter details' not shown on left side panel issue * style change, left side panel dq spin * Issue 334 update ehcache (#488) updated to ehcache 3.0 * updated getJsonElements to handle JSON error better (#490) * removed persistence settings * release 3.0.7 (#493) * 3.0.8-SNAPSHOT * the converted value should be put back to map to be used somewhere else * updated 'exclude count' font style * release 3.0.8 Co-authored-by: Rita Chen <[email protected]> Co-authored-by: Nick dos Remedios <[email protected]> Co-authored-by: vjrj <[email protected]> Co-authored-by: alice.ainsa <[email protected]> Co-authored-by: Dave Martin <[email protected]> Co-authored-by: Bruce Hyslop <[email protected]> Co-authored-by: adam-collins <[email protected]>
advanced search UI refine: state list be populated per country selected
advanced search UI refine: state list be populated per country selected
for #470
states
are populated by the selected countryUnited States
but the API has states forUnited States of America
so if user selectUnited States
, no state will be foundoriginal state list will be used.
This change also exposes /occurrences/getStates which need to be configured to expose