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