estimancy/projestimate

View on GitHub
app/views/views_widgets/_dashboard_views_widgets_results.html.erb

Summary

Maintainability
Test Coverage
<%# @module_positions.times do |j| %>    <!-- @module_positions is the Max Y position of last module -->
<% for j in 0..@module_positions do %>    <!-- @module_positions is the Max Y position of last module -->
    <% position_y = j #j+1 %>
    <!--Get the number of views to show -->
    <% module_projects_to_show = @project.module_projects.where('position_y = ? AND show_results_view = ?', position_y, true).order(:position_x) %>
    <% nb_module_projects_to_show = module_projects_to_show.length %>

    <div class="row-fluid"> <!-- div for Y position -->
      <!-- Iteration for each module in position_y -->
      <% module_projects_to_show.each do |module_project| %>
          <% span_size =  12/nb_module_projects_to_show %>

          <div class='<%= "span#{span_size}" %>'> <!-- div for X position -->
            <div class="widget-box collapsible">  <!-- One widget-box by module -->
              <div class="widget-title" title='<%= I18n.t(:used_view, value: module_project.view.nil? ? '-' : module_project.view.name) %>' style="background-color: <%= module_project.color.nil? ? "lightgrey" : "#{module_project.color}" %>; border-bottom: 1px solid <%="##{module_project.color}"%>;">
                <div class="view_header_data">
                  <h5 class="view_title"><%= "#{module_project}" %></h5>
                  <div class="pull-right">
                    <% if can?(:alter_estimation_plan, @project) || can?(:manage_estimation_widgets, @project) %>
                      <%= link_to "", new_views_widget_path(module_project_id: module_project.id, view_id: module_project.view_id), class: "icon icon-plus", title: I18n.t(:label_add_new_view_widget), remote: true %>
                      <%= link_to "", edit_module_project_view_config_path(module_project_id: module_project.id, view_id: module_project.view_id), class: "icon icon-cog", title: I18n.t(:label_add_new_view_widget), remote: true %>
                    <% end %>
                  </div>
                </div>
              </div>
              <div class="widget-content" class="<%= "module_project_widget_#{module_project.id}" %>">
                <div id="<%="view_widgets_container_#{module_project.id}"%>" class="gridster row-fluid" style="width: 100%;">
                  <!--<div>-->
                    <!--<ul style="width: 100%; margin: 0">-->
                    <ul style="max-width:100%; display:inline-block">
                    <!--<ul style="max-width:100%;">-->
                      <% font_weight = "normal_font_weight" %>
                      <!-- Show all widgets on the current view -->
                      <% if module_project.view %>
                          <% module_project_view_widgets =  module_project.view.views_widgets.order('position').all %>
                          <% module_project_view_widgets.each do |view_widget| %>
                            <!-- Widgets are now showing the value of the widget's module project -->
                            <%# view_widget_data = get_view_widget_data(view_widget.module_project_id, view_widget.id) %>
                            <% if view_widget.is_label_widget? %>
                                <% view_widget_data = get_label_widget_data(view_widget.id) %>
                            <% else %>
                                <% if module_project.pemodule.alias == Projestimate::Application::INITIALIZATION %>
                                    <% view_widget_data = get_view_widget_data(view_widget.module_project_id, view_widget.id) %>
                                <% else %>
                                    <% view_widget_data = get_view_widget_data(module_project.id, view_widget.id) %>
                                <% end %>
                            <% end %>

                            <% value_to_show = view_widget_data[:value_to_show] %>
                            <% view_widget_height = view_widget_data[:height] ; view_widget_width = view_widget_data[:width] %>
                            <% view_widget_font_size = view_widget_data[:icon_font_size] %>
                            <% view_widget_text_size = view_widget_data[:text_size]  %>
                            <% view_widget_min_max_size = view_widget_data[:min_max_size] %>
                            <% min_without_min_max = '12px' ; one_height = ""
                               min_with_min_max = '9px'
                               max_without_min_max = '60px'
                               max_with_min_max = '50px'
                               ft_minMax_minFontSize = '12px'
                               ft_minMax_maxFontSize = '15px'
                               if view_widget.widget_type == "text" || view_widget.widget_type==""
                                 font_weight = "bold_font_weight"

                                 if view_widget.height.to_i == 1
                                    max_with_min_max = '30px'
                                    max_without_min_max = '30px'
                                    ft_minMax_minFontSize = '6px'
                                    ft_minMax_maxFontSize = '10px'
                                    if view_widget.width.to_i <= 1
                                      ft_minMax_minFontSize = '4.5px'
                                      ft_minMax_maxFontSize = '10px'
                                    end
                                 end
                               end
                            %>

                            <% view_widget.widget_type.in?(["table_effort_per_phase", "table_cost_per_phase", "effort_per_phases_profiles_table", "cost_per_phases_profiles_table"]) ? (effort_per_phase_class="effort_per_phase") : (effort_per_phase_class="") %>

                            <li id="<%= "dashboard_widget_#{view_widget.id}" %>" data-row="<%= view_widget.position_y %>" data-col="<%= view_widget.position_x %>" data-sizex="<%=view_widget.width%>" data-sizey=<%="#{view_widget.height}"%> data-view_widget_id="<%= view_widget.id %>" data-container_id="<%="view_widgets_container_#{module_project.id}"%>" class="view_widget <%= "#{effort_per_phase_class}" %>" style="background-color: <%= view_widget.color %>; max-width: 100%;" title="<%= view_widget_title(view_widget) %>">
                                <!--<div id="<%#= "dashboard_widget_#{view_widget.id}" %>" class="span3 view_widget <%#= "#{effort_per_phase_class}" %>" title="<%#= view_widget_title(view_widget) %>" data-view_widget_id="<%#= view_widget.id %>" data-container_id="<%#="view_widgets_container_#{module_project.id}"%>" style="margin-left: 0px; margin-right:10px; margin-bottom: 10px;  background-color: <%#= view_widget.color %>; height: <%#=view_widget_height%>px; width: <%#=view_widget_width%>px; max-width: 100%; position: relative;">-->
                                <!--<div>-->
                                  <div class="row-fluid">
                                    <div class="span9">
                                      <% if view_widget.icon_class.empty? %>
                                          <div class="fa">
                                            <% if view_widget.show_name? %>
                                                <span id="<%= "widget_name_#{view_widget.id}" %>" class="widget_name"><%= view_widget.name %></span>
                                            <% end %>
                                          </div>
                                      <% else %>
                                          <div id="<%= "icon_size_#{view_widget.id}" %>" class="fa <%= view_widget.icon_class %> icon_size" style="font-size: <%=view_widget_font_size%>em">
                                            <% if view_widget.show_name? %>
                                              <span id="<%= "widget_name_#{view_widget.id}" %>" class="widget_name"><%= view_widget.name %></span>
                                            <% end %>
                                          </div>
                                      <% end %>
                                    </div>
                                    <div id="show_view_widget_params_<%= view_widget.id %>" class="span3 widget_icon_edit">
                                      <% if can?(:alter_estimation_plan, @project) || ( can?(:manage_estimation_widgets, @project) && view_widget.project_fields.empty? ) %>
                                        <%= link_to(' ', view_widget, confirm: I18n.t('are_you_sure'), method: :delete, :class => 'icon-trash icon_smaller', :title => I18n.t('delete')) %>
                                        <%= link_to '', edit_views_widget_path(view_widget, module_project_id: module_project.id, view_id: module_project.view_id), class: 'icon-pencil icon_smaller', title: I18n.t(:edit_widget, :value => view_widget.name), remote: true %>
                                      <% end %>
                                    </div>
                                  </div>

                                  <div class="row-fluid widget_values">

                                    <!--Show the selected Ratio name-->
                                    <% if view_widget.show_wbs_activity_ratio %>
                                        <% wa_input = WbsActivityInput.where(wbs_activity_id: view_widget.module_project.wbs_activity, module_project_id: view_widget.module_project_id).first %>
                                        <span class="widget_name">
                                          <%= "#{I18n.t(:ratio)}:" %>  <%= wa_input.nil? ? "-" : wa_input.wbs_activity_ratio %>
                                        </span>
                                    <% end %>

                                    <% if view_widget.show_min_max && effort_per_phase_class.empty? %>
                                        <% one_height = "one_height" %>
                                        <div class="row-fluid">
                                          <div id="<%= "widget_text_#{view_widget.id}" %>" class="widget_text with_min_max <%= font_weight%>" style="font-size: <%=view_widget_text_size%>em; margin-bottom: <%= view_widget.height.to_i < 3 ? (view_widget_height-90) : 90 %>px">
                                            <%= value_to_show %>
                                          </div>

                                          <div>
                                            <span id="<%= "min_max_#{view_widget.id}" %>" class="min_max" style="font-size: <%=view_widget_min_max_size%>em; float: right"><%= view_widget_data[:max_value_text] %></span><br>
                                            <span id="<%= "min_max_#{view_widget.id}" %>" class="min_max" style="font-size: <%=view_widget_min_max_size%>em; float: right"><%= view_widget_data[:min_value_text] %></span>
                                          </div>
                                        </div>
                                    <% else %>
                                        <div id="<%= "widget_text_#{view_widget.id}" %>" class="widget_text without_min_max <%= font_weight%>" style="font-size: <%=view_widget_text_size%>em" >
                                          <%= value_to_show %>
                                        </div>
                                    <% end %>

                                    <% unless view_widget.project_fields.empty? %>
                                      <div class="fa fa-asterisk" style="position: absolute; bottom: 0; left: 0"></div>
                                    <% end %>
                                  </div>
                            </li>
                              <!--script-->
                              <script type="text/javascript">

                                  $("#fittext1").fitText();
                                  $("li.without_min_max").fitText(0.6, { minFontSize: '5px', maxFontSize: '<%= max_without_min_max %>' });
                                  $("li.with_min_max").fitText(0.7, { minFontSize: '9px', maxFontSize: '<%= max_with_min_max %>' });
                                  $("li.no_estimation_value").fitText(2, { minFontSize: '12px', maxFontSize: '12px' });
                                  $(".widget_name").fitText(0.8, { minFontSize: '12px', maxFontSize: '20px' });

                                  //$(".min_max").fitText(0.4, { minFontSize: '12px', maxFontSize: '15px' });
                                  $("li.min_max").fitText(1, { minFontSize: '<%= ft_minMax_minFontSize %>', maxFontSize: '<%= ft_minMax_maxFontSize %>' });
                              </script>
                          <% end %>
                      <% end %>
                    </ul>
                  <!--</div>-->
                </div>
              </div>  <!-- end widget content -->
            </div>  <!-- END widget-box by module -->
          </div>   <!-- END div for each X position -->
      <% end %>    <!-- Iteration for X position -->
    </div>  <!-- END div for Y position -->
<% end %>   <!-- Iteration for Y position -->