Files
storage-service-ui/src/components/table-row-component/TableRowComponent.js

32 lines
1010 B
JavaScript

import Component from '../component/index';
class TableRowComponent extends Component {
constructor (container, object, index) {
super('#table-row', container);
this.row = this.mainNode;
this.indexPlace = this.mainNode.querySelector('.Body__row-index');
this.content = Object.values(object);
this.indexPlace.textContent = index + 1;
this.content.forEach((text) => {
const contentPlace = document.createElement('td');
if (typeof(text) !== 'string') {
contentPlace.textContent = typeof(text);
} else if (text.length > 30) {
contentPlace.textContent = `${text.substr(0, 30)} ...`;
} else {
contentPlace.textContent = text;
}
this.row.appendChild(contentPlace);
});
this.addEventListener(this.mainNode, 'dblclick', (evt) => {
this.next('dblclick', evt);
});
}
}
export default TableRowComponent;