From 24955616b9867e5a8b863002e4659e3409adaf6d Mon Sep 17 00:00:00 2001 From: Jannik Pulfer Date: Fri, 1 Mar 2024 08:33:24 +0100 Subject: [PATCH] add remove button to roles in edit view and fix rendering of form --- app/helpers/role_form_helper.rb | 2 +- app/views/people/_person_role_fields.html.haml | 3 ++- app/views/people/edit.html.haml | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/role_form_helper.rb b/app/helpers/role_form_helper.rb index 94a4e73c5..824e31fe8 100644 --- a/app/helpers/role_form_helper.rb +++ b/app/helpers/role_form_helper.rb @@ -3,7 +3,7 @@ def link_to_add_role(name, form, association) new_role = form.object.send(association).klass.new id = new_role.object_id fields = form.fields_for(association, new_role, child_index: id) do |builder| - render("#{association.to_s.singularize}_fields", form: builder) + render("#{association.to_s.singularize}_fields", person_role: builder) end link_to( name, diff --git a/app/views/people/_person_role_fields.html.haml b/app/views/people/_person_role_fields.html.haml index a74093fe8..893778c59 100644 --- a/app/views/people/_person_role_fields.html.haml +++ b/app/views/people/_person_role_fields.html.haml @@ -6,4 +6,5 @@ Stufe %div.d-flex.fw-light = person_role.collection_select :person_role_level_id, PersonRoleLevel.order(:level), :id, :level, {}, class: "form-select w-50 me-1" - = person_role.number_field :percent, step: 1, class: "form-control w-50" \ No newline at end of file + = person_role.number_field :percent, step: 1, class: "form-control w-50" + = link_to "Remove", "#", class: "remove_fields" \ No newline at end of file diff --git a/app/views/people/edit.html.haml b/app/views/people/edit.html.haml index cbef5e1e1..9832d59b7 100644 --- a/app/views/people/edit.html.haml +++ b/app/views/people/edit.html.haml @@ -21,10 +21,9 @@ = form.fields_for :person_roles do |person_role| %tr %td= render "person_role_fields", person_role: person_role - %tr - %td - = link_to_add_role "Neue Funktion", @person, :person_roles - %button.btn.btn-link Neue Funktion + %tr + %td + = link_to_add_role "Neue Funktion", form, :person_roles %th.fw-normal Organisationseinheit %tr %td= form.collection_select :department_id, Department.order(:name), :id, :name, {}, class: "form-select w-100"