aboutsummaryrefslogtreecommitdiff
path: root/web/viewsjs
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2014-08-21 14:38:23 +0200
committerJochen Topf <jochen@topf.org>2014-08-21 14:38:23 +0200
commit960a39f5937a50b4d999a3fc5e7465412eb377a0 (patch)
treeafd6af6c77f8f30e862ed80c3f2b3279d577e9f0 /web/viewsjs
parentcd12010108e17dfab6ebf6f2902663430505bcfe (diff)
downloadtaginfo-960a39f5937a50b4d999a3fc5e7465412eb377a0.tar
taginfo-960a39f5937a50b4d999a3fc5e7465412eb377a0.tar.gz
Add new 'projects' source.
Any kind of project using OSM tags can create a json-formatted taginfo project file and after its URL is added to the taginfo config, taginfo will integrate this data into its database.
Diffstat (limited to 'web/viewsjs')
-rw-r--r--web/viewsjs/key.js.erb26
-rw-r--r--web/viewsjs/project.js.erb35
-rw-r--r--web/viewsjs/projects.js.erb23
-rw-r--r--web/viewsjs/tag.js.erb26
4 files changed, 110 insertions, 0 deletions
diff --git a/web/viewsjs/key.js.erb b/web/viewsjs/key.js.erb
index f40af36..ad9937d 100644
--- a/web/viewsjs/key.js.erb
+++ b/web/viewsjs/key.js.erb
@@ -1,6 +1,7 @@
<%
osm = @trans.t.osm
misc = @trans.t.misc
+ taginfo = @trans.t.taginfo
page = @trans.t.pages.key
%>
var create_flexigrid_for = {
@@ -143,6 +144,31 @@ var create_flexigrid_for = {
return data;
}
});
+ },
+ projects: function(key, filter_type) {
+ create_flexigrid('grid-projects', {
+ url: '/api/4/tag/projects?key=' + encodeURIComponent(key),
+ colModel: [
+ { display: '<%= h(taginfo.project) %>', name: 'project_name', width: 200, sortable: true },
+ { display: '<%= h(osm.tag) %>', name: 'key', width: 220, sortable: true },
+ { display: '<%= h(misc.description) %>', name: 'description', width: 600, sortable: false, align: 'left' }
+ ],
+ searchitems: [
+ { display: '<%= h(taginfo.project) %>/<%= h(osm.value) %>', name: 'project_value' }
+ ],
+ sortname: 'key',
+ sortorder: 'asc',
+ preProcess: function(data) {
+ data.rows = jQuery.map(data.data, function(row, i) {
+ return { 'cell': [
+ link_to_project(row.project_id, row.project_name),
+ row.value ? link_to_tag(row.key, row.value) : (link_to_key(row.key) + '=*'),
+ project_tag_desc(row.description, row.icon_url, row.doc_url)
+ ] };
+ });
+ return data;
+ }
+ });
}
};
diff --git a/web/viewsjs/project.js.erb b/web/viewsjs/project.js.erb
new file mode 100644
index 0000000..59af6dd
--- /dev/null
+++ b/web/viewsjs/project.js.erb
@@ -0,0 +1,35 @@
+<%
+ osm = @trans.t.osm
+ misc = @trans.t.misc
+ %>
+var create_flexigrid_for = {
+ tags: function(project) {
+ create_flexigrid('grid-tags', {
+ url: '/api/4/project/tags?project=' + encodeURIComponent(project),
+ colModel: [
+ { display: '<%= h(osm.tag) %>', name: 'tag', width: 260, sortable: true },
+ { display: '<%= h(misc.description) %>', name: 'description', width: 800, sortable: false, align: 'left' }
+ ],
+ searchitems: [
+ { display: '<%= h(osm.key) %>/<%= h(osm.value) %>', name: 'key_value' }
+ ],
+ sortname: 'tag',
+ sortorder: 'asc',
+ preProcess: function(data) {
+ data.rows = jQuery.map(data.data, function(row, i) {
+ return { 'cell': [
+ row.value ? link_to_tag(row.key, row.value) : (link_to_key(row.key) + '=*'),
+ project_tag_desc(row.description, row.doc_url, row.icon_url)
+ ] };
+ });
+ delete data.data;
+ return data;
+ }
+ });
+ }
+};
+
+function page_init() {
+ up = function() { window.location = '/projects'; }
+ page_init2();
+}
diff --git a/web/viewsjs/projects.js.erb b/web/viewsjs/projects.js.erb
new file mode 100644
index 0000000..55878c9
--- /dev/null
+++ b/web/viewsjs/projects.js.erb
@@ -0,0 +1,23 @@
+function page_init() {
+ create_flexigrid('grid-projects', {
+ url: '/api/4/projects/all',
+ colModel: [
+ { display: '<%= h(@trans.t.taginfo.project) %>', name: 'name', width: 300, sortable: true },
+ { display: '<%= h(@trans.t.misc.description) %>', name: 'description', width: 600, sortable: false }
+ ],
+ searchitems: [
+ { display: '<%= h(@trans.t.taginfo.project) %>/<%= h(@trans.t.misc.description) %>', name: 'name' }
+ ],
+ sortname: 'name',
+ sortorder: 'asc',
+ preProcess: function(data) {
+ data.rows = jQuery.map(data.data, function(row, i) {
+ return { 'cell': [
+ link_to_project(row.id, row.name),
+ html_escape(row.description)
+ ] };
+ });
+ return data;
+ }
+ });
+}
diff --git a/web/viewsjs/tag.js.erb b/web/viewsjs/tag.js.erb
index f9181d4..d47906e 100644
--- a/web/viewsjs/tag.js.erb
+++ b/web/viewsjs/tag.js.erb
@@ -1,6 +1,7 @@
<%
osm = @trans.t.osm
misc = @trans.t.misc
+ taginfo = @trans.t.taginfo
page = @trans.t.pages.tag
%>
function link_to_key_or_tag(key, value) {
@@ -123,6 +124,31 @@ var create_flexigrid_for = {
return data;
}
});
+ },
+ projects: function(key, value) {
+ create_flexigrid('grid-projects', {
+ url: '/api/4/tag/projects?key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value),
+ colModel: [
+ { display: '<%= h(taginfo.project) %>', name: 'project_name', width: 200, sortable: true },
+ { display: '<%= h(osm.tag) %>', name: 'key', width: 220, sortable: true },
+ { display: '<%= h(misc.description) %>', name: 'description', width: 600, sortable: false, align: 'left' }
+ ],
+ searchitems: [
+ { display: '<%= h(taginfo.project) %>/<%= h(osm.value) %>', name: 'project_value' }
+ ],
+ sortname: 'key',
+ sortorder: 'asc',
+ preProcess: function(data) {
+ data.rows = jQuery.map(data.data, function(row, i) {
+ return { 'cell': [
+ link_to_project(row.project_id, row.project_name),
+ row.value ? link_to_tag(row.key, row.value) : (link_to_key(row.key) + '=*'),
+ project_tag_desc(row.description, row.icon_url, row.doc_url)
+ ] };
+ });
+ return data;
+ }
+ });
}
};