Skip to content

Commit

Permalink
Vereinfachtes anlegen von Zuständigkeiten
Browse files Browse the repository at this point in the history
  • Loading branch information
ro3t committed Oct 9, 2023
1 parent 7cb0fac commit 16979f0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/responsibilities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def index
end

def new
@responsibility = Responsibility.new
@responsibility = Responsibility.new(category_id: params[:category].presence&.to_i)
end

def edit
Expand Down
7 changes: 5 additions & 2 deletions app/helpers/responsibilities_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ def groups_options(resp_or_category)
private

def groups_options_with_selected(responsibility, groups)
group = responsibility.group
options_for_select groups | [[group.to_s, group.id]], selected: group.id
options = groups
if (group = responsibility.group)
options << [[group.to_s, group.id]]
end
options_for_select options, selected: group&.id
end
end
7 changes: 7 additions & 0 deletions app/views/responsibilities/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
</td>
</tr>
<% end %>
<tr>
<td></td>
<td class="float-end">
<%= link_to tag.i('', class: 'fa fa-plus'), new_responsibilities_path(category:),
remote: true, class: 'btn btn-sm btn-outline-primary' %>
</td>
</tr>
</table>
</td>
</tr>
Expand Down
6 changes: 5 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
put :update_statuses
end
end
resources :responsibilities
resources :responsibilities do
collection do
get 'new/:category' => 'responsibilities#new', as: :new
end
end

namespace :citysdk do
get 'coverage' => 'coverage#valid'
Expand Down

0 comments on commit 16979f0

Please sign in to comment.