-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from Dudrie/issue-223-Fix_names_being_display…
…ed_firstname_lastname_instead_of_lastname_firstname Fix names being displayed "firstname lastname" instead of "lastname, firstname"
- Loading branch information
Showing
10 changed files
with
35 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
import { NamedElement } from '../model/Common'; | ||
|
||
interface NameOptions { | ||
lastNameFirst: boolean; | ||
firstNameFirst: boolean; | ||
} | ||
|
||
export function getNameOfEntity(entity: NamedElement, options: Partial<NameOptions> = {}): string { | ||
if (options.lastNameFirst) { | ||
return `${entity.lastname}, ${entity.firstname} `; | ||
} else { | ||
export function getNameOfEntity( | ||
entity: NamedElement, | ||
{ firstNameFirst }: Partial<NameOptions> = {} | ||
): string { | ||
if (firstNameFirst) { | ||
return `${entity.firstname} ${entity.lastname}`; | ||
} else { | ||
return `${entity.lastname}, ${entity.firstname} `; | ||
} | ||
} | ||
|
||
export function sortByName(a: NamedElement, b: NamedElement): number { | ||
const nameOfA = getNameOfEntity(a, { lastNameFirst: true }); | ||
const nameOfB = getNameOfEntity(b, { lastNameFirst: true }); | ||
const nameOfA = getNameOfEntity(a); | ||
const nameOfB = getNameOfEntity(b); | ||
|
||
return nameOfA.localeCompare(nameOfB); | ||
} |