Skip to content

Commit

Permalink
Merge pull request #918 from nasa/rt-updates-910
Browse files Browse the repository at this point in the history
[Table] Remove length check when updating visible rows
  • Loading branch information
VWoeltjen committed May 11, 2016
2 parents a39ce56 + c448753 commit 116c6e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
13 changes: 2 additions & 11 deletions platform/features/table/src/controllers/MCTTableController.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,8 @@ define(

//No need to scroll
if (this.$scope.displayRows.length < this.maxDisplayRows) {
//Check whether need to resynchronize visible with display
// rows (if data added)
if (this.$scope.visibleRows.length !==
this.$scope.displayRows.length){
start = 0;
end = this.$scope.displayRows.length;
} else {
//Data is in sync, and no need to calculate scroll,
// so do nothing.
return;
}
start = 0;
end = this.$scope.displayRows.length;
} else {
//rows has exceeded display maximum, so may be necessary to
// scroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,18 @@ define(
]);
mockElement.find.andReturn(mockElement);
mockElement.prop.andReturn(0);
mockElement[0] = {
scrollTop: 0,
scrollHeight: 500,
offsetHeight: 1000
};

mockScope.displayHeaders = true;
mockTimeout = jasmine.createSpy('$timeout');
mockTimeout.andReturn(promise(undefined));

controller = new MCTTableController(mockScope, mockTimeout, mockElement);
spyOn(controller, 'setVisibleRows');
spyOn(controller, 'setVisibleRows').andCallThrough();
});

it('Reacts to changes to filters, headers, and rows', function() {
Expand Down Expand Up @@ -178,6 +183,16 @@ define(
expect(sortedRows[2].col2.text).toEqual('abc');
});

// https://github.com/nasa/openmct/issues/910
it('updates visible rows in scope', function () {
var oldRows;
mockScope.rows = testRows;
controller.setRows(testRows);
oldRows = mockScope.visibleRows;
mockScope.toggleSort('col2');
expect(mockScope.visibleRows).not.toEqual(oldRows);
});

it('correctly sorts rows of differing types', function () {
mockScope.sortColumn = 'col2';
mockScope.sortDirection = 'desc';
Expand Down

0 comments on commit 116c6e5

Please sign in to comment.