Verified Commit 78e60290 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider
Browse files

Beenden link in client index, and improved error message

parent 9071e8e2
......@@ -70,8 +70,12 @@ class ClientsController < ApplicationController
if @client.update(acceptance: 'resigned', resigned_by: current_user)
redirect_to @client, notice: 'Der klient wurde erfolgreich beendet.'
else
redirect_back(fallback_location: client_path(@client),
notice: 'Der Klient konnte nicht beendet werden.')
redirect_back(fallback_location: client_path(@client), notice: {
message: 'Beenden fehlgeschlagen.',
model_message: @client.errors.messages[:acceptance].first,
action_link: { text: 'Begleitung bearbeiten',
path: edit_assignment_path(@client.assignment) }
})
end
end
......
......@@ -39,7 +39,8 @@ class Client < ApplicationRecord
validates :salutation, presence: true
validates :acceptance, exclusion: {
in: ['resigned'], message: 'Klient kann nicht beendet werden, solange noch ein laufendes Tandem existiert.'
in: ['resigned'],
message: 'Klient/in kann nicht beendet werden, solange noch ein laufendes Tandem existiert.'
}, unless: :terminateable?
scope :with_assignment, (-> { joins(:assignment) })
......@@ -112,7 +113,7 @@ class Client < ApplicationRecord
private
# allow ransack to use the scopes
def self.ransackable_scopes(auth_object = nil)
def self.ransackable_scopes(_auth_object = nil)
['active', 'inactive']
end
......
- if notice.present? || alert.present?
.alert.alert-warning.alert-dismissible role='alert'
button.close aria-label='Close' data-dismiss='alert' type='button'
span aria-hidden='true' &times;
= notice || alert
- if notice.is_a? String
.alert.alert-warning.alert-dismissible role='alert'
button.close aria-label='Close' data-dismiss='alert' type='button'
span aria-hidden='true' &times;
= notice || alert
- else
.alert.alert-danger.alert-dismissible role='alert'
button.close aria-label='Close' data-dismiss='alert' type='button' X
h4= notice['message']
- if notice['model_message'].present?
p= notice['model_message']
p
button.btn.btn-default.m-r-10 aria-label='Close' data-dismiss='alert' type='button' Abbrechen
- if notice['action_link'].present?
= link_to(notice['action_link']['text'], notice['action_link']['path'], target: '_blank', class: 'btn btn-default')
......@@ -22,4 +22,9 @@ tr
td.button-acceptance = link_to t(".acceptance.#{client.acceptance}"), '#',
class: "btn btn-xs btn-acceptance-#{client.acceptance}"
td= client.comments
= render 'index_actions', subject: client
td.index-action-cell.hidden-print
= link_to t_action(:show), client_path(client)
- if policy(client).edit?
= link_to t_action(:edit), edit_client_path(client)
- if policy(client).set_resigned?
= link_to 'Beenden', set_resigned_client_path(client), method: :patch, data: { confirm: 'Klient/in wirklich beenden?' }
......@@ -7,7 +7,7 @@ nav.navbar.section-navigation
li= button_link t_action(:edit), edit_client_path(@client)
li= button_link navigation_glyph(:print), client_path(@client, print: true)
- if !@client.resigned? && policy(@client).set_resigned?
li= link_to 'Beenden', set_resigned_client_path(@client), class: 'btn btn-default', data: { method: 'PATCH' }
li= link_to 'Beenden', set_resigned_client_path(@client), class: 'btn btn-default', method: :patch, data: { confirm: 'Klient/in wirklich beenden?' }
li= button_link navigation_glyph(:back), clients_path
- if policy(Journal).index?
ul.list-inline.pull-right
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment