mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
reload on events (#808)
This commit is contained in:
committed by
Suzana Dirla
parent
ca67da3657
commit
8b1b7a78cc
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<app-page-layout-content>
|
<app-page-layout-content>
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
<adf-document-list #documentList acaDocumentList [display]="documentDisplayMode$ | async" [node]="favoriteList"
|
<adf-document-list #documentList acaDocumentList [display]="documentDisplayMode$ | async" [node]="list"
|
||||||
[loading]="dataIsLoading" selectionMode="single" [navigate]="false" [sorting]="[ 'title', 'asc' ]"
|
[loading]="dataIsLoading" selectionMode="single" [navigate]="false" [sorting]="[ 'title', 'asc' ]"
|
||||||
(node-dblclick)="navigateTo($event.detail?.node)" (name-click)="navigateTo($event.detail?.node)">
|
(node-dblclick)="navigateTo($event.detail?.node)" (name-click)="navigateTo($event.detail?.node)">
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import { FavoriteLibrariesComponent } from './favorite-libraries.component';
|
|||||||
import { AppTestingModule } from '../../testing/app-testing.module';
|
import { AppTestingModule } from '../../testing/app-testing.module';
|
||||||
import { ContentApiService } from '../../services/content-api.service';
|
import { ContentApiService } from '../../services/content-api.service';
|
||||||
import { ExperimentalDirective } from '../../directives/experimental.directive';
|
import { ExperimentalDirective } from '../../directives/experimental.directive';
|
||||||
|
import { ContentManagementService } from '../../services/content-management.service';
|
||||||
import { EffectsModule } from '@ngrx/effects';
|
import { EffectsModule } from '@ngrx/effects';
|
||||||
import { LibraryEffects } from '../../store/effects';
|
import { LibraryEffects } from '../../store/effects';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
@@ -50,6 +51,7 @@ describe('LibrariesComponent', () => {
|
|||||||
let contentApiService: ContentApiService;
|
let contentApiService: ContentApiService;
|
||||||
let router: Router;
|
let router: Router;
|
||||||
let page;
|
let page;
|
||||||
|
let contentManagementService;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
page = {
|
page = {
|
||||||
@@ -73,6 +75,7 @@ describe('LibrariesComponent', () => {
|
|||||||
AppConfigPipe,
|
AppConfigPipe,
|
||||||
ExperimentalDirective
|
ExperimentalDirective
|
||||||
],
|
],
|
||||||
|
providers: [ContentManagementService],
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -81,6 +84,7 @@ describe('LibrariesComponent', () => {
|
|||||||
|
|
||||||
alfrescoApi = TestBed.get(AlfrescoApiService);
|
alfrescoApi = TestBed.get(AlfrescoApiService);
|
||||||
contentApiService = TestBed.get(ContentApiService);
|
contentApiService = TestBed.get(ContentApiService);
|
||||||
|
contentManagementService = TestBed.get(ContentManagementService);
|
||||||
alfrescoApi.reset();
|
alfrescoApi.reset();
|
||||||
router = TestBed.get(Router);
|
router = TestBed.get(Router);
|
||||||
|
|
||||||
@@ -99,9 +103,9 @@ describe('LibrariesComponent', () => {
|
|||||||
spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(
|
spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(
|
||||||
of(page)
|
of(page)
|
||||||
);
|
);
|
||||||
fixture.autoDetectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(component.favoriteList).toEqual(page);
|
expect(component.list).toEqual(page);
|
||||||
expect(component.dataIsLoading).toBe(false);
|
expect(component.dataIsLoading).toBe(false);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@@ -121,4 +125,28 @@ describe('LibrariesComponent', () => {
|
|||||||
expect(router.navigate).toHaveBeenCalledWith(['libraries', 'libraryId']);
|
expect(router.navigate).toHaveBeenCalledWith(['libraries', 'libraryId']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Reload on actions', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(
|
||||||
|
of(page)
|
||||||
|
);
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reload on libraryDeleted action', () => {
|
||||||
|
contentManagementService.libraryDeleted.next();
|
||||||
|
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reload on libraryUpdated action', () => {
|
||||||
|
contentManagementService.libraryUpdated.next();
|
||||||
|
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should reload on favoriteLibraryToggle action', () => {
|
||||||
|
contentManagementService.favoriteLibraryToggle.next();
|
||||||
|
expect(contentApiService.getFavoriteLibraries).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import { PageComponent } from '../page.component';
|
|||||||
})
|
})
|
||||||
export class FavoriteLibrariesComponent extends PageComponent
|
export class FavoriteLibrariesComponent extends PageComponent
|
||||||
implements OnInit {
|
implements OnInit {
|
||||||
favoriteList: FavoritePaging;
|
list: FavoritePaging;
|
||||||
dataIsLoading = true;
|
dataIsLoading = true;
|
||||||
isSmallScreen = false;
|
isSmallScreen = false;
|
||||||
columns: any[] = [];
|
columns: any[] = [];
|
||||||
@@ -57,21 +57,12 @@ export class FavoriteLibrariesComponent extends PageComponent
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
|
|
||||||
this.contentApiService.getFavoriteLibraries().subscribe(
|
this.getList();
|
||||||
(favoriteLibraries: FavoritePaging) => {
|
|
||||||
this.favoriteList = favoriteLibraries;
|
|
||||||
this.dataIsLoading = false;
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.favoriteList = null;
|
|
||||||
this.dataIsLoading = false;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this.subscriptions = this.subscriptions.concat([
|
this.subscriptions = this.subscriptions.concat([
|
||||||
this.content.libraryDeleted.subscribe(() => this.reload()),
|
this.content.libraryDeleted.subscribe(() => this.reloadList()),
|
||||||
this.content.libraryUpdated.subscribe(() => this.reload()),
|
this.content.libraryUpdated.subscribe(() => this.reloadList()),
|
||||||
this.content.favoriteLibraryToggle.subscribe(() => this.reload()),
|
this.content.favoriteLibraryToggle.subscribe(() => this.reloadList()),
|
||||||
|
|
||||||
this.breakpointObserver
|
this.breakpointObserver
|
||||||
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape])
|
||||||
@@ -87,4 +78,22 @@ export class FavoriteLibrariesComponent extends PageComponent
|
|||||||
this.store.dispatch(new NavigateLibraryAction(node.entry.guid));
|
this.store.dispatch(new NavigateLibraryAction(node.entry.guid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getList() {
|
||||||
|
this.contentApiService.getFavoriteLibraries().subscribe(
|
||||||
|
(favoriteLibraries: FavoritePaging) => {
|
||||||
|
this.list = favoriteLibraries;
|
||||||
|
this.dataIsLoading = false;
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.list = null;
|
||||||
|
this.dataIsLoading = false;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private reloadList() {
|
||||||
|
this.reload();
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user