From 29bf3235f82be1f33f349fdf2f491120fea4a533 Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Sun, 20 Jan 2013 17:53:26 +0100 Subject: Add search for relation type --- web/viewsjs/search.js.erb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'web/viewsjs') 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), -- cgit v1.2.3