-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
306 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixTooltip from '@1024pix/pix-ui/components/pix-tooltip'; | ||
import { action } from '@ember/object'; | ||
import { service } from '@ember/service'; | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { not } from 'ember-truth-helpers'; | ||
|
||
import ConfirmPopup from '../confirm-popup'; | ||
|
||
export default class CertificationsHeader extends Component { | ||
@service accessControl; | ||
|
||
@tracked isModalDisplayed = false; | ||
@tracked confirmMessage = null; | ||
|
||
get canPublish() { | ||
return ( | ||
!this.args.juryCertificationSummaries.some( | ||
(certification) => certification.status === 'error' && !certification.isCancelled, | ||
) && this.args.session.isFinalized | ||
); | ||
} | ||
|
||
@action | ||
displayConfirmationModal() { | ||
this.confirmMessage = this.args.session.isPublished | ||
? 'Souhaitez-vous dépublier la session ?' | ||
: 'Souhaitez-vous publier la session ?'; | ||
this.isModalDisplayed = true; | ||
} | ||
|
||
@action | ||
onModalCancel() { | ||
this.isModalDisplayed = false; | ||
} | ||
|
||
@action | ||
async toggleSessionPublication() { | ||
if (this.args.session.isPublished) { | ||
await this.args.unpublishSession(); | ||
} else { | ||
await this.args.publishSession(); | ||
} | ||
this.isModalDisplayed = false; | ||
} | ||
|
||
<template> | ||
<header class="certification-list-page__header"> | ||
<h2>Certifications</h2> | ||
{{#if this.accessControl.hasAccessToCertificationActionsScope}} | ||
<div class="btn-group" role="group"> | ||
|
||
{{#if @session.isPublished}} | ||
<PixButton @triggerAction={{this.displayConfirmationModal}}>Dépublier la session</PixButton> | ||
{{else}} | ||
<PixTooltip @position="left" @isWide={{true}} @hide={{this.canPublish}}> | ||
<:triggerElement> | ||
<PixButton @triggerAction={{this.displayConfirmationModal}} @isDisabled={{not this.canPublish}}> | ||
Publier la session | ||
</PixButton> | ||
</:triggerElement> | ||
<:tooltip> | ||
Vous ne pouvez pas publier la session tant qu'elle n'est pas finalisée ou qu'il reste des certifications | ||
en erreur. | ||
</:tooltip> | ||
</PixTooltip> | ||
{{/if}} | ||
</div> | ||
{{/if}} | ||
</header> | ||
|
||
<ConfirmPopup | ||
@message={{this.confirmMessage}} | ||
@confirm={{this.toggleSessionPublication}} | ||
@cancel={{this.onModalCancel}} | ||
@show={{this.isModalDisplayed}} | ||
/> | ||
</template> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.