Skip to content

Commit

Permalink
Merge pull request #46 from SergioPeralta22/features/style_and_fix_links
Browse files Browse the repository at this point in the history
Improve Style and Fix Links
  • Loading branch information
Mar12358 authored Sep 8, 2023
2 parents 632a599 + 8ca2258 commit 6a1ed1d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 28 deletions.
3 changes: 2 additions & 1 deletion app/controllers/recipe_foods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ def create
end

def destroy
@recipe_id = params[:recipe_id]
@recipe_food = RecipeFood.find(params[:id])
return unless @recipe_food.destroy

redirect_to recipes_path, notice: 'Post was successfully deleted.'
redirect_to recipe_path(id: @recipe_food.recipe_id), notice: 'Post was successfully deleted.'
end

private
Expand Down
8 changes: 0 additions & 8 deletions app/views/devise/shared/_links.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end %>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end %>
Expand Down
20 changes: 8 additions & 12 deletions app/views/inventory_foods/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
<a href="<%= inventory_foods_path %>">
<button id="back-btn">⬅ Back</button>
</a>

<h1 id = "form-title">Add new Food to Inventory</h1>
<h1 id = "form-title", class = "text-center m-2">Add new Food to Inventory</h1>
<%= form_with(model: [@inventory_food], url: inventory_foods_path) do |form| %>
<div class = "form-container">
<div class="field">
<div class="form-group text-center mt-2">
<%= form.hidden_field :inventory_id, value: @inventory_id %>
</div>
<div class="field">
<%= form.collection_select :food_id, Food.all, :id, :name, prompt: "Select a Food" %>
<div class="form-group text-center mt-2">
<%= form.collection_select(:food_id, Food.all, :id, :name, { prompt: "Select a Food" }, { class: "form-select" }) %>
</div>
<div class="field">
<%= form.number_field :quantity, autofocus: true, autocomplete: "quantity", placeholder: "Quantity", class: "border-black border-solid border-2 mt-4" %>
<div class="form-group text-center mt-2">
<%= form.number_field :quantity, autofocus: true, autocomplete: "quantity", placeholder: "Quantity", class: "form-control" %>
</div>



<div class="actions">
<%= form.submit 'Add Food to Inventory' %>
<div class="text-center">
<%= form.submit 'Add Food to Inventory', class: "btn btn-primary mt-3"%>
</div>
</div>
<% end %>
10 changes: 5 additions & 5 deletions app/views/recipe_foods/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<h1 id = "form-title", class = "text-center m-2">Add new Food to Recipe</h1>
<%= form_with(model: [@recipe_food], url: recipe_foods_path) do |form| %>
<div class="d-flex justify-content-evenly">
<div class="d-flex justify-content-center gap-2 w-100">
<div class="field">
<%= form.hidden_field :recipe_id, value: @recipe_id %>
</div>
<div class="field">
<%= form.label :name %><br>
<%= form.collection_select :food_id, Food.all, :id, :name, prompt: "Select a Food",class: "w-100" %>
<%= form.collection_select(:food_id, Food.all, :id, :name, { prompt: "Select a Food" }, { class: "form-select" }) %>
</div>
<div class="field">
<%= form.label :quantity %><br>
<%= form.number_field :quantity, autofocus: true, autocomplete: "quantity", placeholder: "Quantity" %>
</div>
<div>
<%= form.label :action %><br>
<%= form.submit %>
<div class="text-center">
<%= form.submit 'Add Food to Recipe', class: "btn btn-primary mt-3"%>
</div>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/recipes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
<tr>
<th>Food</th>
<th>Quantity</th>
<th>Value</th>
<th>Value per Unit</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @recipe_food.each do |recipe_food| %>
<tr>
<td><%= recipe_food.food.name %></td>
<td><%= recipe_food.quantity %><%= recipe_food.food.measurement_unit %></td>
<td><%= recipe_food.quantity %> <%= recipe_food.food.measurement_unit %></td>
<td>$ <%= recipe_food.food.price %></td>
<% if can? :destroy, recipe_food %>
<td><%= link_to "Delete", recipe_food, class: "btn btn-danger", method: :delete, data: { "turbo-method": :delete, turbo_confirm: "Are you sure?" } %></td>
Expand Down

0 comments on commit 6a1ed1d

Please sign in to comment.