@@ -45,6 +50,13 @@ export default defineComponent({
}
return value;
},
+ handleLinkClick(row: RowItem, event: MouseEvent) {
+ const cellConfig = this.header?.cellConfig;
+ if (cellConfig && typeof cellConfig?.onClick === 'function') {
+ event.preventDefault();
+ this.header.cellConfig.onClick(row, event);
+ }
+ },
},
props: {
link: {
@@ -70,6 +82,10 @@ export default defineComponent({
type: Boolean,
default: false,
},
+ header: {
+ type: Object,
+ default: () => ({}),
+ },
},
computed: {
linkClasses(): object {
diff --git a/components/src/core/components/CardTable/Cell/ProfilePicture.vue b/components/src/core/components/CardTable/Cell/ProfilePicture.vue
index 096c83827..3a8435f6f 100644
--- a/components/src/core/components/CardTable/Cell/ProfilePicture.vue
+++ b/components/src/core/components/CardTable/Cell/ProfilePicture.vue
@@ -12,6 +12,7 @@
:link="profilePicture.link"
:imageSrc="profilePicture.src"
:link-mode="profilePicture.target"
+ :link-handler="handleLinkClick"
v-bind="$attrs"
/>
@@ -52,6 +53,14 @@ export default defineComponent({
type: Boolean,
default: false,
},
+ header: {
+ type: Object,
+ default: () => ({}),
+ },
+ rowItem: {
+ type: Object,
+ default: () => ({}),
+ },
},
setup(props) {
const imgSrc = ref(null);
@@ -87,6 +96,14 @@ export default defineComponent({
const isLoading = computed(() => props.loading || imgLoading.value);
+ const handleLinkClick = (event: MouseEvent) => {
+ const cellConfig = props.header?.cellConfig;
+ if (cellConfig && typeof cellConfig?.onClick === 'function') {
+ event.preventDefault();
+ props.header?.cellConfig.onClick(props.rowItem, event);
+ }
+ };
+
watchEffect(async () => {
imgSrc.value = await loadImage(props.item as string);
});
@@ -94,6 +111,7 @@ export default defineComponent({
return {
isLoading,
profilePicture,
+ handleLinkClick,
};
},
});
diff --git a/components/src/core/components/CardTable/Cell/__tests__/link-with-pill.spec.ts b/components/src/core/components/CardTable/Cell/__tests__/link-with-pill.spec.ts
index 34e59f7c4..10dc30cab 100644
--- a/components/src/core/components/CardTable/Cell/__tests__/link-with-pill.spec.ts
+++ b/components/src/core/components/CardTable/Cell/__tests__/link-with-pill.spec.ts
@@ -109,4 +109,54 @@ describe('CardTable > Cell > LinkWithPill.vue', () => {
.trim(),
).toEqual('external');
});
+
+ it('should trigger handleLinkClick on link click', async () => {
+ const mockOnClick = jest.fn();
+ const rowItem = {
+ url1: 'https://orangehrm.com',
+ tag: 'external',
+ };
+
+ const wrapper = mount(LinkWithPill, {
+ global: GLOBAL,
+ props: {
+ item: 'This is a link',
+ target: '_parent',
+ link: 'url1',
+ rowItem: rowItem,
+ header: {
+ cellConfig: {
+ onClick: mockOnClick,
+ },
+ },
+ },
+ });
+
+ const link = wrapper.find('a');
+ await link.trigger('click');
+
+ expect(mockOnClick).toHaveBeenCalledWith(rowItem, expect.any(MouseEvent));
+ });
+
+ it('should not prevent default behavior if no onClick handler is present', async () => {
+ const wrapper = mount(LinkWithPill, {
+ global: GLOBAL,
+ props: {
+ item: 'This is a link',
+ target: '_blank',
+ link: 'url1',
+ rowItem: {
+ url1: 'https://orangehrm.com',
+ tag: 'external',
+ },
+ },
+ });
+
+ const link = wrapper.find('a');
+ const event = {preventDefault: jest.fn()};
+
+ await link.trigger('click', event);
+
+ expect(event.preventDefault).not.toHaveBeenCalled();
+ });
});
diff --git a/components/src/core/components/Icon/icons.ts b/components/src/core/components/Icon/icons.ts
index e63bd9d22..ea9c430ae 100644
--- a/components/src/core/components/Icon/icons.ts
+++ b/components/src/core/components/Icon/icons.ts
@@ -2117,6 +2117,11 @@ export const oxdRequired: icon = {
`,
};
+export const oxdExternalLink: icon = {
+ name: 'oxd-external-link',
+ value: `
`,
+};
+
const icons: Icons = {
'oxd-likes': oxdLikes,
'oxd-birthday': oxdBirthday,
@@ -2350,6 +2355,7 @@ const icons: Icons = {
'oxd-employee-autocomplete': oxdEmployeeAutocomplete,
'oxd-status': oxdStatus,
'oxd-required': oxdRequired,
+ 'oxd-external-link': oxdExternalLink,
};
export default icons;
diff --git a/components/src/core/components/ProfilePic/ProfilePic.vue b/components/src/core/components/ProfilePic/ProfilePic.vue
index bfa90154e..948c52c26 100644
--- a/components/src/core/components/ProfilePic/ProfilePic.vue
+++ b/components/src/core/components/ProfilePic/ProfilePic.vue
@@ -1,7 +1,12 @@