estimancy/projestimate

View on GitHub
app/views/module_projects/_refresh_selected_module_data.js.erb

Summary

Maintainability
Test Coverage
//Get the current_component first
<% @current_component = current_component %>

$(".estimation_plan_min").html("<%=raw j render 'module_projects/estimation_plan_min', :locals => {:module_projects => @project.module_projects} %>");

$(".input_data").html("<%=raw j(display_input) %>");

$(".output_data").html("<%=raw j(sanitize(display_results, :tags => %w(table tr th td span title h4 strong), :attributes => %w(id class style title colspan rowspan))) %>");

$(".component_name").html("<%=raw @current_component %>");

$("#buttons").html("<%=raw j(render('users/buttons')) %>")

$('.component_tree ul li').hover(
        function () {
            $(this.children).css('display', 'inline');
        },
        function () {
            $('.block_link').hide();
        }
);

$('.spiner').hide();

$("#pbs_list").val(<%= @current_component.nil? ? '' : @current_component.id %>);
$("#select_balancing_attribute").val(<%= current_balancing_attribute.nil? ? '' : current_balancing_attribute.id %>);

$(".header_data").html("<h5><%= @current_component %> - <%= "#{current_module_project}" %></h5>");
<% if current_module_project.pemodule.alias.to_s == Projestimate::Application::BALANCING_MODULE %>
    $(".header_data h5").append("<%= escape_javascript( select_tag('select_balancing_attribute', options_for_select(current_module_project.pemodule.pe_attributes.map{ |attr| [attr.to_s, attr.id]}, :selected => (current_balancing_attribute.id unless current_balancing_attribute.nil?)), :class => 'balancing_attribute', :prompt => I18n.t(:text_select_balancing_attribute)) ).html_safe %> ");
<% end %>

// For the Effort-Breakdown moduel: show the effort per activity
<% if current_module_project.pemodule.alias == Projestimate::Application::EFFORT_BREAKDOWN %>
    $(".effort_breakdown_activities_profiles").show();
    $(".effort_breakdown_activities_profiles").html("<%= raw j(render('users/effort_per_activity')) %>");
<% else %>
    $(".effort_breakdown_activities_profiles").hide();
<% end %>

//Allow to copy value from one field to another
$('.copyLib').css( 'cursor', 'pointer' );
$(".copyLib").click(function(){
    var effort_input_id = "_low"+$(this).data("effort_input_id");
    var first_value = $("#"+effort_input_id).val();

    var low_level =         "_low"+$(this).data("effort_input_id");
    var most_likely_level = "_most_likely"+$(this).data("effort_input_id");
    var high_level =        "_high"+$(this).data("effort_input_id");

    document.getElementById(low_level).value = first_value;
    document.getElementById(most_likely_level).value = first_value;
    document.getElementById(high_level).value = first_value;
    return false;
});

$('.input-small').bind("blur",(
        function(){
            $.ajax({
                url:"check_attribute",
                type: 'POST',
                data: "value=" + this.value + "&level=" + this.className.split(/\s/)[1] + "&est_val_id=" + $(this).data("est_val_id") + "&wbs_project_elt_id=" + $(this).data("wbs_project_elt_id")
            })
        }
        ));

$(".date-picker").datepicker({
    language: '<%= set_user_language %>',
    autoclose: true,
    todayHighlight: true,
    todayBtn: true
}).on("hide", function(e){
            $.ajax({
                url:"check_attribute",
                type: 'POST',
                data: "value=" + this.value + "&level=" + this.className.split(/\s/)[1] + "&est_val_id=" + $(this).data("est_val_id") + "&wbs_project_elt_id=" + $(this).data("wbs_project_elt_id")
            })
        });

$('.attribute_tooltip').tooltip({'html' : true });

//Regenerate the estimation graph according to the current selected component
//$.ajax({
//    url: "/show_estimation_graph",
//    method: "get"
//});

// If single_attribute_value, data if low = most_likely=high
manage_single_entry_attribute();

// Refresh input data according to the selected balancing attribute
update_balancing_module_input();

// Add red border-color to the select_tag
if($("#select_balancing_attribute").val() == "") {
    $("#select_balancing_attribute").css("border-color", "red");
}

$("#setting_module").html("");