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

[BUGFIX] Retirer l'externalId d'une organisation dans le menu lorsque celle ci n'en possède pas (Pix-15658) #10772

Merged
merged 4 commits into from
Dec 11, 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
2 changes: 1 addition & 1 deletion api/db/seeds/data/common/organization-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ async function _createProOrganization(databaseBuilder) {
type: 'PRO',
name: 'PRO Classic',
isManagingStudents: false,
externalId: 'PRO_NOT_MANAGING',
externalId: null,
adminIds: [USER_ID_ADMIN_ORGANIZATION],
memberIds: [USER_ID_MEMBER_ORGANIZATION],
features: [
Expand Down
164 changes: 164 additions & 0 deletions orga/app/components/layout/sidebar.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
import PixNavigation from '@1024pix/pix-ui/components/pix-navigation';
import PixNavigationButton from '@1024pix/pix-ui/components/pix-navigation-button';
import PixNavigationSeparator from '@1024pix/pix-ui/components/pix-navigation-separator';
import { LinkTo } from '@ember/routing';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { t } from 'ember-intl';

import OrganizationPlacesOrCreditInfo from './organization-places-or-credit-info';
import SchoolSessionManagement from './school-session-management';
import UserLoggedMenu from './user-logged-menu';

export default class SidebarMenu extends Component {
@service currentUser;
@service url;

@tracked canShowCredit;

handleCanShowCredit = (value) => {
this.canShowCredit = value;
};

get redirectionRoute() {
if (this.shouldDisplayMissionsEntry) {
return 'authenticated.missions';
} else {
return 'authenticated.campaigns';
}
}

get documentationUrl() {
return this.currentUser.organization.documentationUrl;
}

get shouldDisplayCertificationsEntry() {
return this.currentUser.isAdminInOrganization && this.currentUser.isSCOManagingStudents;
}

get shouldDisplayAttestationsEntry() {
return this.currentUser.canAccessAttestationsPage;
}

get shouldDisplayPlacesEntry() {
return this.currentUser.canAccessPlacesPage;
}

get shouldDisplayMissionsEntry() {
return this.currentUser.canAccessMissionsPage;
}

get shouldDisplayCampaignsEntry() {
return this.currentUser.canAccessCampaignsPage;
}

get shouldDisplayStatisticsEntry() {
return this.currentUser.canAccessStatisticsPage;
}

get shouldDisplaySeparator() {
return this.shouldDisplayMissionsEntry || this.shouldDisplayPlacesEntry || this.canShowCredit;
}

get organizationLearnersList() {
if (this.currentUser.isSCOManagingStudents) {
return {
route: 'authenticated.sco-organization-participants',
label: 'navigation.main.sco-organization-participants',
};
} else if (this.currentUser.isSUPManagingStudents) {
return {
route: 'authenticated.sup-organization-participants',
label: 'navigation.main.sup-organization-participants',
};
} else if (this.currentUser.canAccessMissionsPage) {
return {
route: 'authenticated.organization-participants',
label: 'navigation.main.sco-organization-participants',
};
} else {
return {
route: 'authenticated.organization-participants',
label: 'navigation.main.organization-participants',
};
}
}

<template>
<PixNavigation @variant="orga" @navigationAriaLabel={{t "navigation.main.aria-label"}} @menuLabel="Menu">
<:brand>
<LinkTo @route={{this.redirectionRoute}}>
<img src="{{this.rootUrl}}/pix-orga.svg" class="pix-orga-logo" alt="{{t 'common.home-page'}}" />
</LinkTo>
</:brand>
<:navElements>
{{#if this.shouldDisplayCampaignsEntry}}
<PixNavigationButton @route={{this.redirectionRoute}} @icon="conversionPath">
{{t "navigation.main.campaigns"}}</PixNavigationButton>
{{/if}}

{{#if this.shouldDisplayCertificationsEntry}}
<PixNavigationButton @route="authenticated.certifications" @icon="awards">
{{t "navigation.main.certifications"}}</PixNavigationButton>
{{/if}}

{{#if this.shouldDisplayAttestationsEntry}}
<PixNavigationButton @route="authenticated.attestations" @icon="assignment">
{{t "navigation.main.attestations"}}</PixNavigationButton>
{{/if}}

{{#if this.shouldDisplayMissionsEntry}}
<PixNavigationButton @route="authenticated.missions" @icon="conversionPath">
{{t "navigation.main.missions"}}
</PixNavigationButton>
{{/if}}

<PixNavigationButton @route={{this.organizationLearnersList.route}} @icon="infoUser">
{{t this.organizationLearnersList.label}}
</PixNavigationButton>

<PixNavigationButton @route="authenticated.team" @icon="users">
{{t "navigation.main.team"}}
</PixNavigationButton>

{{#if this.shouldDisplayStatisticsEntry}}
<PixNavigationButton @route="authenticated.statistics" @icon="monitoring">
{{t "navigation.main.statistics"}}
</PixNavigationButton>
{{/if}}

{{#if this.shouldDisplayPlacesEntry}}
<PixNavigationButton @route="authenticated.places" @icon="seat">
{{t "navigation.main.places"}}
</PixNavigationButton>
{{/if}}

{{#if this.documentationUrl}}
<PixNavigationButton href={{this.documentationUrl}} @target="_blank" rel="noopener noreferrer" @icon="book">
{{t "navigation.main.documentation"}}
</PixNavigationButton>
{{/if}}

{{#if this.shouldDisplayMissionsEntry}}
<PixNavigationButton
href="https://pix.fr/support/enseignement-scolaire/1er-degre"
@target="_blank"
rel="noopener noreferrer"
@icon="help"
>
{{t "navigation.main.support"}}
</PixNavigationButton>
{{/if}}
</:navElements>
<:footer>
<OrganizationPlacesOrCreditInfo @placesCount={{@placesCount}} @onCanShowCredit={{this.handleCanShowCredit}} />
<SchoolSessionManagement />
{{#if this.shouldDisplaySeparator}}
<PixNavigationSeparator />
{{/if}}
<UserLoggedMenu @onChangeOrganization={{@onChangeOrganization}} />
</:footer>
</PixNavigation>
</template>
}
77 changes: 0 additions & 77 deletions orga/app/components/layout/sidebar.hbs

This file was deleted.

78 changes: 0 additions & 78 deletions orga/app/components/layout/sidebar.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link';
import PixStructureSwitcher from '@1024pix/pix-ui/components/pix-structure-switcher';
import { action } from '@ember/object';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { t } from 'ember-intl';

export default class UserLoggedMenu extends Component {
@service currentUser;
Expand All @@ -22,10 +25,18 @@ export default class UserLoggedMenu extends Component {
}
return memberships
.slice()
.map((membership) => ({
label: `${membership.organization.get('name')} (${membership.organization.get('externalId')})`,
value: membership.organization.get('id'),
}))
.map((membership) => {
let label = `${membership.organization.get('name')}`;

if (membership.organization.get('externalId')) {
label = label.concat(` (${membership.organization.get('externalId')})`);
}

return {
label,
value: membership.organization.get('id'),
};
})
.sort((a, b) => a.label.localeCompare(b.label));
}

Expand All @@ -51,4 +62,26 @@ export default class UserLoggedMenu extends Component {
await this.currentUser.load();
this.args.onChangeOrganization();
}

<template>
<p>
<strong>
{{this.currentUser.prescriber.firstName}}
{{this.currentUser.prescriber.lastName}}
</strong>
<br />
{{this.organizationNameAndExternalId}}
</p>
{{#if this.belongsToSeveralOrganizations}}
<PixStructureSwitcher
@value={{this.currentUser.organization.id}}
@structures={{this.eligibleOrganizations}}
@label={{t "navigation.user-logged-menu.button"}}
@onChange={{this.onOrganizationChange}}
/>
{{/if}}
<PixButtonLink @variant="tertiary" class="" @route="logout">{{t
"navigation.user-logged-menu.logout"
}}</PixButtonLink>
</template>
}
Loading
Loading