OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/frontend/app/components/wp-fast-table/builders/cell-builder.ts

34 lines
1.2 KiB

import {WorkPackageResourceInterface} from './../../api/api-v3/hal-resources/work-package-resource.service';
import {
DisplayFieldRenderer,
editFieldContainerClass
} from '../../wp-edit-form/display-field-renderer';
export const tdClassName = 'wp-table--cell-td';
export const editCellContainer = 'wp-table--cell-container';
export const wpCellTdClassName = 'wp-table--cell-td';
export class CellBuilder {
private fieldRenderer = new DisplayFieldRenderer('table');
public build(workPackage:WorkPackageResourceInterface, attribute:string) {
const td = document.createElement('td');
td.classList.add(tdClassName, wpCellTdClassName, attribute);
const container = document.createElement('span');
container.classList.add(editCellContainer, editFieldContainerClass, attribute);
const displayElement = this.fieldRenderer.render(workPackage, attribute, null);
container.appendChild(displayElement);
td.appendChild(container);
return td;
}
public refresh(container:HTMLElement, workPackage:WorkPackageResourceInterface, attribute:string) {
const displayElement = this.fieldRenderer.render(workPackage, attribute, null);
container.innerHTML = '';
container.appendChild(displayElement);
}
}