Delete stuff in report view

This commit is contained in:
david 2024-11-11 01:40:04 +01:00
parent 644969c613
commit 50e853098b
16 changed files with 64 additions and 31 deletions

View file

@ -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