diff --git a/app/controllers/elements_controller.rb b/app/controllers/elements_controller.rb
index 3ffdf98..261e359 100644
--- a/app/controllers/elements_controller.rb
+++ b/app/controllers/elements_controller.rb
@@ -31,7 +31,10 @@ class ElementsController < ApplicationController
@element.success_criteria.create!(title: check.name, description_html: check.success_criterion_html,
level: check.level)
end
- redirect_to @element.report, notice: 'Element was successfully created.'
+ respond_to do |format|
+ format.html { redirect_to @element.report, notice: 'Element was successfully created.' }
+ format.turbo_stream
+ end
else
render :new, status: :unprocessable_entity
end
diff --git a/app/views/elements/_form.html.erb b/app/views/elements/_form.html.erb
index 4ec0cee..000bcbe 100644
--- a/app/views/elements/_form.html.erb
+++ b/app/views/elements/_form.html.erb
@@ -1,4 +1,4 @@
-<%= bootstrap_form_with(model: element, data: { turbo_frame: "_top" }) do |form| %>
+<%= bootstrap_form_with(model: element, data: element.persisted? || { turbo_frame: "_top" }) do |form| %>
<%= form.hidden_field :report_id %>
diff --git a/app/views/elements/create.turbo_stream.erb b/app/views/elements/create.turbo_stream.erb
new file mode 100644
index 0000000..458bd31
--- /dev/null
+++ b/app/views/elements/create.turbo_stream.erb
@@ -0,0 +1,2 @@
+<%= turbo_stream.update "new_element_frame", partial: "reports/new_element_button", locals: { report: @element.report } %>
+<%= turbo_stream.append "element_list", @element %>
\ No newline at end of file
diff --git a/app/views/elements/edit.html.erb b/app/views/elements/edit.html.erb
index dbdcb3a..0ce1dc1 100644
--- a/app/views/elements/edit.html.erb
+++ b/app/views/elements/edit.html.erb
@@ -7,6 +7,9 @@
<%= @element.title %>
+
+ <%= @element.path %>
+
<%= link_to(tag.i(class: "bi bi-pencil"), @element, class: "btn btn-link text-warning") %>
diff --git a/app/views/reports/_new_element_button.html.erb b/app/views/reports/_new_element_button.html.erb
new file mode 100644
index 0000000..29f71b1
--- /dev/null
+++ b/app/views/reports/_new_element_button.html.erb
@@ -0,0 +1 @@
+<%= link_to "#{tag.i(class: "bi bi-plus-lg")} Neues Element".html_safe, new_element_path(report_id: report.id), class: "btn btn-primary" %>
diff --git a/app/views/reports/show.html.erb b/app/views/reports/show.html.erb
index 4f66dcf..ad8b9ae 100644
--- a/app/views/reports/show.html.erb
+++ b/app/views/reports/show.html.erb
@@ -12,15 +12,17 @@
<%= turbo_frame_tag "new_element_frame" do %>
- <%= link_to "#{tag.i(class: "bi bi-plus-lg")} Neues Element".html_safe, new_element_path(report_id: @report.id), class: "btn btn-primary" %>
+ <%= render partial: "reports/new_element_button", locals: { report: @report } %>
<% end %>
- <% @report.elements.each do |element| %>
- <%= turbo_frame_tag dom_id(element, :frame) do %>
- <%= render element %>
- <% end %>
- <% end %>
+
+ <% @report.elements.each do |element| %>
+ <%= turbo_frame_tag dom_id(element, :frame) do %>
+ <%= render element %>
+ <% end %>
+ <% end %>
+
diff --git a/public/favicon.ico b/public/favicon.ico
index e69de29..98424e7 100644
Binary files a/public/favicon.ico and b/public/favicon.ico differ