Only filter for active projects

pull/8610/head
Oliver Günther 4 years ago
parent 3a0020f17a
commit 1774f3fc45
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 8
      app/helpers/projects_helper.rb
  2. 8
      app/views/projects/index.html.erb
  3. 15
      spec/features/projects/projects_portfolio_spec.rb

@ -225,6 +225,14 @@ module ProjectsHelper
work_packages_path query_props: generator.call work_packages_path query_props: generator.call
end end
def gantt_portfolio_project_ids(project_scope)
project_scope
.where(active: true)
.select(:id)
.uniq
.pluck(:id)
end
def gantt_portfolio_title def gantt_portfolio_title
title = t('projects.index.open_as_gantt_title') title = t('projects.index.open_as_gantt_title')

@ -53,10 +53,10 @@ See docs/COPYRIGHT.rdoc for more details.
<%= link_to t(:label_overall_activity), activities_path, class: 'button' %> <%= link_to t(:label_overall_activity), activities_path, class: 'button' %>
</li> </li>
<li class="toolbar-item"> <li class="toolbar-item">
<% all_projects = @projects.select(:id).uniq.pluck(:id) %> <% gantt_project_ids = gantt_portfolio_project_ids(@projects) %>
<%= link_to gantt_portfolio_query_link(all_projects), <%= link_to gantt_portfolio_query_link(gantt_project_ids),
disabled: all_projects.empty?, disabled: gantt_project_ids.empty?,
class: "button #{all_projects.empty? ? '-disabled' : ''}", class: "button #{gantt_project_ids.empty? ? '-disabled' : ''}",
title: gantt_portfolio_title, title: gantt_portfolio_title,
target: '_blank' do %> target: '_blank' do %>
<%= op_icon("button--icon icon-view-timeline") %> <%= op_icon("button--icon icon-view-timeline") %>

@ -40,6 +40,7 @@ describe 'Projects index page',
let(:columns) { ::Components::WorkPackages::Columns.new } let(:columns) { ::Components::WorkPackages::Columns.new }
let(:filters) { ::Components::WorkPackages::Filters.new } let(:filters) { ::Components::WorkPackages::Filters.new }
let(:wp_table) { ::Pages::WorkPackagesTable.new } let(:wp_table) { ::Pages::WorkPackagesTable.new }
let(:projects_page) { Pages::Projects::Index.new }
before do before do
login_as admin login_as admin
@ -48,6 +49,20 @@ describe 'Projects index page',
describe 'with no projects on index' do describe 'with no projects on index' do
it 'disables the button' do it 'disables the button' do
visit projects_path visit projects_path
projects_page.open_filters
projects_page.filter_by_active('yes')
expect(page).to have_selector('.button.-disabled', text: 'Open as Gantt view', wait: 10)
end
end
describe 'with only an archived project on index' do
let!(:project) { FactoryBot.create :project, active: false }
it 'disables the button' do
visit projects_path
expect(page).to have_selector('.button.-disabled', text: 'Open as Gantt view') expect(page).to have_selector('.button.-disabled', text: 'Open as Gantt view')
end end
end end

Loading…
Cancel
Save