Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portage de l'ajout des slots de personnalisation des descriptions des cookies #3869

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,15 @@ export default defineComponent({
</VIcon>
</summary>

<CookiesTable :items="tableItems" class="mb-2" />
<CookiesTable :items="tableItems" class="mb-2" >
<template
v-for="(_, slotName) in $slots"
:key="slotName"
v-slot:[slotName]="props"
>
<slot :name="slotName" v-bind="props || {}" />
</template>
</CookiesTable>
</details>

<VRadioGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ export default defineComponent({
:type="key"
:table-items="cookies"
class="mb-6"
/>
>
<template
v-for="(_, slotName) in $slots"
:key="slotName"
#[slotName]="props"
>
<slot :name="slotName" v-bind="props || {}" />
</template>
</CookiesInformation>

<div class="d-flex mt-16">
<VSpacer />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ export default defineComponent({
<tbody>
<tr v-for="(cookie, index) in items" :key="index">
<td>{{ cookie.name }}</td>
<td>{{ cookie.description }}</td>
<td>
<slot
:name="`cookie-description-${cookie.name}`"
:cookie="cookie"
>
{{ cookie.description }}
</slot>
</td>
<td>{{ cookie.conservation }}</td>
</tr>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,53 @@ describe('CookiesPage', () => {

expect(wrapper.emitted()).toHaveProperty('submit')
})

it('displays the cookie description as a scoped slot', () => {
const cookiesList = {
essentials: [
{
name: 'session',
description: 'Sauvegarde la session pour rester connecté.',
conservation: '20 heures',
},
{
name: 'cookie_policy',
description: 'Sauvegarde les préférences de cookies.',
conservation: '1 an',
},
],
functional: [
{
name: 'contrast',
description: 'Sauvegarde la personnalisation de l’affichage.',
conservation: '1 an',
},
],
analytics: [
{
name: 'user_id',
description: 'Sauvegarde l’identifiant unique de visiteur.',
conservation: '6 mois',
},
],
}

const wrapper = mount(CookiesPage, {
global: {
plugins: [vuetify],
},
props: {
items: cookiesList,
},
slots: {
'cookie-description-contrast': `
<template #cookie-description-contrast="{ cookie }">
<a href="#" class="contrast-description">{{ cookie.description }}</a>
</template>
`,
},
})

expect(wrapper.find('a.contrast-description').text()).toContain(cookiesList.functional[0].description)
})
})
Loading