Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
New expenses modal
  • Loading branch information
SelenaSmall committed Sep 20, 2015
1 parent 1d4caf0 commit f66038b
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/controllers/expenses_controller.rb
Expand Up @@ -17,6 +17,7 @@ def create
if @expense.save
format.html { redirect_to [@mybudget, @expenses], notice: 'expense was successfully created.' }
format.json { render :show, status: :created, location: @expense }
format.js {redirect_via_turbolinks_to [@mybudget, @expenses]}
else
format.html { render :new }
format.json { render json: @expense.errors, status: :unprocessable_entity }
Expand Down
@@ -1,4 +1,4 @@
class TransferController < ApplicationController
class TransfersController < ApplicationController
before_action :set_mybudget
before_action :set_transfer, only: [:show, :edit, :update, :destroy]

Expand Down
29 changes: 29 additions & 0 deletions app/views/expenses/_modal_form_new.html.erb
@@ -0,0 +1,29 @@
<div class="modal-dialog reorder-modal-form">
<div class="modal-content">
<%= bootstrap_form_for([@mybudget, @expense], remote: true) do |f| %>
<div class="modal-header">
<h4 class="modal-title">New Income</h4>
</div>

<div class="modal-body">
<table>
<tr>
<td class="field-name">
<%= f.label :expense %><br>
</td>
<td class="field"><%= f.text_field :expense %></td>
</tr>
<tr>
<td class="field-name"> <%= f.label :amount %><br></td>
<td class="field"><%= f.number_field :amount %></td>
</tr>
</table>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" data-behaviour="form-clear">Cancel</button>
<%= f.submit class: "btn btn-primary", data: { trigger: 'loading' } %>
</div>
<% end %>
</div>
</div>
2 changes: 2 additions & 0 deletions app/views/expenses/new.js.erb
@@ -0,0 +1,2 @@
$("#new-expense-modal-form").html("<%= j render('expenses/modal_form_new', expense: @expense) %>");
$('#new-expense-modal-form').modal('show')
1 change: 0 additions & 1 deletion app/views/incomes/new.html.erb

This file was deleted.

5 changes: 4 additions & 1 deletion app/views/mybudgets/_expenses.html.erb
Expand Up @@ -2,7 +2,10 @@

<h2>Expenses</h2>
<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>
<%= link_to 'Add Expense', new_mybudget_expense_path(@mybudget, @expense) %>

<%= link_to new_mybudget_expense_path(@mybudget, @expense),
remote: true, id: "new-item-link", class: "btn btn-sm btn-default round" do %> New
<%end%>

<table class="table" >
<thead>
Expand Down
3 changes: 1 addition & 2 deletions app/views/mybudgets/_incomes.html.erb
@@ -1,8 +1,7 @@
<div class="bordered-form" >
<h2>Incomes</h2>
<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>

<!--<%= link_to 'Add Income', new_mybudget_income_path(@mybudget, @income) %>-->

<%= link_to new_mybudget_income_path(@mybudget, @income),
remote: true, id: "new-item-link", class: "btn btn-sm btn-default round" do %> New
<%end%>
Expand Down
3 changes: 1 addition & 2 deletions app/views/mybudgets/_transfers.html.erb
@@ -1,8 +1,7 @@
<div class="bordered-form" >
<h2>transfers</h2>
<h2>Transfers</h2>
<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>

<!--<%= link_to 'Add transfer', new_mybudget_transfer_path(@mybudget, @transfer) %>-->
<%= link_to new_mybudget_transfer_path(@mybudget, @transfer),
remote: true, id: "new-item-link", class: "btn btn-sm btn-default round" do %> New
<%end%>
Expand Down
2 changes: 2 additions & 0 deletions app/views/mybudgets/show.html.erb
Expand Up @@ -23,5 +23,7 @@

<!-- Modal form -->
<div class="modal fade" id='new-income-modal-form' role='dialog'></div>
<div class="modal fade" id='new-expense-modal-form' role='dialog'></div>
<div class="modal fade" id='new-transfer-modal-form' role='dialog'></div>
<!-- Modal form -->
</div>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f66038b

Please sign in to comment.