diff options
| author | Michel Etienne | 2014-11-17 14:23:40 +0100 |
|---|---|---|
| committer | Michel Etienne | 2014-11-17 14:23:40 +0100 |
| commit | 368f6b6c8b92f89c11b704f6914796d3d424f7ae (patch) | |
| tree | 7b35353d9211d0a93a53c59634491b95abc7c919 | |
| parent | a3999c76b97fa576293a41332a92a14b0d8e210c (diff) | |
| download | chouette-core-368f6b6c8b92f89c11b704f6914796d3d424f7ae.tar.bz2 | |
manage line color with helper
| -rw-r--r-- | app/helpers/lines_helper.rb | 9 | ||||
| -rw-r--r-- | app/views/lines/_line.erb | 9 | ||||
| -rw-r--r-- | app/views/lines/show.html.erb | 2 |
3 files changed, 11 insertions, 9 deletions
diff --git a/app/helpers/lines_helper.rb b/app/helpers/lines_helper.rb index 623d091ca..80073af62 100644 --- a/app/helpers/lines_helper.rb +++ b/app/helpers/lines_helper.rb @@ -16,4 +16,13 @@ module LinesHelper def background_color(line) line.color.blank? ? "white" : "#"+line.color end + + def number_style(line) + if colors?(line) + number_style = "color: #{text_color(line)}; background-color: #{background_color(line)};" + else + number_style = "" + end + + end end diff --git a/app/views/lines/_line.erb b/app/views/lines/_line.erb index 24450fa20..5962cd64f 100644 --- a/app/views/lines/_line.erb +++ b/app/views/lines/_line.erb @@ -12,14 +12,7 @@ <h5> <%= check_box_tag "ids[]", line.id, false, :class => "multiple_selection", :style => "display: none;" %> <% if line.number and line.number.length <= 3 %> - <% if !line.text_color.blank? || !line.color.blank? %> - <% text_color = line.text_color.blank? ? "black" : "##{line.text_color}" %> - <% bg_color = line.color.blank? ? "white" : "##{line.color}" %> - <% number_style = "color: #{text_color}; background-color: #{bg_color};" %> - <% else %> - <% number_style = "" %> - <% end %> - <span class="label label-default line_number" style="<%= number_style %>"><%= line.number %></span> + <span class="label label-default line_number" style="<%= number_style(line) %>"><%= line.number %></span> <% end %> <%= link_to([@referential, line], :class => "preview", :title => "#{Chouette::Line.model_name.human.capitalize} #{line.name}") do %> <span class="name"> diff --git a/app/views/lines/show.html.erb b/app/views/lines/show.html.erb index 12af00ff7..5983aaca0 100644 --- a/app/views/lines/show.html.erb +++ b/app/views/lines/show.html.erb @@ -12,7 +12,7 @@ <% if colors?(@line) %> <p> <label><%= t('lines.index.color') %>: </label> - <label class="color" style='<%="color: #{text_color(@line)}; background-color: #{background_color(@line)};"%>'><%= line_sticker(@line) %></label> + <label class="color" style='<%="#{number_style(@line)}"%>'><%= line_sticker(@line) %></label> </p> <% end %> <p> |
