Skip to content

Commit

Permalink
allow fertilizer trackers to be modifable via ui
Browse files Browse the repository at this point in the history
  • Loading branch information
one-m1nd committed Mar 8, 2024
1 parent 39915b2 commit e33d689
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 5 deletions.
26 changes: 26 additions & 0 deletions app/views/fertilizer_trackers/_fertilizer_tracker.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,30 @@
<%= link_to 'Edit this fertilizer tracker', edit_fertilizer_tracker_path(fertilizer_tracker), class: "rounded-lg py-3 ml-2 px-5 bg-gray-100 inline-block font-medium" %>
<hr class="mt-6">
<% end %>

<table class="table-auto border-spacing-4 border-separate border border-slate-900">
<thead>
<tr>
<th>Attribute</th>
<th>Value</th>
</tr>
</thead>
<tbody>

<tr>
<td class="border border-slate-900">ID</td>
<td class="border border-slate-900"><%= @fertilizer_tracker.id %></td>
</tr>

<tr>
<td class="border border-slate-900">Name</td>
<td class="border border-slate-900"><%= @fertilizer_tracker.name %></td>
</tr>

<tr>
<td class="border border-slate-900">Date</td>
<td class="border border-slate-900"><%= @fertilizer_tracker.date %></td>
</tr>
</tbody>
</table>
</div>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
json.extract! fertilizer_tracker, :id, :created_at, :updated_at
json.extract! fertilizer_tracker, :id, :name, :date, :created_at, :updated_at
json.url fertilizer_tracker_url(fertilizer_tracker, format: :json)
3 changes: 3 additions & 0 deletions app/views/fertilizer_trackers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
</div>
<% end %>
<%= form.text_field :name %>
<%= form.date_field :date %>

<div class="inline">
<%= form.submit class: "rounded-lg py-3 px-5 bg-blue-600 text-white inline-block font-medium cursor-pointer" %>
</div>
Expand Down
21 changes: 20 additions & 1 deletion app/views/fertilizer_trackers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@
</div>

<div id="fertilizer_trackers" class="min-w-full">
<%= render @fertilizer_trackers %>
<table class="table-auto border-spacing-4 border-separate border border-slate-900">
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th>Show</th>
</tr>
</thead>
<tbody>
<% @fertilizer_trackers.each do |tracker| %>
<tr>
<td class="border border-slate-900"><%= tracker.name %></td>
<td class="border border-slate-900"><%= tracker.date %></td>
<td class="border border-slate-900">
<a href="<%= fertilizer_tracker_url(tracker) %>">Show</a>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
6 changes: 3 additions & 3 deletions app/views/fertilizer_trackers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<%= render @fertilizer_tracker %>
<%= link_to 'Edit this fertilizer_tracker', edit_fertilizer_tracker_path(@fertilizer_tracker), class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to 'Edit this fertilizer tracker', edit_fertilizer_tracker_path(@fertilizer_tracker), 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 fertilizer_tracker', fertilizer_tracker_path(@fertilizer_tracker), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
<%= button_to 'Destroy this fertilizer tracker', fertilizer_tracker_path(@fertilizer_tracker), method: :delete, class: "mt-2 rounded-lg py-3 px-5 bg-gray-100 font-medium" %>
</div>
<%= link_to 'Back to fertilizer_trackers', fertilizer_trackers_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
<%= link_to 'Back to fertilizer trackers', fertilizer_trackers_path, class: "ml-2 rounded-lg py-3 px-5 bg-gray-100 inline-block font-medium" %>
</div>
</div>
1 change: 1 addition & 0 deletions app/views/layouts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<li><a href=<%= url_for(action: :index, controller: :families) %>>Families</a></li>
<li><a href=<%= url_for(action: :index, controller: :sunlight_hours) %>>Sunlight Hours</a></li>
<li><a href=<%= url_for(action: :index, controller: :watertrackers) %>>Water tracker</a></li>
<li><a href=<%= url_for(action: :index, controller: :fertilizer_trackers) %>>Fertilizer tracker</a></li>
</ul>

0 comments on commit e33d689

Please sign in to comment.