1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-23 12:27:48 +00:00

optimized code

This commit is contained in:
shanshuirenjia
2019-05-07 21:15:37 +08:00
parent 615330980f
commit 3bfaea8914
3 changed files with 9 additions and 7 deletions

View File

@@ -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();
} }

View File

@@ -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;
} }

View File

@@ -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);