mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-1488] reset selection on Document List data change (#2341)
* reset selection on data change * unit tests * fix unit tests
This commit is contained in:
committed by
Eugenio Romano
parent
3c1729b960
commit
43277148b2
@@ -89,8 +89,8 @@ describe('PeopleService', () => {
|
||||
(users: User[]) => {
|
||||
expect(users).toBeDefined();
|
||||
expect(users.length).toBe(2);
|
||||
expect(users[0].userImage).toContain('/app/rest/users/' + users[0].id + '/picture');
|
||||
expect(users[1].userImage).toContain('/app/rest/users/' + users[1].id + '/picture');
|
||||
expect(users[0].userImage).toContain('/users/' + users[0].id + '/picture');
|
||||
expect(users[1].userImage).toContain('/users/' + users[1].id + '/picture');
|
||||
done();
|
||||
});
|
||||
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||
@@ -104,7 +104,7 @@ describe('PeopleService', () => {
|
||||
service.addImageToUser(firstInvolvedUser).subscribe(
|
||||
(user: User) => {
|
||||
expect(user).toBeDefined();
|
||||
expect(user.userImage).toContain('/app/rest/users/' + user.id + '/picture');
|
||||
expect(user.userImage).toContain('/users/' + user.id + '/picture');
|
||||
expect(user.id).toBe('1');
|
||||
done();
|
||||
});
|
||||
@@ -113,7 +113,7 @@ describe('PeopleService', () => {
|
||||
it('should return user image url', () => {
|
||||
let url = service.getUserImage(firstInvolvedUser);
|
||||
|
||||
expect(url).toContain('/app/rest/users/' + firstInvolvedUser.id + '/picture');
|
||||
expect(url).toContain('/users/' + firstInvolvedUser.id + '/picture');
|
||||
});
|
||||
|
||||
it('should return empty list when there are no users to involve', (done) => {
|
||||
|
@@ -183,6 +183,21 @@ describe('DocumentList', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should reset selection upon reload', () => {
|
||||
spyOn(documentList, 'resetSelection').and.callThrough();
|
||||
|
||||
documentList.reload();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(documentList.resetSelection).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should reset selection on loading folder by node id', () => {
|
||||
spyOn(documentList, 'resetSelection').and.callThrough();
|
||||
documentList.loadFolderByNodeId('-trashcan-');
|
||||
expect(documentList.resetSelection).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should empty template be present when no element are present', (done) => {
|
||||
documentList.currentFolderId = '1d26e465-dea3-42f3-b415-faa8364b9692';
|
||||
documentList.folderNode = new NodeMinimal();
|
||||
|
@@ -255,6 +255,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
this.loadFolderByNodeId(changes.currentFolderId.currentValue);
|
||||
} else if (this.data) {
|
||||
if (changes.node && changes.node.currentValue) {
|
||||
this.resetSelection();
|
||||
this.data.loadPage(changes.node.currentValue);
|
||||
} else if (changes.rowFilter) {
|
||||
this.data.setFilter(changes.rowFilter.currentValue);
|
||||
@@ -269,6 +270,8 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
|
||||
reload() {
|
||||
this.ngZone.run(() => {
|
||||
this.resetSelection();
|
||||
|
||||
if (this.folderNode) {
|
||||
this.loadFolder();
|
||||
} else if (this.currentFolderId) {
|
||||
@@ -399,6 +402,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
// gets folder node and its content
|
||||
loadFolderByNodeId(nodeId: string) {
|
||||
this.loading = true;
|
||||
this.resetSelection();
|
||||
|
||||
if (nodeId === '-trashcan-') {
|
||||
this.loadTrashcan();
|
||||
@@ -425,6 +429,7 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
|
||||
loadFolderNodesByFolderNodeId(id: string, maxItems: number, skipCount: number): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.resetSelection();
|
||||
this.documentListService
|
||||
.getFolder(null, {
|
||||
maxItems: maxItems,
|
||||
@@ -454,6 +459,10 @@ export class DocumentListComponent implements OnInit, OnChanges, AfterContentIni
|
||||
|
||||
}
|
||||
|
||||
resetSelection() {
|
||||
this.selection = [];
|
||||
}
|
||||
|
||||
private loadTrashcan(): void {
|
||||
const options = {
|
||||
include: [ 'path', 'properties' ],
|
||||
|
Reference in New Issue
Block a user