diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-20 17:53:26 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-20 17:53:26 +0100 |
commit | 29bf3235f82be1f33f349fdf2f491120fea4a533 (patch) | |
tree | dc2b154b1b27cc16f3d7a792f9e2ca70eb401305 | |
parent | 722c7680195a9e6dba98950e8bdbe373b6830fbc (diff) | |
download | taginfo-29bf3235f82be1f33f349fdf2f491120fea4a533.tar taginfo-29bf3235f82be1f33f349fdf2f491120fea4a533.tar.gz |
Add search for relation type
-rw-r--r-- | web/views/search.erb | 6 | ||||
-rw-r--r-- | web/viewsjs/search.js.erb | 27 |
2 files changed, 33 insertions, 0 deletions
diff --git a/web/views/search.erb b/web/views/search.erb index 8b0af63..b6bf5ce 100644 --- a/web/views/search.erb +++ b/web/views/search.erb @@ -6,6 +6,7 @@ <ul> <li><a href="#keys"><%= t.osm.keys %></a></li> <li><a href="#values"><%= t.osm.values %></a></li> + <li><a href="#relations"><%= t.osm.relation_types %></a></li> <li><a href="#roles"><%= t.osm.relation_member_roles %></a></li> <li><a href="#fulltext"><%= t.pages.search.fulltext %></a></li> </ul> @@ -19,6 +20,11 @@ <table id="grid-values"> </table> </div> + <div id="relations"> + <h2><%= t.osm.relation_types %></h2> + <table id="grid-relations"> + </table> + </div> <div id="roles"> <h2><%= t.osm.relation_member_roles %></h2> <table id="grid-roles"> diff --git a/web/viewsjs/search.js.erb b/web/viewsjs/search.js.erb index 9dcafa2..3e65214 100644 --- a/web/viewsjs/search.js.erb +++ b/web/viewsjs/search.js.erb @@ -22,6 +22,13 @@ function link_to_value_with_highlight(key, value, query) { ); } +function link_to_rtype_with_highlight(rtype, query) { + return link( + url_for_rtype(rtype), + highlight(rtype, query) + ); +} + var create_flexigrid_for = { keys: function(query) { create_flexigrid('grid-keys', { @@ -65,6 +72,26 @@ var create_flexigrid_for = { } }); }, + relations: function(query) { + create_flexigrid('grid-relations', { + url: '/api/4/relations/all?query=' + encodeURIComponent(query), + colModel: [ + { display: '<%= misc.count %>', name: 'count', width: 80, sortable: true, align: 'right' }, + { display: '<%= osm.relation_type %>', name: 'rtype', width: 500, sortable: true } + ], + sortname: 'count', + sortorder: 'desc', + preProcess: function(data) { + data.rows = jQuery.map(data.data, function(row, i) { + return { 'cell': [ + fmt_with_ts(row.count), + link_to_rtype_with_highlight(row.rtype, query) + ] }; + }); + return data; + } + }); + }, roles: function(query) { create_flexigrid('grid-roles', { url: '/api/4/search/by_role?query=' + encodeURIComponent(query), |