Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.0.6 taskboard optimization #1095

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/helpers/rb_common_helper.rb
Expand Up @@ -5,6 +5,7 @@ module RbCommonHelper
unloadable

include CustomFieldsHelper
include RbPartialsHelper

def assignee_id_or_empty(story)
story.new_record? ? "" : story.assigned_to_id
Expand Down
39 changes: 39 additions & 0 deletions app/helpers/rb_partials_helper.rb
@@ -0,0 +1,39 @@
module RbPartialsHelper
unloadable

PLUGIN_VIEWS_PATH = File.expand_path('../../views', __FILE__)

class << self

def def_erb_method(method_name_and_args, filename)
erb_data = File.read(filename)
eruby = Erubis::FastEruby.new(erb_data)
eruby.def_method(self, method_name_and_args)
method_name = method_name_and_args[/^[^(]+/].strip.to_sym
define_method "#{method_name}_with_html_safe" do |*args, &block|
send("#{method_name}_without_html_safe", *args, &block).html_safe
end
alias_method_chain method_name, :html_safe
method_name
end

def def_rb_partial_method(method_name_and_args, rb_partial_filename)
filename = File.expand_path(rb_partial_filename, PLUGIN_VIEWS_PATH)
def_erb_method(method_name_and_args, filename)
end

end


def_rb_partial_method 'render_rb_task(task)', 'rb_tasks/_task.html.erb'

def render_rb_task_collection(tasks)
capture do
tasks.each do |task|
concat render_rb_task(task)
end
end
end

end

11 changes: 11 additions & 0 deletions app/models/rb_story.rb
Expand Up @@ -434,6 +434,17 @@ def set_closed_status_if_following_to_close
end
end

def descendants(*args)
descendants = super
descendants.each do |issue|
next unless issue.is_task?
if self.id == (issue.parent_id || issue.parent_issue_id)
issue.instance_variable_set(:@rb_story, self)
end
end
descendants
end

private

def calc_total_auto(p,days,in_release_first)
Expand Down
7 changes: 4 additions & 3 deletions app/views/rb_taskboards/show.html.erb
Expand Up @@ -103,9 +103,10 @@
<tr id="swimlane-<%= story.id %>" class="story-swimlane">
<td>
<div class="story <%= mark_if_closed(story) %>" <%= build_inline_style(story).html_safe %>>
<div class="id story_tooltip">
<div class="tooltip_text"><%= render :partial => "rb_stories/tooltip", :object => story %></div>
<div class="id story_tooltip_ajax">
<div class="tooltip_text"></div>
<%= link_to story.id, {:controller => 'issues', :action => 'show', :id => story.id}, { :target => "_blank" } %>
<div class="v"><%= story.id %></div>
<% if User.current.allowed_to?(:create_tasks, @project) %>
<span class="add_new">
<%= image_tag("add.png", :alt => "+") %>
Expand All @@ -128,7 +129,7 @@
</td>
<%- @statuses.each do |status| %>
<td class="swimlane list <%= status.is_closed? ? 'closed' : '' %>" id="<%= story.id %>_<%= status.id %>" -rb-status-id="<%= status.id %>" -rb-project-id="<%= story.project.id %>">
<%= render :partial => "rb_tasks/task", :collection => story.descendants.select{|task| task.status.id==status.id} %>
<%= render_rb_task_collection(story.descendants.select{|task| task.status_id==status.id}) %>
</td>
<%- end %>
</tr>
Expand Down