Skip to content

Commit

Permalink
Income to render with turbo.
Browse files Browse the repository at this point in the history
  • Loading branch information
neb417 committed Nov 7, 2024
1 parent 5c1f6c9 commit 411571c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/controllers/incomes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class IncomesController < ApplicationController
# GET /incomes or /incomes.json
def index
@incomes = Income.all

respond_to do |format|
format.html
format.turbo_stream
end
end

# GET /incomes/1 or /incomes/1.json
Expand Down
4 changes: 3 additions & 1 deletion app/views/components/_toolbar.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%# locals: (active_tab:) %>

<%= turbo_frame_tag "dashboard_toolbar" do %>
<ul class="flex flex-wrap text-sm font-medium text-center text-gray-500 border-b border-gray-200">
<li class="mx-auto">
Expand All @@ -7,7 +9,7 @@
<%= link_to "Federal Tax Brackets", federal_tax_brackets_path, data: { turbo_stream: true }, class: active_tab == :federal_tax_brackets ? "active-toolbar-tab" : "inactive-toolbar-tab" %>
</li>
<li class="mx-auto">
<%= link_to "Incomes", incomes_path, data: { turbo: false }, class: active_tab == :incomes ? "active-toolbar-tab" : "inactive-toolbar-tab" %>
<%= link_to "Incomes", incomes_path, data: { turbo_stream: true }, class: active_tab == :incomes ? "active-toolbar-tab" : "inactive-toolbar-tab" %>
</li>
<li class="mx-auto">
<%= link_to "Fixed Expenses", fixed_expenses_path, data: { turbo: false }, class: active_tab == :fixed_expenses ? "active-toolbar-tab" : "inactive-toolbar-tab" %>
Expand Down
3 changes: 3 additions & 0 deletions app/views/incomes/_dashboard.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%= turbo_frame_tag "primary_frame" do %>
<%= render partial: "incomes/index" %>
<% end %>
2 changes: 2 additions & 0 deletions app/views/incomes/index.turbo_stream.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<%= turbo_stream.replace "primary_frame", partial: "incomes/dashboard" %>
<%= turbo_stream.replace "dashboard_toolbar", partial: "components/toolbar", locals: { active_tab: :incomes } %>

0 comments on commit 411571c

Please sign in to comment.