-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Users/Dossiers#update): track changes live and pop modal when el…
…igibilite_rules is false
- Loading branch information
Showing
10 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
app/components/dossiers/invalid_eligibilite_rules_component.rb
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,24 @@ | ||
class Dossiers::InvalidEligibiliteRulesComponent < ApplicationComponent | ||
delegate :can_passer_en_construction?, to: :@dossier | ||
|
||
def initialize(dossier:) | ||
@dossier = dossier | ||
@revision = dossier.revision | ||
end | ||
|
||
def render? | ||
eligibilite_rules_computable? && !can_passer_en_construction? | ||
end | ||
|
||
def error_message | ||
@dossier.revision.eligibilite_message | ||
end | ||
|
||
private | ||
|
||
def eligibilite_rules_computable? | ||
@revision.eligibilite_enabled && | ||
@revision.eligibilite_message.present? && | ||
@revision&.eligibilite_rules&.computable?(@dossier.champs) | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
...s/dossiers/invalid_eligibilite_rules_component/invalid_eligibilite_rules_component.en.yml
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,6 @@ | ||
fr: | ||
modal: | ||
title: "Your file does not match submission criteria" | ||
close: "Close" | ||
close_alt: "Close this modal" | ||
body: "The procedure « %{procedure_libelle} » have submission criteria, unfortunately your file does not match them. You can not submit your file" |
5 changes: 5 additions & 0 deletions
5
...s/dossiers/invalid_eligibilite_rules_component/invalid_eligibilite_rules_component.fr.yml
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,5 @@ | ||
fr: | ||
modal: | ||
title: "Vous ne pouvez pas déposer votre dossier" | ||
close: "Fermer" | ||
close_alt: "Fermer la fenêtre modale" |
16 changes: 16 additions & 0 deletions
16
...ossiers/invalid_eligibilite_rules_component/invalid_eligibilite_rules_component.html.haml
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,16 @@ | ||
%div{ id: dom_id(@dossier, :eligibilite_rules_broken), data: { controller: 'invalid-eligibilite-rules', turbo_force: :server } } | ||
%button.fr-sr-only{ aria: {controls: 'modal-eligibilite-rules-dialog' }, data: {'fr-opened': "false" } } | ||
show modal | ||
|
||
%dialog.fr-modal{ "aria-labelledby" => "fr-modal-title-modal-1", role: "dialog", id: 'modal-eligibilite-rules-dialog', data: { 'invalid-eligibilite-rules-target' => 'dialog' } } | ||
.fr-container.fr-container--fluid.fr-container-md | ||
.fr-grid-row.fr-grid-row--center | ||
.fr-col-12.fr-col-md-8.fr-col-lg-6 | ||
.fr-modal__body | ||
.fr-modal__header | ||
%button.fr-btn--close.fr-btn{ aria: { controls: 'modal-eligibilite-rules-dialog' }, title: t('.modal.close_alt') }= t('.modal.close') | ||
.fr-modal__content | ||
%h1#fr-modal-title-modal-1.fr-modal__title | ||
%span.fr-icon-arrow-right-line.fr-icon--lg> | ||
= t('.modal.title') | ||
%p= error_message |
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
19 changes: 19 additions & 0 deletions
19
app/javascript/controllers/invalid_eligibilite_rules_controller.ts
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,19 @@ | ||
import { ApplicationController } from './application_controller'; | ||
declare interface modal { | ||
disclose: () => void; | ||
} | ||
declare interface dsfr { | ||
modal: modal; | ||
} | ||
declare const window: Window & | ||
typeof globalThis & { dsfr: (elem: HTMLElement) => dsfr }; | ||
|
||
export class InvalidEligibiliteRulesController extends ApplicationController { | ||
static targets = ['dialog']; | ||
|
||
declare dialogTarget: HTMLElement; | ||
|
||
connect() { | ||
setTimeout(() => window.dsfr(this.dialogTarget).modal.disclose(), 100); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
= render partial: 'shared/dossiers/update_champs', locals: { to_show: @to_show, to_hide: @to_hide, to_update: @to_update, dossier: @dossier } | ||
|
||
- if !params.key?(:validate) | ||
- if @eligibilite_rules_is_computable | ||
= turbo_stream.remove(dom_id(@dossier, :eligibilite_rules_broken)) | ||
|
||
- if (@eligibilite_rules_computable_changed && !@can_passer_en_construction_is) || (@can_passer_en_construction_was && !@can_passer_en_construction_is) | ||
= turbo_stream.append('contenu', render(Dossiers::InvalidEligibiliteRulesComponent.new(dossier: @dossier))) |
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