Skip to content

Commit

Permalink
delete udah make stream dan edit tanggal make turbo frame
Browse files Browse the repository at this point in the history
  • Loading branch information
buncis committed Jul 19, 2022
1 parent 151fa94 commit 32038b8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
5 changes: 4 additions & 1 deletion app/controllers/line_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def update

def destroy
@line_item.destroy
redirect_to quote_path(@quote), notice: "Item was successfully destroyed."
respond_to do |format|
format.html { redirect_to quote_path(@quote), notice: "Item was successfully destroyed." }
format.turbo_stream { flash.now[:notice] = "Item was successfully destroyed." }
end
end

private
Expand Down
18 changes: 10 additions & 8 deletions app/views/line_item_dates/_line_item_date.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<%= turbo_frame_tag line_item_date do %>
<div class="line-item-date">
<div class="line-item-date__header">
<h2 class="line-item-date__title">
<%= l(line_item_date.date, format: :long)%>
</h2>
<div class="line-item-date__actions">
<%= button_to "Delete",
<%= turbo_frame_tag dom_id(line_item_date, :edit) do %>
<div class="line-item-date__header">
<h2 class="line-item-date__title">
<%= l(line_item_date.date, format: :long)%>
</h2>
<div class="line-item-date__actions">
<%= button_to "Delete",
[quote, line_item_date],
method: :delete,
form: { data: { turbo_confirm: "Are you sure? " } },
class: "btn btn--light" %>
<%= link_to "Edit",
<%= link_to "Edit",
[:edit, quote, line_item_date],
class: "btn btn--light" %>
</div>
</div>
</div>
<% end %>
<div class="line-item_date__body">
<div class="line-item line-item--header">
<div class="line-item__name">Article</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/line_item_dates/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="header">
<h1>Edit date</h1>
</div>
<%= turbo_frame_tag @line_item_date do %>
<%= turbo_frame_tag dom_id(@line_item_date, :edit) do %>
<%= render "form", quote: @quote, line_item_date: @line_item_date %>
<% end %>
</main>
7 changes: 3 additions & 4 deletions app/views/line_items/_line_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
</div>
<div class="line-item__actions">
<%= button_to "Delete",
[quote, line_item_date, line_item],
method: :delete,
form: { data: { turbo_frame: "_top" } },
class: "btn btn--light" %>
[quote, line_item_date, line_item],
method: :delete,
class: "btn btn--light" %>
<%= link_to "Edit",
[:edit, quote,line_item_date, line_item],
class: "btn btn--light" %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/line_items/destroy.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= turbo_stream.remove @line_item %>
<%= render_turbo_stream_flash_messages %>

0 comments on commit 32038b8

Please sign in to comment.