afimb/chouette2

View on GitHub
app/views/rule_parameter_sets/show.html.erb

Summary

Maintainability
Test Coverage
<%= title_tag t('rule_parameter_sets.show.title', :rule_parameter_set => @rule_parameter_set.name ) %>

<div class="rule_parameter_set_show">

  <div class="summary">
    <p>
      <label><%= RuleParameterSet.human_attribute_name("stop_areas_area") %>: </label>
      <%= @rule_parameter_set.stop_areas_area %>
    </p>
    <div class="attributes_group" >
      <span class="title"><%= t(".min_distance") %></span>
      <div class="columns">
        <div class="two_columns">
          <label><%= t(".inter_stop_area_distance_min") %> : </label>
          <span class="value"><%= @rule_parameter_set.inter_stop_area_distance_min %></span>
        </div>
        <div class="two_columns">
          <label><%= t(".inter_access_point_distance_min") %> : </label>
          <span class="value"><%= @rule_parameter_set.inter_access_point_distance_min %></span>
        </div>
      </div>
    </div>
    <div class="attributes_group" >
      <span class="title"><%= t(".max_distance") %></span>
      <div class="columns">
        <div class="two_columns">
          <label><%= t(".parent_stop_area_distance_max") %>: </label>
          <span class="value"><%= @rule_parameter_set.parent_stop_area_distance_max %></span>
        </div>
        <div class="two_columns">
          <label><%= t(".inter_connection_link_distance_max") %>: </label>
          <span class="value"><%= @rule_parameter_set.inter_connection_link_distance_max %></span>
        </div>
      </div>
      <div class="columns">
        <div class="two_columns">
          <label><%= t(".inter_access_link_distance_max") %>: </label>
          <span class="value"><%= @rule_parameter_set.inter_access_link_distance_max %></span>
        </div>
        <div class="two_columns">
          <label><%= t(".facility_stop_area_distance_max") %>: </label>
          <span class="value"><%= @rule_parameter_set.facility_stop_area_distance_max %></span>
        </div>
      </div>
    </div>
    <div class="attributes_group" >
      <span class="title"><%= t(".walk_speed") %></span>
      <div class="columns">
        <div class="four_columns">
          <label><%= t(".walk_default_speed_max") %>: </label>
          <span class="value"><%= @rule_parameter_set.walk_default_speed_max %></span>
        </div>
        <div class="four_columns">
          <label><%= t(".walk_occasional_traveller_speed_max") %>: </label>
          <span class="value"><%= @rule_parameter_set.walk_occasional_traveller_speed_max %></span>
        </div>
        <div class="four_columns">
          <label><%= t(".walk_frequent_traveller_speed_max") %>: </label>
          <span class="value"><%= @rule_parameter_set.walk_frequent_traveller_speed_max %></span>
        </div>
        <div class="four_columns">
          <label><%= t(".walk_mobility_restricted_traveller_speed_max") %>: </label>
          <span class="value"><%= @rule_parameter_set.walk_mobility_restricted_traveller_speed_max %></span>
        </div>
      </div>
    </div>
    <p>
      <label><%= t(".inter_stop_duration_max") %>: </label>
      <%= @rule_parameter_set.inter_stop_duration_max %>
    </p>

    <p>
      <label><%= RuleParameterSet.human_attribute_name("check_lines_in_groups") %>: </label>
      <%= boolean_value(@rule_parameter_set.check_lines_in_groups)%>
    </p>

    <p>
      <label><%= RuleParameterSet.human_attribute_name("check_line_routes") %>: </label>
      <%= boolean_value(@rule_parameter_set.check_line_routes)  %>
    </p>

    <p>
      <label><%= RuleParameterSet.human_attribute_name("check_stop_parent") %>: </label>
      <%= boolean_value(@rule_parameter_set.check_stop_parent)  %>
    </p>

    <p>
      <label><%= RuleParameterSet.human_attribute_name("check_connection_link_on_physical") %>: </label>
      <%= boolean_value(@rule_parameter_set.check_connection_link_on_physical) %>
    </p>

    </p>
      <label><%= RuleParameterSet.human_attribute_name("check_allowed_transport_modes") %>: </label>
      <%= boolean_value(@rule_parameter_set.check_allowed_transport_modes) %>
    </p>


