Track incomes
This commit is contained in:
parent
ab00344de0
commit
e098ab48ca
19 changed files with 337 additions and 1 deletions
42
app/views/incomes/_form.html.erb
Normal file
42
app/views/incomes/_form.html.erb
Normal file
|
@ -0,0 +1,42 @@
|
|||
<%= form_with(model: income, class: "contents") do |form| %>
|
||||
<% if income.errors.any? %>
|
||||
<div id="error_explanation" class="bg-red-50 text-red-500 px-3 py-2 font-medium rounded-lg mt-3">
|
||||
<h2><%= pluralize(income.errors.count, "error") %> prohibited this income from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% income.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :description %>
|
||||
<%= form.text_field :description, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :included %>
|
||||
<%= form.check_box :included, class: "block mt-2 h-5 w-5" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :amount %>
|
||||
<%= form.text_field :amount, class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full" %>
|
||||
</div>
|
||||
|
||||
<div class="my-5">
|
||||
<%= form.label :member_id %>
|
||||
<%=
|
||||
form.select :member_id,
|
||||
options_for_select(members, income.member_id),
|
||||
{},
|
||||
class: "block shadow rounded-md border border-gray-200 outline-none px-3 py-2 mt-2 w-full"
|
||||
%>
|
||||
</div>
|
||||
|
||||
<div class="inline">
|
||||
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
|
||||
</div>
|
||||
<% end %>
|
27
app/views/incomes/_income.html.erb
Normal file
27
app/views/incomes/_income.html.erb
Normal file
|
@ -0,0 +1,27 @@
|
|||
<div id="<%= dom_id income %>">
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Description:</strong>
|
||||
<%= income.description %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Included:</strong>
|
||||
<%= income.included %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Amount:</strong>
|
||||
<%= income.amount %>
|
||||
</p>
|
||||
|
||||
<p class="my-5">
|
||||
<strong class="block font-medium mb-1">Member:</strong>
|
||||
<%= income.member_id %>
|
||||
</p>
|
||||
|
||||
<% if action_name != "show" %>
|
||||
<%= link_to "Show this income", income, class: "rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to 'Edit this income', edit_income_path(income), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<hr class="mt-6">
|
||||
<% end %>
|
||||
</div>
|
2
app/views/incomes/_income.json.jbuilder
Normal file
2
app/views/incomes/_income.json.jbuilder
Normal file
|
@ -0,0 +1,2 @@
|
|||
json.extract! income, :id, :description, :included, :amount, :member_id, :created_at, :updated_at
|
||||
json.url income_url(income, format: :json)
|
8
app/views/incomes/edit.html.erb
Normal file
8
app/views/incomes/edit.html.erb
Normal file
|
@ -0,0 +1,8 @@
|
|||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">Editing income</h1>
|
||||
|
||||
<%= render "form", income: @income %>
|
||||
|
||||
<%= link_to "Show this income", @income, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<%= link_to "Back to incomes", incomes_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
14
app/views/incomes/index.html.erb
Normal file
14
app/views/incomes/index.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<div class="w-full">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<h1 class="font-bold text-4xl">Incomes</h1>
|
||||
<%= link_to 'New income', new_income_path, class: "rounded-lg py-3 px-5 bg-blue-600 text-white block font-medium" %>
|
||||
</div>
|
||||
|
||||
<div id="incomes" class="min-w-full">
|
||||
<%= render @incomes %>
|
||||
</div>
|
||||
</div>
|
1
app/views/incomes/index.json.jbuilder
Normal file
1
app/views/incomes/index.json.jbuilder
Normal file
|
@ -0,0 +1 @@
|
|||
json.array! @incomes, partial: "incomes/income", as: :income
|
7
app/views/incomes/new.html.erb
Normal file
7
app/views/incomes/new.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<div class="mx-auto md:w-2/3 w-full">
|
||||
<h1 class="font-bold text-4xl">New income</h1>
|
||||
|
||||
<%= render "form", income: @income %>
|
||||
|
||||
<%= link_to 'Back to incomes', incomes_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
15
app/views/incomes/show.html.erb
Normal file
15
app/views/incomes/show.html.erb
Normal file
|
@ -0,0 +1,15 @@
|
|||
<div class="mx-auto md:w-2/3 w-full flex">
|
||||
<div class="mx-auto">
|
||||
<% if notice.present? %>
|
||||
<p class="py-2 px-3 bg-green-50 mb-5 text-green-500 font-medium rounded-lg inline-block" id="notice"><%= notice %></p>
|
||||
<% end %>
|
||||
|
||||
<%= render @income %>
|
||||
|
||||
<%= link_to 'Edit this income', edit_income_path(@income), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
<div class="inline-block ml-2">
|
||||
<%= button_to 'Destroy this income', income_path(@income), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
|
||||
</div>
|
||||
<%= link_to 'Back to incomes', incomes_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
|
||||
</div>
|
||||
</div>
|
1
app/views/incomes/show.json.jbuilder
Normal file
1
app/views/incomes/show.json.jbuilder
Normal file
|
@ -0,0 +1 @@
|
|||
json.partial! "incomes/income", income: @income
|
Loading…
Add table
Add a link
Reference in a new issue