diff options
author | Jochen Topf <jochen@topf.org> | 2013-01-07 15:47:05 +0100 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2013-01-07 15:47:05 +0100 |
commit | a334668751ca122e0e34c77d297f60818e951df6 (patch) | |
tree | 608072104444ab955774f6eb7dc6ac4ac419c343 | |
parent | 6c3cf500cd115227148c8a8a8e8ce9c51ac337bc (diff) | |
download | taginfo-a334668751ca122e0e34c77d297f60818e951df6.tar taginfo-a334668751ca122e0e34c77d297f60818e951df6.tar.gz |
Empty table issue cleanup.
Sometimes there are not results for some query and you'll end up with an empty
table. It would be nice if no empty table appears in this case but instead some
nice message. But we can't simply remove the table, because if people use the
search-inside-table function and that was the result of the empty table they
loose the ability to change the search term.
We could only draw the table in the first place if there will be something in
it. But just finding out whether there will be something in the table can be
quite expensive, for instance with searches for values. So we don't want to do
this twice (once in the template to find out whether to draw the table in the
first place and once in the API call filling the table.) So we are currently
stuck with what we have until somebody invents a better way.
-rw-r--r-- | web/i18n/de.yml | 1 | ||||
-rw-r--r-- | web/i18n/en.yml | 1 | ||||
-rw-r--r-- | web/i18n/pl.yml | 1 | ||||
-rw-r--r-- | web/lib/ui/keys_tags.rb | 2 | ||||
-rw-r--r-- | web/public/js/flexigrid.js | 5 | ||||
-rw-r--r-- | web/views/key.erb | 8 | ||||
-rw-r--r-- | web/views/tag.erb | 8 | ||||
-rw-r--r-- | web/viewsjs/key.js.erb | 1 | ||||
-rw-r--r-- | web/viewsjs/search.js.erb | 4 | ||||
-rw-r--r-- | web/viewsjs/tag.js.erb | 2 |
10 files changed, 14 insertions, 19 deletions
diff --git a/web/i18n/de.yml b/web/i18n/de.yml index da8c841..55f37f8 100644 --- a/web/i18n/de.yml +++ b/web/i18n/de.yml @@ -184,7 +184,6 @@ pages: to_count_tooltip: Anzahl Objekte mit diesem Tag, die auch den anderen Tag/Key haben. other_key_tooltip: Andere Tags/Keys, die zusammen mit diesem Tag vorkommen. from_count_tooltip: Anzahl Objekte mit dem anderen Tag, die auch diesen Tag/Key haben. - none_found: Keine Kombinationen gefunden (nur die häufigsten Kombinationen wurden geprüft). combinations: title: Kombinationen description: Diese Tabelle zeigt nur die häufigsten Kombinationen der häufigsten Tags. diff --git a/web/i18n/en.yml b/web/i18n/en.yml index 6d4a0c8..a1c5ad5 100644 --- a/web/i18n/en.yml +++ b/web/i18n/en.yml @@ -180,7 +180,6 @@ pages: to_count_tooltip: Number of objects with this tag that also have the other tag/key. other_key_tooltip: Tags/Keys used together with this tag. from_count_tooltip: Number of objects with other tag/key that also have this tag. - none_found: No combinations found (only checked the most common ones). combinations: title: Combinations description: This table shows only the most common combinations of the most common tags. diff --git a/web/i18n/pl.yml b/web/i18n/pl.yml index ab72853..a733799 100644 --- a/web/i18n/pl.yml +++ b/web/i18n/pl.yml @@ -171,7 +171,6 @@ pages: to_count_tooltip: Liczba obiektów z tym tagiem, które mają także inne tagi/klucze. other_key_tooltip: Tagi/klucze użyte wraz z tym tagiem. from_count_tooltip: Liczba obiektów z innym tagiem/kluczem, które mają także ten tag. - none_found: Brak znalezionych powiązań (tylko najbardziej powrzechne). combinations: title: Połączenia description: Ta tabela pokazuje tylko najbardziej powszechne połączenia najpopularniejszych tagów. diff --git a/web/lib/ui/keys_tags.rb b/web/lib/ui/keys_tags.rb index 2685a5f..8c59e17 100644 --- a/web/lib/ui/keys_tags.rb +++ b/web/lib/ui/keys_tags.rb @@ -40,6 +40,7 @@ class Taginfo < Sinatra::Base @prevalent_values << { 'value' => '(other)', 'count' => @count_all_values - sum } end + @josm_count = @db.count('josm_style_rules').condition('k = ?', @key).get_first_value().to_i @wiki_count = @db.count('wiki.wikipages').condition('value IS NULL').condition('key=?', @key).get_first_value().to_i @user_count = @db.select('SELECT users_all FROM db.keys').condition('key=?', @key).get_first_value().to_i @@ -91,6 +92,7 @@ class Taginfo < Sinatra::Base @sel[@filter_type] = ' selected="selected"' @filter_xapi = { 'all' => '*', nil => '*', 'nodes' => 'node', 'ways' => 'way', 'relations' => 'relation' }[@filter_type]; + @josm_count = @db.count('josm_style_rules').condition('k = ?', @key).condition('v = ?', @value).get_first_value().to_i @wiki_count = @db.count('wiki.wikipages').condition('key=?', @key).condition('value=?', @value).get_first_value().to_i if @wiki_count == 0 @wiki_count_key = @db.count('wiki.wikipages').condition('key=?', @key).condition('value IS NULL').get_first_value().to_i diff --git a/web/public/js/flexigrid.js b/web/public/js/flexigrid.js index 6649004..83fbc54 100644 --- a/web/public/js/flexigrid.js +++ b/web/public/js/flexigrid.js @@ -406,11 +406,6 @@ if (this.pDiv) {
this.domElements.pPageStat.html(p.nomsg);
}
-/* if (p.emptymsg != null) {
- jQuery(this.gDiv).replaceWith('<p class="empty">' + p.emptymsg + '</p>');
- } else {
- jQuery(this.gDiv).remove();
- }*/
return false;
}
diff --git a/web/views/key.erb b/web/views/key.erb index 8833eb6..14f952a 100644 --- a/web/views/key.erb +++ b/web/views/key.erb @@ -87,8 +87,12 @@ <option>Standard</option> </select> </form>--> - <table id="grid-josm"> - </table> +<% if @josm_count > 0 %> + <table id="grid-josm"> + </table> +<% else %> + <p class="empty"><%= t.pages.key.josm.no_styles %></p> +<% end %> </div> </div> <iframe id="josmiframe" name="josmiframe"></iframe> diff --git a/web/views/tag.erb b/web/views/tag.erb index caf436d..70ebd8c 100644 --- a/web/views/tag.erb +++ b/web/views/tag.erb @@ -57,8 +57,12 @@ <option>Standard</option> </select> </form>--> - <table id="grid-josm"> - </table> +<% if @josm_count > 0 %> + <table id="grid-josm"> + </table> +<% else %> + <p class="empty"><%= t.pages.key.josm.no_styles %></p> +<% end %> </div> </div> <iframe id="josmiframe" name="josmiframe"></iframe> diff --git a/web/viewsjs/key.js.erb b/web/viewsjs/key.js.erb index 6e84c1a..8fc4a04 100644 --- a/web/viewsjs/key.js.erb +++ b/web/viewsjs/key.js.erb @@ -129,7 +129,6 @@ var create_flexigrid_for = { ], sortname: 'value', sortorder: 'asc', - emptymsg: '<%= page.josm.no_styles %>', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ diff --git a/web/viewsjs/search.js.erb b/web/viewsjs/search.js.erb index 22f0a92..5c51364 100644 --- a/web/viewsjs/search.js.erb +++ b/web/viewsjs/search.js.erb @@ -13,7 +13,6 @@ var create_flexigrid_for = { ], sortname: 'count_all', sortorder: 'desc', - emptymsg: '<%= search.no_keys %>', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ @@ -35,7 +34,6 @@ var create_flexigrid_for = { ], sortname: 'count_all', sortorder: 'desc', - emptymsg: '<%= search.no_values %>', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ @@ -59,7 +57,6 @@ var create_flexigrid_for = { ], sortname: 'count_all', sortorder: 'desc', - emptymsg: '<%= search.no_tags %>', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ @@ -81,7 +78,6 @@ var create_flexigrid_for = { ], sortname: 'key', sortorder: 'asc', - emptymsg: '<%= search.no_match %>', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ diff --git a/web/viewsjs/tag.js.erb b/web/viewsjs/tag.js.erb index 7f745ba..88e1e41 100644 --- a/web/viewsjs/tag.js.erb +++ b/web/viewsjs/tag.js.erb @@ -40,7 +40,6 @@ var create_flexigrid_for = { ], sortname: 'to_count', sortorder: 'desc', - emptymsg: '<%= page.other_tags_used.none_found %>', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ @@ -102,7 +101,6 @@ var create_flexigrid_for = { ], sortname: 'value', sortorder: 'asc', - emptymsg: '<%= page.josm.no_styles %>', preProcess: function(data) { data.rows = jQuery.map(data.data, function(row, i) { return { 'cell': [ |