Skip to content

Commit

Permalink
Do not update data if expanded item have no children (T621704) (#3681)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-simionov authored Apr 13, 2018
1 parent 109d690 commit fedf88a
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/ui/pivot_grid/data_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ module.exports = Class.inherit((function() {
newCell,
rowIndex,
columnIndex,
dataSourceCells = dataSource.values;
dataSourceCells = dataSource.values,
isNewDataSourceNotEmpty = newRowItemIndexesToCurrent.length + newColumnItemIndexesToCurrent.length;

if(newDataSourceCells) {
if(newDataSourceCells && isNewDataSourceNotEmpty) {
for(newRowIndex = 0; newRowIndex <= newDataSourceCells.length; newRowIndex++) {
newRowCells = newDataSourceCells[newRowIndex];
rowIndex = newRowItemIndexesToCurrent[newRowIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1828,6 +1828,95 @@ QUnit.test("apply partial dataController with columns path", function(assert) {
]);
});

QUnit.test("Apply partial dataController with empty data. Update columns", function(assert) {
var dataController = new DataController({
dataSource: {
fields: [
{ area: "row" },
{ area: "column" }, { area: "column" },
{ caption: 'Sum', format: 'fixedPoint', area: "data" }
],
rows: [{ value: 'Vasya', index: 0 }, { value: 'Piter', index: 1 }],
columns: [
{ value: 'A', index: 2, children: [{ value: 'P1', index: 0 }, { value: 'P2', index: 1 }] },
{ value: 'C', index: 3 }
],
values: [
[1, 2, 3, 6, 12],
[2, 3, 4, 9, 18],
[3, 5, 7, 15, 30]
]
}
});
dataController.applyPartialDataSource('column', ['C'], {
columns: [],
rows: [],
values: [
[0]
]
});
assert.deepEqual(prepareLoadedData(dataController.getData().columns), [
{ value: 'A', index: 2, children: [{ value: 'P1', index: 0 }, { value: 'P2', index: 1 }] },
{ value: 'C', index: 3, children: [] }
]);

var cells = [];
$.each(dataController.getCellsInfo(), function() {
cells.push($.map(this, function(cell) {
return cell && cell.text;
}));
});
assert.deepEqual(cells, [
['1', '2', '3', '6', '12'],
['2', '3', '4', '9', '18'],
['3', '5', '7', '15', '30']
]);
});

QUnit.test("Apply partial dataController with empty data. Update Rows", function(assert) {
var dataController = new DataController({
dataSource: {
fields: [
{ area: "row" },
{ area: "column" }, { area: "column" },
{ caption: 'Sum', format: 'fixedPoint', area: "data" }
],
rows: [{ value: 'Vasya', index: 0 }, { value: 'Piter', index: 1 }],
columns: [
{ value: 'A', index: 2, children: [{ value: 'P1', index: 0 }, { value: 'P2', index: 1 }] },
{ value: 'C', index: 3 }
],
values: [
[1, 2, 3, 6, 12],
[2, 3, 4, 9, 18],
[3, 5, 7, 15, 30]
]
}
});
dataController.applyPartialDataSource('row', ['Vasya'], {
columns: [],
rows: [],
values: [
[0]
]
});
assert.deepEqual(prepareLoadedData(dataController.getData().rows), [
{ value: 'Vasya', index: 0, children: [] }, { value: 'Piter', index: 1 }
]);

var cells = [];
$.each(dataController.getCellsInfo(), function() {
cells.push($.map(this, function(cell) {
return cell && cell.text;
}));
});
assert.deepEqual(cells, [
['1', '2', '3', '6', '12'],
['2', '3', '4', '9', '18'],
['3', '5', '7', '15', '30']
]);
});

// B234872
QUnit.test("apply partial dataController with empty data", function(assert) {
var dataController = new DataController({
Expand Down

0 comments on commit fedf88a

Please sign in to comment.