feat(rc.1): refine with better translations, better design
This commit is contained in:
parent
3b78a9d81a
commit
d4c74b5621
6 changed files with 41 additions and 9 deletions
|
@ -6,9 +6,9 @@ module Instructeurs
|
|||
def destroy
|
||||
result = CommentaireService.soft_delete(current_instructeur, params.permit(:dossier_id, :id))
|
||||
if result.status
|
||||
flash[:notice] = 'Votre message a été supprimé'
|
||||
flash[:notice] = t('views.shared.commentaires.destroy.notice')
|
||||
else
|
||||
flash[:alert] = "Votre message ne peut être supprimé: #{result.error_message}"
|
||||
flash[:alert] = t('views.shared.commentaires.destroy.alert', reason: result.error_message)
|
||||
end
|
||||
redirect_to(messagerie_instructeur_dossier_path(params[:procedure_id], params[:dossier_id]))
|
||||
end
|
||||
|
|
|
@ -27,13 +27,16 @@ class CommentaireService
|
|||
.find(params[:id])
|
||||
if commentaire.sent_by?(user)
|
||||
commentaire.piece_jointe.purge_later if commentaire.piece_jointe.attached?
|
||||
commentaire.update!(body: "Message supprimé", deleted_at: Time.now.utc)
|
||||
commentaire.update!(body: I18n.t('views.shared.commentaires.destroy.deleted_body'),
|
||||
deleted_at: Time.now.utc)
|
||||
OpenStruct.new(status: true)
|
||||
else
|
||||
OpenStruct.new(status: false, error_message: "Impossible de supprimer le message, celui ci ne vous appartient pas")
|
||||
OpenStruct.new(status: false,
|
||||
error_message: I18n.t('views.shared.commentaires.destroy.alert_reasons.acl'))
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound => e
|
||||
return OpenStruct.new(status: false, error_message: "#{e.model.humanize} introuvable")
|
||||
return OpenStruct.new(status: false,
|
||||
error_message: I18n.t('views.shared.commentaires.destroy.alert_reasons.ar_not_found', model_name: e.model.humanize))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
|
||||
.message-extras.flex.justify-start
|
||||
- if commentaire.sent_by?(connected_user) && commentaire.sent_by_instructeur? && commentaire.deleted_at.nil?
|
||||
= button_to instructeur_commentaire_path(commentaire.dossier.procedure, commentaire.dossier, commentaire), method: :delete do
|
||||
Supprimer
|
||||
= button_to instructeur_commentaire_path(commentaire.dossier.procedure, commentaire.dossier, commentaire), method: :delete, class: 'button danger', data: { confirm: t('views.shared.commentaires.destroy.confirm') } do
|
||||
%span.icon.delete
|
||||
= t('views.shared.commentaires.destroy.button')
|
||||
|
||||
- if commentaire.piece_jointe.attached?
|
||||
.attachment-link
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
en:
|
||||
views:
|
||||
shared:
|
||||
dossiers:
|
||||
identite_entreprise:
|
||||
warning_for_private_info: "The establishment %{etablissement} applied his right to not publish information regarding his identity. These informaiton won't be visible from instructor services"
|
||||
avis:
|
||||
demande_envoyee_le: "Feedback send at %{date}"
|
||||
demande_revoquee_le: "Feedback revoked at %{date}"
|
||||
reponse_donnee_le: "Response sent at %{date}"
|
||||
en_attente: "Waiting for response"
|
||||
france_connect_login:
|
||||
title: "With FranceConnect"
|
||||
description: "France connect is a solution proposed by the government to secure and simplify the connection to web services."
|
||||
|
@ -12,3 +20,13 @@ en:
|
|||
already_user: "I already have an account"
|
||||
create: 'Create an account'
|
||||
signin: 'Sign in'
|
||||
commentaires:
|
||||
destroy:
|
||||
button: 'Destroy this message'
|
||||
confirm: "Are you sure you want to destroy this message ?"
|
||||
deleted_body: Message deleted
|
||||
notice: 'Your message had been deleted'
|
||||
alert: 'Can not destroy message: #{result.error_message}'
|
||||
alert_reasons:
|
||||
acl: "Can not destroy message: it does not belong to you"
|
||||
ar_not_found: "%{model_name} not found"
|
||||
|
|
|
@ -20,3 +20,13 @@ fr:
|
|||
already_user: 'J’ai déjà un compte'
|
||||
create: 'Créer un compte'
|
||||
signin: 'Connexion'
|
||||
commentaires:
|
||||
destroy:
|
||||
button: 'Supprimer le message'
|
||||
confirm: "Êtes-vous sûr de vouloir supprimer ce message ?"
|
||||
deleted_body: Message supprimé
|
||||
notice: 'Votre message a été supprimé'
|
||||
alert: 'Votre message ne peut être supprimé: #{result.error_message}'
|
||||
alert_reasons:
|
||||
acl: "Impossible de supprimer le message, celui ci ne vous appartient pas"
|
||||
ar_not_found: "%{model_name} introuvable"
|
||||
|
|
|
@ -14,7 +14,7 @@ describe Instructeurs::CommentairesController, type: :controller do
|
|||
end
|
||||
it 'flash success' do
|
||||
subject
|
||||
expect(flash[:notice]).to eq('Votre message a été supprimé')
|
||||
expect(flash[:notice]).to eq(I18n.t('views.shared.commentaires.destroy.notice'))
|
||||
end
|
||||
|
||||
context 'when it fails' do
|
||||
|
@ -27,7 +27,7 @@ describe Instructeurs::CommentairesController, type: :controller do
|
|||
end
|
||||
it 'flash success' do
|
||||
subject
|
||||
expect(flash[:alert]).to eq("Votre message ne peut être supprimé: #{error.error_message}")
|
||||
expect(flash[:alert]).to eq(I18n.t('views.shared.commentaires.destroy.alert', reason: error.error_message))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue