1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 14:50:29 +00:00

delete error code

This commit is contained in:
shanshuirenjia
2019-05-06 14:56:43 +08:00
parent 0a8a176cc4
commit a82d70a18a
3 changed files with 0 additions and 107 deletions

View File

@@ -1,52 +0,0 @@
import OperationTypes from './operation-types';
import GridColumn from '../model/grid-column';
import GridRow from '../model/grid-row';
function apply(value, op) {
let { type } = op;
let next = value.slice(0); // clone a copy
switch(type) {
case OperationTypes.DELETE_ROW : {
let { rowIdx } = op;
next.splice(rowIdx, 1);
return next;
}
case OperationTypes.INSERT_ROW : {
let { newRowIdx } = op;
let row = new GridRow({newRowIdx});
next.push(row);
return next;
}
case OperationTypes.DELETE_COLUMN : {
let { idx } = op;
next.splice(idx, 1);
return next;
}
case OperationTypes.INSERT_COLUMN : {
let { idx, columnName, columnType } = op;
let column = new GridColumn({idx, columnName, columnType});
next.push(column);
return next;
}
case OperationTypes.MODIFY_CELL : {
let { rowIdx, key, newCellValue } = op;
next[rowIdx][key] = newCellValue;
return next;
}
case OperationTypes.MODIFY_COLUMN : {
let { idx, newColumnName } = op;
next[idx]['key'] = newColumnName;
next[idx]['name'] = newColumnName;
return next;
}
}
}
export default apply;

View File

@@ -1,35 +0,0 @@
import Operation from './operation';
import OperationTypes from './operation-types';
function invert(operation) {
let op = new Operation(operation);
let { type } = operation;
switch(type) {
case OperationTypes.DELETE_COLUMN : {
op.type = OperationTypes.INSERT_COLUMN;
return op;
}
case OperationTypes.INSERT_COLUMN : {
op.type = OperationTypes.DELETE_COLUMN;
return op;
}
case OperationTypes.DELETE_ROW : {
op.type = OperationTypes.INSERT_ROW;
return op;
}
case OperationTypes.INSERT_ROW : {
op.type = OperationTypes.DELETE_ROW;
return op;
}
default :
break;
}
}
export default invert;

View File

@@ -1,20 +0,0 @@
import apply from './apply';
import invert from './invert';
export default class Operation {
constructor(operation) {
this.operation = operation;
}
apply(value) {
let next = apply(value, this.operation);
return next;
}
invert() {
let inverted = invert(this);
return inverted;
}
}