Commit 84bad1c0 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider

client and volunteer assignment/group_assignment offer edit links

- for group_assignment in case volunteer and client are not resigned
- volunteer view gets client edit link in case client not reactivated
- client view gets volunteer edit link in case volunteer not reactivated
parent 8f99d575
Pipeline #39884 failed with stage
in 13 minutes and 3 seconds
...@@ -53,9 +53,17 @@ ...@@ -53,9 +53,17 @@
.index-action-cell { .index-action-cell {
white-space: nowrap; white-space: nowrap;
a, span { a,
span {
display: block; display: block;
margin-right: 2px; margin-right: 2px;
&.single-line {
& > span,
& > a {
display: inline-block;
}
}
} }
a.btn { a.btn {
...@@ -74,9 +82,6 @@ ...@@ -74,9 +82,6 @@
} }
} }
.modal-header-sm { .modal-header-sm {
padding: 7px 15px; padding: 7px 15px;
} }
...@@ -216,3 +221,22 @@ li.button-acceptance a { ...@@ -216,3 +221,22 @@ li.button-acceptance a {
margin: 16px; margin: 16px;
font-size: 16px; font-size: 16px;
} }
.link-icon-span-text {
.glyphicon {
display: inline-block;
}
.icon-span-text {
display: inline-block;
margin-left: 5px;
}
&:hover,
&:focus,
&:active {
.icon-span-text {
text-decoration: underline;
}
}
}
class VolunteersController < ApplicationController class VolunteersController < ApplicationController
before_action :set_volunteer, only: [:show, :edit, :update, :terminate, :account, :update_bank_details, :reactivate] before_action :set_volunteer, only: [:show, :edit, :update, :terminate, :account, :update_bank_details, :reactivate]
before_action :set_active_and_archived_missions, only: [:show, :edit]
def index def index
authorize Volunteer authorize Volunteer
...@@ -27,12 +28,6 @@ class VolunteersController < ApplicationController ...@@ -27,12 +28,6 @@ class VolunteersController < ApplicationController
@group_offer_categories = @volunteer.group_offer_categories.active.without_house_moving @group_offer_categories = @volunteer.group_offer_categories.active.without_house_moving
@group_offer_categories_house_moving = @volunteer.group_offer_categories.active.house_moving @group_offer_categories_house_moving = @volunteer.group_offer_categories.active.house_moving
@current_assignments = @volunteer.assignments.unterminated
@archived_assignments = @volunteer.assignment_logs
@current_group_assignments = @volunteer.group_assignments.unterminated
@archived_group_assignments = @volunteer.group_assignment_logs
end end
def new def new
...@@ -151,6 +146,14 @@ class VolunteersController < ApplicationController ...@@ -151,6 +146,14 @@ class VolunteersController < ApplicationController
authorize @volunteer authorize @volunteer
end end
def set_active_and_archived_missions
@current_assignments = @volunteer.assignments.unterminated
@archived_assignments = @volunteer.assignment_logs
@current_group_assignments = @volunteer.group_assignments.unterminated
@archived_group_assignments = @volunteer.group_assignment_logs
end
def volunteer_params def volunteer_params
params.require(:volunteer).permit policy(Volunteer).permitted_attributes params.require(:volunteer).permit policy(Volunteer).permitted_attributes
end end
......
module ActionAndControllerNameHelper module ActionAndControllerNameHelper
def action_new? def action_name?(action)
action_name == 'new' || action_name == 'create' action_name == action.to_s
end end
def action_index? def action_index?
action_name == 'index' action_name?(:index)
end end
def action_show? def action_show?
action_name == 'show' action_name?(:show)
end
def action_new?
action_name?(:new) || action_name?(:create)
end end
def action_edit? def action_edit?
action_name == 'edit' || action_name == 'update' action_name?(:edit) || action_name?(:update)
end end
def action_in?(*names) def action_in?(*names)
names.map(&:to_s).include? action_name names.map(&:to_s).include? action_name
end end
def controller_name?(name)
controller_name == name.to_s
end
def controller_in?(*names) def controller_in?(*names)
names.map(&:to_s).include? controller_name names.map(&:to_s).include? controller_name
end end
def controller_action?(controller, action)
controller_name?(controller) && action_name?(action)
end
end end
table.table.table-striped.assignments-table table.table.table-striped.assignments-table
thead thead
tr tr
th
th= t_model(Volunteer) th= t_model(Volunteer)
th= t_model(Client)
th= t_attr(:period_start, Assignment) th= t_attr(:period_start, Assignment)
th= t_attr(:period_end, Assignment) th= t_attr(:period_end, Assignment)
th= t_attr(:created_by) th= t_attr(:created_by)
...@@ -10,10 +10,29 @@ table.table.table-striped.assignments-table ...@@ -10,10 +10,29 @@ table.table.table-striped.assignments-table
th Bemerkungen th Bemerkungen
tbody tbody
- assignments.each do |assignment| - assignments.each do |assignment_log|
- assignment = assignment_log.assignment
- volunteer = assignment.volunteer
tr tr
td = link_to_if policy(assignment.volunteer).show?, assignment.volunteer, assignment.volunteer td.index-action-cell.hidden-print
td= link_to_if policy(assignment.client).show?, assignment.client, assignment.client - if policy(assignment).reactivate?
span.single-line
= button_link icon_span(:edit), edit_assignment_path(assignment)
span.m-l-10
em= t('.edit_for_reactivate')
td.index-action-cell
- if policy(volunteer).reactivate?
= link_to edit_volunteer_path(volunteer), target: '_blank', rel: 'noopener',
class: 'link-icon-span-text',
title: t('.ractivate_link_title') do
= icon_span(:edit)
span.icon-span-text= volunteer.full_name
- elsif policy(volunteer).show?
= link_to volunteer_path(volunteer), class: 'link-icon-span-text' do
= icon_span(:show)
span.icon-span-text= volunteer.full_name
- else
= volunteer.full_name
td= l(assignment.period_start) if assignment.period_start td= l(assignment.period_start) if assignment.period_start
td= l(assignment.period_end) if assignment.period_end td= l(assignment.period_end) if assignment.period_end
td= link_to_if policy(User).show?, td= link_to_if policy(User).show?,
...@@ -21,4 +40,3 @@ table.table.table-striped.assignments-table ...@@ -21,4 +40,3 @@ table.table.table-striped.assignments-table
profile_url_path(assignment.client.involved_authority || assignment.creator) profile_url_path(assignment.client.involved_authority || assignment.creator)
- if policy(Assignment).show_comments? - if policy(Assignment).show_comments?
= td_truncate_content_modal(assignment.comments, 'Bemerkungen') = td_truncate_content_modal(assignment.comments, 'Bemerkungen')
...@@ -10,39 +10,56 @@ table.table.table-striped.assignment-logs-table ...@@ -10,39 +10,56 @@ table.table.table-striped.assignment-logs-table
th= t_attr(:comments) th= t_attr(:comments)
th colspan=2 th colspan=2
tbody tbody
- assignment_logs.each do |assignment| - assignment_logs.each do |assignment_log|
- assignment = assignment_log.assignment
- client = assignment.client
tr tr
td.index-action-cell.hidden-print td.index-action-cell.hidden-print
- if policy(assignment.assignment).show? && assignment.assignment.pdf.exists? - if policy(assignment).show? && assignment.pdf.exists?
= button_link icon_span(:download), assignment_path(assignment.assignment, format: :pdf), = button_link icon_span(:download), assignment_path(assignment, format: :pdf),
title: 'Herunterladen' title: 'Herunterladen'
- if policy(assignment.assignment).reactivate? - if policy(assignment).reactivate?
= button_link icon_span(:edit), edit_assignment_path(assignment.assignment) span.single-line
td= link_to_if(policy(Client).show?, assignment.client.contact.full_name, assignment.client) = button_link icon_span(:edit), edit_assignment_path(assignment)
span.m-l-10
em= t('.edit_for_reactivate')
td.index-action-cell
- if policy(client).reactivate?
= link_to edit_client_path(client), target: '_blank', rel: 'noopener',
class: 'link-icon-span-text',
title: t('.ractivate_link_title') do
= icon_span(:edit)
span.icon-span-text= client.contact.full_name
- elsif policy(client).show?
= link_to client_path(client), class: 'link-icon-span-text' do
= icon_span(:show)
span.icon-span-text= client.contact.full_name
- else
= client.contact.full_name
td= l(assignment.period_start) if assignment.period_start td= l(assignment.period_start) if assignment.period_start
td= l(assignment.period_end) if assignment.period_end td= l(assignment.period_end) if assignment.period_end
td td
- if assignment.client.involved_authority - if client.involved_authority
= link_to_if policy(User).show?, = link_to_if policy(User).show?,
assignment.client.involved_authority.full_name, client.involved_authority.full_name,
profile_url_path(assignment.client.involved_authority) profile_url_path(client.involved_authority)
- else - else
= link_to_if policy(User).show?, = link_to_if policy(User).show?,
assignment.creator.full_name, assignment.creator.full_name,
profile_url_path(assignment.creator) profile_url_path(assignment.creator)
td= link_to_if(assignment.assignment && policy(assignment.assignment).show?, td= link_to_if(assignment && policy(assignment).show?,
t_action(:show), assignment.assignment) { '' } t_action(:show), assignment) { '' }
- if policy(Assignment).show_comments? - if policy(Assignment).show_comments?
= td_truncate_content_modal(assignment.comments, 'Bemerkungen') = td_truncate_content_modal(assignment.comments, 'Bemerkungen')
td.index-action-cell.hidden-print td.index-action-cell.hidden-print
span span
- unless assignment.assignment.volunteer.external? - unless assignment.volunteer.external?
= link_to_if(policy(TrialFeedback).index?, t_title(:index, TrialFeedback), = link_to_if(policy(TrialFeedback).index?, t_title(:index, TrialFeedback),
polymorphic_path([assignment.assignment.volunteer, assignment.assignment, TrialFeedback])) { '' } polymorphic_path([assignment.volunteer, assignment, TrialFeedback])) { '' }
= link_to_if(policy(Feedback).index?, t_title(:index, Feedback), = link_to_if(policy(Feedback).index?, t_title(:index, Feedback),
polymorphic_path([assignment.assignment.volunteer, assignment.assignment, Feedback])) { '' } polymorphic_path([assignment.volunteer, assignment, Feedback])) { '' }
= link_to_if(policy(Assignment).verify_termination?, 'Beendigungsformular', = link_to_if(policy(Assignment).verify_termination?, 'Beendigungsformular',
polymorphic_path(assignment.assignment, action: :terminate)) { '' } polymorphic_path(assignment, action: :terminate)) { '' }
td.index-action-cell.hidden-print td.index-action-cell.hidden-print
span span
= "Quittiert von " = "Quittiert von "
......
...@@ -7,9 +7,9 @@ tr ...@@ -7,9 +7,9 @@ tr
- if policy(assignment).show? && assignment.pdf.exists? - if policy(assignment).show? && assignment.pdf.exists?
= button_link icon_span(:download), assignment_path(assignment, format: :pdf), title: 'Herunterladen' = button_link icon_span(:download), assignment_path(assignment, format: :pdf), title: 'Herunterladen'
td.button-acceptance= assignment_status_badge(assignment) td.button-acceptance= assignment_status_badge(assignment)
- if controller_name != 'volunteers' - unless controller_in?(:volunteers)
td = link_to_if policy(assignment.volunteer).show?, assignment.volunteer, edit_volunteer_path(assignment.volunteer) td = link_to_if policy(assignment.volunteer).show?, assignment.volunteer, edit_volunteer_path(assignment.volunteer)
- if controller_name != 'clients' - unless controller_in?(:clients)
td= link_to_if policy(assignment.client).show?, assignment.client.contact.full_name, edit_client_path(assignment.client) td= link_to_if policy(assignment.client).show?, assignment.client.contact.full_name, edit_client_path(assignment.client)
td= l(assignment.period_start) if assignment.period_start td= l(assignment.period_start) if assignment.period_start
td= l(assignment.period_end) if assignment.period_end td= l(assignment.period_end) if assignment.period_end
......
...@@ -3,9 +3,9 @@ table.table.table-striped.assignments-table ...@@ -3,9 +3,9 @@ table.table.table-striped.assignments-table
tr tr
th.hidden-print Aktionen th.hidden-print Aktionen
th Status th Status
- if controller_name != 'volunteers' - unless controller_in?(:volunteers)
th= t_model(Volunteer) th= t_model(Volunteer)
- if controller_name != 'clients' - unless controller_in?(:clients)
th= t_model(Client) th= t_model(Client)
th= t_attr(:period_start, Assignment) th= t_attr(:period_start, Assignment)
th= t_attr(:period_end, Assignment) th= t_attr(:period_end, Assignment)
......
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
- if @archived_assignments.present? - if @archived_assignments.present?
h3 Archivierte Begleitungen h3 Archivierte Begleitungen
= render 'assignment_logs/client_volunteer_index', assignments: @archived_assignments = render 'assignment_logs/client_index', assignments: @archived_assignments
- ga_logs.order('created_at asc').each do |ga_log|
- group_assignment = ga_log.group_assignment
- volunteer = group_assignment.volunteer
tr
td.index-action-cell.hidden-print
- if policy(group_assignment).show? && group_assignment.pdf.exists?
= button_link icon_span(:download), group_assignment_path(group_assignment, format: :pdf),
title: 'Herunterladen'
- if policy(group_assignment).reactivate?
span.single-line
= button_link icon_span(:edit), edit_group_assignment_path(group_assignment)
span.m-l-10
em= t('.edit_for_reactivate')
td.index-action-cell
- if policy(volunteer).reactivate?
= link_to edit_volunteer_path(volunteer), target: '_blank', rel: 'noopener',
class: 'link-icon-span-text',
title: t('.ractivate_link_title') do
= icon_span(:edit)
span.icon-span-text= volunteer.full_name
- else
= link_to_if policy(volunteer).edit?, volunteer.contact.full_name, edit_volunteer_path(volunteer)
td= ga_log.responsible ? t_attr(:responsible, GroupAssignment) : t_attr(:member, GroupAssignment)
td= l(ga_log.period_start) if ga_log.period_start
td= l(ga_log.period_end) if ga_log.period_end
td= l(ga_log.created_at)
td
= "Quittiert von "
= link_to_if policy(ga_log.termination_verified_by.profile).edit?,
ga_log.termination_verified_by.full_name,
profile_url_path(ga_log.termination_verified_by)
= " am #{l(ga_log.termination_verified_at.to_date)}"
table.table.table-striped.group-assignments-table
thead
tr
th
th= t_attr(:title, GroupOffer)
th= t_attr(:role, GroupAssignment)
th= t_attr(:period_start, GroupAssignment)
th= t_attr(:period_end, GroupAssignment)
- if policy(GroupAssignment).show_comments?
th= t_attr(:comments)
th colspan=2
tbody
- group_assignment_logs.each do |group_assignment_log|
- group_assignment = group_assignment_log.group_assignment
- group_offer = group_assignment.group_offer
tr
td.index-action-cell.hidden-print
- if policy(group_assignment).reactivate?
span.single-line
= link_to edit_group_assignment_path(group_assignment), target: '_blank', rel: 'noopener',
class: 'link-icon-span-text',
title: t('.ractivate_link_title') do
= icon_span(:edit)
span.icon-span-text= t('.reactivatable_link')
td.index-action-cell.hidden-print
span.single-line
- if policy(group_offer).show?
= link_to group_offer_path(group_offer), class: 'link-icon-span-text' do
= icon_span(:show)
span.icon-span-text= group_offer.title
- else
= group_offer.title
td= t_attr(group_assignment.responsible ? :responsible : :member, GroupAssignment)
td= l(group_assignment.period_start) if group_assignment.period_start
td= l(group_assignment.period_end) if group_assignment.period_end
- if policy(GroupAssignment).show_comments?
= td_truncate_content_modal(group_assignment.comments, 'Bemerkungen')
td= link_to_if(policy(group_offer).show? && !group_offer.deleted?,
t_action(:show), group_offer_path(group_offer)) { '' }
td.index-action-cell.hidden-print
span
- unless @volunteer.external?
= link_to_if(policy(TrialFeedback).index?, t_title(:index, TrialFeedback),
polymorphic_path([@volunteer, group_offer, TrialFeedback])) { '' }
= link_to_if(policy(Feedback).index?, t_title(:index, Feedback),
polymorphic_path([@volunteer, group_offer, Feedback])) { '' }
= link_to_if(policy(GroupAssignment).verify_termination?, 'Beendigungsformular',
polymorphic_path(group_assignment, action: :terminate)) { '' }
td.index-action-cell.hidden-print
span
= "Quittiert von "
= link_to_if(policy(Assignment).verify_termination?, group_assignment.termination_verified_by.full_name,
profile_url_path(group_assignment.termination_verified_by)) { '' }
= " am #{l(group_assignment.termination_verified_at.to_date)}"
...@@ -16,19 +16,4 @@ ...@@ -16,19 +16,4 @@
th Begleitung Beendet th Begleitung Beendet
th Archiviert th Archiviert
tbody tbody
- @group_offer.group_assignment_logs.order('created_at asc').each do |ga_log| = render 'group_assignment_logs/group_offer_index', ga_logs: @group_offer.group_assignment_logs
tr
td.index-action-cell.hidden-print
- if policy(ga_log.group_assignment).show? && ga_log.group_assignment.pdf.exists?
= button_link icon_span(:download), group_assignment_path(ga_log.group_assignment, format: :pdf),
title: 'Herunterladen'
td= link_to_if(policy(Volunteer).edit?, ga_log.volunteer.contact.full_name,
edit_volunteer_path(ga_log.volunteer)) { ga_log.volunteer.contact.full_name }
td= ga_log.responsible ? t_attr(:responsible, GroupAssignment) : t_attr(:member, GroupAssignment)
td= l(ga_log.period_start) if ga_log.period_start
td= l(ga_log.period_end) if ga_log.period_end
td= l(ga_log.created_at)
td
= "Quittiert von "
= link_to_if policy(ga_log.termination_verified_by.profile).edit?, ga_log.termination_verified_by.full_name, profile_url_path(ga_log.termination_verified_by)
= " am #{l(ga_log.termination_verified_at.to_date)}"
- if @current_assignments.any? || @current_group_assignments.any?
h2.small Aktuelle Einsätze
- if @current_assignments.any?
h3.small#assignments Begleitungen
= render 'assignments/client_volunteer_index', assignments: @current_assignments
- if @current_group_assignments.any?
h3.small#assignments Gruppenangebote
= render 'group_assignments/volunteer_group_assignments', group_assignments: @current_group_assignments, editable: true
- if @archived_assignments.any? || @archived_group_assignments.any?
h2.small Archivierte Einsätze
- if @archived_assignments.any?
h3.small Begleitungen
= render 'assignment_logs/volunteer_index', assignment_logs: @archived_assignments
- if @archived_group_assignments.any?
h3.small Gruppenangebote
= render 'group_assignment_logs/volunteer_index', group_assignment_logs: @archived_group_assignments
hr
...@@ -7,22 +7,7 @@ ...@@ -7,22 +7,7 @@
= f.button :submit = f.button :submit
= render 'volunteers/form', f: f, volunteer: @volunteer = render 'volunteers/form', f: f, volunteer: @volunteer
= render 'active_and_archived_missions'
- if @volunteer.assignments.unterminated.any?
h2.small#assignments Aktuelle Begleitungen
= render 'assignments/client_volunteer_index', assignments: @volunteer.assignments.unterminated
- if @volunteer.assignment_logs.any?
h2.small Archivierte Begleitungen
= render 'assignment_logs/assignment_logs_volunteer_index', assignment_logs: @volunteer.assignment_logs
- if @volunteer.group_assignments.unterminated.any?
h2.small#assignments= t('volunteer_applications.show.group_assignments')
= render 'group_assignments/volunteer_group_assignments', group_assignments: @volunteer.group_assignments.unterminated, editable: true
- if @volunteer.group_assignment_logs.any?
h2.small= t('volunteer_applications.show.old_group_assignments')
= render 'group_assignments/volunteer_group_assignments_logs', group_assignment_logs: @volunteer.group_assignment_logs
- if policy(Event).show? && @volunteer_events.present? - if policy(Event).show? && @volunteer_events.present?
= render 'events/volunteer_events', events: @volunteer_events = render 'events/volunteer_events', events: @volunteer_events
......
...@@ -143,24 +143,7 @@ h4.label-list ...@@ -143,24 +143,7 @@ h4.label-list
- else - else
em keine em keine
- if @current_assignments.present? = render 'active_and_archived_missions'
h2.small#assignments Aktuelle Begleitungen
= render 'assignments/client_volunteer_index', assignments: @current_assignments
- if @archived_assignments.present?
h2.small Archivierte Begleitungen
= render 'assignment_logs/assignment_logs_volunteer_index',
assignment_logs: @archived_assignments
- if @current_group_assignments.present?
h2.small#assignments= t('.group_assignments')
= render 'group_assignments/volunteer_group_assignments',
group_assignments: @current_group_assignments, editable: true
- if @archived_group_assignments.present?
h2.small= t('.old_group_assignments')
= render 'group_assignments/volunteer_group_assignments_logs',
group_assignment_logs: @archived_group_assignments
- if policy(Event).show? && @volunteer_events.present? - if policy(Event).show? && @volunteer_events.present?
= render 'events/volunteer_events', events: @volunteer_events = render 'events/volunteer_events', events: @volunteer_events
......
...@@ -654,6 +654,24 @@ de: ...@@ -654,6 +654,24 @@ de:
when: Tag / Zeit when: Tag / Zeit
zurich: Zürich zurich: Zürich
agreement_text: Vereinbarungstext agreement_text: Vereinbarungstext
assignment_logs:
client_index: &assignment_logs_index
edit_for_reactivate: Kann reaktiviert werden
ractivate_link_title: Freiwillige/n reaktivieren um Einsatz reaktivieren zu können
volunteer_index:
<<: *assignment_logs_index
ractivate_link_title: Klient/in reaktivieren um Einsatz reaktivieren zu können
assignments:
form:
reactivate:
title: Beendetes Tandem wieder Aktivieren
hint: Das beendete Tandem wird wieder aktiviert und das Einsatzende wieder zurückgesetzt.
button: Tandem wieder aktivieren
confirm: Soll das Tandem wirklich wieder auf aktiv gesetzt werden?
notices:
reactivation:
success: Das Tandem wurde erfolgreich reaktiviert
failure: Das Tandem konnte nicht reaktiviert werden
billing_expense_pdf: billing_expense_pdf:
<<: *id-generic_keys <<: *id-generic_keys
account: Konto account: Konto
...@@ -670,17 +688,6 @@ de: ...@@ -670,17 +688,6 @@ de:
visum_k: K-Visum visum_k: K-Visum
visum_kst: KST-Visum visum_kst: KST-Visum
year: Jahr year: Jahr
assignments:
form:
reactivate:
title: Beendetes Tandem wieder Aktivieren
hint: Das beendete Tandem wird wieder aktiviert und das Einsatzende wieder zurückgesetzt.
button: Tandem wieder aktivieren
confirm: Soll das Tandem wirklich wieder auf aktiv gesetzt werden?
notices:
reactivation:
success: Das Tandem wurde erfolgreich reaktiviert
failure: Das Tandem konnte nicht reaktiviert werden
certificates: certificates:
certificate: &id-certificates-show certificate: &id-certificates-show
hours_given: 'Total %{hours} Stunden' hours_given: 'Total %{hours} Stunden'
...@@ -737,6 +744,13 @@ de: ...@@ -737,6 +744,13 @@ de:
index: *id-kinds-event index: *id-kinds-event
show: *id-kinds-event show: *id-kinds-event
volunteer_events: *id-kinds-event volunteer_events: *id-kinds-event
group_assignment_logs:
group_offer_index:
<<: *assignment_logs_index
volunteer_index:
<<: *assignment_logs_index
ractivate_link_title: Gruppeneinsatz kann reaktiviert werden
reactivatable_link: Gruppeneinsatz bearbeiten (reaktivierbar)
group_assignments: group_assignments:
form: form:
reactivate: reactivate:
......
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