OSDN Git Service

Refactor: move method to Project#css_classes
authorEric Davis <edavis@littlestreamsoftware.com>
Fri, 10 Sep 2010 23:07:10 +0000 (23:07 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Fri, 10 Sep 2010 23:07:10 +0000 (23:07 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4080 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/admin_helper.rb
app/models/project.rb
app/views/admin/projects.rhtml

index b49a567..8f81f66 100644 (file)
@@ -20,12 +20,4 @@ module AdminHelper
     options_for_select([[l(:label_all), ''], 
                         [l(:status_active), 1]], selected)
   end
-  
-  def css_project_classes(project)
-    s = 'project'
-    s << ' root' if project.root?
-    s << ' child' if project.child?
-    s << (project.leaf? ? ' leaf' : ' parent')
-    s
-  end
 end
index 5ef7915..40898a3 100644 (file)
@@ -413,6 +413,14 @@ class Project < ActiveRecord::Base
     description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
   end
 
+  def css_classes
+    s = 'project'
+    s << ' root' if root?
+    s << ' child' if child?
+    s << (leaf? ? ' leaf' : ' parent')
+    s
+  end
+
   # The earliest start date of a project, based on it's issues and versions
   def start_date
     if module_enabled?(:issue_tracking)
index 6cf933d..47a2d05 100644 (file)
@@ -26,7 +26,7 @@
   </tr></thead>
   <tbody>
 <% project_tree(@projects) do |project, level| %>
-  <tr class="<%= cycle("odd", "even") %> <%= css_project_classes(project) %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
+  <tr class="<%= cycle("odd", "even") %> <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
        <td class="name"><%= link_to_project(project, :action => 'settings') %></td>
        <td><%= textilizable project.short_description, :project => project %></td>
        <td align="center"><%= checked_image project.is_public? %></td>