diff options
| author | vlatka pavisic | 2016-11-15 15:55:39 +0100 |
|---|---|---|
| committer | vlatka pavisic | 2016-11-15 15:55:44 +0100 |
| commit | 9b52eb60503dca1294b677fa65cb6bbdbb81cd82 (patch) | |
| tree | f5e2dc019e110d0b0598d185e63983fa626bdc15 | |
| parent | e652bbfa3f1665a405b361488a9e48a09b8ebb64 (diff) | |
| download | chouette-core-9b52eb60503dca1294b677fa65cb6bbdbb81cd82.tar.bz2 | |
Refs #1935: Do not show select if there are no options
| -rw-r--r-- | app/views/lines/index.html.slim | 10 | ||||
| -rw-r--r-- | app/views/referential_lines/index.html.slim | 6 |
2 files changed, 7 insertions, 9 deletions
diff --git a/app/views/lines/index.html.slim b/app/views/lines/index.html.slim index 92c04a193..11aa1810a 100644 --- a/app/views/lines/index.html.slim +++ b/app/views/lines/index.html.slim @@ -14,12 +14,10 @@ .row .col-md-10.col-sm-9 .row - .col-md-4.col-sm-4 - = f.select(:network_id_eq, @line_referential.networks.collect {|n| [ n.name, n.id ] }.unshift([t('.no_networks'), -1]), {include_blank: t('.all_networks')}, {class: 'form-control'}) - .col-md-4.col-sm-4 - = f.select(:company_id_eq, @line_referential.companies.collect {|c| [ c.name, c.id ] }.unshift([t('.no_companies'), -1]), {include_blank: t('.all_companies')}, {class: 'form-control'}) - .col-md-4.col-sm-4 - = f.select(:group_of_lines_id_eq, @line_referential.group_of_lines.collect {|c| [ c.name, c.id ] }.unshift([t('.no_group_of_lines'), -1]), {include_blank: t('.all_group_of_lines')}, {class: 'form-control'}) + - %w(networks companies group_of_lines).each do |filter| + .col-md-4.col-sm-4 + - if @referential && @referential.send(filter).any? + = f.select(:"#{filter.singularize unless filter == 'group_of_lines'}_id_eq", @referential.send(filter).collect { |f| [f.name, f.id] }.unshift([t(".no_#{filter}"), -1]), { include_blank: t(".all_#{filter}") }, { class: 'form-control' }) .col-md-2.col-sm-3 button.btn.btn-primary.btn-block type="submit" Filtrer diff --git a/app/views/referential_lines/index.html.slim b/app/views/referential_lines/index.html.slim index 5647bde0c..1bae6468a 100644 --- a/app/views/referential_lines/index.html.slim +++ b/app/views/referential_lines/index.html.slim @@ -15,9 +15,9 @@ #advanced_search.panel-collapse.collapse .panel-body - = f.select(:network_id_eq, @referential.networks.collect {|n| [ n.name, n.id ] }.unshift([t('.no_networks'), -1]), {include_blank: t('.all_networks')}, { :class => 'form-control' }) - = f.select(:company_id_eq, @referential.companies.collect {|c| [ c.name, c.id ] }.unshift([t('.no_companies'), -1]), { include_blank: t('.all_companies')}, { :class => 'form-control' }) - = f.select(:group_of_lines_id_eq, @referential.group_of_lines.collect {|c| [ c.name, c.id ] }.unshift([t('.no_group_of_lines'), -1]), {include_blank: t('.all_group_of_lines')}, { :class => 'form-control' }) + - %w(networks companies group_of_lines).each do |filter| + - if @referential.send(filter).any? + = f.select(:"#{filter.singularize unless filter == 'group_of_lines'}_id_eq", @referential.send(filter).collect { |f| [f.name, f.id] }.unshift([t(".no_#{filter}"), -1]), { include_blank: t(".all_#{filter}") }, { class: 'form-control' }) #lines = render 'lines' |
