]> source.dussan.org Git - redmine.git/commitdiff
Performance improvement on calendar and gantt (about 45% on gantt for large number...
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 3 Oct 2007 17:20:04 +0000 (17:20 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Wed, 3 Oct 2007 17:20:04 +0000 (17:20 +0000)
Partial issues/_tooltip is replaced by an helper and some translated strings are now cached.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@794 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/controllers/timelog_controller.rb
app/helpers/application_helper.rb
app/helpers/issues_helper.rb
app/views/issues/_tooltip.rhtml [deleted file]
app/views/projects/calendar.rhtml
app/views/projects/gantt.rhtml
app/views/timelog/details.rhtml

index 892d0391152b34f5905db41efea1059db537dd2d..d2d132458e06fe90e64d65d6d662722701685fb2 100644 (file)
@@ -34,6 +34,7 @@ class ProjectsController < ApplicationController
   include CustomFieldsHelper   
   helper :ifpdf
   include IfpdfHelper
+  helper :issues
   helper IssuesHelper
   helper :queries
   include QueriesHelper
index 1c15fa56416f66349713e38b84a3f6f6e5a79a09..68c0edefa08238914f18c44c33bd32273ff5184b 100644 (file)
@@ -21,6 +21,7 @@ class TimelogController < ApplicationController
 
   helper :sort
   include SortHelper
+  helper :issues
   
   def report
     @available_criterias = { 'version' => {:sql => "#{Issue.table_name}.fixed_version_id",
index e52d1492ecf3f516d5d3b981d908e3f708fd04cb..6f6458650064e24d3dba95d5b7ca6f532edcacb0 100644 (file)
@@ -70,8 +70,8 @@ module ApplicationHelper
   
   def format_date(date)
     return nil unless date
-    @date_format_setting ||= Setting.date_format.to_i
-    @date_format_setting == 0 ? l_date(date) : date.strftime("%Y-%m-%d")
+    @date_format ||= (Setting.date_format.to_i == 0 ? l(:general_fmt_date) : date.strftime("%Y-%m-%d"))
+    date.strftime(@date_format)
   end
   
   def format_time(time)
index 8ef1de8f77e29dc738209632db3d58f8631dae64..997f094a41b586db91ee853adaaef60415fe4fbe 100644 (file)
 
 module IssuesHelper
 
+  def render_issue_tooltip(issue)
+    @cached_label_start_date ||= l(:field_start_date)
+    @cached_label_due_date ||= l(:field_due_date)
+    @cached_label_assigned_to ||= l(:field_assigned_to)
+    @cached_label_priority ||= l(:field_priority)
+    
+    link_to_issue(issue) + ": #{h(issue.subject)}<br /><br />" +
+      "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
+      "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
+      "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
+      "<strong>#{@cached_label_priority}</strong>: #{issue.priority.name}"
+  end
+
   def show_detail(detail, no_html=false)
     case detail.property
     when 'attr'
diff --git a/app/views/issues/_tooltip.rhtml b/app/views/issues/_tooltip.rhtml
deleted file mode 100644 (file)
index de0330f..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-<%= link_to_issue issue %></strong>: <%=h issue.subject %><br />
-<br />
-<strong><%= l(:field_start_date) %></strong>: <%= format_date(issue.start_date) %><br />
-<strong><%= l(:field_due_date) %></strong>: <%= format_date(issue.due_date) %><br />
-<strong><%= l(:field_assigned_to) %></strong>: <%= issue.assigned_to ? issue.assigned_to.name : "-" %><br />
-<strong><%= l(:field_priority) %></strong>: <%= issue.priority.name %>
index ad022f303dbe4f64d867a737adecff3dcec00709..b6f2958f383bf81b73b1896fdc4cfcabbdb57548 100644 (file)
@@ -49,7 +49,7 @@ while day <= @date_to
         <%= h(truncate(i.subject, 30)) %>
                </small>
         <span class="tip">
-        <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
+        <%= render_issue_tooltip i %>
         </span>                
                </div>
                <% else %>
index d3b3167fc6de15fd5ee786782013a3a73a3f7b87..75e5b9fc52ece9e245c8ccc67d18000f443ec34d 100644 (file)
@@ -192,7 +192,7 @@ top = headers_height + 10
        <% # === tooltip === %>
        <div class="tooltip" style="position: absolute;top:<%= top %>px;left:<%= i_left %>px;width:<%= i_width %>px;height:12px;">
        <span class="tip">
-    <%= render :partial => "issues/tooltip", :locals => { :issue => i }%>
+    <%= render_issue_tooltip i %>
        </span></div>
 <% else 
     i_left = ((i.start_date - @date_from)*zoom).floor
index 5683a2f3fe0e4a6e6a18f715df4595bb85e5c04e..ac647c3a5ca14e4126a79306baa05f1fb70d15cd 100644 (file)
@@ -29,9 +29,9 @@
 <td align="center">\r
     <% if entry.issue %>\r
     <div class="tooltip">\r
-    <%= link_to "#{entry.issue.tracker.name} ##{entry.issue.id}", {:action => 'details', :issue_id => entry.issue } %>\r
+    <%= link_to_issue entry.issue %>\r
     <span class="tip">\r
-    <%= render :partial => "issues/tooltip", :locals => { :issue => entry.issue }%>\r
+    <%= render_issue_tooltip entry.issue %>\r
     </span>            \r
        </div>\r
        <% end %>\r