Skip to content

Commit

Permalink
Portage de l'ajout des slots de personnalisation des descriptions des…
Browse files Browse the repository at this point in the history
… cookies (#3869)
  • Loading branch information
4dr1en authored Dec 9, 2024
1 parent c0551fa commit 98947e7
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
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)
})
})

0 comments on commit 98947e7

Please sign in to comment.