Skip to content

Commit

Permalink
#269 fix image url when a species name changed
Browse files Browse the repository at this point in the history
  • Loading branch information
qifeng-bai committed Sep 19, 2023
1 parent 69407f0 commit 191b205
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,15 @@ class EditorController {
//check if name information has changed
if (params.rawScientificName.trim() != sli.rawScientificName.trim()) {
log.debug "rawScientificName is different: " + params.rawScientificName + " VS " + sli.rawScientificName
log.debug "re-matching name for ${params.rawScientificName}"
sli.rawScientificName = params.rawScientificName
changed = true
// lookup guid
helperService.matchNameToSpeciesListItem(sli.rawScientificName, sli, sli.mylist)
//sli.guid = helperService.findAcceptedLsidByScientificName(sli.rawScientificName)?: helperService.findAcceptedLsidByCommonName(sli.rawScientificName)
}
if (changed) {
log.debug "re-matching name for ${params.rawScientificName}"
helperService.matchNameToSpeciesListItem(sli.rawScientificName, sli, sli.mylist)
//Update image url
helperService.getCommonNamesAndUpdateRecords([sli],[sli.guid])
sl.lastMatched = new Date()
//sli.guid = helperService.findAcceptedLsidByScientificName(sli.rawScientificName)?: helperService.findAcceptedLsidByCommonName(sli.rawScientificName)
}

if (!sli.validate()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ class HelperService {
sli.commonName = null
sli.family = null
sli.kingdom = null
sli.imageUrl = null
}
}

Expand Down
5 changes: 3 additions & 2 deletions grails-app/views/speciesListItem/list.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@

var speciesUrl = "${createLink(controller: "ws", action: 'findSpeciesByName')}"
$.get(speciesUrl,{ name: rawScientificName, id:id}, function( result ) {
var updatedIcon = "<i class='glyphicon glyphicon-check text-success'></i> ";
var guid = result.guid;
if (guid === "" || guid === null || guid === undefined){
//raw name
var google = "http://google.com/search?q=" + rawScientificName;
var biocache = "${grailsApplication.config.biocache.baseURL}/occurrences/search?q="+rawScientificName;
var guidText= rawScientificName + "<br>(unmatched - try <a href='" + google +"' target='google' class='btn btn-primary btn-xs'>Google</a>," +
var guidText= updatedIcon + rawScientificName + "<br>(unmatched - try <a href='" + google +"' target='google' class='btn btn-primary btn-xs'>Google</a>," +
"<a href='" + biocache +" target='biocache' class='btn btn-success btn-xs'>${message(code:'generic.lists.button.Occurrences.label', default:'Occurrences')}</a>)";
row.find("td.rawScientificName").html(guidText);
Expand All @@ -141,6 +142,7 @@
} else {
var bie = "<a href=${bieUrl}/species/" + guid + " title='click to view species page'>"+result.matchedName + "</a>"
row.find("td.matchedName").html(bie)
row.find("td.rawScientificName").html( "<div>"+ updatedIcon + rawScientificName +"</div>");
if(result.imageUrl === "" || result.imageUrl === null || result.imageUrl === undefined) {
row.find("td.imageUrl").html("");
Expand All @@ -149,7 +151,6 @@
row.find("td.imageUrl").html(image_url);
}
}
row.find("td.author").text(result.author);
var terms = ["commonName", "family","kingdom"];
terms.forEach( function(item) {
Expand Down

0 comments on commit 191b205

Please sign in to comment.