336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.
http://oneifather.tistory.com/126 전에 포스팅한 내용으로 잘 쓰고 있었는데 ....
버그가 좀 나와서 코드를 수정해야 했다.
버그 내용이 다른건 아니고 원본 레드마인 소스가 하나의 버전을 기준으로
데이터가 나오게 만들어진거라
전에 소스 기준으로 콤보박스를 변경하면 데이터가 정상적으로 출력되지 않는다
모 레일즈 전문가가 하면 5분이면 dhml 스타일로 이쁘게수정하겠지만
난 그냥 사채 프로그래머니 전통적인 Page Load 방식으로 수정한다
우선 레이아웃을 위와 같이 수정했다.
하나의 콤보로 모든 버전의 데이터가 변경 되는 구조이다.
apps\redmine\htdocs\app\views\projects\show.html.erb 을 수정했다
<div class="issues box">
<table class="issue-report-complete">
<h3>
<legend>
<select onChange="window.location.href=this.value">
<% if params[:status_by] == "tracker" || params[:status_by] == ""%>
<option value="<%= project_path(@project)%>?status_by=tracker" selected="selected">유형</option>
<% else %>
<option value="<%= project_path(@project)%>?status_by=tracker">유형</option>
<%end%>
<% if params[:status_by] == "status"%>
<option value="<%= project_path(@project)%>?status_by=status" selected="selected">상태</option>
<% else %>
<option value="<%= project_path(@project)%>?status_by=status">상태</option>
<%end%>
<% if params[:status_by] == "priority"%>
<option value="<%= project_path(@project)%>?status_by=priority" selected="selected">우선순위</option>
<% else %>
<option value="<%= project_path(@project)%>?status_by=priority">우선순위</option>
<%end%>
<% if params[:status_by] == "author"%>
<option value="<%= project_path(@project)%>?status_by=author" selected="selected">저자</option>
<% else %>
<option value="<%= project_path(@project)%>?status_by=author">저자</option>
<%end%>
<% if params[:status_by] == "assigned_to"%>
<option value="<%= project_path(@project)%>?status_by=assigned_to" selected="selected">담당자</option>
<% else %>
<option value="<%= project_path(@project)%>?status_by=assigned_to">담당자</option>
<%end%>
<% if params[:status_by] == "category"%>
<option value="<%= project_path(@project)%>?status_by=category" selected="selected">범주</option>
<% else %>
<option value="<%= project_path(@project)%>?status_by=category">범주</option>
<%end%>
</select> 별 일감
</legend>
</h3>
<tr>
<td>
<% @versions.each do |version| %>
<header>
<h4 class="version"><%= link_to_version version, :name => version_anchor(version) %></h4>
</header>
<%= render :partial => 'projects/overview', :locals => {:version => version} %>
<%end%>
</td>
</tr>
</table>
</div>
이런식의 구성을 취하도록 수정했다
overview의 내용도
<% if version.completed? %>
<p><%= format_date(version.effective_date) %></p>
<% elsif version.effective_date %>
<p><strong><%= due_date_distance_in_words(version.effective_date) %></strong> (<%= format_date(version.effective_date) %>)</p>
<% end %>
<p><%=h version.description %></p>
<% if version.custom_field_values.any? %>
<ul>
<% render_custom_field_values(version) do |custom_field, formatted| %>
<li><span class="label"><%= custom_field.name %>:</span> <%= formatted %></li>
<% end %>
</ul>
<% end %>
<% if version.issues_count > 0 %>
<%= progress_bar([version.closed_percent, version.completed_percent],
:width => '90%', :legend => ('%0.0f%' % version.completed_percent)) %>
<p class="progress-info">
<%= link_to(l(:label_x_issues, :count => version.issues_count),
version_filtered_issues_path(version, :status_id => '*')) %>
(<%= link_to_if(version.closed_issues_count > 0,
l(:label_x_closed_issues_abbr, :count => version.closed_issues_count),
version_filtered_issues_path(version, :status_id => 'c')) %>
—
<%= link_to_if(version.open_issues_count > 0,
l(:label_x_open_issues_abbr, :count => version.open_issues_count),
version_filtered_issues_path(version, :status_id => 'o')) %>)
</p>
<div id="status_by">
<%= render_issue_status_by_project(version, params[:status_by]) %>
</div>
<% else %>
<p class="progress-info"><%= l(:label_roadmap_no_issues) %></p>
<% end %>
요렇게 수정 했다.
내용을 보면 render_issue_status_by_project 함수 보일거고
projects_helper.rb에 아래처럼 추가하고
def render_issue_status_by_project(version, criteria)
criteria = 'tracker' unless STATUS_BY_CRITERIAS.include?(criteria)
h = Hash.new {|k,v| k[v] = [0, 0]}
begin
# Total issue count
version.fixed_issues.group(criteria).count.each {|c,s| h[c][0] = s}
# Open issues count
version.fixed_issues.open.group(criteria).count.each {|c,s| h[c][1] = s}
rescue ActiveRecord::RecordNotFound
# When grouping by an association, Rails throws this exception if there's no result (bug)
end
# Sort with nil keys in last position
counts = h.keys.sort {|a,b| a.nil? ? 1 : (b.nil? ? -1 : a <=> b)}.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}}
max = counts.collect {|c| c[:total]}.max
render :partial => 'projects/issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max}
end
_issue_counts.html.erb에 아래와 같이 추가 했다
<%= form_tag({}, :id => "status_by_form") do -%>
<fieldset>
<% if counts.empty? %>
<p><em><%= l(:label_no_data) %></em></p>
<% else %>
<table class="version-issue">
<% counts.each do |count| %>
<tr>
<td>
<% if count[:group] -%>
<%= link_to(count[:group], project_issues_path(version.project, :set_filter => 1, :status_id => '*', :fixed_version_id => version, "#{criteria}_id" => count[:group])) %>
<% else -%>
<%= link_to(l(:label_none), project_issues_path(version.project, :set_filter => 1, :status_id => '*', :fixed_version_id => version, "#{criteria}_id" => "!*")) %>
<% end %>
</td>
<td>
<%= progress_bar((count[:closed].to_f / count[:total])*100,
:legend => "#{count[:closed]}/#{count[:total]}",
:width => "#{(count[:total].to_f / max * 200).floor}px;") %>
</td>
</tr>
<% end %>
</table>
<% end %>
</fieldset>
<% end %>
끝!!!!