[26951] Fix parent column rendering (#6145)

https://community.openproject.com/wp/26951

[ci skip]
pull/6146/head
Oliver Günther 7 years ago committed by GitHub
parent 8c732b9a42
commit 60dbca6a4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      frontend/app/components/wp-display/field-types/wp-display-work-package-field.module.ts
  2. 40
      spec/features/work_packages/table/hierarchy/parent_column_spec.rb

@ -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;
}

@ -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
Loading…
Cancel
Save