diff --git a/src/components/InitialsAvatar/InitialsAvatar.stories.js b/src/components/InitialsAvatar/InitialsAvatar.stories.js index a7b347a30..22fedba25 100644 --- a/src/components/InitialsAvatar/InitialsAvatar.stories.js +++ b/src/components/InitialsAvatar/InitialsAvatar.stories.js @@ -15,34 +15,29 @@ export default { }; export const Default = { - args: {givenName: 'Ramiro', familyName: 'Vaca'}, -}; - -export const GivenNameOnly = { - args: {givenName: 'Daniel'}, + args: {initials: 'RV'}, }; export const IsSecondary = { - args: {givenName: 'David', familyName: 'Buskins', isSecondary: true}, + args: {initials: 'DB', isSecondary: true}, }; export const IsWarnable = { - args: {givenName: 'Aisla', familyName: 'McCrae', isWarnable: true}, + args: {initials: 'AG', isWarnable: true}, }; export const IsDisabled = { args: { - givenName: 'Adela', - familyName: 'Gallego', + initials: 'AG', isSecondary: true, isDisabled: true, }, }; -export const UndefinedName = { +export const UndefinedInitials = { args: {}, }; export const SmallIcon = { - args: {givenName: 'Paul', familyName: 'Hudson', shrink: true}, + args: {initials: 'PH', shrink: true}, }; diff --git a/src/components/InitialsAvatar/InitialsAvatar.vue b/src/components/InitialsAvatar/InitialsAvatar.vue index 39e501dfe..3e64c5798 100644 --- a/src/components/InitialsAvatar/InitialsAvatar.vue +++ b/src/components/InitialsAvatar/InitialsAvatar.vue @@ -9,16 +9,6 @@ import {computed} from 'vue'; import Icon from '../Icon/Icon.vue'; const props = defineProps({ - /** User's given name */ - givenName: { - type: String, - required: true, - }, - /** User's family name */ - familyName: { - type: String, - default: '', - }, /** If the background should use primary color (blue) */ isPrimary: { type: Boolean, @@ -44,10 +34,11 @@ const props = defineProps({ type: Boolean, default: false, }, -}); - -const initials = computed(() => { - return `${props.givenName?.charAt(0) || ''}${props.familyName?.charAt(0) || ''}`.toUpperCase(); + /** Initials to display */ + initials: { + type: String, + required: true, + }, }); const classes = computed(() => ({ diff --git a/src/components/UserAvatar/UserAvatar.stories.js b/src/components/UserAvatar/UserAvatar.stories.js index 27052a967..444f903f3 100644 --- a/src/components/UserAvatar/UserAvatar.stories.js +++ b/src/components/UserAvatar/UserAvatar.stories.js @@ -14,14 +14,7 @@ export default { export const Default = { args: { - userFullName: 'Nama Sampan-Nirmal Lengkap', - userId: 136, - }, -}; - -export const Arabic = { - args: { - userFullName: 'خالد محمود الفارسي', + initials: 'NL', userId: 136, }, }; diff --git a/src/components/UserAvatar/UserAvatar.vue b/src/components/UserAvatar/UserAvatar.vue index a93509478..57b487603 100644 --- a/src/components/UserAvatar/UserAvatar.vue +++ b/src/components/UserAvatar/UserAvatar.vue @@ -11,9 +11,7 @@ diff --git a/src/composables/useParticipant.js b/src/composables/useParticipant.js index 49ad92b58..9a34187d6 100644 --- a/src/composables/useParticipant.js +++ b/src/composables/useParticipant.js @@ -7,22 +7,7 @@ export function useParticipant() { ]; } - function getUserAvatarInitialsFromName(fullName) { - const fullNameParts = fullName.split(' '); - - return fullNameParts - .map((part) => { - const partTrimmed = part.trim(); - if (partTrimmed.length) { - return partTrimmed[0].toUpperCase(); - } - return ''; - }) - .join('') - .substring(0, 3); - } return { - getUserAvatarInitialsFromName, getEditorRoleIds, }; } diff --git a/src/composables/useParticipant.test.js b/src/composables/useParticipant.test.js deleted file mode 100644 index 745547f6b..000000000 --- a/src/composables/useParticipant.test.js +++ /dev/null @@ -1,29 +0,0 @@ -import {expect, test, describe} from 'vitest'; -import {useParticipant} from './useParticipant'; - -describe('useParticipant', () => { - describe('getUserAvatarInitials', () => { - const {getUserAvatarInitialsFromName} = useParticipant(); - test('Two names', () => { - expect(getUserAvatarInitialsFromName('Charlotte Reynolds')).toBe('CR'); - }); - - test('Three names with dash', () => { - expect(getUserAvatarInitialsFromName('Nama Sampan-Nirmal Lengkap')).toBe( - 'NSL', - ); - }); - - test('Three names', () => { - expect(getUserAvatarInitialsFromName('Theresa Jessie Franklin')).toBe( - 'TJF', - ); - }); - - test('Four names (max 3 initials)', () => { - expect( - getUserAvatarInitialsFromName('Theresa Jessie Franklin Jasmin'), - ).toBe('TJF'); - }); - }); -}); diff --git a/src/managers/ParticipantManager/ParticipantManager.vue b/src/managers/ParticipantManager/ParticipantManager.vue index a2d5c16f2..00824191a 100644 --- a/src/managers/ParticipantManager/ParticipantManager.vue +++ b/src/managers/ParticipantManager/ParticipantManager.vue @@ -23,7 +23,7 @@
diff --git a/src/managers/ParticipantManager/participantManagerStore.js b/src/managers/ParticipantManager/participantManagerStore.js index 84b2407d3..2b4e4c346 100644 --- a/src/managers/ParticipantManager/participantManagerStore.js +++ b/src/managers/ParticipantManager/participantManagerStore.js @@ -50,6 +50,7 @@ export const useParticipantManagerStore = defineComponentStore( roleId: stageAssignment.stageAssignmentUserGroup.roleId, userGroupId: stageAssignment.stageAssignmentUserGroup.id, recommendOnly: stageAssignment.recommendOnly, + displayInitials: participant.displayInitials, }); }); }); diff --git a/src/pages/dashboard/components/DashboardTable/CellSubmissionActivity/CellSubmissionActivityReviewsOpen.vue b/src/pages/dashboard/components/DashboardTable/CellSubmissionActivity/CellSubmissionActivityReviewsOpen.vue index 3d69b94ec..b950fca19 100644 --- a/src/pages/dashboard/components/DashboardTable/CellSubmissionActivity/CellSubmissionActivityReviewsOpen.vue +++ b/src/pages/dashboard/components/DashboardTable/CellSubmissionActivity/CellSubmissionActivityReviewsOpen.vue @@ -11,7 +11,7 @@