-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add some stuff * Render updated total costs as stream * Render updated total costs as stream when new expense created * Render updated total costs as stream when expense destroyed * Lint
- Loading branch information
Showing
21 changed files
with
130 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class ApplicationController < ActionController::Base | ||
include SetDashboardInstanceVariables | ||
end |
12 changes: 12 additions & 0 deletions
12
app/controllers/concerns/set_dashboard_instance_variables.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module SetDashboardInstanceVariables | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
# before_action :set_variables | ||
end | ||
|
||
def set_variables | ||
Rails.logger.debug "**** Dashboard Vars Being Set ****" | ||
@totals = FixedExpense.total_costs | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
class DashboardController < ApplicationController | ||
include SetDashboardInstanceVariables | ||
def index | ||
@incomes = Income.all | ||
@fixed_expenses = FixedExpense.all.order(annual_cost_cents: :desc) | ||
@fixed_expenses = FixedExpense.get_ordered | ||
@totals = FixedExpense.total_costs | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
// import { get } from "@rails/request.js" | ||
|
||
export default class extends Controller { | ||
static targets = [ "fixedTotals" ] | ||
|
||
updateTotals(event) { | ||
const data = Object.fromEntries(new FormData(event.target).entries()) | ||
console.log(data) | ||
console.log(data["fixed_expense[amount]"]) | ||
console.log(data["fixed_expense[frequency]"]) | ||
console.log(this.fixedTotalsTarget) | ||
let amount = data["fixed_expense[amount]"] | ||
let frequency = data["fixed_expense[frequency]"] | ||
// get(`/fixed_expenses/total_expenses?`) | ||
} | ||
} | ||
|
||
|
||
// export default class extends Controller { | ||
// static targets = ["monthlyPaymentDisplay"] | ||
// | ||
// homeDataUpdate(event){ | ||
// let homeId = event.target.selectedOptions[0].value | ||
// let target = this.monthlyPaymentDisplayTarget.id | ||
// get(`/recurring_payments/monthly_payment?home=${homeId}&target=${target}`,{ | ||
// responseKind: "turbo-stream" | ||
// }) | ||
// } | ||
// } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,8 @@ | ||
<%= turbo_frame_tag :fixed_expenses do %> | ||
<div class="grid grid-cols-6"> | ||
<% fixed_headings = ["Expense Name", "Annual Cost", "Monthly Cost", "Bi-weekly Cost"] %> | ||
<% fixed_headings.each do |fixed_heading| %> | ||
<div class="px-5"><strong><%= fixed_heading %></strong></div> | ||
<% end %> | ||
</div> | ||
<div id="fixed_expense_labels" class="grid grid-cols-6"> | ||
<% fixed_headings = ["Expense Name", "Annual Cost", "Monthly Cost", "Bi-weekly Cost"] %> | ||
<% fixed_headings.each do |fixed_heading| %> | ||
<div class="px-5 py-4"><strong><%= fixed_heading %></strong></div> | ||
<% end %> | ||
</div> | ||
|
||
<%= render @fixed_expenses %> | ||
|
||
<div class="grid grid-cols-6"> | ||
<% total_costs = [ | ||
"Total", | ||
humanized_money_with_symbol(@totals.total_annual_cost), | ||
humanized_money_with_symbol(@totals.total_monthly_cost), | ||
humanized_money_with_symbol(@totals.total_bi_weekly_cost) | ||
] | ||
%> | ||
<% total_costs.each do |total| %> | ||
<div class="px-5"><strong><%= total %></strong></div> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
<%= render @fixed_expenses %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<%= turbo_stream.replace "fixed_expenses" do %> | ||
<%= render @fixed_expenses %> | ||
<% end %> | ||
|
||
<%= turbo_stream.replace "total_costs" do %> | ||
<%= render partial: "shared/total_costs", locals: { totals: @totals } %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= turbo_stream.remove @fixed_expense %> | ||
|
||
<%= turbo_stream.replace "total_costs" do %> | ||
<%= render partial: "shared/total_costs", locals: { totals: @totals } %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= turbo_stream.update @fixed_expense %> | ||
|
||
<%= turbo_stream.replace "total_costs" do %> | ||
<%= render partial: "shared/total_costs", locals: { totals: @totals } %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="px-5"> | ||
<span><strong><%= humanized_money_with_symbol(total) %></strong></span> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="grid grid-cols-6"> | ||
<div class="px-5"> | ||
<strong>Total</strong> | ||
</div> | ||
|
||
<div> | ||
<%= render partial: "shared/total", locals: { total: @totals.total_annual_cost } %> | ||
</div> | ||
|
||
<div> | ||
<%= render partial: "shared/total", locals: { total: @totals.total_monthly_cost } %> | ||
</div> | ||
|
||
<div> | ||
<%= render partial: "shared/total", locals: { total: @totals.total_bi_weekly_cost } %> | ||
</div> | ||
</div> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters