Verified Commit 02f69065 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

form and filter use

parent 9cb9d43d
......@@ -185,3 +185,7 @@ li.button-acceptance a {
max-height: 150px;
overflow-y: auto;
}
.disabled-title {
color: $gray-light;
}
......@@ -35,7 +35,8 @@ class GroupAssignmentsController < ApplicationController
def set_end_today
if @group_assignment.update(period_end: Time.zone.today, period_end_set_by: current_user)
redirect_to @group_assignment.group_offer, notice: 'Einsatzende wurde erfolgreich gesetzt.'
redirect_to polymorphic_path(@group_assignment.group_offer, action: params[:redirect_to]),
notice: 'Einsatzende wurde erfolgreich gesetzt.'
else
redirect_to @group_assignment.group_offer, notice: 'Einsatzende konnte nicht gesetzt werden.'
end
......
......@@ -77,9 +77,17 @@ class GroupOffersController < ApplicationController
end
end
def initiate_termination; end
def initiate_termination
@group_offer.period_end = Time.zone.today
end
def submit_initiate_termination; end
def submit_initiate_termination
if @group_offer.update(period_end: group_offer_params[:period_end], period_end_set_by: current_user)
redirect_to group_offers_path, notice: 'Gruppenangebots beendigung erfolgreich eingeleitet.'
else
render :initiate_termination
end
end
private
......@@ -121,6 +129,6 @@ class GroupOffersController < ApplicationController
:necessary_volunteers, :description, :women, :men, :children, :teenagers, :unaccompanied,
:all, :long_term, :regular, :short_term, :workday, :weekend, :morning, :afternoon, :evening,
:flexible, :schedule_details, :department_id, :creator_id, :organization, :location,
:group_offer_category_id, group_assignments_attributes)
:group_offer_category_id, :period_end, group_assignments_attributes)
end
end
- redirect_to_action ||= nil
.table-responsive.assignments-table
table.table.table-no-border-top
thead
tr
th= t_attr(:volunteer, GroupAssignment)
th= t_attr(:role, GroupAssignment)
th= t_attr(:period_start, GroupAssignment)
th= t_attr(:period_end, GroupAssignment)
th.hidden-print colspan=2 Aktionen
tbody
- group_assignments.each do |group_assignment|
tr
td
= link_to_if(policy(Volunteer).show?, group_assignment.volunteer.contact.full_name, volunteer_path(group_assignment.volunteer))
- if params[:format] == 'pdf'
td= group_assignment.volunteer.contact.primary_email
td= group_assignment.responsible ? t_attr(:responsible, GroupAssignment) : t_attr(:member, GroupAssignment)
td= l(group_assignment.period_start) if group_assignment.period_start
td= l(group_assignment.period_end) if group_assignment.period_end
td.index-action-cell.hidden-print
= link_to_if(policy(group_assignment).edit?, 'Bearbeiten', edit_group_assignment_path(group_assignment)) { '' }
- if group_assignment.period_end.blank?
= link_to_if(policy(group_assignment).set_end_today?, 'Heute beenden',
set_end_today_group_assignment_path(group_assignment, redirect_to: redirect_to_action),
data: { method: 'PUT' }) { '' }
- elsif group_assignment.termination_submitted_by_id.blank?
= link_to_if(policy(group_assignment).terminate?, 'Beendigungsformular an Freiwillige/n mailen',
polymorphic_path([group_assignment, ReminderMailing], action: :new_termination),
class: 'index-action-link')
= link_to_if(policy(group_assignment).terminate?, 'Beendigungsformular ausfüllen',
polymorphic_path(group_assignment, action: :terminate))
td
- if group_assignment.period_end.present? && policy(GroupAssignment).verify_termination?
= link_to_if(group_assignment.termination_verified_by.blank?, 'Beendigung Quittieren',
verify_termination_group_assignment_path(group_assignment), class: 'btn btn-default',
data: { method: 'PATCH' }) { '' }
......@@ -17,7 +17,12 @@ nav.navbar.section-navigation#filters
ul.list-inline
li= button_link t('clear_filters'), group_offers_path, dimension: 'sm'
= custom_filter_dropdown('Standort', *Department.filterable)
= boolean_toggler_filter_dropdown(:active, 'Status', 'Aktiv', 'Beendet')
= boolean_toggler_filter_dropdown(:active, 'Status', 'Aktiv', 'Deaktiviert')
= custom_filter_dropdown('Beendet',
{ q: :period_end_blank, text: 'Laufend', value: 'true'},
{ q: :period_end_not_null, text: 'Beendung initiert', value: 'true'},
{ q: :termination_verified_by_id_blank, qs: [:period_end_not_null], text: 'Unquitiert', value: 'true'},
{ q: :termination_verified_by_id_not_null, text: 'Beendet', value: 'true'})
= list_filter_dropdown(:offer_state, GroupOffer::OFFER_STATES)
= custom_filter_dropdown('Kategorie', *GroupOfferCategory.filterable_group_offer)
= button_link 'Beendete Begleitungen',
......
h1 Gruppenangebot Beenden
= simple_form_for(@group_offer, url: initiate_termination_group_offer_path(@group_offer)) do |f|
= f.input :period_end, as: :date_picker
= simple_form_for(@group_offer, method: :put, url: submit_initiate_termination_group_offer_path(@group_offer)) do |f|
- if @group_offer.group_assignments.running.any?
h2 Noch nicht beendete Gruppeneinsätze
= render 'group_assignments_index', group_assignments: @group_offer.group_assignments.running,
redirect_to_action: :initiate_termination
h2 class=('disabled-title' if @group_offer.group_assignments.running.any?) Enddatum für das Gruppenangebot setzen
- if @group_offer.group_assignments.running.any?
p.text-danger.text-bigger-1 Um das Gruppenangebot zu beenden, müssen erst alle zugehörigen Gruppeneinsätze beendet sein.
= f.input :period_end, as: :date_picker, disabled: @group_offer.group_assignments.running.any?
p.text-info.m-b-10.text-bigger-1
em Die Voreinstellung für das Enddatum kann auf ein beliebiges Datum angepasst werden
hr
= f.button :submit, disabled: @group_offer.group_assignments.running.any?
......@@ -73,44 +73,7 @@ h2= @group_offer.title
- if @group_offer.group_assignments.any?
h2 Aktuelle Gruppeneinsätze
.table-responsive.assignments-table
table.table.table-no-border-top
thead
tr
th= t_attr(:volunteer, GroupAssignment)
- if params[:format] == 'pdf'
th Freiwillige Mailadresse
th= t_attr(:role, GroupAssignment)
th= t_attr(:period_start, GroupAssignment)
th= t_attr(:period_end, GroupAssignment)
th.hidden-print colspan=2 Aktionen
tbody
- @group_offer.group_assignments.each do |group_assignment|
- if group_assignment.volunteer
tr
td
= link_to_if(policy(Volunteer).show?, group_assignment.volunteer.contact.full_name, volunteer_path(group_assignment.volunteer))
- if params[:format] == 'pdf'
td= group_assignment.volunteer.contact.primary_email
td= group_assignment.responsible ? t_attr(:responsible, GroupAssignment) : t_attr(:member, GroupAssignment)
td= l(group_assignment.period_start) if group_assignment.period_start
td= l(group_assignment.period_end) if group_assignment.period_end
td.index-action-cell.hidden-print
= link_to_if(policy(group_assignment).edit?, 'Bearbeiten', edit_group_assignment_path(group_assignment)) { '' }
- if group_assignment.period_end.blank?
= link_to_if(policy(group_assignment).set_end_today?, 'Heute beenden',
set_end_today_group_assignment_path(group_assignment),
data: { method: 'PUT' }) { '' }
- elsif group_assignment.termination_submitted_by_id.blank?
= link_to_if(policy(group_assignment).terminate?, 'Beendigungsformular an Freiwillige/n mailen',
polymorphic_path([group_assignment, ReminderMailing], action: :new_termination))
= link_to_if(policy(group_assignment).terminate?, 'Beendigungsformular ausfüllen',
polymorphic_path(group_assignment, action: :terminate))
td
- if group_assignment.period_end.present? && policy(GroupAssignment).verify_termination?
= link_to_if(group_assignment.termination_verified_by.blank?, 'Beendigung Quittieren',
verify_termination_group_assignment_path(group_assignment), class: 'btn btn-default',
data: { method: 'PATCH' }) { '' }
= render 'group_assignments_index', group_assignments: @group_offer.group_assignments
- if @group_offer.group_assignment_logs.any?
h2 Archivierte Gruppeneinsätze
......
......@@ -364,6 +364,7 @@ de:
volunteers: Freiwillige
volunteer_state: Interne oder externe Freiwillige
women: Frauen
period_end: Angebotsenddatum
group_offer_category:
category_name: Name
category_state: Status
......
......@@ -69,7 +69,7 @@ Rails.application.routes.draw do
resources :group_offers, concerns: :search do
put :change_active_state, on: :member
get :initiate_termination, on: :member
put :initiate_termination, on: :member, to: 'group_offers#submit_initiate_termination'
put :submit_initiate_termination, on: :member
end
get 'list_responses/hours', to: 'list_responses#hours'
......
Supports Markdown
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