From a82d70a18ae48ae1930ff61f22483074b0a6815e Mon Sep 17 00:00:00 2001 From: shanshuirenjia <978987373@qq.com> Date: Mon, 6 May 2019 14:56:43 +0800 Subject: [PATCH] delete error code --- frontend/src/pages/data-grid/store/Apply.js | 52 ------------------- frontend/src/pages/data-grid/store/Invert.js | 35 ------------- .../src/pages/data-grid/store/Operation.js | 20 ------- 3 files changed, 107 deletions(-) delete mode 100644 frontend/src/pages/data-grid/store/Apply.js delete mode 100644 frontend/src/pages/data-grid/store/Invert.js delete mode 100644 frontend/src/pages/data-grid/store/Operation.js diff --git a/frontend/src/pages/data-grid/store/Apply.js b/frontend/src/pages/data-grid/store/Apply.js deleted file mode 100644 index 3085811486..0000000000 --- a/frontend/src/pages/data-grid/store/Apply.js +++ /dev/null @@ -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; diff --git a/frontend/src/pages/data-grid/store/Invert.js b/frontend/src/pages/data-grid/store/Invert.js deleted file mode 100644 index e015f19572..0000000000 --- a/frontend/src/pages/data-grid/store/Invert.js +++ /dev/null @@ -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; diff --git a/frontend/src/pages/data-grid/store/Operation.js b/frontend/src/pages/data-grid/store/Operation.js deleted file mode 100644 index 24aa2a846e..0000000000 --- a/frontend/src/pages/data-grid/store/Operation.js +++ /dev/null @@ -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; - } - -}