Fix missing rendered call in hierarchy render pass

pull/5505/head
Oliver Günther 8 years ago
parent 41cd372a32
commit 4ad0647aac
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 3
      frontend/app/components/wp-fast-table/builders/modes/hierarchy/hierarchy-render-pass.ts
  2. 9
      frontend/app/components/wp-fast-table/builders/modes/hierarchy/single-hierarchy-row-builder.ts
  3. 2
      frontend/app/components/wp-fast-table/builders/modes/rows-builder.ts
  4. 6
      frontend/app/components/wp-fast-table/builders/rows/row-refresh-builder.ts
  5. 5
      frontend/app/components/wp-fast-table/wp-fast-table.ts
  6. 16
      spec/features/work_packages/details/details_relations_spec.rb

@ -214,7 +214,7 @@ export class HierarchyRenderPass extends TableRenderPass {
const hierarchyGroup = `.__hierarchy-group-${parentId}`;
// Insert into table
const target = jQuery(this.tableBody).find(`${hierarchyRoot},${hierarchyGroup}`).last()
const target = jQuery(this.tableBody).find(`${hierarchyRoot},${hierarchyGroup}`).last();
target.after(el);
// Mark as rendered at the given position
@ -224,6 +224,7 @@ export class HierarchyRenderPass extends TableRenderPass {
classIdentifier: rowClass(workPackage.id),
hidden: hidden
});
this.rendered[workPackage.id] = true;
// Insert into timeline
const timelineRow = this.buildTimelineRow(workPackage);

@ -41,16 +41,17 @@ export class SingleHierarchyRowBuilder extends RowRefreshBuilder {
* Refresh a single row after structural changes.
* Remembers and re-adds the hierarchy indicator if neccessary.
*/
public refreshRow(row: WorkPackageTableRow, editForm: WorkPackageEditForm | undefined):[HTMLElement, boolean] {
public refreshRow(row: WorkPackageTableRow, editForm: WorkPackageEditForm | undefined):[HTMLElement, boolean]|null {
// Remove any old hierarchy
const [newRow, hidden] = super.refreshRow(row, editForm);
const result = super.refreshRow(row, editForm);
if (newRow) {
if (result !== null) {
const [newRow, _hidden] = result;
jQuery(newRow).find(`.wp-table--hierarchy-span`).remove();
this.appendHierarchyIndicator(row.object, newRow);
}
return [newRow, hidden];
return result;
}
/**

@ -31,7 +31,7 @@ export abstract class RowsBuilder {
* Refresh a single row after structural changes.
* Will perform dirty checking for when a work package is currently being edited.
*/
public refreshRow(row:WorkPackageTableRow):[HTMLElement, boolean] {
public refreshRow(row:WorkPackageTableRow):[HTMLElement, boolean]|null {
let editing = this.states.editing.get(row.workPackageId).value;
return this.refreshBuilder.refreshRow(row, editing);
}

@ -4,18 +4,20 @@ import {locateRow} from "../../helpers/wp-table-row-helpers";
import {WorkPackageTableRow} from "../../wp-table.interfaces";
import {wpCellTdClassName} from "../cell-builder";
import {SingleRowBuilder} from "./single-row-builder";
import {debugLog} from '../../../../helpers/debug_output';
export class RowRefreshBuilder extends SingleRowBuilder {
/**
* Refresh a row that is currently being edited, that is, some edit fields may be open
*/
public refreshRow(row: WorkPackageTableRow, editForm: WorkPackageEditForm | undefined):[HTMLElement, boolean] {
public refreshRow(row: WorkPackageTableRow, editForm: WorkPackageEditForm | undefined):[HTMLElement, boolean] | null {
// Get the row for the WP if refreshing existing
const rowElement = row.element || locateRow(row.workPackageId);
if (!rowElement) {
throw new Error(`Trying to refresh row for ${row.workPackageId} that is not in the table`);
debugLog(`Trying to refresh row for ${row.workPackageId} that is not in the table`);
return null;
}
// Iterate all columns, reattaching or rendering new columns

@ -96,9 +96,10 @@ export class WorkPackageTable {
public refreshRow(row:WorkPackageTableRow) {
// Find the row we want to replace
let oldRow = row.element || locateRow(row.workPackageId);
let [newRow, hidden] = this.rowBuilder.refreshRow(row);
let result = this.rowBuilder.refreshRow(row);
if (newRow && oldRow && oldRow.parentNode) {
if (result !== null && oldRow && oldRow.parentNode) {
let [newRow, _hidden] = result;
oldRow.parentNode.replaceChild(newRow, oldRow);
row.element = newRow;
this.rowIndex[row.workPackageId] = row;

@ -84,14 +84,14 @@ describe 'Work package relations tab', js: true, selenium: true do
end
describe 'as admin' do
let!(:parent) { FactoryGirl.create(:work_package, project: project) }
let!(:child) { FactoryGirl.create(:work_package, project: project) }
let!(:child2) { FactoryGirl.create(:work_package, project: project, subject: 'Something new') }
let!(:parent) { FactoryGirl.create(:work_package, project: project) }
let!(:child) { FactoryGirl.create(:work_package, project: project) }
let!(:child2) { FactoryGirl.create(:work_package, project: project, subject: 'Something new') }
it 'allows to mange hierarchy' do
# Shows link parent link
expect(page).to have_selector('#hierarchy--add-parent')
find('.wp-inline-create--add-link',
find('.work-packages--details .wp-inline-create--add-link',
text: I18n.t('js.relation_buttons.add_parent')).click
# Add parent
@ -99,14 +99,14 @@ describe 'Work package relations tab', js: true, selenium: true do
##
# Add child #1
find('.wp-inline-create--add-link',
find('.work-packages--details .wp-inline-create--add-link',
text: I18n.t('js.relation_buttons.add_existing_child')).click
add_hierarchy('.wp-relations--child-form', child.id, child.subject)
##
# Add child #2
find('.wp-inline-create--add-link',
find('.work-packages--details .wp-inline-create--add-link',
text: I18n.t('js.relation_buttons.add_existing_child')).click
add_hierarchy('.wp-relations--child-form', child2.subject, child2.subject)
@ -208,7 +208,7 @@ describe 'Work package relations tab', js: true, selenium: true do
it 'should be able to link parent and children' do
# Shows link parent link
expect(page).to have_selector('#hierarchy--add-parent')
find('.wp-inline-create--add-link',
find('.work-packages--details .wp-inline-create--add-link',
text: I18n.t('js.relation_buttons.add_parent')).click
# Add parent
@ -216,7 +216,7 @@ describe 'Work package relations tab', js: true, selenium: true do
##
# Add child
find('.wp-inline-create--add-link',
find('.work-packages--details .wp-inline-create--add-link',
text: I18n.t('js.relation_buttons.add_existing_child')).click
add_hierarchy('.wp-relations--child-form', child.id, child.subject)

Loading…
Cancel
Save