Skip to content

Commit

Permalink
feat(api): handle generate username password behaviour
Browse files Browse the repository at this point in the history
in sco organization participant list page
  • Loading branch information
er-lim committed Sep 18, 2024
1 parent 1face50 commit 4192424
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
10 changes: 9 additions & 1 deletion orga/app/components/sco-organization-participant/list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@
</InElement>
{{#if someSelected}}
<InElement @destinationId={{this.actionBarId}}>
<ScoOrganizationParticipant::ActionBar
<ScoOrganizationParticipant::ListActionBar
@count={{selectedStudents.length}}
@openGenerateUsernamePasswordModal={{fn this.openGenerateUsernamePasswordModal selectedStudents}}
@openResetPasswordModal={{fn this.openResetPasswordModal selectedStudents}}
@isGarIdentityProvider={{this.isGarIdentityProvider}}
/>
<ScoOrganizationParticipant::ResetPasswordModal
@showModal={{this.showResetPasswordModal}}
Expand All @@ -53,6 +55,12 @@
@onTriggerAction={{fn this.resetPasswordForStudents this.affectedStudents reset}}
@onCloseModal={{this.closeResetPasswordModal}}
/>
<ScoOrganizationParticipant::GenerateUsernamePasswordModal
@showModal={{this.showGenerateUsernamePasswordModal}}
@totalAffectedStudents={{this.affectedStudents.length}}
@onTriggerAction={{fn this.resetPasswordForStudents this.affectedStudents reset}}
@onCloseModal={{this.closeGenerateUsernamePasswordModal}}
/>
</InElement>
{{/if}}
</:manager>
Expand Down
18 changes: 18 additions & 0 deletions orga/app/components/sco-organization-participant/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default class ScoList extends Component {
@tracked student = null;
@tracked isShowingAuthenticationMethodModal = false;
@tracked showResetPasswordModal = false;
@tracked showGenerateUsernamePasswordModal = false;
@tracked divisions;

@tracked affectedStudents = [];
Expand Down Expand Up @@ -71,6 +72,10 @@ export default class ScoList extends Component {
return Boolean(this.args.students.length);
}

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

@action
openAuthenticationMethodModal(student, event) {
event.stopPropagation();
Expand All @@ -95,6 +100,18 @@ export default class ScoList extends Component {
this.showResetPasswordModal = false;
}

@action
openGenerateUsernamePasswordModal(students, event) {
event.stopPropagation();
this.affectedStudents = students.filter((student) => student.isAssociated);
this.showGenerateUsernamePasswordModal = true;
}

@action
closeGenerateUsernamePasswordModal() {
this.showGenerateUsernamePasswordModal = false;
}

@action
async resetPasswordForStudents(affectedStudents, resetSelectedStudents) {
const affectedStudentsIds = affectedStudents.map((affectedStudents) => affectedStudents.id);
Expand All @@ -111,6 +128,7 @@ export default class ScoList extends Component {
this.notifications.sendSuccess(
this.intl.t('pages.sco-organization-participants.messages.password-reset-success'),
);
await this.args.refreshValues();
} catch (fetchErrors) {
const error = Array.isArray(fetchErrors) && fetchErrors.length > 0 && fetchErrors[0];
let errorMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
@divisionSort={{this.divisionSort}}
@lastnameSort={{this.lastnameSort}}
@hasComputeOrganizationLearnerCertificabilityEnabled={{this.hasComputeOrganizationLearnerCertificabilityEnabled}}
@refreshValues={{this.refresh}}
/>
</div>

0 comments on commit 4192424

Please sign in to comment.