Skip to content

Commit

Permalink
[#3757] Auto resize staffed columns too.
Browse files Browse the repository at this point in the history
  • Loading branch information
edavis10 committed Apr 8, 2010
1 parent aacf92f commit 243d3a5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 15 deletions.
27 changes: 27 additions & 0 deletions app/helpers/kanbans_helper.rb
Expand Up @@ -104,4 +104,31 @@ def column_width(column)

return ((column_ratios[column].to_f / visible) * 96).round(2)
end

# Calculates the width of the column. Max of 96 since they need
# some extra for the borders.
def staffed_column_width(column)
# weights of the columns
column_ratios = {
:user => 1,
:active => 2,
:testing => 2,
:finished => 2,
:canceled => 2
}
return 0.0 if column == :active && !pane_configured?(:active)
return 0.0 if column == :testing && !pane_configured?(:testing)
return 0.0 if column == :finished && !pane_configured?(:finished)
return 0.0 if column == :canceled && !pane_configured?(:canceled)

visible = 0
visible += column_ratios[:user]
visible += column_ratios[:active] if pane_configured?(:active)
visible += column_ratios[:testing] if pane_configured?(:testing)
visible += column_ratios[:finished] if pane_configured?(:finished)
visible += column_ratios[:canceled] if pane_configured?(:canceled)

return ((column_ratios[column].to_f / visible) * 96).round(2)
end

end
10 changes: 5 additions & 5 deletions app/views/kanbans/_user.html.erb
@@ -1,26 +1,26 @@
<div class="staff">
<div id="user-<%= h user.id -%>" class="staffed-column pane user">
<div id="user-<%= h user.id -%>" class="staffed-column pane user" style="width: <%= staffed_column_width(:user) %>%">
<%= link_to_user(user) %>
<%= call_hook(:view_kanbans_user_name, :user => user) %>
</div>
<% if pane_configured?('active') %>
<div id="active-<%= h user.id -%>" class="staffed-column pane active user-<%= h user.id -%>">
<div id="active-<%= h user.id -%>" class="staffed-column pane active user-<%= h user.id -%>" style="width: <%= staffed_column_width(:active) %>%">
<%= render(:partial => 'active', :locals => {:user => user}) %>
</div>
<% end %>
<% if pane_configured?('testing') %>
<div id="testing-<%= h user.id -%>" class="staffed-column pane testing user-<%= h user.id -%>">
<div id="testing-<%= h user.id -%>" class="staffed-column pane testing user-<%= h user.id -%>" style="width: <%= staffed_column_width(:testing) %>%">
<%= render(:partial => 'testing', :locals => {:user => user}) %>
</div>
<% end %>
<% if pane_configured?('finished') %>
<div id="finished-<%= h user.id -%>" class="staffed-column pane finished user-<%= h user.id -%>">
<div id="finished-<%= h user.id -%>" class="staffed-column pane finished user-<%= h user.id -%>" style="width: <%= staffed_column_width(:finished) %>%">
<%= render(:partial => 'finished', :locals => {:user => user}) %>
</div>
<% end %>
<% if pane_configured?('canceled') %>
<div id="canceled-<%= h user.id -%>" class="staffed-column pane canceled user-<%= h user.id -%>">
<div id="canceled-<%= h user.id -%>" class="staffed-column pane canceled user-<%= h user.id -%>" style="width: <%= staffed_column_width(:canceled) %>%">
<%= render(:partial => 'canceled', :locals => {:user => user}) %>
</div>
<% end %>
Expand Down
10 changes: 5 additions & 5 deletions app/views/kanbans/show.html.erb
Expand Up @@ -41,11 +41,11 @@
<% end %>
<div id="staffed-requests" class="column" style="width: <%= column_width(:staffed) %>%">
<div id="staffed-requests-header" class="staff">
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_user)), :class => "staffed-column user") %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_active)), :class => "staffed-column active") if pane_configured?('active') %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_testing)), :class => "staffed-column testing") if pane_configured?('testing') %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_finished_requests)), :class => "staffed-column finished") if pane_configured?('finished') %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_canceled_requests)), :class => "staffed-column canceled") if pane_configured?('canceled') %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_user)), :class => "staffed-column user", :style => "width: #{staffed_column_width(:user)}%") %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_active)), :class => "staffed-column active", :style => "width: #{staffed_column_width(:active)}%") if pane_configured?('active') %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_testing)), :class => "staffed-column testing", :style => "width: #{staffed_column_width(:testing)}%") if pane_configured?('testing') %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_finished_requests)), :class => "staffed-column finished", :style => "width: #{staffed_column_width(:finished)}%") if pane_configured?('finished') %>
<%= content_tag(:div, content_tag(:h3, l(:kanban_text_canceled_requests)), :class => "staffed-column canceled", :style => "width: #{staffed_column_width(:canceled)}%") if pane_configured?('canceled') %>
</div>
<div style="clear:both"></div>

Expand Down
10 changes: 5 additions & 5 deletions assets/stylesheets/redmine_kanban.css
Expand Up @@ -6,11 +6,11 @@
#incoming {min-height: 200px;}
#backlog { }
#staffed-requests { padding: 0; }
#staffed-requests .user { width: 10%; font-weight: bold; }
#staffed-requests .active { width: 22%;}
#staffed-requests .testing { width: 22%;}
#staffed-requests .finished { width: 22%;}
#staffed-requests .canceled { width: 22%;}
#staffed-requests .user { font-weight: bold; }
#staffed-requests .active { }
#staffed-requests .testing { }
#staffed-requests .finished { }
#staffed-requests .canceled { }

.column { min-height: 600px; float:left; border: 2px solid #333333; padding: 5px;}
.staff { border-top: 2px solid #333333; padding: 5px; min-height: 60px; }
Expand Down

0 comments on commit 243d3a5

Please sign in to comment.