diff --git a/frontend/app/components/wp-display/field-types/wp-display-work-package-field.module.ts b/frontend/app/components/wp-display/field-types/wp-display-work-package-field.module.ts index 3b23680794..381d3ca2a0 100644 --- a/frontend/app/components/wp-display/field-types/wp-display-work-package-field.module.ts +++ b/frontend/app/components/wp-display/field-types/wp-display-work-package-field.module.ts @@ -31,7 +31,7 @@ import {WorkPackageResource} from "../../api/api-v3/hal-resources/work-package-r import {UiStateLinkBuilder} from '../../wp-fast-table/builders/ui-state-link-builder'; export class WorkPackageDisplayField extends DisplayField { - public text:{ linkTitle:string }; + public text:{ linkTitle:string, none:string }; private uiStateBuilder:UiStateLinkBuilder; @@ -42,12 +42,14 @@ export class WorkPackageDisplayField extends DisplayField { this.uiStateBuilder = new UiStateLinkBuilder(); this.text = { - linkTitle: this.I18n.t('js.work_packages.message_successful_show_in_fullscreen') + linkTitle: this.I18n.t('js.work_packages.message_successful_show_in_fullscreen'), + none: this.I18n.t('js.filter.noneElement') }; } public render(element:HTMLElement, displayText:string): void { - if (!this.value) { + if (this.isEmpty()) { + element.innerText = this.placeholder; return; } @@ -65,7 +67,19 @@ export class WorkPackageDisplayField extends DisplayField { return this.resource[this.name]; } + public get title() { + if (this.isEmpty()) { + return this.text.none; + } else { + return this.value.name; + } + } + public get wpId() { + if (this.isEmpty()) { + return null; + } + if (this.value.$loaded) { return this.value.id; } diff --git a/spec/features/work_packages/table/hierarchy/parent_column_spec.rb b/spec/features/work_packages/table/hierarchy/parent_column_spec.rb new file mode 100644 index 0000000000..fbff2e3427 --- /dev/null +++ b/spec/features/work_packages/table/hierarchy/parent_column_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe 'Work Package table parent column', js: true do + let(:user) { FactoryGirl.create :admin } + let(:project) { FactoryGirl.create(:project) } + + let(:wp_table) { Pages::WorkPackagesTable.new(project) } + + before do + login_as(user) + end + + + let!(:parent) { FactoryGirl.create(:work_package, project: project) } + let!(:child) { FactoryGirl.create(:work_package, project: project, parent: parent) } + + let!(:query) do + query = FactoryGirl.build(:query, user: user, project: project) + query.column_names = ['subject', 'parent'] + query.filters.clear + query.show_hierarchies = false + + query.save! + query + end + + it 'shows parent columns correctly (Regression #26951)' do + wp_table.visit_query query + wp_table.expect_work_package_listed(parent, child) + + # Hierarchy mode is enabled by default + page.within(".wp-row-#{parent.id}") do + expect(page).to have_selector('td.parent', text: '-') + end + + page.within(".wp-row-#{child.id}") do + expect(page).to have_selector('td.parent', text: "##{parent.id}") + end + end +end