Undev/redmine-stuff-to-do-plugin

View on GitHub
app/views/stuff_to_do/_time_grid.html.erb

Summary

Maintainability
Test Coverage
<div id="time-grid">
<h2><%= l(:stuff_to_do_time_grid) %></h2>

<div id="time-grid-error" class="flash error time-grid-flash" style="display:none"><%= h flash[:time_grid_error] %></div>
<div id="time-grid-warning" class="flash warning time-grid-flash" style="display:none"><%= h flash[:time_grid_warning] %></div>
<div id="time-grid-notice" class="flash notice time-grid-flash" style="display:none"><%= h flash[:time_grid_notice] %></div>

<%= render :partial => 'time_grid_form' %>

<%= submit_tag l(:button_save), :class => 'save-time-grid', :style => 'display:none;' %>

<table class="cal" id="time-grid-table">
  <thead>
    <tr>
      <th class="time-grid-project"><%= l(:field_project) %></th>
      <th class="time-grid-issue"><%= l(:field_issue) %></th>
      <% day = @calendar.startdt
      while day <= @calendar.enddt %>
      <th class="time-grid-date">
        <%= day_name(day.cwday) %>
        <br />
        <%= day.day %>
      </th>
      <% day = day + 1 %>
      <% end %>
      <th class="time-grid-running-total">Running Total</th>
    </tr>
  </thead>
  <tbody>
    <% @issues.each do |issue| %>
    <%= content_tag_for(:tr, issue) do %>
      <td class="time-grid-project">
        <%= link_to(h(issue.project), :controller => 'projects', :action => 'show', :id => issue.project) %>
      </td>
      <td class="time-grid-issue">
        <%= link_to("##{issue.id} " + h(issue.subject), :controller => 'issues', :action => 'show', :id => issue) %>
      </td>
      <% day = @calendar.startdt
      while day <= @calendar.enddt %>
      <td class="time-grid-date <%= h day -%> hascontextmenu">
        <%= h total_hours_for_user_on_day(issue, User.current, day) %>
      </td>
      <% day = day + 1 %>
      <% end %>
      <td class="time-grid-running-total issue-<%= h issue.id -%>">
        <%= h total_hours_for_issue_for_user(issue, User.current) %>
      </td>
    <% end %>
    <% end %>
    <tr class="daily-totals">
      <td colspan="2" class="label">
        Daily Totals
      </td>
      <% day = @calendar.startdt
      while day <= @calendar.enddt %>
      <td class="time-grid-date <%= h day -%> totals hascontextmenu">
        <%= h total_hours_for_date(@issues, User.current, day) %>
      </td>
      <% day = day + 1 %>
      <% end %>
      <td class="time-grid-grand-total">
        <%= h total_hours_for_user(@issues, User.current) %>
      </td>
    </tr>

  </tbody>
</table>

<%= submit_tag l(:button_save), :class => 'save-time-grid', :style => 'display:none;' %>

</div>

<ul id="time-grid-menu" class="context-menu" style="display:none;">
    <li>
      <%= content_tag(:a, l(:button_log_time), :class => 'icon-time-add', :id => 'log-time', :href => '#logtime') %>
    </li>
</ul>

<div id="logtime" style="display:none;">
<h2><%= l(:label_spent_time) %></h2>

<%= labelled_form_for 'time_entry[]'.to_sym, @time_entry, :url => {}, :html => {:id => 'new-time-entry'} do |f| %>
<%= error_messages_for 'time_entry' %>
<%= back_url_hidden_field_tag %>

<div class="box">
<p><%= f.text_field :issue_id, :required => true, :size => 6 %> <em><%= h("#{@time_entry.issue.tracker.name} ##{@time_entry.issue.id}: #{@time_entry.issue.subject}") if @time_entry.issue %></em></p>
<p>
  <%= f.text_field :spent_on, :size => 10, :required => true, :id => 'time_entry__core'  %>
  <%= include_calendar_headers_tags %>
  <%= image_tag("calendar.png", {:id => "time_entry__core_trigger",:class => "calendar-trigger"}) -%>
</p>
<p><%= f.text_field :hours, :size => 6, :required => true %></p>
<p><%= f.text_field :comments, :size => 100, :required => true %></p>
<p><%= f.select :activity_id, activity_collection_for_select_options, :required => true %></p>
<% @time_entry.custom_field_values.each do |value| %>
    <p><%= custom_field_tag_with_label :time_entry, value %></p>
<% end %>
<%= call_hook(:view_timelog_edit_form_bottom, { :time_entry => @time_entry, :form => f }) %>
</div>

<%= submit_tag l(:button_save) %>

<% end %>

</div>

<script type="text/javascript">
jQuery(function($) {
    initTimeGrid();
    attachSortables();
});
</script>