-
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
1 parent
4cbf727
commit 0c7f7a3
Showing
3 changed files
with
99 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,90 @@ | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import PixTooltip from '@1024pix/pix-ui/components/pix-tooltip'; | ||
import { service } from '@ember/service'; | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import ConfirmPopup from '../confirm-popup'; | ||
import Component from '@glimmer/component'; | ||
|
||
|
||
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}} | ||
|
||
{{#if this.canPublish}} | ||
<PixButton @triggerAction={{this.displayConfirmationModal}}>Publier la session</PixButton> | ||
{{else}} | ||
|
||
<PixTooltip @position="left" @isWide={{true}}> | ||
<:triggerElement> | ||
<PixButton | ||
@triggerAction={{this.displayConfirmationModal}} | ||
@isDisabled={{true}} | ||
> | ||
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}} | ||
|
||
{{/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