OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/views/projects/index.html.erb

221 lines
12 KiB

<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2017 the OpenProject Foundation (OPF)
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-2017 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 doc/COPYRIGHT.rdoc for more details.
++#%>
<% content_for :header_tags do %>
<%= javascript_include_tag "project/description_handling.js" %>
<%= javascript_include_tag "project/filters.js" %>
<% end %>
<% html_title(t(:label_project_plural)) -%>
<%= toolbar title: t(:label_project_plural) do %>
<% if User.current.allowed_to?(:add_project, nil, global: true) %>
<li class="toolbar-item">
<%= link_to new_project_path,
{ class: 'button -alt-highlight',
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>
<% end %>
</li>
<% end %>
<li class="toolbar-item">
<button id="projects-filter-toggle-button" title="<%= t(:label_filters_toggle) %>" class="button toolbar-icon <%= filter_set? ? '-active' : '' %>">
<op-icon icon-classes="icon-filter button--icon"></op-icon>
</button>
</li>
<li class="toolbar-item">
<%= link_to t(:label_overall_activity), activities_path, class: 'button' %>
</li>
<% end %>
<%= render partial: 'filters', 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>
<%= sort_header_tag('name', caption: Project.model_name.human) %>
<%= sort_header_tag('is_public', caption:Project.human_attribute_name(:is_public)) %>
<% if EnterpriseToken.allows_to?(:custom_fields_in_projects_list) %>
<% @custom_fields.each do |custom_field| %>
<th>
<div class="generic-table--header-outer">
<div class="generic-table--header">
<%= custom_field.name %>
</div>
</div>
</th>
<% end %>
<% end %>
<% if User.current.admin? %>
<%= sort_header_tag('required_disk_space', caption: I18n.t(:label_required_disk_storage)) %>
<%= sort_header_tag('created_on', caption: Project.human_attribute_name(:created_on)) %>
<%= sort_header_tag('latest_activity_at', caption: Project.human_attribute_name(:latest_activity_at)) %>
<% 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: request.query_parameters.except(:expand)} %>
<% else %>
<%= link_to t(:button_expand_all), {params: request.query_parameters.merge(expand: 'all')} %>
<% end %>
</div>
</div>
</th>
</tr>
</thead>
<tbody>
<% project_tree_when_sorted(@projects) do |project, level| %>
<% show_hierarchy = sort_clause =~ /^lft/ ? true : false
efective_level = show_hierarchy ? level : 0 %>
<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>
<% end %>
<%= link_to_project(project, {}, {}, false) %>
</td>
<td><%= checked_image project.is_public? %></td>
<% if EnterpriseToken.allows_to?(:custom_fields_in_projects_list) %>
<% @custom_fields.each do |custom_field| %>
<td>
<% if project.custom_value_for(custom_field).present? %>
<% if custom_field.field_format == 'string' %>
<%= project.custom_value_for(custom_field).value.to_s %>
<% elsif custom_field.field_format == 'text' %>
<%= project.custom_value_for(custom_field).try(:value).try(:gsub, /\A(.{20}[^\n\r]*).*\z/m, '\1...').try(:strip) %>
<% elsif custom_field.field_format == 'bool' %>
<%= project.custom_value_for(custom_field).formatted_value %>
<% elsif custom_field.field_format == 'list' %>
<%= project.custom_value_for(custom_field).formatted_value %>
<% elsif custom_field.field_format == 'user' %>
<%= project.custom_value_for(custom_field).formatted_value %>
<% elsif custom_field.field_format == 'date' %>
<%= project.custom_value_for(custom_field).formatted_value %>
<% elsif custom_field.field_format == 'int' %>
<%= project.custom_value_for(custom_field).value.to_s %>
<% elsif custom_field.field_format == 'float' %>
<%= project.custom_value_for(custom_field).value.to_s %>
<% end %>
<% end %>
</td>
<% end %>
<% end %>
<% if User.current.admin? %>
<td><%= number_to_human_size(project.required_disk_space, precision: 2) if project.required_disk_space.to_i > 0 %></td>
<td><%= format_date(project.created_on) %></td>
<td><%= format_date(project.latest_activity_at) %></td>
<% end %>
<td class="buttons">
<% if more_menu_allowed?(project) %>
<!-- toolbar and legacy-actions-more are only for styling purposes.
Because of multiple diverging implementations of dropdowns the normal dropdown classes cannot be used any more without making special rules -->
<ul class="toolbar project-actions">
<li aria-haspopup="true" title="<%= t(:label_more) %>" class="drop-down">
<a class="icon icon-show-more-horizontal" title="<%= t(:label_more) %>" href="#"></a>
<ul style="display:none;" class="legacy-actions-more dropdown-menu">
<% unless project.archived? %>
<% if User.current.allowed_to? :add_subprojects, project %>
<%= li_unless_nil(link_to(t(:label_subproject_new),
new_project_path(parent_id: project),
class: 'icon-context icon-add',
title: t(:label_subproject_new))) %>
<% end %>
<% if User.current.allowed_to?({action: :settings}, project) %>
<%= li_unless_nil(link_to(t(:label_project_settings),
{action: 'settings', id: project},
class: 'icon-context icon-settings') ) %>
<% end %>
<% end %>
<% if User.current.admin? %>
<% if project.active? %>
<%= li_unless_nil(link_to(t(:button_archive),
archive_project_path(project, status: params[:status]),
data: { confirm: t('project.archive.are_you_sure', name: project.name) },
method: :put,
class: 'icon-context icon-locked') ) %>
<% elsif project.parent.nil? || project.parent.active? %>
<%= li_unless_nil(link_to(t(:button_unarchive),
unarchive_project_path(project, status: params[:status]),
method: :put,
class: 'icon-context icon-unlocked') ) %>
<% end %>
<% end %>
<% if !project.archived? && User.current.allowed_to?(:copy_projects, project) %>
<%= li_unless_nil(link_to(t(:button_copy),
copy_from_project_path(project, :admin),
class: 'icon-context icon-copy') ) %>
<% end %>
<% if User.current.admin? %>
<%= li_unless_nil(link_to(t(:button_delete),
confirm_destroy_project_path(project),
class: 'icon-context icon-delete') ) %>
<% end %>
</ul>
</li>
</ul>
<% end %>
<% unless project.short_description.empty? %>
<a class="icon collapse icon-arrow-up1" title="<%= t('label_project_hide_details') %>" onclick="toggleDescription(this);"></a>
<a class="icon expand icon-arrow-down1" title="<%= t('label_project_show_details') %>" onclick="toggleDescription(this);"></a>
<% end %>
</td>
</tr>
<% unless project.short_description.empty? %>
<tr class="project-description <%= project.css_classes %> <%= efective_level > 0 ? "idnt idnt-#{efective_level}" : nil %> <%= params[:expand] == 'all' ? '-expanded' : '' %>">
<td colspan="<%= @custom_fields.size + (User.current.admin? ? 6 : 3) %>" class="project--hierarchy">
<div class="description-container">
<span class="wiki"><%= format_text(project.short_description, project: project) %></span>
</div>
</td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<%= pagination_links_full @projects %>
</div>
</div>
<% else %>
<%= no_results_box(action_url: new_project_path, display_action: true) %>
<% end %>
<% if User.current.admin? %>
<p class="information-section">
<%= op_icon('icon-info1') %>
<%= t(:label_projects_storage_information,
count: Project.count,
storage: number_to_human_size(Project.total_projects_size, precision: 2)) %>
</p>
<% end %>