Delete stuff in report view
This commit is contained in:
parent
644969c613
commit
50e853098b
16 changed files with 64 additions and 31 deletions
|
|
@ -57,8 +57,16 @@ class ElementsController < ApplicationController
|
|||
|
||||
# DELETE /elements/1
|
||||
def destroy
|
||||
@element.destroy!
|
||||
redirect_to page_elements_url(@element.page), notice: "Element was successfully destroyed.", status: :see_other
|
||||
Element.connection.transaction do
|
||||
@element.destroy!
|
||||
@element.page.elements.where("position > ?", @element.position).update_all("position = position - 1")
|
||||
end
|
||||
respond_to do |format|
|
||||
format.turbo_stream
|
||||
format.html do
|
||||
redirect_to page_elements_url(@element.page), notice: "Element was successfully destroyed.", status: :see_other
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue