agile-alliance-brazil/submissions

View on GitHub
app/views/layouts/_actions.html.haml

Summary

Maintainability
Test Coverage
- if user_signed_in?
  - if (current_user.reviewer? || current_user.organizer?) && (@conference.in_early_review_phase? || @conference.in_final_review_phase?)
    - if (next_deadline = @conference.next_deadline(:reviewer))
      #date
        %p= t("conference.dates.#{next_deadline.last}")
        %p <strong>#{l(next_deadline.first.to_date)}</strong>
        #review_progress_count
          #{t('actions.review_goal')}:
          %span.progress
  - elsif current_user.organizer? && (next_deadline = @conference.next_deadline(:organizer)) && (next_deadline.last == :author_notification || next_deadline.last == :author_confirmation)
    #date
      %p= t("conference.dates.#{next_deadline.last}")
      %p <strong>#{l(next_deadline.first.to_date)}</strong>
      #review_decisions_progress_count
        #{t('actions.review_goal')}:
        %span.progress
  - elsif current_user.author?
    - if (next_deadline = @conference.next_deadline(:author))
      #date
        %p= t("conference.dates.#{next_deadline.last}")
        %p <strong>#{l(next_deadline.first.to_date)}</strong>

  %h3
    = render_avatar(current_user)
    &= current_user.full_name

  - sections_for(current_user, @conference, filter_params).each do |section|
    - if section.actions.size > 0
      %h4= section.title
      %ul
      - section.actions.each do |action|
        %li= link_to action[:name], action[:link], action[:options]

  - if (current_user.reviewer? || current_user.organizer?) && (@conference.in_early_review_phase? || @conference.in_final_review_phase?)
    :javascript
      $(document).ready(function() {
        $.getJSON('#{reviews_path(@conference, format: :js)}', function(data) {
          var orange = Math.floor(parseInt(data.required_reviews) * 0.30);
          var yellow = Math.floor(parseInt(data.required_reviews) * 0.60);
          var green = Math.floor(parseInt(data.required_reviews) * 0.90);
          var progressImages = {};
          progressImages[0] = '#{asset_path('progressbg_red.gif')}';
          progressImages[orange] = '#{asset_path('progressbg_orange.gif')}';
          progressImages[yellow] = '#{asset_path('progressbg_yellow.gif')}';
          progressImages[green] = '#{asset_path('progressbg_green.gif')}';

          if ($("#review_progress_count .progress").length > 0) {
            $("#review_progress_count .progress").progressBar(data.total_reviews, {
              boxImage : '#{asset_path('progressbar.gif')}',
              max : data.required_reviews,
              textFormat : 'fraction',
              barImage : progressImages
            });
          }
        })
      })
  - elsif current_user.organizer? && (next_deadline = @conference.next_deadline(:organizer)) && (next_deadline.last == :author_notification || next_deadline.last == :author_confirmation)
    - goal = next_deadline.last == :author_notification ? 'data.required_decisions' : 'data.total_accepted'
    - progress = next_deadline.last == :author_notification ? 'data.total_decisions' : 'data.total_confirmed'
    :javascript
      $(document).ready(function() {
        $.getJSON('#{review_decisions_path(@conference, format: :json)}', function(data) {
          var orange = Math.floor(parseInt(#{goal}) * 0.30);
          var yellow = Math.floor(parseInt(#{goal}) * 0.60);
          var green = Math.floor(parseInt(#{goal}) * 0.90);
          var progressImages = {};
          progressImages[0] = '#{asset_path('progressbg_red.gif')}';
          progressImages[orange] = '#{asset_path('progressbg_orange.gif')}';
          progressImages[yellow] = '#{asset_path('progressbg_yellow.gif')}';
          progressImages[green] = '#{asset_path('progressbg_green.gif')}';

          if ($("#review_progress_count .progress").length > 0) {
            $("#review_decisions_progress_count .progress").progressBar(#{progress}, {
              boxImage : '#{asset_path('progressbar.gif')}',
              max : #{goal},
              textFormat : 'fraction',
              barImage : progressImages
            });
          }
        })
      })

- else
  = semantic_form_for :user, url: user_session_path do |f|
    = f.inputs do
      = f.input :username, required: true, input_html: {tabindex: autotab}
      = f.input :password, required: true, hint: false, input_html: {tabindex: autotab}
    = f.actions do
      = f.action :submit, label: 'Log in', button_html: {tabindex: autotab}

  %ul
    - if can? :create, User
      %li= link_to t('actions.signup'), new_user_registration_path
    %li= link_to t('title.lost_password'), new_user_password_path

  %br
  #warning
    %p= t('tips.users_from_last_year').html_safe

- if user_signed_in? && @conference.in_final_review_phase?
  %div{id: 'burndown_container', style: 'width:100px; height:300px;', 'data-ideal': ideal_reviews_burn(@conference), 'data-actual': actual_reviews_burn(@conference) }

- if @conference.tracks.size > 1
  %h4.charts= t('actions.submissionByTrack')
  %div.charts{ id: 'submittedByTrack', style: 'margin-left: -3em;'}

- if @conference.session_types.size > 1
  %h4.charts= t('actions.submissionByType')
  %div.charts{ id: 'submittedByType', style: 'margin-left: -3em;'}

:javascript
  var sessionsByTrack = #{sessions_by_track.inspect.html_safe};
  var sessionsByType = #{sessions_by_type.inspect.html_safe};
  var chartData = {};
  if (sessionsByTrack.length > 2) {
    chartData['submittedByTrack'] = {
      'data': sessionsByTrack,
      'colors': ["#00991f", "#003499", "#9923e8", "#ff0000", "#e87b0c", "#ffe100"]
    }
  }
  if (sessionsByType.length > 2) {
    chartData['submittedByType'] = {
      'data': sessionsByType,
      'color': ["#2d8e6c", "#61a363", "#9cb95a", "#d1cd52"]
    }
  }
  if(#{Session.for_conference(@conference).count > 0} && chartData.length > 0) {
    jQuery.submissions.initializeCharts(chartData);
  }