<div class="rule_parameter_by_mode">
    <label><%= t(".rule_parameter_by_mode") %>
        <%= t(".modes_allowed") if @rule_parameter_set.check_allowed_transport_modes == "1" %>
    </label>
    <table class="table table-striped table-condensed">
      <tr>
        <th><%= t("transport_modes.name") %></th>
      <% RuleParameterSet.mode_attribute_prefixes.each do |prefix| %>
        <% unless prefix == "allowed_transport" %>
              <th><%= RuleParameterSet.human_attribute_name(prefix) %></th>
            <% end %>
      <% end %>
      </tr>
      
      <% Chouette::Line.transport_modes.map(&:to_s).each do |mode| %>
      <% if @rule_parameter_set.allowed(mode) %>
      <tr>
      <td><%= t("transport_modes.label.#{mode}") %></td>
      <% RuleParameterSet.mode_attribute_prefixes.each do |prefix| %>
    
        <% unless prefix == "allowed_transport" %>
        <td><%= @rule_parameter_set.send  "#{prefix}_mode_#{mode}" %></td>
        <% end %>
      <% end %>
          </tr>
      <% end %>
      <% end %>
    </table>
    </div>
    <div class="rule_parameter_by_object">
    <label><%= t("rule_parameter_sets.labels.columns_restrictions") %>  </label>
    <table class="table table-bordered table-condensed">
    <% RuleParameterSet.validable_objects.each do |obj| %>
    <% if @rule_parameter_set.selected(obj.table_name.singularize) %>
      <thead>
      <tr>
            <th> <%= t("activerecord.models.#{obj.table_name.singularize}.one") %></th>
            <th><%= RuleParameterSet.human_attribute_name("attribute") %></th>
            <th><%= RuleParameterSet.human_attribute_name("unique") %></th>
            <th><%= RuleParameterSet.human_attribute_name("string_type") %></th>
            <th><%= RuleParameterSet.human_attribute_name("min_size") %></th>
            <th><%= RuleParameterSet.human_attribute_name("max_size") %></th>
      </tr>
      </thead>
      <tbody>
      <% RuleParameterSet.validable_columns[obj.table_name.singularize].each do |col| %>
      <% if @rule_parameter_set.selected_column(obj.table_name.singularize,col)%>
        <tr>
          <td></td>
          <td><%= t("activerecord.attributes.#{obj.table_name.singularize}.#{col}") %></td>
          <% suffix = "column_#{col}_object_#{obj.table_name.singularize}"%>
          <td><%= unique(@rule_parameter_set.send  "unique_#{suffix}".to_sym) %></td>
          <td><%= pattern(@rule_parameter_set.send  "pattern_#{suffix}".to_sym) %></td>
          <td><%= @rule_parameter_set.send  "min_size_#{suffix}".to_sym %></td>
          <td><%= @rule_parameter_set.send  "max_size_#{suffix}".to_sym %></td>
        </tr>
        <% end %>
      <% end %>
      </tbody>
    <% end %>
    <% end %>
    </table>
    </div>
  </div>
</div>

<% content_for :sidebar do %>
<ul class="actions">
  <li><%= link_to t('rule_parameter_sets.actions.new'), new_organisation_rule_parameter_set_path, :class => "add" %></li>
  <% if @rule_parameter_set.persisted? %>
  <li><%= link_to t('rule_parameter_sets.actions.edit'), edit_organisation_rule_parameter_set_path( @rule_parameter_set), :class => "edit" %></li>
  <% if current_organisation.rule_parameter_sets.size > 1 %>
  <li><%= link_to  t('rule_parameter_sets.actions.destroy'), organisation_rule_parameter_set_path( @rule_parameter_set), :method => :delete, :data => {:confirm =>  t('rule_parameter_sets.actions.destroy_confirm')}, :class => "remove" %></li>
  <% end %>
  <% end %>
</ul>
<% end %>