Skip to content

Commit f66038b

Browse files
committed
New expenses modal
1 parent 1d4caf0 commit f66038b

13 files changed

+41
-7
lines changed

app/controllers/expenses_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def create
1717
if @expense.save
1818
format.html { redirect_to [@mybudget, @expenses], notice: 'expense was successfully created.' }
1919
format.json { render :show, status: :created, location: @expense }
20+
format.js {redirect_via_turbolinks_to [@mybudget, @expenses]}
2021
else
2122
format.html { render :new }
2223
format.json { render json: @expense.errors, status: :unprocessable_entity }

app/controllers/transfer_controller.rb renamed to app/controllers/transfers_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class TransferController < ApplicationController
1+
class TransfersController < ApplicationController
22
before_action :set_mybudget
33
before_action :set_transfer, only: [:show, :edit, :update, :destroy]
44

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<div class="modal-dialog reorder-modal-form">
2+
<div class="modal-content">
3+
<%= bootstrap_form_for([@mybudget, @expense], remote: true) do |f| %>
4+
<div class="modal-header">
5+
<h4 class="modal-title">New Income</h4>
6+
</div>
7+
8+
<div class="modal-body">
9+
<table>
10+
<tr>
11+
<td class="field-name">
12+
<%= f.label :expense %><br>
13+
</td>
14+
<td class="field"><%= f.text_field :expense %></td>
15+
</tr>
16+
<tr>
17+
<td class="field-name"> <%= f.label :amount %><br></td>
18+
<td class="field"><%= f.number_field :amount %></td>
19+
</tr>
20+
</table>
21+
</div>
22+
23+
<div class="modal-footer">
24+
<button type="button" class="btn btn-default" data-dismiss="modal" data-behaviour="form-clear">Cancel</button>
25+
<%= f.submit class: "btn btn-primary", data: { trigger: 'loading' } %>
26+
</div>
27+
<% end %>
28+
</div>
29+
</div>

app/views/expenses/new.js.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$("#new-expense-modal-form").html("<%= j render('expenses/modal_form_new', expense: @expense) %>");
2+
$('#new-expense-modal-form').modal('show')

app/views/incomes/new.html.erb

Lines changed: 0 additions & 1 deletion
This file was deleted.

app/views/mybudgets/_expenses.html.erb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
<h2>Expenses</h2>
44
<div> - this will do the same as above. There will be links for each allowing for the calculation of new expenses added on the spot.</div>
5-
<%= link_to 'Add Expense', new_mybudget_expense_path(@mybudget, @expense) %>
5+
6+
<%= link_to new_mybudget_expense_path(@mybudget, @expense),
7+
remote: true, id: "new-item-link", class: "btn btn-sm btn-default round" do %> New
8+
<%end%>
69

710
<table class="table" >
811
<thead>

app/views/mybudgets/_incomes.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<div class="bordered-form" >
22
<h2>Incomes</h2>
33
<div> - this is going to be an incomes show page which will list all of the incomes and allow the user to add new income values as the week goes. In the long run this will help keep track of projections.</div>
4-
5-
<!--<%= link_to 'Add Income', new_mybudget_income_path(@mybudget, @income) %>-->
4+
65
<%= link_to new_mybudget_income_path(@mybudget, @income),
76
remote: true, id: "new-item-link", class: "btn btn-sm btn-default round" do %> New
87
<%end%>

app/views/mybudgets/_transfers.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<div class="bordered-form" >
2-
<h2>transfers</h2>
2+
<h2>Transfers</h2>
33
<div> - this is going to be an transfers show page which will list all of the transfers and allow the user to add new transfer values as the week goes. In the long run this will help keep track of projections.</div>
44

5-
<!--<%= link_to 'Add transfer', new_mybudget_transfer_path(@mybudget, @transfer) %>-->
65
<%= link_to new_mybudget_transfer_path(@mybudget, @transfer),
76
remote: true, id: "new-item-link", class: "btn btn-sm btn-default round" do %> New
87
<%end%>

app/views/mybudgets/show.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@
2323

2424
<!-- Modal form -->
2525
<div class="modal fade" id='new-income-modal-form' role='dialog'></div>
26+
<div class="modal fade" id='new-expense-modal-form' role='dialog'></div>
27+
<div class="modal fade" id='new-transfer-modal-form' role='dialog'></div>
2628
<!-- Modal form -->
2729
</div>

0 commit comments

Comments
 (0)