|
112 | 112 |
|
113 | 113 | $.post("${createLink(controller: "editor", action: 'editRecord')}", thisFormData, function(data, textStatus, jqXHR) {
|
114 | 114 | $(modal).modal('hide');
|
115 |
| - alert(jqXHR.responseText); |
116 |
| - window.location.reload(true); |
| 115 | + var idItem = thisFormData.find(o=>o.name === "id"); |
| 116 | + var rawScientificName = thisFormData.find(o=>o.name === "rawScientificName")?.value; |
| 117 | + if (idItem) { |
| 118 | + var id = idItem.value; |
| 119 | + var row = $("tr#row_"+ id); |
| 120 | + //Only change rawScientificName, and KVP |
| 121 | + thisFormData.forEach(item=>{ |
| 122 | + //Avoid keys such as 'Profile No' |
| 123 | + var td = row.find("td."+item.name.replace(" ", "_")); |
| 124 | + if (td.length > 0) { |
| 125 | + td.html("<div>"+ item.value +"</div>"); |
| 126 | + } |
| 127 | + }); |
| 128 | + |
| 129 | + var speciesUrl = "${createLink(controller: "ws", action: 'findSpeciesByName')}" |
| 130 | + $.get(speciesUrl,{ name: rawScientificName, id:id}, function( result ) { |
| 131 | + var updatedIcon = "<i class='glyphicon glyphicon-check text-success'></i> "; |
| 132 | + var guid = result.guid; |
| 133 | + if (guid === "" || guid === null || guid === undefined){ |
| 134 | + //raw name |
| 135 | + var google = "http://google.com/search?q=" + rawScientificName; |
| 136 | + var biocache = "${grailsApplication.config.biocache.baseURL}/occurrences/search?q="+rawScientificName; |
| 137 | + var guidText= updatedIcon + rawScientificName + "<br>(unmatched - try <a href='" + google +"' target='google' class='btn btn-primary btn-xs'>Google</a>," + |
| 138 | + "<a href='" + biocache +" target='biocache' class='btn btn-success btn-xs'>${message(code:'generic.lists.button.Occurrences.label', default:'Occurrences')}</a>)"; |
| 139 | +
|
| 140 | + row.find("td.rawScientificName").html(guidText); |
| 141 | + row.find("td.matchedName").html(result.matchedName); |
| 142 | + row.find("td.imageUrl").html(""); |
| 143 | + } else { |
| 144 | + var bie = "<a href=${bieUrl}/species/" + guid + " title='click to view species page'>"+result.matchedName + "</a>" |
| 145 | + row.find("td.matchedName").html(bie) |
| 146 | + row.find("td.rawScientificName").html( "<div>"+ updatedIcon + rawScientificName +"</div>"); |
| 147 | +
|
| 148 | + if(result.imageUrl === "" || result.imageUrl === null || result.imageUrl === undefined) { |
| 149 | + row.find("td.imageUrl").html(""); |
| 150 | + } else { |
| 151 | + var image_url ="<a href=${bieUrl}/species/"+guid+" title='click to view species page'><img src="+result.imageUrl+" class='smallSpeciesImage'/></a>"; |
| 152 | + row.find("td.imageUrl").html(image_url); |
| 153 | + } |
| 154 | + } |
| 155 | + row.find("td.author").text(result.author); |
| 156 | + var terms = ["commonName", "family","kingdom"]; |
| 157 | + terms.forEach( function(item) { |
| 158 | + var td = row.find("td."+item); |
| 159 | + if ( td.length>0 ) { |
| 160 | + td.text(result[item]); |
| 161 | + td[0].id= td[0].id.substring(0,3) + guid; |
| 162 | + } |
| 163 | + }) |
| 164 | + }) |
| 165 | + } |
117 | 166 | }).error(function(jqXHR, textStatus, error) {
|
118 | 167 | alert("An error occurred: " + error + " - " + jqXHR.responseText);
|
119 | 168 | $(modal).modal('hide');
|
|
942 | 991 | </tr>
|
943 | 992 | </thead>
|
944 | 993 | <tbody>
|
| 994 | + |
945 | 995 | <g:each var="result" in="${results}" status="i">
|
946 | 996 | <g:set var="recId" value="${result.id}"/>
|
947 | 997 | %{-- <g:set var="bieTitle">${message(code:'public.lists.view.table.tooltip03', default:'species page for')} <i>${result.rawScientificName}</i></g:set>--}%
|
|
981 | 1031 | ${result.matchedName}
|
982 | 1032 | </g:else>
|
983 | 1033 | </td>
|
984 |
| - <td id="img_${result.guid}"> |
| 1034 | + <td id="img_${result.guid}" class="imageUrl"> |
985 | 1035 | <g:if test="${result.imageUrl}">
|
986 | 1036 | <a href="${bieUrl}/species/${result.guid}" title="click to view species page"><img
|
987 | 1037 | src="${result.imageUrl}"
|
988 | 1038 | class="smallSpeciesImage"/></a>
|
989 | 1039 | </g:if>
|
990 | 1040 | </td>
|
991 |
| - <td>${result.author}</td> |
992 |
| - <td id="cn_${result.guid}">${result.commonName}</td> |
993 |
| - <td id="fm_${result.guid}">${result.family}</td> |
994 |
| - <td id="kn_${result.guid}">${result.kingdom}</td> |
| 1041 | + <td class="author">${result.author}</td> |
| 1042 | + <td id="cn_${result.guid}" class="commonName" >${result.commonName}</td> |
| 1043 | + <td id="fm_${result.guid}" class="family">${result.family}</td> |
| 1044 | + <td id="kn_${result.guid}" class="kingdom">${result.kingdom}</td> |
995 | 1045 | <g:each in="${keys}" var="key">
|
996 | 1046 | <g:set var="kvp" value="${result.kvpValues.find { it.key == key }}"/>
|
997 | 1047 | <g:set var="val" value="${kvp?.vocabValue ?: kvp?.value}"/>
|
998 |
| - <td class="kvp ${val?.length() > 35 ? 'scrollWidth' : ''}"><div>${val}</div> |
| 1048 | + <td class="kvp ${key.replace(" ","_")} ${val?.length() > 35 ? 'scrollWidth' : ''}"><div>${val}</div> |
999 | 1049 | </td>
|
1000 | 1050 | </g:each>
|
1001 | 1051 | </tr>
|
|
1008 | 1058 | <div class="searchWidgets">
|
1009 | 1059 | ${message(code:'generic.lists.ItemsPerPage', default:'Items per page:')}
|
1010 | 1060 | <select id="maxItems" onchange="reloadWithMax(this)">
|
1011 |
| - <g:each in="${[10, 25, 50, 100]}" var="max"> |
| 1061 | + <g:each in="${[10, 25, 50, 100, 500, 1000]}" var="max"> |
1012 | 1062 | <option ${(params.max == max) ? 'selected="selected"' : ''}>${max}</option>
|
1013 | 1063 | </g:each>
|
1014 | 1064 | </select>
|
|
1133 | 1183 | });
|
1134 | 1184 | });
|
1135 | 1185 | </asset:script>
|
| 1186 | +
|
1136 | 1187 | </body>
|
1137 | 1188 | </html>
|
0 commit comments