Skip to content

Commit

Permalink
hotfix: handle ro to translation in detail view (#1282)
Browse files Browse the repository at this point in the history
Co-authored-by: Abderrahmane Smimite <[email protected]>
  • Loading branch information
Mohamed-Hacene and ab-smith authored Dec 30, 2024
1 parent 7d6bea3 commit 86b3a87
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
14 changes: 11 additions & 3 deletions frontend/src/lib/components/DetailView/DetailView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,17 @@
(item) => item.field === key
)?.urlModel
}/${value.id}`}
<Anchor breadcrumbAction="push" href={itemHref} class="anchor"
>{value.str}</Anchor
>
{#if key === 'ro_to_couple'}
<Anchor breadcrumbAction="push" href={itemHref} class="anchor"
>{safeTranslate(toCamelCase(value.str.split(' - ')[0]))} - {value.str.split(
'-'
)[1]}</Anchor
>
{:else}
<Anchor breadcrumbAction="push" href={itemHref} class="anchor"
>{value.str}</Anchor
>
{/if}
<!-- Shortcut before DetailView refactoring -->
{:else if value === 'P1'}
<li class="fa-solid fa-flag text-red-500"></li>
Expand Down
15 changes: 12 additions & 3 deletions frontend/src/lib/components/ModelTable/ModelTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
} from '$lib/utils/crud';
import { stringify } from '$lib/utils/helpers';
import { safeTranslate, unsafeTranslate } from '$lib/utils/i18n';
import { toCamelCase } from '$lib/utils/locales.js';
import { createEventDispatcher, onMount } from 'svelte';
import { tableA11y } from './actions';
Expand Down Expand Up @@ -345,9 +346,17 @@
{:else if value && value.str}
{#if value.id}
{@const itemHref = `/${URL_MODEL_MAP[URLModel]['foreignKeyFields']?.find((item) => item.field === key)?.urlModel}/${value.id}`}
<Anchor href={itemHref} class="anchor" stopPropagation
>{value.str ?? '-'}</Anchor
>
{#if key === 'ro_to_couple'}
<Anchor breadcrumbAction="push" href={itemHref} class="anchor"
>{safeTranslate(toCamelCase(value.str.split(' - ')[0]))} - {value.str.split(
'-'
)[1]}</Anchor
>
{:else}
<Anchor breadcrumbAction="push" href={itemHref} class="anchor"
>{value.str}</Anchor
>
{/if}
{:else}
{value.str ?? '-'}
{/if}
Expand Down

0 comments on commit 86b3a87

Please sign in to comment.