Compare commits

...
7 changed files with 18 additions and 41 deletions
@@ -1,4 +1,3 @@
<ng-container>
<adf-content-user-info
*ngIf="mode === userInfoMode.CONTENT || mode === userInfoMode.CONTENT_SSO"
[ecmUser]="ecmUser$ | async"
@@ -18,4 +17,3 @@
[isLoggedIn]="isLoggedIn"
[mode]="mode"
></adf-process-user-info>
</ng-container>
@@ -18,7 +18,6 @@
import { FullNamePipe } from './full-name.pipe';
describe('FullNamePipe', () => {
let pipe: FullNamePipe;
beforeEach(() => {
@@ -31,27 +30,27 @@ describe('FullNamePipe', () => {
});
it('should return only firstName as fullName when there is no lastName ', () => {
const user = {firstName : 'Abc'};
const user = { firstName: 'Abc' };
expect(pipe.transform(user)).toBe('Abc');
});
it('should return only lastName as fullName when there is no firstName ', () => {
const user = {lastName : 'Xyz'};
const user = { lastName: 'Xyz' };
expect(pipe.transform(user)).toBe('Xyz');
});
it('should return fullName when firstName and lastName are available', () => {
const user = {firstName : 'Abc', lastName : 'Xyz'};
const user = { firstName: 'Abc', lastName: 'Xyz' };
expect(pipe.transform(user)).toBe('Abc Xyz');
});
it('should return username when firstName and lastName are not available', () => {
const user = {firstName : '', lastName : '', username: 'username'};
const user = { firstName: '', lastName: '', username: 'username' };
expect(pipe.transform(user)).toBe('username');
});
it('should return user eamil when firstName, lastName and username are not available', () => {
const user = {firstName : '', lastName : '', username: '', email: 'abcXyz@gmail.com'};
it('should return user email when firstName, lastName and username are not available', () => {
const user = { firstName: '', lastName: '', username: '', email: 'abcXyz@gmail.com' };
expect(pipe.transform(user)).toBe('abcXyz@gmail.com');
});
});
+6 -14
View File
@@ -18,25 +18,17 @@
import { Pipe, PipeTransform } from '@angular/core';
import { UserLike } from './user-like.interface';
@Pipe({
name: 'fullName',
standalone: true
})
@Pipe({
name: 'fullName',
standalone: true
})
export class FullNamePipe implements PipeTransform {
transform(user: UserLike): string {
return this.buildFullName(user) ? this.buildFullName(user) : this.buildFromUsernameOrEmail(user);
}
buildFullName(user: UserLike): string {
const fullName: string[] = [];
fullName.push(user?.firstName);
fullName.push(user?.lastName);
return fullName.join(' ').trim();
}
buildFromUsernameOrEmail(user: UserLike): string {
return (user?.username || user?.email) ?? '';
const fullName = `${user?.firstName || ''} ${user?.lastName || ''}`.trim();
return fullName || user?.username || user?.email || '';
}
}
+1
View File
@@ -34,3 +34,4 @@ export * from './date-time.pipe';
export * from './filter-string.pipe';
export * from './filter-out-every-object-by-prop.pipe';
export * from './boolean.pipe';
export * from './user-like.interface';
@@ -20,4 +20,4 @@ export interface UserLike {
firstName?: string;
lastName?: string;
email?: string;
};
}
@@ -19,20 +19,7 @@
import { ExtensionElement } from './extension-element';
export interface DataColumnTypes {
text: string;
image: string;
date: string;
json: string;
icon: string;
fileSize: string;
location: string;
boolean: string;
amount: string;
number: string;
}
export type DataColumnType = keyof DataColumnTypes;
export type DataColumnType = 'text' | 'image' | 'date' | 'json' | 'icon' | 'fileSize' | 'location' | 'boolean' | 'amount' | 'number';
export interface DocumentListPresetRef extends ExtensionElement {
key: string;
@@ -32,7 +32,7 @@ import {
} from '@angular/core';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { switchMap, debounceTime, distinctUntilChanged, mergeMap, tap, filter, takeUntil } from 'rxjs/operators';
import { FullNamePipe } from '@alfresco/adf-core';
import { FullNamePipe, UserLike } from '@alfresco/adf-core';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { ComponentSelectionMode } from '../../types';
import { IdentityUserModel } from '../models/identity-user.model';
@@ -409,8 +409,8 @@ export class PeopleCloudComponent implements OnInit, OnChanges, OnDestroy {
return this.invalidUsers && this.invalidUsers.length > 0;
}
getDisplayName(user): string {
return FullNamePipe.prototype.transform(user);
getDisplayName(user: UserLike): string {
return new FullNamePipe().transform(user);
}
private isMultipleMode(): boolean {