Add option to Project’s css_classes to ignore hierarchy

pull/5981/head
Wieland Lindenthal 7 years ago committed by Jens Ulferts
parent 1c066afc6d
commit 46a692cef8
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 12
      app/models/project.rb
  2. 4
      app/views/projects/index.html.erb

@ -644,11 +644,15 @@ class Project < ActiveRecord::Base
description.gsub(/\A(.{#{length}}[^\n\r]*).*\z/m, '\1...').strip
end
def css_classes
def css_classes(options = {})
s = 'project'
s << ' root' if root?
s << ' child' if child?
s << (leaf? ? ' leaf' : ' parent')
if options[:ignore_hierarchy]
s << ' root leaf'
else
s << ' root' if root?
s << ' child' if child?
s << (leaf? ? ' leaf' : ' parent')
end
s
end

@ -96,9 +96,9 @@ See doc/COPYRIGHT.rdoc for more details.
</thead>
<tbody>
<% project_tree_when_sorted(@projects) do |project, level| %>
<% show_hierarchy = sort_clause =~ /^lft /
<% show_hierarchy = sort_clause =~ /^lft/ ? true : false
efective_level = show_hierarchy ? level : 0 %>
<tr class="basics <%= show_hierarchy ? project.css_classes : project.css_classes.gsub('parent', '').gsub('child', '') + ' root leaf' %> <%= efective_level > 0 ? "idnt idnt-#{efective_level}" : nil %> <%= params[:expand] == 'all' && project.short_description.present? ? '-no-highlighting -expanded' : '' %>">
<tr class="basics <%= project.css_classes(ignore_hierarchy: !show_hierarchy) %> <%= efective_level > 0 ? "idnt idnt-#{efective_level}" : nil %> <%= params[:expand] == 'all' && project.short_description.present? ? '-no-highlighting -expanded' : '' %>">
<td class="name project--hierarchy <%= project.archived? ? 'archived' : '' %>">
<% if project.archived? %>
<span class="archived-label"><%= t('project.archive.archived') %></span>

Loading…
Cancel
Save