Skip to content

Commit

Permalink
add merge button
Browse files Browse the repository at this point in the history
  • Loading branch information
Floppy committed Dec 3, 2021
1 parent 1856972 commit 402efb2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/controllers/models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ def update
redirect_to [@library, @model]
end

def merge
if (@parent = @model.parent)
@model.merge_into_parent!
redirect_to [@library, @parent]
else
render status: :bad_request
end
end

def bulk_edit
@creators = Creator.all
@models = @library.models
Expand Down
1 change: 1 addition & 0 deletions app/views/models/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<%= card :secondary, "Actions" do %>
<%= link_to "Edit Details", edit_library_model_path(@library, @model), class: "btn btn-primary" %>
<%= link_to "Merge Into Parent", merge_library_model_path(@library, @model), class: "btn btn-danger", method: :post if @model.parent %>
<% end %>
<%= render 'tags_card', tags: @model.tags, selected: nil %>
Expand Down
3 changes: 3 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
post "/", controller: :search, action: :index
resources :libraries do
resources :models, except: [:index, :destroy] do
member do
post "merge"
end
collection do
get "edit", action: "bulk_edit"
patch "update", action: "bulk_update"
Expand Down

0 comments on commit 402efb2

Please sign in to comment.