Skip to content

Commit

Permalink
feat(orga): add icon in options list & information about simplified a…
Browse files Browse the repository at this point in the history
…ccess in campaign creation
  • Loading branch information
Alexandre-Monney committed Feb 13, 2025
1 parent 5352be4 commit 0b93ef7
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
5 changes: 5 additions & 0 deletions orga/app/components/campaign/create-form.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export default class CreateForm extends Component {
value: targetProfile.id,
label: targetProfile.name,
category: this.intl.t(`pages.campaign-creation.tags.${targetProfile.category}`),
icon: targetProfile.isSimplifiedAccess ? 'accountOff' : 'users',
iconTitle: targetProfile.isSimplifiedAccess
? 'common.target-profile-details.simplified-access.without-account'
: 'common.target-profile-details.simplified-access.with-account',
order: 'OTHER' === targetProfile.category ? 1 : 0,
};
});
Expand Down Expand Up @@ -301,6 +305,7 @@ export default class CreateForm extends Component {
@hasBadges={{gt @campaign.targetProfile.thematicResultCount 0}}
@targetProfileTubesCount={{@campaign.targetProfile.tubeCount}}
@targetProfileThematicResultCount={{@campaign.targetProfile.thematicResultCount}}
@simplifiedAccess={{@campaign.targetProfile.isSimplifiedAccess}}
/>
</:message>
</ExplanationCard>
Expand Down
11 changes: 11 additions & 0 deletions orga/app/components/campaign/target-profile-details.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ export default class CampaignTargetProfileDetails extends Component {
};
}

get simplifiedAccessInfo() {
return this.args.simplifiedAccess
? { icon: 'accountOff', label: 'common.target-profile-details.simplified-access.without-account' }
: { icon: 'users', label: 'common.target-profile-details.simplified-access.with-account' };
}

<template>
<span class="target-profile-details" ...attributes>
{{#if @targetProfileDescription}}
Expand All @@ -33,6 +39,11 @@ export default class CampaignTargetProfileDetails extends Component {
{{t "common.target-profile-details.thematic-results" value=@targetProfileThematicResultCount}}
</li>
{{/if}}
<li class="target-profile-details__specificity__row target-profile-details__specificity__row--add-separator">
<PixIcon @name={{this.simplifiedAccessInfo.icon}} />
{{t this.simplifiedAccessInfo.label}}
</li>

<li class="target-profile-details__specificity__row target-profile-details__specificity__row--break-line">
<span class="target-profile-details__specificity__white-space">
{{t "common.target-profile-details.results.common"}}
Expand Down
63 changes: 63 additions & 0 deletions orga/tests/integration/components/campaign/create-form-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,69 @@ module('Integration | Component | Campaign::CreateForm', function (hooks) {
assert.dom(screen.getByText(t('common.target-profile-details.results.common'))).exists();
});

module('simplified access', function () {
test('it should display with simplified access', async function (assert) {
// given
this.targetProfiles = [
store.createRecord('target-profile', {
id: '1',
name: 'targetProfile1',
isSimplifiedAccess: true,
}),
];

// when
const screen = await render(
hbs`<Campaign::CreateForm
@campaign={{this.campaign}}
@targetProfiles={{this.targetProfiles}}
@onSubmit={{this.createCampaignSpy}}
@onCancel={{this.cancelSpy}}
@errors={{this.errors}}
@membersSortedByFullName={{this.defaultMembers}}
/>`,
);

await clickByName(t('pages.campaign-creation.purpose.assessment'));

await click(screen.getByLabelText(t('pages.campaign-creation.target-profiles-list-label'), { exact: false }));
await click(await screen.findByRole('option', { name: 'targetProfile1' }));

// then
assert.ok(screen.getByText(t('common.target-profile-details.simplified-access.without-account')));
});

test('it should display without simplified access', async function (assert) {
// given
this.targetProfiles = [
store.createRecord('target-profile', {
id: '1',
name: 'targetProfile1',
isSimplifiedAccess: false,
}),
];

// when
const screen = await render(
hbs`<Campaign::CreateForm
@campaign={{this.campaign}}
@targetProfiles={{this.targetProfiles}}
@onSubmit={{this.createCampaignSpy}}
@onCancel={{this.cancelSpy}}
@errors={{this.errors}}
@membersSortedByFullName={{this.defaultMembers}}
/>`,
);
await clickByName(t('pages.campaign-creation.purpose.assessment'));

await click(screen.getByLabelText(t('pages.campaign-creation.target-profiles-list-label'), { exact: false }));
await click(await screen.findByRole('option', { name: 'targetProfile1' }));

// then
assert.ok(screen.getByText(t('common.target-profile-details.simplified-access.with-account')));
});
});

module('Displaying options and categories', function () {
test('it should display options in alphapetical order', async function (assert) {
// given
Expand Down
4 changes: 4 additions & 0 deletions orga/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@
"percent": "percentage",
"star": "stars"
},
"simplified-access": {
"with-account": "Access with account",
"without-account": "Access without account"
},
"subjects": "Topics: {value, number}",
"thematic-results": "Thematic results: {value, number}"
}
Expand Down
4 changes: 4 additions & 0 deletions orga/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@
"percent": "pourcentage",
"star": "étoile"
},
"simplified-access": {
"with-account": "Accès avec compte",
"without-account": "Accès sans compte"
},
"subjects": "Sujets : {value, number}",
"thematic-results": "Résultats thématiques : {value, number}"
}
Expand Down
4 changes: 4 additions & 0 deletions orga/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@
"percent": "percentage",
"star": "ster"
},
"simplified-access": {
"with-account": "Toegang account",
"without-account": "Toegang zonder account"
},
"subjects": "Onderwerpen: {value, number}",
"thematic-results": "Thematische resultaten: {value, number}"
},
Expand Down

0 comments on commit 0b93ef7

Please sign in to comment.