Skip to content

Commit

Permalink
add remove button to roles in edit view and fix rendering of form
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomTannenbaum committed Mar 1, 2024
1 parent 857e9c4 commit 2495561
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/helpers/role_form_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion app/views/people/_person_role_fields.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
= person_role.number_field :percent, step: 1, class: "form-control w-50"
= link_to "Remove", "#", class: "remove_fields"
7 changes: 3 additions & 4 deletions app/views/people/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 2495561

Please sign in to comment.