Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Remove TableItemWrapper #252
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunkat committed Feb 14, 2017
1 parent 00e8633 commit 802b9cb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 122 deletions.
101 changes: 37 additions & 64 deletions src/components/table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -550,80 +550,53 @@ 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(
<TableItemWrapper
key={i}
odd={i & 1}
item={item[key]}
entity={entity}
tabId={tabid}
cols={cols}
type={type}
docId={docId}
tabIndex={tabIndex}
readonly={readonly}
mainTable={mainTable}
selected={selected}
keyProperty={keyProp}
onDoubleClick={onDoubleClick}
handleClick={this.handleClick}
handleRightClick={this.handleRightClick}
changeListenOnTrue={() => this.changeListen(true)}
changeListenOnFalse={() => this.changeListen(false)}
newRow={i === keys.length-1 ? newRow : false}
handleSelect={this.selectRangeProduct}
indentSupported={indentSupported}
rows={this.mapIncluded(item[key])}
/>
<tbody key={i}>
<TableItem
key={i}
odd={i & 1}
item={item[key]}
entity={entity}
fields={item[key].fields}
rowId={item[key][keyProp]}
tabId={tabid}
cols={cols}
type={type}
docId={docId}
tabIndex={tabIndex}
readonly={readonly}
mainTable={mainTable}
selected={selected}
keyProperty={keyProp}
onDoubleClick={() => 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}
/>
</tbody>
);
}

return ret;
}
}

// return (
// <tbody>
// {rows.map((row, index) =>
// <TableItem
// odd={i & 1}
// entity={entity}
// fields={row.fields}
// rowId={row[keyProp]}
// tabId={tabId}
// cols={cols}
// type={type}
// docId={docId}
// tabIndex={tabIndex}
// readonly={readonly}
// mainTable={mainTable}
// onDoubleClick={() => 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}
// />
// )}
// </tbody>
// );

renderEmptyInfo = (data, tabId) => {
const {emptyText, emptyHint} = this.props;

Expand Down
57 changes: 0 additions & 57 deletions src/components/table/TableItemWrapper.js

This file was deleted.

2 changes: 2 additions & 0 deletions src/components/widget/Devices/Device.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Device extends Component {

render() {
const {value, index, isMore} = this.state;
const {tabIndex} = this.props;

if(!!value){
return (
Expand All @@ -49,6 +50,7 @@ class Device extends Component {
(isMore ? "btn-flagged ": "")
}
onClick={this.handleClick}
tabIndex={tabIndex ? tabIndex : ""}
>
{isMore && <span className="btn-flag">{index + 1}</span>}
{value}
Expand Down
3 changes: 2 additions & 1 deletion src/components/widget/Devices/DevicesWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -20,6 +20,7 @@ class DevicesWidget extends Component {
index={index}
handleChange={handleChange}
isMore={isMore}
tabIndex={tabIndex}
/>
)}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/widget/RawWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ class RawWidget extends Component {
{fields[0].devices && !widgetData[0].readonly &&
<DevicesWidget
devices={fields[0].devices}
tabIndex={1}
handleChange={(value) =>
handlePatch && handlePatch(fields[0].field, value)
}
Expand Down

0 comments on commit 802b9cb

Please sign in to comment.