Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Refactor project list into cell

Oliver Günther79bfe2a92284
diff --git a/app/cells/projects/row_cell.rb b/app/cells/projects/row_cell.rb
new file mode 100644
index 00000000000..c5000c9ecde
--- /dev/null
+++ b/app/cells/projects/row_cell.rb
@@ -0,0 +1,131 @@
+module Projects
+ class RowCell < ::RowCell
+ include ProjectsHelper
+ include ProjectStatusHelper
+ include ApplicationHelper
+ include ::Redmine::I18n
+
+ def project
+ model.first
+ end
+
+ def level
+ model.last
+ end
+
+ # Hierarchy cell is just a placeholder
+ def hierarchy
+ ''
+ end
+
+ def column_value(column)
+ if column.to_s.start_with? 'cf_'
+ escaped(custom_field_column(column))
+ else
+ super
+ end
+ end
+
+ def custom_field_column(column)
+ cf = custom_field(column)
+ custom_value = project.custom_value_for(cf).formatted_value
+
+ if cf.field_format == 'text'
+ shorten_text(custom_value, 20)
+ else
+ custom_value
+ end
+ end
+
+ def created_at
+ format_date(project.created_at)
+ end
+
+ def latest_activity_at
+ format_date(project.latest_activity_at)
+ end
+
+ def required_disk_space
+ return '' unless project.required_disk_space.to_i > 0
+
+ number_to_human_size(project.required_disk_space, precision: 2)
+ end
+
+ def name
+ content = content_tag(:i, '', class: "projects-table--hierarchy-icon")
+
+ if project.archived?
+ content << ' '
+ content << content_tag(:span, I18n.t('project.archive.archived'), class: 'archived-label')
+ end
+
+ content << ' '
+ content << link_to_project(project, {}, {}, false)
+ content
+ end
+
+ def project_status
+ content = ''.html_safe
+
+ if project.status.try(:code)
+ classes = project_status_css_class(project.status)
+ content << content_tag(:span, '', class: "project-status--bulb -inline #{classes}")
+ content << content_tag(:span, project_status_name(project.status), class: "project-status--name #{classes}")
+ end
+
+ content
+ end
+
+ def public
+ checked_image project.public?
+ end
+
+ def row_css_class
+ classes = %w[basics context-menu--reveal]
+ classes << project_css_classes
+ classes << row_css_level_classes
+
+ if params[:expand] == 'all' && project.description.present?
+ classes << ' -no-highlighting -expanded'
+ end
+
+ classes.join(" ")
+ end
+
+ def row_css_level_classes
+ if level > 0
+ "idnt idnt-#{level}"
+ else
+ ""
+ end
+ end
+
+ def project_css_classes
+ s = ' project '
+
+ s << ' root' if project.root?
+ s << ' child' if project.child?
+ s << (project.leaf? ? ' leaf' : ' parent')
+
+ s
+ end
+
+ def column_css_class(column)
+ "#{super} #{additional_css_class(column)}"
+ end
+
+ def custom_field(name)
+ table.project_custom_fields.fetch(name)
+ end
+
+ def additional_css_class(column)
+ case column
+ when :name
+ "project--hierarchy #{project.archived? ? 'archived' : ''}"
+ when /\Acf_/
+ cf = custom_field(column)
+ "format-#{cf.field_format}"
+ end
+ end
+ end
+end
diff --git a/app/cells/projects/table_cell.rb b/app/cells/projects/table_cell.rb
new file mode 100644
index 00000000000..5d27029e81c
--- /dev/null
+++ b/app/cells/projects/table_cell.rb
@@ -0,0 +1,108 @@
+module Projects
+ class TableCell < ::TableCell
+ include ProjectsHelper
+
+ options :params # We read collapsed state from params
+ options :current_user # adds this option to those of the base class
+
+ def initial_sort
+ [:lft, :asc]
+ end
+
+ def table_id
+ 'project-table'
+ end
+
+ ##
+ # The project sort by is handled differently
+ def build_sort_header(column, options)
+ projects_sort_header_tag(column, options.merge(param: :json))
+ end
+
+ # We don't return the project row
+ # but the [project, level] array from the helper
+ def rows
+ @rows ||= to_enum(:projects_with_levels_order_sensitive, model).to_a
+ end
+
+ def initialize_sorted_model
+ sort_clear
+
+ orders = options[:orders]
+ sort_init orders
+ sort_update orders.map(&:first)
+ end
+
+ def paginated?
+ true
+ end
+
+ def deactivate_class_on_lft_sort
+ if sorted_by_lft?
+ '-inactive'
+ end
+ end
+
+ def href_only_when_not_sort_lft
+ unless sorted_by_lft?
+ projects_path(sortBy: JSON::dump([['lft', 'asc']]))
+ end
+ end
+
+ def all_columns
+ @all_columns ||= begin
+ [
+ [:hierarchy, builtin: true],
+ [:name, builtin: true, caption: Project.human_attribute_name(:name)],
+ [:project_status, caption: Project.human_attribute_name(:status)],
+ [:public, caption: Project.human_attribute_name(:public)],
+ *custom_field_columns,
+ *admin_columns
+ ]
+ end
+ end
+
+ def headers
+ all_columns
+ end
+
+ def sortable_column?(_column)
+ true
+ end
+
+ def columns
+ @columns ||= headers.map(&:first)
+ end
+
+ def admin_columns
+ return [] unless current_user.admin?
+
+ [
+ [:created_at, caption: Project.human_attribute_name(:created_at)],
+ [:latest_activity_at, caption: Project.human_attribute_name(:latest_activity_at)],
+ [:required_disk_space, caption: I18n.t(:label_required_disk_storage)]
+ ]
+ end
+
+ def custom_field_columns
+ project_custom_fields.values.map do |custom_field|
+ [:"cf_#{custom_field.id}", caption: custom_field.name, custom_field: true]
+ end
+ end
+
+ def project_custom_fields
+ @project_custom_fields ||= begin
+ fields =
+ if EnterpriseToken.allows_to?(:custom_fields_in_projects_list)
+ ProjectCustomField.visible(current_user).order(:position)
+ else
+ ProjectCustomField.none
+ end
+
+ fields
+ .map { |cf| [:"cf_#{cf.id}", cf] }
+ .to_h
+ end
+ end
+ end
+end
diff --git a/app/cells/rails_cell.rb b/app/cells/rails_cell.rb
index 7b629b533a2..0358c4eb794 100644
--- a/app/cells/rails_cell.rb
+++ b/app/cells/rails_cell.rb
@@ -42,9 +42,16 @@ class RailsCell < Cell::ViewModel
# but don't use the request method itself.
@_request = request
+ # Prepare the model for rendering
+ prepare
+
render
end
+ def prepare
+ # Nothing to do by default
+ end
+
def controller
context[:controller]
end
@@ -61,12 +68,6 @@ class RailsCell < Cell::ViewModel
controller.send(:form_authenticity_token, *args)
end
- # override cell-erb's behaviour to not escape
- # https://github.com/trailblazer/cells-erb/tree/v0.1.0#html-escaping
- def content_tag(name, content_or_options_with_block = nil, options = nil, escape = true, &block)
- super
- end
-
def request
controller.request
end
diff --git a/app/cells/row_cell.rb b/app/cells/row_cell.rb
index ee6219feacb..20b408b5978 100644
--- a/app/cells/row_cell.rb
+++ b/app/cells/row_cell.rb
@@ -13,6 +13,11 @@ class RowCell < RailsCell
def column_value(column)
value = send column
+
+ escaped(value)
+ end
+
+ def escaped(value)
if value.html_safe?
value
else
diff --git a/app/cells/table_cell.rb b/app/cells/table_cell.rb
index ec3629056dd..5ae464f8aac 100644
--- a/app/cells/table_cell.rb
+++ b/app/cells/table_cell.rb
@@ -8,6 +8,7 @@ class TableCell < RailsCell
options :groups, :roles, :status, :project
options show_inline_create: true
+ options table_id: nil
class << self
##
@@ -75,14 +76,14 @@ class TableCell < RailsCell
end
end
- def initialize(rows, opts = {}, &block)
- super
+ def prepare
+ initialize_sorted_model if sortable?
+ end
- if sortable?
- sort_init *initial_sort.map(&:to_s)
- sort_update sortable_columns.map(&:to_s)
- @model = sort_and_paginate_collection model
- end
+ def initialize_sorted_model
+ sort_init *initial_sort.map(&:to_s)
+ sort_update sortable_columns.map(&:to_s)
+ @model = sort_and_paginate_collection model
end
def sort_and_paginate_collection(ar_collection)
@@ -108,10 +109,6 @@ class TableCell < RailsCell
.per_page(per_page_param)
end
- def show
- render
- end
-
def rows
model
end
@@ -136,6 +133,14 @@ class TableCell < RailsCell
rows.respond_to? :total_entries
end
+ def build_sort_header(column, options)
+ sort_header_tag(column, options)
+ end
+
+ def button_header
+ content_tag :div, '', class: 'generic-table--empty-header'
+ end
+
def inline_create_link
nil
end
diff --git a/app/cells/views/projects/row/show.erb b/app/cells/views/projects/row/show.erb
new file mode 100644
index 00000000000..daf8840e8d6
--- /dev/null
+++ b/app/cells/views/projects/row/show.erb
@@ -0,0 +1,71 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2020 the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See docs/COPYRIGHT.rdoc for more details.
+
+++#%>
+
+<tr <%= "id=\"#{row_css_id}\"" if row_css_id %> class="<%= row_css_class %>">
+ <% columns.each do |column| %>
+ <td class="<%= column_css_class(column) %>"
+ <%= title = column_title(column); "title=\"#{title}\"" if title %>
+ >
+ <%= column_value(column) %>
+ </td>
+ <% end %>
+ <td class="buttons">
+ <% items = project_more_menu_items(project) %>
+ <% if items.any? %>
+ <ul class="project-actions">
+ <li aria-haspopup="true" title="<%= I18n.t(:label_open_menu) %>" class="drop-down">
+ <a class="icon icon-show-more-horizontal context-menu--icon" title="<%= t(:label_open_menu) %>" href></a>
+ <ul style="display:none;" class="menu-drop-down-container">
+ <% items.each do |item| %>
+ <li>
+ <%= link_to(*item) %>
+ </li>
+ <% end %>
+ </ul>
+ </li>
+ </ul>
+ <% end %>
+ <% unless project.description.blank? %>
+ <a class="icon collapse icon-arrow-up1 projects-table--description-toggle" href title="<%= t('label_project_hide_details') %>"></a>
+ <a class="icon expand icon-arrow-down1 projects-table--description-toggle" href title="<%= t('label_project_show_details') %>"></a>
+ <% end %>
+ </td>
+</tr>
+<% if project.description.present? %>
+ <tr class="project-description <%= project_css_classes %> <%= row_css_level_classes %> <%= params[:expand] == 'all' ? '-expanded' : '' %>">
+ <td></td>
+ <td colspan="<%= columns.length%>" class="project--hierarchy">
+ <div class="description-container">
+ <span class="wiki">
+ <%= format_text(short_project_description(project), project: project) %>
+ </span>
+ </div>
+ </td>
+ </tr>
+<% end %>
diff --git a/app/cells/views/projects/table/show.erb b/app/cells/views/projects/table/show.erb
new file mode 100644
index 00000000000..d11caa04ccb
--- /dev/null
+++ b/app/cells/views/projects/table/show.erb
@@ -0,0 +1,101 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2020 the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See docs/COPYRIGHT.rdoc for more details.
+
+++#%>
+
+<div class="generic-table--container">
+ <div class="generic-table--results-container">
+ <table class="generic-table" <%= table_id ? "id=\"#{table_id}\"" : '' %>>
+ <colgroup>
+ <% headers.each do |_name, _options| %>
+ <col highlight-col>
+ <% end %>
+ <col>
+ </colgroup>
+ <thead>
+ <tr>
+ <% headers.each do |name, options| %>
+ <% if name == :hierarchy %>
+ <th id="project-table--hierarchy-header">
+ <div class="generic-table--sort-header-outer">
+ <div class="generic-table--sort-header">
+ <%= content_tag :a,
+ op_icon("icon-hierarchy"),
+ href: href_only_when_not_sort_lft,
+ class: deactivate_class_on_lft_sort,
+ title: t(:label_sort_by, value: %("#{t(:label_project_hierarchy)}")) %>
+ </div>
+ </div>
+ </th>
+ <% elsif sortable_column?(name) %>
+ <%= build_sort_header name, options %>
+ <% else %>
+ <th>
+ <div class="generic-table--sort-header-outer">
+ <div class="generic-table--sort-header">
+ <span>
+ <%= options[:caption] %>
+ </span>
+ </div>
+ </div>
+ </th>
+ <% end %>
+ <% end %>
+ <th class="-right">
+ <div class="generic-table--header-outer">
+ <div class="generic-table--header">
+ <% if params[:expand] == 'all' %>
+ <%= link_to t(:button_collapse_all), { params: safe_query_params(%w{filters page per_page sortBy}).except(:expand) } %>
+ <% else %>
+ <%= link_to t(:button_expand_all), { params: safe_query_params(%w{filters page per_page sortBy}).merge(expand: 'all') } %>
+ <% end %>
+ </div>
+ </div>
+ </th>
+ </tr>
+ </thead>
+ <tbody>
+ <% if rows.empty? %>
+ <tr class="generic-table--empty-row">
+ <td colspan="<%= headers.length + 1 %>"><%= empty_row_message %></td>
+ </tr>
+ <% end %>
+ <% for row in rows do -%>
+ <%= render_row row %>
+ <% end -%>
+ </tbody>
+ </table>
+ <% if inline_create_link && show_inline_create %>
+ <div class="wp-inline-create-button">
+ <%= inline_create_link %>
+ </div>
+ <% end %>
+ </div>
+</div>
+<% if paginated? %>
+ <%= pagination_links_full model %>
+<% end %>
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 5091310f7b6..33a4057d0a4 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -47,13 +47,13 @@ class ProjectsController < ApplicationController
# Lists visible projects
def index
query = load_query
- set_sorting(query)
unless query.valid?
flash[:error] = query.errors.full_messages
end
@projects = load_projects query
+ @orders = set_sorting query
render layout: 'no_menu'
end
@@ -287,14 +287,6 @@ class ProjectsController < ApplicationController
call_result
end
- def set_sorting(query)
- orders = query.orders.select(&:valid?).map { |o| [o.attribute.to_s, o.direction.to_s] }
-
- sort_clear
- sort_init orders
- sort_update orders.map(&:first)
- end
-
def load_projects(query)
query
.results
@@ -304,6 +296,10 @@ class ProjectsController < ApplicationController
.paginate(page: page_param, per_page: per_page_param)
end
+ def set_sorting(query)
+ query.orders.select(&:valid?).map { |o| [o.attribute.to_s, o.direction.to_s] }
+ end
+
def update_demo_project_settings(project, value)
# e.g. when one of the demo projects gets deleted or a archived
if project.identifier == 'your-scrum-project' || project.identifier == 'demo-project'
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 1a0c634214a..138da76a7e2 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -65,14 +65,6 @@ module ProjectsHelper
end
end
- def project_custom_fields_for_index
- @project_custom_fields_for_index ||= if EnterpriseToken.allows_to?(:custom_fields_in_projects_list)
- ProjectCustomField.visible(User.current).order(:position)
- else
- ProjectCustomField.none
- end
- end
-
def project_more_menu_items(project)
[project_more_menu_subproject_item(project),
project_more_menu_settings_item(project),
@@ -178,16 +170,6 @@ module ProjectsHelper
end
end
- def project_css_classes(project)
- s = 'project'
-
- s << ' root' if project.root?
- s << ' child' if project.child?
- s << (project.leaf? ? ' leaf' : ' parent')
-
- s
- end
-
def projects_level_list_json(projects)
projects_list = projects.map do |item|
project = item[:project]
@@ -225,18 +207,6 @@ module ProjectsHelper
@sort_criteria.criteria = former_criteria
end
- def deactivate_class_on_lft_sort
- if sorted_by_lft?
- '-inactive'
- end
- end
-
- def href_only_when_not_sort_lft
- unless sorted_by_lft?
- "href=#{projects_path(sortBy: JSON::dump([['lft', 'asc']]))}"
- end
- end
-
def sorted_by_lft?
@sort_criteria.first_key == 'lft'
end
diff --git a/app/views/projects/_hierarchy_header.html.erb b/app/views/projects/_hierarchy_header.html.erb
deleted file mode 100644
index a4ef88dda04..00000000000
--- a/app/views/projects/_hierarchy_header.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<th id="project-table--hierarchy-header">
- <div class="generic-table--sort-header-outer">
- <div class="generic-table--sort-header">
- <a title="<%= t(:label_sort_by, value: "\"#{t(:label_project_hierarchy)}\"") %>"
- <%= href_only_when_not_sort_lft %>
- class="<%= deactivate_class_on_lft_sort %>">
- <%= op_icon("icon-hierarchy") %>
- </a>
- </div>
- </div>
-</th>
diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb
index 756d4f28f60..833b392a3c1 100644
--- a/app/views/projects/index.html.erb
+++ b/app/views/projects/index.html.erb
@@ -27,7 +27,7 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<% content_for :header_tags do %>
- <meta name="required_script" content="project" />
+ <meta name="required_script" content="project"/>
<% end %>
<% html_title(t(:label_project_plural)) -%>
@@ -37,7 +37,7 @@ See docs/COPYRIGHT.rdoc for more details.
<li class="toolbar-item">
<%= link_to new_project_path,
{ class: 'button -alt-highlight',
- aria: {label: t(:label_project_new)},
+ aria: { label: t(:label_project_new) },
title: t(:label_project_new) } do %>
<%= op_icon('button--icon icon-add') %>
<span class="button--text"><%= Project.model_name.human %></span>
@@ -56,113 +56,11 @@ See docs/COPYRIGHT.rdoc for more details.
<%= render partial: 'projects/filters/form', locals: { query: @query } %>
-<% if @projects.any? %>
- <div class="generic-table--container">
- <div class="generic-table--results-container">
- <table class="generic-table" id="project-table">
- <thead>
- <tr>
- <%= render partial: 'hierarchy_header' %>
- <%= projects_sort_header_tag('name', caption: Project.human_attribute_name(:name), param: :json) %>
- <%= projects_sort_header_tag('project_status', caption: Project.human_attribute_name(:status), param: :json) %>
- <%= projects_sort_header_tag('public', caption: Project.human_attribute_name(:public), param: :json) %>
- <% project_custom_fields_for_index.each do |custom_field| %>
- <%= sort_header_tag("cf_#{custom_field.id}", caption: custom_field.name, param: :json) %>
- <% end %>
- <% if User.current.admin? %>
- <%= projects_sort_header_tag('created_at', caption: Project.human_attribute_name(:created_at), param: :json) %>
- <%= projects_sort_header_tag('latest_activity_at', caption: Project.human_attribute_name(:latest_activity_at), param: :json) %>
- <%= projects_sort_header_tag('required_disk_space', caption: I18n.t(:label_required_disk_storage), param: :json) %>
- <% end %>
- <th class="-right">
- <div class="generic-table--header-outer">
- <div class="generic-table--header">
- <% if params[:expand] == 'all' %>
- <%= link_to t(:button_collapse_all), { params: safe_query_params(%w{filters page per_page sortBy}).except(:expand) } %>
- <% else %>
- <%= link_to t(:button_expand_all), { params: safe_query_params(%w{filters page per_page sortBy}).merge(expand: 'all') } %>
- <% end %>
- </div>
- </div>
- </th>
- </tr>
- </thead>
- <tbody>
- <% projects_with_levels_order_sensitive(@projects) do |project, level| %>
- <tr class="basics context-menu--reveal <%= project_css_classes(project) %> <%= level > 0 ? "idnt idnt-#{level}" : nil %> <%= params[:expand] == 'all' && short_project_description(project).present? ? '-no-highlighting -expanded' : '' %>">
- <td></td>
- <td class="name project--hierarchy <%= project.archived? ? 'archived' : '' %>">
- <i class="projects-table--hierarchy-icon"></i>
- <% if project.archived? %>
- <span class="archived-label"><%= t('project.archive.archived') %></span>
- <% end %>
- <%= link_to_project(project, {}, {}, false) %>
- </td>
- <td>
- <% if project.status.try(:code) %>
- <span class="project-status--bulb -inline <%= project_status_css_class(project.status) %>"></span>
- <span class="project-status--name <%= project_status_css_class(project.status) %>"><%= project_status_name(project.status) %></span>
- <% end %>
- </td>
- <td><%= checked_image project.public? %></td>
- <% project_custom_fields_for_index.each do |custom_field| %>
- <td class="format-<%= custom_field.field_format %>">
- <% custom_value = project.custom_value_for(custom_field).formatted_value %>
-
- <% if custom_field.field_format == 'text' %>
- <%= shorten_text(custom_value, 20) %>
- <% else %>
- <%= custom_value %>
- <% end %>
- </td>
- <% end %>
- <% if User.current.admin? %>
- <td><%= format_date(project.created_at) %></td>
- <td><%= format_date(project.latest_activity_at) %></td>
- <td><%= number_to_human_size(project.required_disk_space, precision: 2) if project.required_disk_space.to_i > 0 %></td>
- <% end %>
- <td class="buttons">
- <% items = project_more_menu_items(project) %>
- <% if items.any? %>
- <ul class="project-actions">
- <li aria-haspopup="true" title="<%= t(:label_open_menu) %>" class="drop-down">
- <a class="icon icon-show-more-horizontal context-menu--icon" title="<%= t(:label_open_menu) %>" href></a>
- <ul style="display:none;" class="menu-drop-down-container">
- <% items.each do |item| %>
- <li>
- <%= link_to(*item) %>
- </li>
- <% end %>
- </ul>
- </li>
- </ul>
- <% end %>
- <% unless project.description.blank? %>
- <a class="icon collapse icon-arrow-up1 projects-table--description-toggle" href title="<%= t('label_project_hide_details') %>"></a>
- <a class="icon expand icon-arrow-down1 projects-table--description-toggle" href title="<%= t('label_project_show_details') %>"></a>
- <% end %>
- </td>
- </tr>
- <% unless project.description.blank? %>
- <tr class="project-description <%= project_css_classes(project) %> <%= level > 0 ? "idnt idnt-#{level}" : nil %> <%= params[:expand] == 'all' ? '-expanded' : '' %>">
- <td></td>
- <td colspan="<%= project_custom_fields_for_index.length + (User.current.admin? ? 7 : 4) %>" class="project--hierarchy">
- <div class="description-container">
- <span class="wiki"><%= format_text(short_project_description(project), project: project) %></span>
- </div>
- </td>
- </tr>
- <% end %>
- <% end %>
- </tbody>
- </table>
- </div>
- </div>
- <%= pagination_links_full @projects %>
-<% else %>
- <%= no_results_box(no_projects_result_box_params) %>
-<% end %>
-
+<%= cell Projects::TableCell,
+ @projects,
+ current_user: current_user,
+ orders: @orders,
+ params: params %>
<% if User.current.admin? %>
<p class="information-section">
diff --git a/app/views/settings/_projects.html.erb b/app/views/settings/_projects.html.erb
index 63954400d5d..ad9e156cd46 100644
--- a/app/views/settings/_projects.html.erb
+++ b/app/views/settings/_projects.html.erb
@@ -30,14 +30,30 @@ See docs/COPYRIGHT.rdoc for more details.
<%= styled_form_tag(update_projects_settings_path, method: :patch) do %>
<section class="form--section">
- <div class="form--field"><%= setting_check_box :default_projects_public %></div>
- <div class="form--field"><%= setting_multiselect(:default_projects_modules,
- OpenProject::AccessControl.available_project_modules.collect {|m| [l_or_humanize(m, prefix: "project_module_"), m.to_s]}) %></div>
- <div class="form--field"><%= setting_check_box :sequential_project_identifiers %></div>
- <div class="form--field"><%= setting_select :new_project_user_role_id,
- Role.givable.collect {|r| [r.name, r.id.to_s]},
- blank: "--- #{t(:actionview_instancetag_blank_option)} ---",
- container_class: '-middle' %></div>
+ <fieldset class="form--fieldset">
+ <legend class="form--fieldset-legend"><%= t('settings.projects.section_new_projects') %></legend>
+ <div class="form--field"><%= setting_check_box :default_projects_public %></div>
+ <div class="form--field"><%= setting_multiselect(:default_projects_modules,
+ OpenProject::AccessControl.available_project_modules.collect {|m| [l_or_humanize(m, prefix: "project_module_"), m.to_s]}) %></div>
+ <div class="form--field"><%= setting_check_box :sequential_project_identifiers %></div>
+ <div class="form--field"><%= setting_select :new_project_user_role_id,
+ Role.givable.collect {|r| [r.name, r.id.to_s]},
+ blank: "--- #{t(:actionview_instancetag_blank_option)} ---",
+ container_class: '-middle' %></div>
+ </fieldset>
+ </section>
+
+ <section class="form--section">
+ <fieldset class="form--fieldset">
+ <legend class="form--fieldset-legend"><%= t('settings.projects.section_project_overview') %></legend>
+ <%
+ column_choices = Query.new.available_columns.map { |column|
+ { caption: column.caption, value: column.name.to_s }
+ }
+ %>
+ <%= settings_matrix([:work_package_list_default_columns],
+ column_choices, label_choices: :setting_work_package_properties) %>
+ </fieldset>
</section>
<%= styled_button_tag t(:button_save), class: '-highlight -with-icon icon-checkmark' %>
<% end %>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 1bf75736a6e..b986f39f3a1 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -2288,6 +2288,9 @@ en:
passwords: "Passwords"
session: "Session"
brute_force_prevention: "Automated user blocking"
+ projects:
+ section_new_projects: "Settings for new projects"
+ section_project_overview: "Settings for project overview list"
user:
default_preferences: "Default preferences"
deletion: "Deletion"