Skip to content

Commit

Permalink
followup of cf#851: fixes row number on submission table after refres…
Browse files Browse the repository at this point in the history
…h button (#864)
  • Loading branch information
sadiqkhoja authored Sep 19, 2023
1 parent d268b03 commit 972062f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/components/submission/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,8 @@ export default {
}
),
clear: clear && !refresh,
patch: (loaded > 0 && !clear) || (loaded > 0 && refresh)
? (response) => {
if (clear && refresh) this.odata.removeData();
this.odata.addChunk(response.data);
}
patch: loaded > 0 && !clear && !refresh
? (response) => this.odata.addChunk(response.data)
: null
})
.finally(() => { this.refreshing = false; })
Expand Down
3 changes: 0 additions & 3 deletions src/request-data/submissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ export default () => {
nextLink: data['@odata.nextLink']
});
},
removeData() {
odata.value.splice(0, odata.value.length);
},
addChunk(chunk) {
for (const submission of chunk.value) {
odata.value.push(submission);
Expand Down
18 changes: 18 additions & 0 deletions test/components/submission/list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ describe('SubmissionList', () => {
})
.respondWithData(testData.submissionOData);
});

it('should show correct row number after refresh', () => {
testData.extendedSubmissions.createPast(1);
return loadSubmissionList()
.complete()
.request(component =>
component.get('#submission-list-refresh-button').trigger('click'))
.beforeEachResponse(component => {
testData.extendedSubmissions.createPast(1);
component.get('#odata-loading-message').should.be.hidden();
})
.respondWithData(testData.submissionOData)
.afterResponse(component => {
component.findAllComponents(SubmissionMetadataRow).forEach((r, i) => {
r.props().rowNumber.should.be.equal(2 - i);
});
});
});
});

describe('load by chunk', () => {
Expand Down

0 comments on commit 972062f

Please sign in to comment.