save instructeur commentaire local storage
This commit is contained in:
parent
0e2f5a18f4
commit
90371bbb82
2 changed files with 18 additions and 3 deletions
|
@ -5,6 +5,6 @@
|
||||||
= render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at, show_reply_button: show_reply_button(commentaire, connected_user) }
|
= render partial: "shared/dossiers/messages/message", locals: { commentaire: commentaire, connected_user: connected_user, messagerie_seen_at: messagerie_seen_at, show_reply_button: show_reply_button(commentaire, connected_user) }
|
||||||
|
|
||||||
- if dossier.messagerie_available?
|
- if dossier.messagerie_available?
|
||||||
= render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url }
|
= render partial: "shared/dossiers/messages/form", locals: { commentaire: new_commentaire, form_url: form_url, dossier: dossier }
|
||||||
- else
|
- else
|
||||||
= render partial: "shared/dossiers/messages/messagerie_disabled", locals: { service: dossier.procedure.service, dossier: dossier }
|
= render partial: "shared/dossiers/messages/messagerie_disabled", locals: { service: dossier.procedure.service, dossier: dossier }
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
= form_for(commentaire, url: form_url, html: { class: 'form' }) do |f|
|
= form_for(commentaire, url: form_url, html: { class: 'form', id: "commentaire-form-#{@dossier.id}" }) do |f|
|
||||||
|
- dossier = commentaire.dossier
|
||||||
- placeholder = t('views.shared.dossiers.messages.form.write_message_to_administration_placeholder')
|
- placeholder = t('views.shared.dossiers.messages.form.write_message_to_administration_placeholder')
|
||||||
- if instructeur_signed_in? || administrateur_signed_in?
|
- if instructeur_signed_in? || administrateur_signed_in?
|
||||||
- placeholder = t('views.shared.dossiers.messages.form.write_message_placeholder')
|
- placeholder = t('views.shared.dossiers.messages.form.write_message_placeholder')
|
||||||
= f.text_area :body, rows: 5, placeholder: placeholder, required: true, class: 'message-textarea'
|
= f.text_area :body, rows: 5, placeholder: placeholder, required: true, class: 'message-textarea', id: "messagerie-#{@dossier.id}"
|
||||||
.flex.justify-between.wrap
|
.flex.justify-between.wrap
|
||||||
%div
|
%div
|
||||||
= f.label :piece_jointe, for: :piece_jointe do
|
= f.label :piece_jointe, for: :piece_jointe do
|
||||||
|
@ -12,3 +13,17 @@
|
||||||
|
|
||||||
%div
|
%div
|
||||||
= f.submit t('views.shared.dossiers.messages.form.send_message'), class: 'button primary send', data: { disable: true }
|
= f.submit t('views.shared.dossiers.messages.form.send_message'), class: 'button primary send', data: { disable: true }
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
const commentaireInput = document.getElementById('messagerie-#{@dossier.id}')
|
||||||
|
const commentaireForm = document.getElementById('commentaire-form-#{@dossier.id}')
|
||||||
|
commentaireInput.value = localStorage.getItem(`message-#{@dossier.id}`)
|
||||||
|
|
||||||
|
commentaireInput.addEventListener('change', (event) => {
|
||||||
|
localStorage.setItem(`message-#{@dossier.id}`, event.target.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
commentaireForm.addEventListener('submit', () => {
|
||||||
|
localStorage.removeItem(`message-#{@dossier.id}`);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue