<commit_before>module WbsActivityElementsHelper

  def generate_activity_element_tree(element, tree)
    #Root is always display
    tree ||= String.new
    unless element.nil?
      if element.is_root?
        tree << "<ul style='margin-left:1em;' id='tree'>
                   <li style='margin-left:-1em;'>
                    <div class='block_label'>
                        #{show_element_name(element)}
                    </div>
                    <div class='block_link'>
                      #{ link_activity_element(element) }
                    </div>
                  </li>"
      end

      if element.has_children?
        tree << "<ul class='sortable'>"
        element.children.each do |e|
          tree << "<ul>
                     <li style='margin-left:#{element.depth}em;' >
                      <div class='block_label'>
                        #{show_element_name(e)}
                      </div>
                      <div class='block_link'>
                        #{ link_activity_element(e) }
                      </div>
                    </li>"

          generate_activity_element_tree(e, tree)
        end
        tree << "</ul>"
      end
    end
    tree
  end


  def generate_wbs_project_elt_tree(element, tree, show_hidden=false)
    #Root is always display
    tree ||= String.new
    unless element.nil?
      if element.is_root?
        tree << "<ul style='margin-left:1em;' id='tree'>
                   <li style='margin-left:-1em;'>
                    <div class='block_label'>
                        #{show_element_name(element)}
                    </div>
                    <div class='block_link'>
                      #{ link_activity_element(element) }
                    </div>
                  </li>"
      end

      if element.has_children?
        tree << "<ul class='sortable'>"
        element.children.each do |e|
          if show_hidden == "true"
            tree << "<ul>
                       <li style='margin-left:#{element.depth}em;' >
                        <div class='block_label'>
                          #{show_element_name(e)}
                        </div>
                        <div class='block_link'>
                          #{ link_activity_element(e) }
                        </div>
                      </li>"

            generate_wbs_project_elt_tree(e, tree, show_hidden)
          else
              unless e.exclude
                tree << "<ul>
                       <li style='margin-left:#{element.depth}em;' >
                        <div class='block_label'>
                          #{show_element_name(e)}
                        </div>
                        <div class='block_link'>
                          #{ link_activity_element(e) }
                        </div>
                      </li>"

                generate_wbs_project_elt_tree(e, tree, show_hidden)
              end
          end
        end
        tree << "</ul>"
      end
    end
    tree
  end


  def show_element_name(element)
    if element.attributes.has_key? "record_status_id"
      if element.is_root?
        "<span class='#{ element.record_status.to_s }'>Root element - #{element.name} </span>"
      else
        "<span class='#{ element.record_status.to_s }'> #{element.name} </span>"
      end

    else
      if element.is_root?
        #"<span class=''>#{element.pe_wbs_project.name} WBS-Activity</span>"
        "<span class=''>#{@project.title} WBS-Activity : Activity breakdown Structure </span>"
      else
        "<span class=''> #{element.name} </span>"
      end
    end
  end


  def link_activity_element(element)
    res = String.new
    if element.attributes.has_key? "record_status_id"
      res << link_to( '', new_wbs_activity_element_path(:selected_parent_id => element.id, :activity_id => element.wbs_activity_id), :class => "icon-plus icon-large")
      res << link_to( '', edit_wbs_activity_element_path(element, :activity_id => element.wbs_activity_id), :class => "icon-edit icon-large", :title => "Edit", :confirm => ("We don't provide any workflow to modify this table, if you continue you will be editing the 'defined' record itself. Please confirm you accept to continue" if element.is_defined?) )
      res << link_to( '', element, confirm: 'Are you sure?', method: :delete, :class => "icon-trash icon-large", :title => "Delete")
      res << link_to_if(element.is_childless?, '', new_ej_estimation_value_path(:wbs_activity_element_id => element.id), :class => "icon-bar-chart icon-large", :title => "Estimation Attributes")
