From 802b9cb0cb59370aaae2f90771af3b6cbfe2a446 Mon Sep 17 00:00:00 2001 From: Katarzyna Dunikowska Date: Tue, 14 Feb 2017 13:27:00 +0100 Subject: [PATCH] Remove TableItemWrapper #252 --- src/components/table/Table.js | 101 +++++++----------- src/components/table/TableItemWrapper.js | 57 ---------- src/components/widget/Devices/Device.js | 2 + .../widget/Devices/DevicesWidget.js | 3 +- src/components/widget/RawWidget.js | 1 + 5 files changed, 42 insertions(+), 122 deletions(-) delete mode 100644 src/components/table/TableItemWrapper.js diff --git a/src/components/table/Table.js b/src/components/table/Table.js index 41b2fb5c9..8b6261b16 100644 --- a/src/components/table/Table.js +++ b/src/components/table/Table.js @@ -16,7 +16,7 @@ import { import Prompt from '../app/Prompt'; import TableFilter from './TableFilter'; -import TableItemWrapper from './TableItemWrapper'; +import TableItem from './TableItem'; import TablePagination from './TablePagination'; import TableHeader from './TableHeader'; import TableContextMenu from './TableContextMenu'; @@ -550,39 +550,46 @@ class Table extends Component { const {selected, rows} = this.state; const keyProp = keyProperty ? keyProperty : "rowId"; - console.log(rows); - - if(!!rowData && rowData[tabid]){ - let keys = Object.keys(rowData[tabid]); - const item = rowData[tabid]; + if(rows){ + let keys = Object.keys(rows); + const item = rows; let ret = []; for(let i=0; i < keys.length; i++) { const key = keys[i]; ret.push( - this.changeListen(true)} - changeListenOnFalse={() => this.changeListen(false)} - newRow={i === keys.length-1 ? newRow : false} - handleSelect={this.selectRangeProduct} - indentSupported={indentSupported} - rows={this.mapIncluded(item[key])} - /> + + onDoubleClick && onDoubleClick(item[key][keyProp])} + onMouseDown={(e) => this.handleClick(e, item[key][keyProp])} + handleRightClick={(e) => this.handleRightClick(e, item[key][keyProp])} + changeListenOnTrue={() => this.changeListen(true)} + changeListenOnFalse={() => this.changeListen(false)} + newRow={i === keys.length-1 ? newRow : false} + isSelected={selected.indexOf(item[key][keyProp]) > -1} + handleSelect={this.selectRangeProduct} + indentSupported={indentSupported} + indent={item[key].indent} + includedDocuments={item[key].includedDocuments} + rows={this.mapIncluded(item[key])} + lastSibling={item[key].lastChild} + contextType={item[key].type} + /> + ); } @@ -590,40 +597,6 @@ class Table extends Component { } } - // return ( - // - // {rows.map((row, index) => - // onDoubleClick && onDoubleClick(row[keyProp])} - // onMouseDown={(e) => handleClick && handleClick(e, row[keyProp])} - // handleRightClick={(e) => handleRightClick(e, row[keyProp])} - // changeListenOnTrue={() => changeListenOnTrue && changeListenOnTrue()} - // changeListenOnFalse={() => changeListenOnFalse && changeListenOnFalse()} - // newRow={i === keys.length-1 ? newRow : false} - // isSelected={selected.indexOf(row[keyProp]) > -1} - // key={index} - // indentSupported={indentSupported} - // indent={row.indent} - // includedDocuments={row.includedDocuments} - // lastSibling={row.lastChild} - // handleSelect={this.selectRangeProduct} - // contextType={row.type} - // /> - // )} - // - // ); - renderEmptyInfo = (data, tabId) => { const {emptyText, emptyHint} = this.props; diff --git a/src/components/table/TableItemWrapper.js b/src/components/table/TableItemWrapper.js deleted file mode 100644 index 05edd8e8e..000000000 --- a/src/components/table/TableItemWrapper.js +++ /dev/null @@ -1,57 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import TableItem from './TableItem'; -import update from 'react-addons-update'; - -import {flattenLastElem} from '../../actions/MenuActions'; - -class TableItemWrapper extends Component { - constructor(props){ - super(props); - } - - render() { - const { - item, entity, tabId, cols, type, docId, selected, onDoubleClick, - handleClick, handleRightClick, changeListenOnTrue, changeListenOnFalse, - newRow, tabIndex, readonly, mainTable, handleSelect, odd, keyProperty, - indentSupported, rows - } = this.props; - - console.log(rows); - - return ( - - {rows.map((row, index) => - onDoubleClick && onDoubleClick(row[keyProperty])} - onMouseDown={(e) => handleClick && handleClick(e, row[keyProperty])} - handleRightClick={(e) => handleRightClick(e, row[keyProperty])} - changeListenOnTrue={() => changeListenOnTrue && changeListenOnTrue()} - changeListenOnFalse={() => changeListenOnFalse && changeListenOnFalse()} - newRow={newRow} - isSelected={selected.indexOf(row[keyProperty]) > -1} - key={index} - indentSupported={indentSupported} - indent={row.indent} - includedDocuments={row.includedDocuments} - lastSibling={row.lastChild} - handleSelect={handleSelect} - odd={(odd && (rows.length & 1))} - contextType={row.type} - /> - )} - - ); - } -} -export default TableItemWrapper; diff --git a/src/components/widget/Devices/Device.js b/src/components/widget/Devices/Device.js index c5bf42d66..95b9790cd 100644 --- a/src/components/widget/Devices/Device.js +++ b/src/components/widget/Devices/Device.js @@ -41,6 +41,7 @@ class Device extends Component { render() { const {value, index, isMore} = this.state; + const {tabIndex} = this.props; if(!!value){ return ( @@ -49,6 +50,7 @@ class Device extends Component { (isMore ? "btn-flagged ": "") } onClick={this.handleClick} + tabIndex={tabIndex ? tabIndex : ""} > {isMore && {index + 1}} {value} diff --git a/src/components/widget/Devices/DevicesWidget.js b/src/components/widget/Devices/DevicesWidget.js index 33deff9e3..3e31bdc0c 100644 --- a/src/components/widget/Devices/DevicesWidget.js +++ b/src/components/widget/Devices/DevicesWidget.js @@ -8,7 +8,7 @@ class DevicesWidget extends Component { } render() { - const {devices, handleChange} = this.props; + const {devices, handleChange, tabIndex} = this.props; const isMore = devices.length > 1; return ( @@ -20,6 +20,7 @@ class DevicesWidget extends Component { index={index} handleChange={handleChange} isMore={isMore} + tabIndex={tabIndex} /> )} diff --git a/src/components/widget/RawWidget.js b/src/components/widget/RawWidget.js index 170bab1cc..d7519f590 100644 --- a/src/components/widget/RawWidget.js +++ b/src/components/widget/RawWidget.js @@ -612,6 +612,7 @@ class RawWidget extends Component { {fields[0].devices && !widgetData[0].readonly && handlePatch && handlePatch(fields[0].field, value) }