diff --git a/src/common/table.js b/src/common/table.js index 12d0ebf..ed936e8 100644 --- a/src/common/table.js +++ b/src/common/table.js @@ -29,7 +29,7 @@ class CustomTable extends Component { this.state = { rows: CustomTable.getRows(props), - editCell: [ -1, -1 ] + editCell: [-1, -1] }; } @@ -38,7 +38,7 @@ class CustomTable extends Component { }; onClick(event, row, column) { - this.setState({ editCell: [ column, row ]}); // x, y + this.setState({ editCell: [column, row] }); // x, y } static addCell(data, index, child) { @@ -71,6 +71,12 @@ class CustomTable extends Component { cell.push({content}); } else if (child.props.clickable) { cell.push(); + } else if (linkKey == 'filebuttons') { + content.forEach(element => { + cell.push(Download {element}} > + ); + }); } else { cell.push(content); } @@ -90,8 +96,8 @@ class CustomTable extends Component { cell.push(   - {labelContent} - + {labelContent} + ); } @@ -103,14 +109,14 @@ class CustomTable extends Component { // add buttons if (child.props.editButton) { - let disable = (typeof data.managedexternally !== "undefined" && data.managedexternally); - cell.push({disable? "Externally managed ICs cannot be edited" : "edit"} } > - ); + let disable = (typeof data.managedexternally !== "undefined" && data.managedexternally); + cell.push({disable ? "Externally managed ICs cannot be edited" : "edit"} } > + ); } if (child.props.deleteButton) { cell.push( Delete } > - ); + ); } if (child.props.checkbox) { @@ -121,18 +127,23 @@ class CustomTable extends Component { if (child.props.exportButton) { cell.push( Export } > - ); + ); } if (child.props.duplicateButton) { cell.push( Duplicate } > - ); + ); + } + + if (child.props.downloadAllButton) { + cell.push(Download All Files} > + ); } return cell; } // addCell - static getDerivedStateFromProps(props, state){ + static getDerivedStateFromProps(props, state) { const rows = CustomTable.getRows(props); return { rows }; @@ -147,12 +158,12 @@ class CustomTable extends Component { onCellFocus(index) { // When a cell focus is detected, update the current state in order to uncover the input element - this.setState({ editCell: [ index.cell, index.row ]}); + this.setState({ editCell: [index.cell, index.row] }); } cellLostFocus() { // Reset cell selection state - this.setState({ editCell: [ -1, -1 ] }); + this.setState({ editCell: [-1, -1] }); } static getRows(props) { @@ -164,7 +175,7 @@ class CustomTable extends Component { // check if multiple columns if (Array.isArray(props.children) === false) { // table only has a single column - return [ CustomTable.addCell(data, index, props.children) ]; + return [CustomTable.addCell(data, index, props.children)]; } const row = []; @@ -181,7 +192,7 @@ class CustomTable extends Component { // get children let children = this.props.children; if (Array.isArray(this.props.children) === false) { - children = [ children ]; + children = [children]; } return ( @@ -200,28 +211,28 @@ class CustomTable extends Component { let isCellInlineEditable = children[cellIndex].props.inlineEditable === true; - let tabIndex = isCellInlineEditable? 0 : -1; + let tabIndex = isCellInlineEditable ? 0 : -1; let evtHdls = isCellInlineEditable ? { onCellClick: (event) => this.onClick(event, rowIndex, cellIndex), - onCellFocus: () => this.onCellFocus({cell: cellIndex, row: rowIndex}), + onCellFocus: () => this.onCellFocus({ cell: cellIndex, row: rowIndex }), onCellBlur: () => this.cellLostFocus() } : { - onCellClick: () => {}, - onCellFocus: () => {}, - onCellBlur: () => {} - }; + onCellClick: () => { }, + onCellFocus: () => { }, + onCellBlur: () => { } + }; - return ( - {(this.state.editCell[0] === cellIndex && this.state.editCell[1] === rowIndex ) ? ( + return ( + {(this.state.editCell[0] === cellIndex && this.state.editCell[1] === rowIndex) ? ( children[cellIndex].props.onInlineChange(event, rowIndex, cellIndex)} ref={ref => { this.activeInput = ref; }} /> ) : ( - - {cell.map((element, elementIndex) => ( - {element} - ))} - - )} + + {cell.map((element, elementIndex) => ( + {element} + ))} + + )} ) }) }