[28187] Fix all open static query name

https://community.openproject.com/wp/28187
pull/6538/head
Oliver Günther 6 years ago
parent 41743b2865
commit 766f795f32
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 2
      frontend/src/app/components/routing/wp-list/wp-list.component.ts
  2. 16
      frontend/src/app/components/wp-query-select/wp-static-queries.service.ts
  3. 2
      spec/features/work_packages/pagination_spec.rb
  4. 4
      spec/features/work_packages/table/queries/query_history_spec.rb
  5. 3
      spec/features/work_packages/work_package_index_spec.rb

@ -249,7 +249,7 @@ export class WorkPackagesListComponent implements OnInit, OnDestroy {
this.selectedTitle = query.name; this.selectedTitle = query.name;
this.titleEditingEnabled = true; this.titleEditingEnabled = true;
} else { } else {
this.selectedTitle = this.wpStaticQueries.getStaticName(); this.selectedTitle = this.wpStaticQueries.getStaticName(query);
this.titleEditingEnabled = false; this.titleEditingEnabled = false;
} }
} }

@ -106,11 +106,23 @@ export class WorkPackageStaticQueriesService {
return items; return items;
} }
public getStaticName() { public getStaticName(query:QueryResource) {
const matched = _.find(this.all, item => const matched = _.find(this.all, item =>
item.query_props && item.query_props === this.$state.params.query_props item.query_props && item.query_props === this.$state.params.query_props
); );
return matched ? matched.label : this.text.work_packages; if (matched) {
return matched.label
}
// Try to detect the all open filter
if (query.filters.length === 1 && // Only one filter
query.filters[0].id === 'status' && // that is status
query.filters[0].operator.id === 'o') { // and is open
return this.text.all_open;
}
// Otherwise, fall back to work packages
return this.text.work_packages
} }
} }

@ -48,7 +48,7 @@ RSpec.feature 'Work package pagination', js: true do
end end
scenario do scenario do
expect(page).to have_content('Work packages') expect(page).to have_content('All open')
within('.work-packages-list-view--container') do within('.work-packages-list-view--container') do
expect(page).to have_content(work_package_1.subject) expect(page).to have_content(work_package_1.subject)

@ -101,7 +101,7 @@ describe 'Going back and forth through the browser history', type: :feature, js:
it 'updates the filters and query results on history back and forth', retry: 1 do it 'updates the filters and query results on history back and forth', retry: 1 do
wp_table.visit! wp_table.visit!
wp_table.expect_title('Work packages', editable: false) wp_table.expect_title('All open', editable: false)
wp_table.visit_query(assignee_query) wp_table.visit_query(assignee_query)
wp_table.expect_title(assignee_query.name) wp_table.expect_title(assignee_query.name)
@ -132,7 +132,7 @@ describe 'Going back and forth through the browser history', type: :feature, js:
page.execute_script('window.history.back()') page.execute_script('window.history.back()')
wp_table.expect_title('Work packages', editable: false) wp_table.expect_title('All open', editable: false)
wp_table.expect_work_package_listed work_package_1 wp_table.expect_work_package_listed work_package_1
wp_table.expect_work_package_listed work_package_2 wp_table.expect_work_package_listed work_package_2
wp_table.expect_work_package_listed work_package_3 wp_table.expect_work_package_listed work_package_3

@ -31,6 +31,7 @@ require 'spec_helper'
RSpec.feature 'Work package index view' do RSpec.feature 'Work package index view' do
let(:user) { FactoryBot.create(:admin) } let(:user) { FactoryBot.create(:admin) }
let(:project) { FactoryBot.create(:project) } let(:project) { FactoryBot.create(:project) }
let(:wp_table) { Pages::WorkPackagesTable.new(project) }
before do before do
login_as(user) login_as(user)
@ -49,7 +50,7 @@ RSpec.feature 'Work package index view' do
expect(current_path).to eql("/projects/#{project.identifier}/work_packages") expect(current_path).to eql("/projects/#{project.identifier}/work_packages")
within('#content') do within('#content') do
expect(page).to have_content('Work packages') wp_table.expect_title('All open', editable: false)
expect(page).to have_content('No work packages to display') expect(page).to have_content('No work packages to display')
end end
end end

Loading…
Cancel
Save