mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[AAE-1152] Making sure the people and group widget is working fine as part of form (#5322)
* Making sure the people and group widget is working fine as part of the form * Be able to save a form with people and group * Fix tslint * Fix html error * Fix unit test
This commit is contained in:
committed by
Eugenio Romano
parent
d8b703b6ef
commit
88d89b4ca8
@@ -34,8 +34,6 @@ import {
|
||||
groupsMockApi,
|
||||
roleMappingApi,
|
||||
clientRoles,
|
||||
returnCallQueryParameters,
|
||||
returnCallUrl,
|
||||
applicationDetailsMockApi,
|
||||
mockApiError,
|
||||
mockIdentityGroup1,
|
||||
@@ -233,22 +231,14 @@ describe('IdentityGroupService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should append to the call all the parameters', (done) => {
|
||||
spyOn(apiService, 'getInstance').and.returnValue(returnCallQueryParameters);
|
||||
service.findGroupsByName(<IdentityGroupSearchParam> {name: 'mock'}).subscribe((res) => {
|
||||
expect(res).toBeDefined();
|
||||
expect(res).not.toBeNull();
|
||||
expect(res.search).toBe('mock');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should request groups api url', (done) => {
|
||||
spyOn(apiService, 'getInstance').and.returnValue(returnCallUrl);
|
||||
service.findGroupsByName(<IdentityGroupSearchParam> {name: 'mock'}).subscribe((requestUrl) => {
|
||||
expect(requestUrl).toBeDefined();
|
||||
expect(requestUrl).not.toBeNull();
|
||||
expect(requestUrl).toContain('/groups');
|
||||
it('should return only the properties of IdentityGroupSearchParam', (done) => {
|
||||
spyOn(apiService, 'getInstance').and.returnValue(groupsMockApi);
|
||||
service.findGroupsByName(<IdentityGroupSearchParam> {name: 'mock'}).subscribe((groups) => {
|
||||
expect(groups).toBeDefined();
|
||||
expect(groups).toBeDefined();
|
||||
expect(groups[0].id).toEqual('mock-group-id-1');
|
||||
expect(groups[0].name).toEqual('Mock Group 1');
|
||||
expect(groups[0]['subGroups']).not.toBeDefined();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -173,7 +173,7 @@ export class IdentityGroupService {
|
||||
* @param searchParams Object containing the name filter string
|
||||
* @returns List of group information
|
||||
*/
|
||||
findGroupsByName(searchParams: IdentityGroupSearchParam): Observable<any> {
|
||||
findGroupsByName(searchParams: IdentityGroupSearchParam): Observable<IdentityGroupModel[]> {
|
||||
if (searchParams.name === '') {
|
||||
return of([]);
|
||||
}
|
||||
@@ -181,12 +181,17 @@ export class IdentityGroupService {
|
||||
const httpMethod = 'GET', pathParams = {}, queryParams = {search: searchParams.name}, bodyParam = {}, headerParams = {},
|
||||
formParams = {}, contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
|
||||
return (from(this.alfrescoApiService.getInstance().oauth2Auth.callCustomApi(
|
||||
return from(this.alfrescoApiService.getInstance().oauth2Auth.callCustomApi(
|
||||
url, httpMethod, pathParams, queryParams,
|
||||
headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts, Object, null, null)
|
||||
)).pipe(
|
||||
catchError((error) => this.handleError(error))
|
||||
).pipe(
|
||||
map((response: []) => {
|
||||
return response.map( (group: IdentityGroupModel) => {
|
||||
return {id: group.id, name: group.name};
|
||||
});
|
||||
}),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -78,7 +78,7 @@ export class IdentityUserService {
|
||||
* @param search Search query string
|
||||
* @returns List of users
|
||||
*/
|
||||
findUsersByName(search: string): Observable<any> {
|
||||
findUsersByName(search: string): Observable<IdentityUserModel[]> {
|
||||
if (search === '') {
|
||||
return of([]);
|
||||
}
|
||||
@@ -86,11 +86,18 @@ export class IdentityUserService {
|
||||
const httpMethod = 'GET', pathParams = {}, queryParams = { search: search }, bodyParam = {}, headerParams = {},
|
||||
formParams = {}, contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
|
||||
return (from(this.alfrescoApiService.getInstance().oauth2Auth.callCustomApi(
|
||||
return from(this.alfrescoApiService.getInstance().oauth2Auth.callCustomApi(
|
||||
url, httpMethod, pathParams, queryParams,
|
||||
headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts, Object, null, null)
|
||||
));
|
||||
).pipe(
|
||||
map((response: []) => {
|
||||
return response.map( (user: IdentityUserModel) => {
|
||||
return {id: user.id, firstName: user.firstName, lastName: user.lastName, email: user.email, username: user.username};
|
||||
});
|
||||
}),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +105,7 @@ export class IdentityUserService {
|
||||
* @param username Search query string
|
||||
* @returns List of users
|
||||
*/
|
||||
findUserByUsername(username: string): Observable<any> {
|
||||
findUserByUsername(username: string): Observable<IdentityUserModel[]> {
|
||||
if (username === '') {
|
||||
return of([]);
|
||||
}
|
||||
@@ -106,11 +113,18 @@ export class IdentityUserService {
|
||||
const httpMethod = 'GET', pathParams = {}, queryParams = { username: username }, bodyParam = {}, headerParams = {},
|
||||
formParams = {}, contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
|
||||
return (from(this.alfrescoApiService.getInstance().oauth2Auth.callCustomApi(
|
||||
return from(this.alfrescoApiService.getInstance().oauth2Auth.callCustomApi(
|
||||
url, httpMethod, pathParams, queryParams,
|
||||
headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts, Object, null, null)
|
||||
));
|
||||
).pipe(
|
||||
map((response: []) => {
|
||||
return response.map( (user: IdentityUserModel) => {
|
||||
return {id: user.id, firstName: user.firstName, lastName: user.lastName, email: user.email, username: user.username};
|
||||
});
|
||||
}),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +132,7 @@ export class IdentityUserService {
|
||||
* @param email Search query string
|
||||
* @returns List of users
|
||||
*/
|
||||
findUserByEmail(email: string): Observable<any> {
|
||||
findUserByEmail(email: string): Observable<IdentityUserModel[]> {
|
||||
if (email === '') {
|
||||
return of([]);
|
||||
}
|
||||
@@ -126,11 +140,18 @@ export class IdentityUserService {
|
||||
const httpMethod = 'GET', pathParams = {}, queryParams = { email: email }, bodyParam = {}, headerParams = {},
|
||||
formParams = {}, contentTypes = ['application/json'], accepts = ['application/json'];
|
||||
|
||||
return (from(this.alfrescoApiService.getInstance().oauth2Auth.callCustomApi(
|
||||
return from(this.alfrescoApiService.getInstance().oauth2Auth.callCustomApi(
|
||||
url, httpMethod, pathParams, queryParams,
|
||||
headerParams, formParams, bodyParam,
|
||||
contentTypes, accepts, Object, null, null)
|
||||
));
|
||||
).pipe(
|
||||
map((response: []) => {
|
||||
return response.map( (user: IdentityUserModel) => {
|
||||
return {id: user.id, firstName: user.firstName, lastName: user.lastName, email: user.email, username: user.username};
|
||||
});
|
||||
}),
|
||||
catchError((err) => this.handleError(err))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user