mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4056][ADF-4060][ADF-3930] Content Node Selector fix (#4293)
* remove target when search * content panel component infinite pagiantion and dropdown integration * fix insight karma
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<div *ngIf="pagination?.hasMoreItems || isLoading" class="adf-infinite-pagination">
|
||||
|
||||
<button mat-button
|
||||
*ngIf="!isLoading"
|
||||
class="adf-infinite-pagination-load-more"
|
||||
|
@@ -23,7 +23,7 @@ import { PaginatedComponent } from './paginated-component.interface';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreTestingModule } from '../testing/core.testing.module';
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, ChangeDetectorRef } from '@angular/core';
|
||||
import { PaginationModel } from '../models/pagination.model';
|
||||
import { RequestPaginationModel } from '../models/request-pagination.model';
|
||||
|
||||
@@ -57,6 +57,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
let fixture: ComponentFixture<InfinitePaginationComponent>;
|
||||
let component: InfinitePaginationComponent;
|
||||
let pagination: Pagination;
|
||||
let changeDetectorRef: ChangeDetectorRef;
|
||||
|
||||
setupTestBed({
|
||||
imports: [CoreTestingModule],
|
||||
@@ -68,6 +69,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(InfinitePaginationComponent);
|
||||
component = fixture.componentInstance;
|
||||
changeDetectorRef = fixture.componentRef.injector.get(ChangeDetectorRef);
|
||||
|
||||
component.target = TestBed.createComponent(TestPaginatedComponent).componentInstance;
|
||||
pagination = {
|
||||
@@ -86,7 +88,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
pagination.hasMoreItems = true;
|
||||
component.isLoading = true;
|
||||
component.target = null;
|
||||
fixture.detectChanges();
|
||||
changeDetectorRef.detectChanges();
|
||||
|
||||
let loadingSpinner = fixture.debugElement.query(By.css('[data-automation-id="adf-infinite-pagination-spinner"]'));
|
||||
expect(loadingSpinner).not.toBeNull();
|
||||
@@ -96,7 +98,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
pagination.hasMoreItems = true;
|
||||
component.target.updatePagination(pagination);
|
||||
component.isLoading = false;
|
||||
fixture.detectChanges();
|
||||
changeDetectorRef.detectChanges();
|
||||
|
||||
let loadingSpinner = fixture.debugElement.query(By.css('[data-automation-id="adf-infinite-pagination-spinner"]'));
|
||||
expect(loadingSpinner).toBeNull();
|
||||
@@ -106,7 +108,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
pagination.hasMoreItems = true;
|
||||
component.target.updatePagination(pagination);
|
||||
component.isLoading = false;
|
||||
fixture.detectChanges();
|
||||
changeDetectorRef.detectChanges();
|
||||
|
||||
let loadMoreButton = fixture.debugElement.query(By.css('[data-automation-id="adf-infinite-pagination-button"]'));
|
||||
expect(loadMoreButton).not.toBeNull();
|
||||
@@ -117,7 +119,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
|
||||
component.target.pagination.next(pagination);
|
||||
|
||||
fixture.detectChanges();
|
||||
changeDetectorRef.detectChanges();
|
||||
|
||||
component.onLoadMore();
|
||||
|
||||
@@ -133,7 +135,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
|
||||
component.target.pagination.next(pagination);
|
||||
|
||||
fixture.detectChanges();
|
||||
changeDetectorRef.detectChanges();
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
let loadMoreButton = fixture.debugElement.query(By.css('[data-automation-id="adf-infinite-pagination-button"]'));
|
||||
@@ -145,7 +147,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
it('should NOT show anything if pagination has NO more items', () => {
|
||||
pagination.hasMoreItems = false;
|
||||
component.target.updatePagination(pagination);
|
||||
fixture.detectChanges();
|
||||
changeDetectorRef.detectChanges();
|
||||
|
||||
let loadMoreButton = fixture.debugElement.query(By.css('[data-automation-id="adf-infinite-pagination-button"]'));
|
||||
expect(loadMoreButton).toBeNull();
|
||||
@@ -160,7 +162,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
|
||||
component.isLoading = false;
|
||||
component.pageSize = 5;
|
||||
fixture.detectChanges();
|
||||
changeDetectorRef.detectChanges();
|
||||
|
||||
component.loadMore.subscribe((newPagination: Pagination) => {
|
||||
expect(newPagination.skipCount).toBe(0);
|
||||
@@ -178,7 +180,7 @@ describe('InfinitePaginationComponent', () => {
|
||||
|
||||
component.isLoading = false;
|
||||
component.pageSize = 5;
|
||||
fixture.detectChanges();
|
||||
changeDetectorRef.detectChanges();
|
||||
|
||||
component.loadMore.subscribe((newPagination: RequestPaginationModel) => {
|
||||
expect(newPagination.merge).toBe(false);
|
||||
|
@@ -29,6 +29,7 @@ import { PaginationComponentInterface } from './pagination-component.interface';
|
||||
import { PaginationModel } from '../models/pagination.model';
|
||||
import { RequestPaginationModel } from '../models/request-pagination.model';
|
||||
import { UserPreferencesService, UserPreferenceValues } from '../services/user-preferences.service';
|
||||
import { Pagination } from '@alfresco/js-api';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-infinite-pagination',
|
||||
@@ -40,9 +41,35 @@ import { UserPreferencesService, UserPreferenceValues } from '../services/user-p
|
||||
})
|
||||
export class InfinitePaginationComponent implements OnInit, OnDestroy, PaginationComponentInterface {
|
||||
|
||||
static DEFAULT_PAGINATION: Pagination = new Pagination({
|
||||
skipCount: 0,
|
||||
maxItems: 25,
|
||||
totalItems: 0
|
||||
});
|
||||
|
||||
_target: PaginatedComponent;
|
||||
|
||||
/** Component that provides custom pagination support. */
|
||||
@Input()
|
||||
target: PaginatedComponent;
|
||||
set target(target: PaginatedComponent) {
|
||||
if (target) {
|
||||
this._target = target;
|
||||
this.paginationSubscription = target.pagination.subscribe((pagination: PaginationModel) => {
|
||||
this.isLoading = false;
|
||||
this.pagination = pagination;
|
||||
|
||||
if (!this.pagination.hasMoreItems) {
|
||||
this.pagination.hasMoreItems = false;
|
||||
}
|
||||
|
||||
this.cdr.detectChanges();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get target() {
|
||||
return this._target;
|
||||
}
|
||||
|
||||
/** Number of items that are added with each "load more" event. */
|
||||
@Input()
|
||||
@@ -56,7 +83,7 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
|
||||
@Output()
|
||||
loadMore: EventEmitter<RequestPaginationModel> = new EventEmitter<RequestPaginationModel>();
|
||||
|
||||
pagination: PaginationModel;
|
||||
pagination: PaginationModel = InfinitePaginationComponent.DEFAULT_PAGINATION;
|
||||
|
||||
requestPaginationModel: RequestPaginationModel = {
|
||||
skipCount: 0,
|
||||
@@ -69,19 +96,6 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.target) {
|
||||
this.paginationSubscription = this.target.pagination.subscribe((pagination: PaginationModel) => {
|
||||
this.isLoading = false;
|
||||
this.pagination = pagination;
|
||||
|
||||
if (!this.pagination.hasMoreItems) {
|
||||
this.pagination.hasMoreItems = false;
|
||||
}
|
||||
|
||||
this.cdr.detectChanges();
|
||||
});
|
||||
}
|
||||
|
||||
this.userPreferencesService.select(UserPreferenceValues.PaginationSize).subscribe((pagSize) => {
|
||||
this.pageSize = this.pageSize || pagSize;
|
||||
this.requestPaginationModel.maxItems = this.pageSize;
|
||||
@@ -96,16 +110,19 @@ export class InfinitePaginationComponent implements OnInit, OnDestroy, Paginatio
|
||||
|
||||
this.loadMore.next(this.requestPaginationModel);
|
||||
|
||||
if (this.target) {
|
||||
if (this._target) {
|
||||
this.isLoading = true;
|
||||
this.target.updatePagination(<RequestPaginationModel> this.requestPaginationModel);
|
||||
this._target.updatePagination(<RequestPaginationModel> this.requestPaginationModel);
|
||||
}
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.pagination.skipCount = 0;
|
||||
this.pagination.maxItems = this.pageSize;
|
||||
this.target.updatePagination(this.pagination);
|
||||
|
||||
if (this._target) {
|
||||
this._target.updatePagination(this.pagination);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
Reference in New Issue
Block a user