<commit_msg>Solve wbs activity edit error due to ej_estimation_value migration suppression: refs #380<commit_after>module WbsActivityElementsHelper

  def generate_activity_element_tree(element, tree)
    #Root is always display
    tree ||= String.new
    unless element.nil?
      if element.is_root?
        tree << "<ul style='margin-left:1em;' id='tree'>
                   <li style='margin-left:-1em;'>
                    <div class='block_label'>
                        #{show_element_name(element)}
                    </div>
                    <div class='block_link'>
                      #{ link_activity_element(element) }
                    </div>
                  </li>"
      end

      if element.has_children?
        tree << "<ul class='sortable'>"
        element.children.each do |e|
          tree << "<ul>
                     <li style='margin-left:#{element.depth}em;' >
                      <div class='block_label'>
                        #{show_element_name(e)}
                      </div>
                      <div class='block_link'>
                        #{ link_activity_element(e) }
                      </div>
                    </li>"

          generate_activity_element_tree(e, tree)
        end
        tree << "</ul>"
      end
    end
    tree
  end


  def generate_wbs_project_elt_tree(element, tree, show_hidden=false)
    #Root is always display
    tree ||= String.new
    unless element.nil?
      if element.is_root?
        tree << "<ul style='margin-left:1em;' id='tree'>
                   <li style='margin-left:-1em;'>
                    <div class='block_label'>
                        #{show_element_name(element)}
                    </div>
                    <div class='block_link'>
                      #{ link_activity_element(element) }
                    </div>
                  </li>"
      end

      if element.has_children?
        tree << "<ul class='sortable'>"
        element.children.each do |e|
          if show_hidden == "true"
            tree << "<ul>
                       <li style='margin-left:#{element.depth}em;' >
                        <div class='block_label'>
                          #{show_element_name(e)}
                        </div>
                        <div class='block_link'>
                          #{ link_activity_element(e) }
                        </div>
                      </li>"

            generate_wbs_project_elt_tree(e, tree, show_hidden)
          else
              unless e.exclude
                tree << "<ul>
                       <li style='margin-left:#{element.depth}em;' >
                        <div class='block_label'>
                          #{show_element_name(e)}
                        </div>
                        <div class='block_link'>
                          #{ link_activity_element(e) }
                        </div>
                      </li>"

                generate_wbs_project_elt_tree(e, tree, show_hidden)
              end
          end
        end
        tree << "</ul>"
      end
    end
    tree
  end


  def show_element_name(element)
    if element.attributes.has_key? "record_status_id"
      if element.is_root?
        "<span class='#{ element.record_status.to_s }'>Root element - #{element.name} </span>"
      else
        "<span class='#{ element.record_status.to_s }'> #{element.name} </span>"
      end

    else
      if element.is_root?
        #"<span class=''>#{element.pe_wbs_project.name} WBS-Activity</span>"
        "<span class=''>#{@project.title} WBS-Activity : Activity breakdown Structure </span>"
      else
        "<span class=''> #{element.name} </span>"
      end
    end
  end


  def link_activity_element(element)
    res = String.new
    if element.attributes.has_key? "record_status_id"
      res << link_to( '', new_wbs_activity_element_path(:selected_parent_id => element.id, :activity_id => element.wbs_activity_id), :class => "icon-plus icon-large")
      res << link_to( '', edit_wbs_activity_element_path(element, :activity_id => element.wbs_activity_id), :class => "icon-edit icon-large", :title => "Edit", :confirm => ("We don't provide any workflow to modify this table, if you continue you will be editing the 'defined' record itself. Please confirm you accept to continue" if element.is_defined?) )
      res << link_to( '', element, confirm: 'Are you sure?', method: :delete, :class => "icon-trash icon-large", :title => "Delete")

{'fraction_non_alphanumeric': 0.12360048775080368, 'fraction_numerical': 0.0012193770092007539, 'mean_word_length': 1.606008087810514, 'pattern_counts': {'":': 0, '<': 151, '<?xml version=': 0, '>': 122, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4928470', 'n_tokens_mistral': 2541, 'n_tokens_neox': 2462, 'n_words': 535}