JS handler to display initial relations, drop-down, etc.

This commit is contained in:
Sanj 2011-09-01 07:34:48 +05:30
parent 7301d5157a
commit 385e3bc467
2 changed files with 23 additions and 2 deletions

View File

@ -70,7 +70,8 @@ def search_related(request):
'feature_type': FeatureType.objects.get(pk=s.feature_type_id),
'preferred_name': s.preferred_name,
'similarity': s.similarity,
'distance': s.distance
'distance': s.distance,
'relationship': ''
})
return render_to_response("search_related.html", {

View File

@ -14,6 +14,8 @@ $(function() {
});
});
var RELATIONSHIP_OPTIONS = ['conflates', 'contains', 'consumes', 'supersedes']
function getRow(d) {
var $tr = $('<tr />');
var $one = $('<td />').appendTo($tr);
@ -32,6 +34,24 @@ function getRow(d) {
$.noop();
}
var $relations_td = $('<td />').appendTo($tr);
var $relationselect = $('<select />').appendTo($relations_td);
var $opt1 = $('<option />').val('').text('---').appendTo($relationselect);
for (var i=0; i<RELATIONSHIP_OPTIONS.length; i++) {
var r = RELATIONSHIP_OPTIONS[i];
$('<option />').val(r).text(r).appendTo($relationselect);
}
if (d.relationship != '') {
$relationselect.children().each(function() {
if ($(this).val() == d.relationship) {
$(this).attr("selected", "selected");
}
});
}
return $tr;
}