mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[ADF-3299] and [ADF-3300] upgrade to Angular and Material 6 (#3579)
* upgrade to HttpClient * upgrade to Renderer2 * upgrade Document reference * remove useless test with deprecated ReflectiveInjector * upgrade to latest typescript * upgrade libs * upgrade package scripts * remove rxjs blacklists and duplicate rules * add rxjs compat to help with migration * fix breaking changes * fix breaking changes in material * fix breaking changes (material 6) * upgrade rxjs, ngx-translate and flex layout * update unit tests * restore providers * upgrade deprecated Observable.error * rebase fix first configuration problems * fix style issues commented * fix core build * fix lib template errors * move lib test execution in angular.json * ignore * karma conf files * fix import statement test * single run option * update packages reporter * restore report * increase timeout * improve karma conf test configuration * fix test issues about lint * fix test analytics * fix process service test * content service fix test * fix logout directive test * fix core test * fix build * update node-sass to latest * update angular cli dependencies * improve build script create directorites and move files only if previous command succeded * upgrade individual libs to 6.0 * remove old webpack files * revert sass change * fix type issues fix style issues * fix tslint demo shell issue * fix peerdependencies * fix test e2e BC * package upate * fix style import issue * extract-text-webpack-plugin beta * fix test dist build command * remove alpha js-api * fix tslint issue add banner tslint rule * upload service fix * change BC script * fix test dist script * increase demo shell timeout test * verbose copy * path absolute * fix script bc * fix copy part * fix path warning fix monaco editor * remove duplicate header * remove unused import * fix align and check ago tests * add missing import * fix notification button selector * [ANGULAR6] fixed core tests * fix CS test * fix cs test step 2 * increase travis_wait for dist * fix attachment PS * fix checklist test * use pdf min
This commit is contained in:
committed by
Eugenio Romano
parent
c510ec864d
commit
6b24bfb1d4
@@ -18,8 +18,8 @@
|
||||
import { UserProcessModel, TranslationService, PeopleProcessService } from '@alfresco/adf-core';
|
||||
import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { debounceTime, switchMap } from 'rxjs/operators';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { PerformSearchCallback } from '../../interfaces/perform-search-callback.interface';
|
||||
import { getDisplayUser } from '../../helpers/getDisplayUser';
|
||||
|
||||
@@ -50,14 +50,16 @@ export class PeopleSearchFieldComponent {
|
||||
constructor(public peopleProcessService: PeopleProcessService,
|
||||
private translationService: TranslationService) {
|
||||
this.users$ = this.searchUser.valueChanges
|
||||
.pipe(debounceTime(200))
|
||||
.switchMap((searchWord: string) => {
|
||||
if (searchWord && searchWord.trim()) {
|
||||
return this.performSearch(searchWord);
|
||||
} else {
|
||||
return Observable.of([]);
|
||||
}
|
||||
});
|
||||
.pipe(
|
||||
debounceTime(200),
|
||||
switchMap((searchWord: string) => {
|
||||
if (searchWord && searchWord.trim()) {
|
||||
return this.performSearch(searchWord);
|
||||
} else {
|
||||
return of([]);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
this.defaultPlaceholder = this.translationService.instant(this.defaultPlaceholder);
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { UserProcessModel, setupTestBed } from '@alfresco/adf-core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of } from 'rxjs';
|
||||
import { PeopleSearchComponent } from './people-search.component';
|
||||
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
||||
|
||||
@@ -51,7 +51,7 @@ describe('PeopleSearchComponent', () => {
|
||||
fixture = TestBed.createComponent(PeopleSearchComponent);
|
||||
peopleSearchComponent = fixture.componentInstance;
|
||||
element = fixture.nativeElement;
|
||||
peopleSearchComponent.results = Observable.of([]);
|
||||
peopleSearchComponent.results = of([]);
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
@@ -70,7 +70,7 @@ describe('PeopleSearchComponent', () => {
|
||||
});
|
||||
|
||||
it('should show user which can be involved ', (done) => {
|
||||
peopleSearchComponent.results = Observable.of(userArray);
|
||||
peopleSearchComponent.results = of(userArray);
|
||||
peopleSearchComponent.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
@@ -93,7 +93,7 @@ describe('PeopleSearchComponent', () => {
|
||||
expect(user.firstName).toBe('fake-name');
|
||||
done();
|
||||
});
|
||||
peopleSearchComponent.results = Observable.of(userArray);
|
||||
peopleSearchComponent.results = of(userArray);
|
||||
peopleSearchComponent.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable()
|
||||
@@ -105,7 +105,7 @@ describe('PeopleSearchComponent', () => {
|
||||
});
|
||||
|
||||
it('should remove clicked user', (done) => {
|
||||
peopleSearchComponent.results = Observable.of(userArray);
|
||||
peopleSearchComponent.results = of(userArray);
|
||||
peopleSearchComponent.ngOnInit();
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@@ -17,8 +17,9 @@
|
||||
|
||||
import { UserProcessModel } from '@alfresco/adf-core';
|
||||
import { Component, EventEmitter, OnInit, Input, Output, ViewEncapsulation } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable } from 'rxjs';
|
||||
import { PerformSearchCallback } from '../../interfaces/perform-search-callback.interface';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-people-search',
|
||||
@@ -55,9 +56,12 @@ export class PeopleSearchComponent implements OnInit {
|
||||
constructor() {}
|
||||
|
||||
ngOnInit() {
|
||||
this.filteredResults$ = this.results.map((users) => {
|
||||
return users.filter(user => user.id !== this.selectedUser.id);
|
||||
});
|
||||
this.filteredResults$ = this.results
|
||||
.pipe(
|
||||
map((users) => {
|
||||
return users.filter(user => user.id !== this.selectedUser.id);
|
||||
})
|
||||
);
|
||||
this.performSearch = this.performSearchCallback.bind(this);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { LogService, PeopleProcessService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { PeopleSelectorComponent } from './people-selector.component';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { of, throwError } from 'rxjs';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
||||
|
||||
@@ -51,17 +51,17 @@ describe('PeopleSelectorComponent', () => {
|
||||
|
||||
it('should call the PeopleProcessService\'s getWorkflowUsers method on search', () => {
|
||||
const peopleProcessService = TestBed.get(PeopleProcessService);
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(Observable.of([]));
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(of([]));
|
||||
|
||||
component.performSearch('Chloe Price');
|
||||
|
||||
expect(peopleProcessService.getWorkflowUsers).toHaveBeenCalledWith(undefined, 'Chloe Price');
|
||||
});
|
||||
|
||||
it('should log error on getWorkflowUsers\'s error', () => {
|
||||
it('should log error on getWorkflowUsers error', () => {
|
||||
const peopleProcessService = TestBed.get(PeopleProcessService);
|
||||
const logService = TestBed.get(LogService);
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(Observable.throw(new Error()));
|
||||
spyOn(peopleProcessService, 'getWorkflowUsers').and.returnValue(throwError(new Error()));
|
||||
spyOn(logService, 'error');
|
||||
|
||||
component.performSearch('Chloe Price')
|
||||
|
@@ -20,7 +20,8 @@ import { PerformSearchCallback } from '../../interfaces/perform-search-callback.
|
||||
import { PeopleProcessService, UserProcessModel, LogService, TranslationService } from '@alfresco/adf-core';
|
||||
import { PeopleSearchFieldComponent } from '../people-search-field/people-search-field.component';
|
||||
import { getDisplayUser } from '../../helpers/getDisplayUser';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { catchError } from 'rxjs/operators';
|
||||
|
||||
const DEFAULT_ASSIGNEE_PLACEHOLDER = 'ADF_TASK_LIST.PEOPLE.ASSIGNEE';
|
||||
|
||||
@@ -60,12 +61,14 @@ export class PeopleSelectorComponent {
|
||||
|
||||
searchUser(searchWord: string): Observable<{} | UserProcessModel[]> {
|
||||
return this.peopleProcessService.getWorkflowUsers(undefined, searchWord)
|
||||
.catch(this.onSearchUserError.bind(this));
|
||||
.pipe(
|
||||
catchError(this.onSearchUserError.bind(this))
|
||||
);
|
||||
}
|
||||
|
||||
private onSearchUserError(): Observable<UserProcessModel[]> {
|
||||
this.logService.error('getWorkflowUsers threw error');
|
||||
return Observable.of([]);
|
||||
return of([]);
|
||||
}
|
||||
|
||||
userSelected(user: UserProcessModel): void {
|
||||
|
@@ -18,10 +18,10 @@
|
||||
import { LogService, UserProcessModel } from '@alfresco/adf-core';
|
||||
import { PeopleProcessService } from '@alfresco/adf-core';
|
||||
import { AfterViewInit, Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { Observer } from 'rxjs/Observer';
|
||||
import { Observable, Observer } from 'rxjs';
|
||||
import { UserEventModel } from '../../../task-list/models/user-event.model';
|
||||
import { PeopleSearchComponent } from '../people-search/people-search.component';
|
||||
import { share } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-people',
|
||||
@@ -51,7 +51,10 @@ export class PeopleComponent implements OnInit, AfterViewInit {
|
||||
peopleSearch$: Observable<UserProcessModel[]>;
|
||||
|
||||
constructor(private logService: LogService, public peopleProcessService: PeopleProcessService) {
|
||||
this.peopleSearch$ = new Observable<UserProcessModel[]>(observer => this.peopleSearchObserver = observer).share();
|
||||
this.peopleSearch$ = new Observable<UserProcessModel[]>(observer => this.peopleSearchObserver = observer)
|
||||
.pipe(
|
||||
share()
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
Reference in New Issue
Block a user