- Fix Datamanager.init
- Revert oldValue when setValue promise fails
This commit is contained in:
parent
3c2c530127
commit
86f9bba5d2
@ -962,14 +962,17 @@ var CellManager = function () {
|
|||||||
if (editing) {
|
if (editing) {
|
||||||
var value = editing.getValue();
|
var value = editing.getValue();
|
||||||
var done = editing.setValue(value);
|
var done = editing.setValue(value);
|
||||||
|
var oldValue = this.getCell(colIndex, rowIndex).content;
|
||||||
|
|
||||||
|
// update cell immediately
|
||||||
|
this.updateCell(rowIndex, colIndex, value);
|
||||||
|
|
||||||
if (done && done.then) {
|
if (done && done.then) {
|
||||||
// wait for promise then update internal state
|
// revert to oldValue if promise fails
|
||||||
done.then(function () {
|
done.catch(function (e) {
|
||||||
return _this7.updateCell(rowIndex, colIndex, value);
|
console.log(e);
|
||||||
|
_this7.updateCell(rowIndex, colIndex, oldValue);
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.updateCell(rowIndex, colIndex, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1732,7 +1735,6 @@ var DataManager = function () {
|
|||||||
_classCallCheck(this, DataManager);
|
_classCallCheck(this, DataManager);
|
||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.rowCount = 0;
|
|
||||||
this.currentSort = {
|
this.currentSort = {
|
||||||
sortBy: -1, // colIndex
|
sortBy: -1, // colIndex
|
||||||
sortOrder: 'none' // asc, desc, none
|
sortOrder: 'none' // asc, desc, none
|
||||||
@ -1746,6 +1748,10 @@ var DataManager = function () {
|
|||||||
rows = data.rows;
|
rows = data.rows;
|
||||||
|
|
||||||
|
|
||||||
|
this.rowCount = 0;
|
||||||
|
this.columns = [];
|
||||||
|
this.rows = [];
|
||||||
|
|
||||||
this.columns = this.prepareColumns(columns);
|
this.columns = this.prepareColumns(columns);
|
||||||
this.rows = this.prepareRows(rows);
|
this.rows = this.prepareRows(rows);
|
||||||
|
|
||||||
|
|||||||
@ -412,14 +412,17 @@ export default class CellManager {
|
|||||||
if (editing) {
|
if (editing) {
|
||||||
const value = editing.getValue();
|
const value = editing.getValue();
|
||||||
const done = editing.setValue(value);
|
const done = editing.setValue(value);
|
||||||
|
const oldValue = this.getCell(colIndex, rowIndex).content;
|
||||||
|
|
||||||
|
// update cell immediately
|
||||||
|
this.updateCell(rowIndex, colIndex, value);
|
||||||
|
|
||||||
if (done && done.then) {
|
if (done && done.then) {
|
||||||
// wait for promise then update internal state
|
// revert to oldValue if promise fails
|
||||||
done.then(
|
done.catch((e) => {
|
||||||
() => this.updateCell(rowIndex, colIndex, value)
|
console.log(e);
|
||||||
);
|
this.updateCell(rowIndex, colIndex, oldValue);
|
||||||
} else {
|
});
|
||||||
this.updateCell(rowIndex, colIndex, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { isNumeric } from './utils';
|
|||||||
export default class DataManager {
|
export default class DataManager {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.rowCount = 0;
|
|
||||||
this.currentSort = {
|
this.currentSort = {
|
||||||
sortBy: -1, // colIndex
|
sortBy: -1, // colIndex
|
||||||
sortOrder: 'none' // asc, desc, none
|
sortOrder: 'none' // asc, desc, none
|
||||||
@ -13,6 +12,10 @@ export default class DataManager {
|
|||||||
init(data) {
|
init(data) {
|
||||||
let { columns, rows } = data;
|
let { columns, rows } = data;
|
||||||
|
|
||||||
|
this.rowCount = 0;
|
||||||
|
this.columns = [];
|
||||||
|
this.rows = [];
|
||||||
|
|
||||||
this.columns = this.prepareColumns(columns);
|
this.columns = this.prepareColumns(columns);
|
||||||
this.rows = this.prepareRows(rows);
|
this.rows = this.prepareRows(rows);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user