From 195c640b0e3d1987468baba550be09d6981cf1a2 Mon Sep 17 00:00:00 2001 From: LionelB Date: Mon, 29 Apr 2024 13:53:12 +0200 Subject: [PATCH 1/2] feat(orga): add controller for place route --- orga/app/controllers/authenticated/places.js | 6 ++++++ .../unit/controllers/authenticated/places_test.js | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 orga/app/controllers/authenticated/places.js create mode 100644 orga/tests/unit/controllers/authenticated/places_test.js diff --git a/orga/app/controllers/authenticated/places.js b/orga/app/controllers/authenticated/places.js new file mode 100644 index 00000000000..426949dac8e --- /dev/null +++ b/orga/app/controllers/authenticated/places.js @@ -0,0 +1,6 @@ +import Controller from '@ember/controller'; +import { service } from '@ember/service'; + +export default class AuthenticatedPlacesController extends Controller { + @service currentUser; +} diff --git a/orga/tests/unit/controllers/authenticated/places_test.js b/orga/tests/unit/controllers/authenticated/places_test.js new file mode 100644 index 00000000000..7a91d9156af --- /dev/null +++ b/orga/tests/unit/controllers/authenticated/places_test.js @@ -0,0 +1,11 @@ +import { setupTest } from 'ember-qunit'; +import { module, test } from 'qunit'; + +module('Unit | Controller | authenticated/places', function (hooks) { + setupTest(hooks); + + test('it has access to currentUser', function (assert) { + const controller = this.owner.lookup('controller:authenticated/places'); + assert.ok(controller.currentUser); + }); +}); From bd8ab778a1142050c6b8e8456677439634a1048f Mon Sep 17 00:00:00 2001 From: LionelB Date: Mon, 29 Apr 2024 13:24:01 +0200 Subject: [PATCH 2/2] feat(orga): add place definition block --- orga/app/components/places/place-info.gjs | 28 +++++++++ orga/app/styles/components/places/index.scss | 1 + .../styles/components/places/place-info.scss | 24 ++++++++ orga/app/templates/authenticated/places.hbs | 4 +- orga/public/icons/place-info.svg | 1 + .../components/places/place-info_test.gjs | 57 +++++++++++++++++++ orga/translations/en.json | 5 ++ orga/translations/fr.json | 6 +- 8 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 orga/app/components/places/place-info.gjs create mode 100644 orga/app/styles/components/places/place-info.scss create mode 100644 orga/public/icons/place-info.svg create mode 100644 orga/tests/integration/components/places/place-info_test.gjs diff --git a/orga/app/components/places/place-info.gjs b/orga/app/components/places/place-info.gjs new file mode 100644 index 00000000000..3d9e2627b5f --- /dev/null +++ b/orga/app/components/places/place-info.gjs @@ -0,0 +1,28 @@ +import PixBlock from '@1024pix/pix-ui/components/pix-block'; +import { LinkTo } from '@ember/routing'; +import { t } from 'ember-intl'; + +function getParticipantsRoute(currentUser) { + if (currentUser.isSCOManagingStudents) { + return 'authenticated.sco-organization-participants'; + } else if (currentUser.isSUPManagingStudents) { + return 'authenticated.sup-organization-participants'; + } else { + return 'authenticated.organization-participants'; + } +} + + diff --git a/orga/app/styles/components/places/index.scss b/orga/app/styles/components/places/index.scss index 185a2ea0b1c..ddcf7a6fac6 100644 --- a/orga/app/styles/components/places/index.scss +++ b/orga/app/styles/components/places/index.scss @@ -1,2 +1,3 @@ @import 'title'; @import 'statistics'; +@import 'place-info'; diff --git a/orga/app/styles/components/places/place-info.scss b/orga/app/styles/components/places/place-info.scss new file mode 100644 index 00000000000..748c22fc929 --- /dev/null +++ b/orga/app/styles/components/places/place-info.scss @@ -0,0 +1,24 @@ +.place-info { + display: flex; + flex-direction: row; + gap: var(--pix-spacing-6x); + align-items: center; + justify-content: flex-start; + margin-top: var(--pix-spacing-8x); + padding: var(--pix-spacing-3x) var(--pix-spacing-6x); + + &__illustration { + width:64px; + } + + &__description { + @extend %pix-body-s; + } + + &__link { + @extend %pix-body-s; + + font-weight: var(--pix-font-medium); + text-decoration: underline; + } +} diff --git a/orga/app/templates/authenticated/places.hbs b/orga/app/templates/authenticated/places.hbs index ce1e3e41f41..45d9e128f1a 100644 --- a/orga/app/templates/authenticated/places.hbs +++ b/orga/app/templates/authenticated/places.hbs @@ -1,4 +1,6 @@ {{page-title (t "pages.places.title")}} - \ No newline at end of file + + + \ No newline at end of file diff --git a/orga/public/icons/place-info.svg b/orga/public/icons/place-info.svg new file mode 100644 index 00000000000..1aada070a58 --- /dev/null +++ b/orga/public/icons/place-info.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/orga/tests/integration/components/places/place-info_test.gjs b/orga/tests/integration/components/places/place-info_test.gjs new file mode 100644 index 00000000000..7a89e9a5602 --- /dev/null +++ b/orga/tests/integration/components/places/place-info_test.gjs @@ -0,0 +1,57 @@ +import { render } from '@1024pix/ember-testing-library'; +import PlaceInfo from 'pix-orga/components/places/place-info'; +import { module, test } from 'qunit'; + +import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; + +module('Integration | Component | Places | PlaceInfo', function (hooks) { + setupIntlRenderingTest(hooks); + + test('it should render', async function (assert) { + // given + const currentUser = { isSCOManagingStudents: false, isSUPManagingStudents: false }; + + // when + const screen = await render(); + + // then + assert.ok(screen.getByText(this.intl.t('cards.place-info.message'))); + assert.ok(screen.getByText(this.intl.t('cards.place-info.details'))); + }); + module('link', function () { + test('it should link to sup participant page', async function (assert) { + // given + const currentUser = { isSUPManagingStudents: true }; + + // when + const screen = await render(); + const link = screen.getByRole('link', { name: this.intl.t('cards.place-info.link') }); + + // then + assert.strictEqual(link.getAttribute('href'), '/etudiants'); + }); + + test('it should link to sco participant page', async function (assert) { + // given + const currentUser = { isSCOManagingStudents: true }; + + // when + const screen = await render(); + const link = screen.getByRole('link', { name: this.intl.t('cards.place-info.link') }); + + // then + assert.strictEqual(link.getAttribute('href'), '/eleves'); + }); + test('it should link to participant page', async function (assert) { + // given + const currentUser = {}; + + // when + const screen = await render(); + const link = screen.getByRole('link', { name: this.intl.t('cards.place-info.link') }); + + // then + assert.strictEqual(link.getAttribute('href'), '/participants'); + }); + }); +}); diff --git a/orga/translations/en.json b/orga/translations/en.json index 2e62593fff1..11de906cda2 100644 --- a/orga/translations/en.json +++ b/orga/translations/en.json @@ -86,6 +86,11 @@ "information": "Find here the total number of participations in your campaign. This includes all the participants who have entered the code and started their customised test or submitted their profile.", "loader": "Loading total participants" }, + "place-info": { + "details": "with at least one participation in a campaign.", + "link": "Free a place from the \"Participants\" tab.", + "message": "1 place occupied = 1 participant" + }, "submitted-count": { "title": "Submitted results", "information": "Find here the results submitted by your participants. This includes all the participants who have finished and clicked on the button \"Submit my results\" or \"Submit my profile\".", diff --git a/orga/translations/fr.json b/orga/translations/fr.json index 727889e1e38..7c685a434ec 100644 --- a/orga/translations/fr.json +++ b/orga/translations/fr.json @@ -86,6 +86,11 @@ "information": "Retrouvez ici le nombre de participants total de votre campagne. Ce nombre comprend l'ensemble des participants ayant saisi le code et commencé leur parcours ou leur envoi de profil.", "loader": "Chargement du total de participants" }, + "place-info": { + "details": "ayant au moins une participation à une campagne.", + "link": "Libérer une place depuis l’onglet “Participants”", + "message": "1 place occupée = 1 participant" + }, "submitted-count": { "title": "Résultats reçus", "information": "Retrouvez ici les résultats envoyés par vos participants. Ce nombre comprend l’ensemble des participants ayant terminé et cliqué sur le bouton \"J'envoie mes résultats\" ou \"J'envoie mon profil\".", @@ -1102,7 +1107,6 @@ }, "students-count": "{count, plural, =0 {0 élève} =1 {1 élève} other {{count} élèves}}" }, - "manage-authentication-method-modal": { "title": "Gestion du compte Pix de l’élève", "authentication-methods": "Méthodes de connexion",