mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-23 20:37:42 +00:00
optimized code
This commit is contained in:
@@ -123,11 +123,10 @@ class AppMain extends React.Component {
|
|||||||
this.props.onContentChanged();
|
this.props.onContentChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGridRowsUpdated = ({ cellKey, fromRow, updated }) => {
|
handleGridRowsUpdated = ({fromRow, updated}) => {
|
||||||
let rowIdx = fromRow;
|
let rowIdx = fromRow;
|
||||||
let value = this.dTableStore.modifyCell(rowIdx, cellKey, updated[cellKey]);
|
let value = this.dTableStore.modifyCell(rowIdx, updated);
|
||||||
this.setState({value});
|
this.setState({value});
|
||||||
this.forceUpdate();
|
|
||||||
|
|
||||||
this.props.onContentChanged();
|
this.props.onContentChanged();
|
||||||
}
|
}
|
||||||
|
@@ -35,8 +35,10 @@ function apply(value, op) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case OperationTypes.MODIFY_CELL : {
|
case OperationTypes.MODIFY_CELL : {
|
||||||
let { rowIdx, key, newValue } = op;
|
let { rowIdx, updated } = op;
|
||||||
next[rowIdx][key] = newValue;
|
let updateRow = next[rowIdx];
|
||||||
|
updateRow = Object.assign({}, {...updateRow}, updated); // todo
|
||||||
|
next[rowIdx] = updateRow;
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,9 +108,10 @@ export default class DTableStore {
|
|||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
modifyCell(rowIdx, key, newValue) {
|
modifyCell(rowIdx, updated) {
|
||||||
let type = OperationTypes.MODIFY_CELL;
|
let type = OperationTypes.MODIFY_CELL;
|
||||||
let operation = this.createOperation({type, rowIdx, key, newValue});
|
let operation = this.createOperation({type, rowIdx, updated});
|
||||||
|
|
||||||
let next = operation.apply(this.value.rows);
|
let next = operation.apply(this.value.rows);
|
||||||
|
|
||||||
this.operations.push(operation);
|
this.operations.push(operation);
|
||||||
|
Reference in New Issue
Block a user