bit of UI cleanup
This commit is contained in:
parent
2ea20048d4
commit
977e0e8d6a
@ -21,20 +21,14 @@ module ApplicationHelper
|
|||||||
nav = [
|
nav = [
|
||||||
nav_item('Recipes', recipes_path, 'recipes'),
|
nav_item('Recipes', recipes_path, 'recipes'),
|
||||||
nav_item('Ingredients', ingredients_path, 'ingredients'),
|
nav_item('Ingredients', ingredients_path, 'ingredients'),
|
||||||
nav_item('Logs', logs_path, 'logs'),
|
nav_item('Logs', logs_path, 'logs', current_user?),
|
||||||
nav_item('Calculator', calculator_path, 'calculator'),
|
nav_item('Calculator', calculator_path, 'calculator'),
|
||||||
nav_item('About', about_path, 'home')
|
nav_item('About', about_path, 'home'),
|
||||||
|
nav_item('Notes', notes_path, 'notes', current_user?),
|
||||||
|
nav_item('Admin', admin_users_path, 'admin/users', current_user? && current_user.admin?)
|
||||||
]
|
]
|
||||||
|
|
||||||
if current_user
|
nav.compact
|
||||||
nav << nav_item('Notes', notes_path, 'notes')
|
|
||||||
end
|
|
||||||
|
|
||||||
if current_user && current_user.admin?
|
|
||||||
nav << nav_item('Admin', admin_users_path, 'admin/users')
|
|
||||||
end
|
|
||||||
|
|
||||||
nav
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def profile_nav_items
|
def profile_nav_items
|
||||||
@ -57,8 +51,8 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def nav_item(name, url, controller = nil)
|
def nav_item(name, url, controller = nil, visible = true)
|
||||||
content_tag('li', link_to(name, url), class: active_for_controller(controller))
|
!visible ? nil : content_tag('li', link_to(name, url), class: active_for_controller(controller))
|
||||||
end
|
end
|
||||||
|
|
||||||
def active_for_controller(controller)
|
def active_for_controller(controller)
|
||||||
|
@ -8,7 +8,9 @@
|
|||||||
<p>No Ingredients</p>
|
<p>No Ingredients</p>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
||||||
|
<% if current_user? %>
|
||||||
<%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-default' %>
|
<%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-default' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
@ -19,22 +21,26 @@
|
|||||||
<th>USDA</th>
|
<th>USDA</th>
|
||||||
<th>KCal per 100g</th>
|
<th>KCal per 100g</th>
|
||||||
<th>Density (oz/cup)</th>
|
<th>Density (oz/cup)</th>
|
||||||
|
<% if current_user? %>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<% decorate(@ingredients, IngredientDecorator).each do |ingredient| %>
|
<% decorate(@ingredients, IngredientDecorator).each do |ingredient| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= link_to ingredient.name, edit_ingredient_path(ingredient) %></td>
|
<td><%= link_to_if current_user?, ingredient.name, edit_ingredient_path(ingredient) %></td>
|
||||||
<td><%= ingredient.ndbn_check %></td>
|
<td><%= ingredient.ndbn_check %></td>
|
||||||
<td><%= ingredient.kcal %></td>
|
<td><%= ingredient.kcal %></td>
|
||||||
<td><%= ingredient.density %></td>
|
<td><%= ingredient.density %></td>
|
||||||
|
<% if current_user? %>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to ingredient, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-xs btn-danger' do %>
|
<%= link_to ingredient, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-xs btn-danger' do %>
|
||||||
<span class="glyphicon glyphicon-remove"></span>
|
<span class="glyphicon glyphicon-remove"></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
<% end %>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -43,7 +49,9 @@
|
|||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
<% if current_user? %>
|
||||||
<%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-default' %>
|
<%= link_to 'New Ingredient', new_ingredient_path, class: 'btn btn-default' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
3
app/views/kaminari/_first_page.html.erb
Normal file
3
app/views/kaminari/_first_page.html.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<li>
|
||||||
|
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
|
||||||
|
</li>
|
3
app/views/kaminari/_gap.html.erb
Normal file
3
app/views/kaminari/_gap.html.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<li class='disabled'>
|
||||||
|
<%= content_tag :a, raw(t 'views.pagination.truncate') %>
|
||||||
|
</li>
|
3
app/views/kaminari/_last_page.html.erb
Normal file
3
app/views/kaminari/_last_page.html.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<li>
|
||||||
|
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
|
||||||
|
</li>
|
3
app/views/kaminari/_next_page.html.erb
Normal file
3
app/views/kaminari/_next_page.html.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<li>
|
||||||
|
<%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
|
||||||
|
</li>
|
9
app/views/kaminari/_page.html.erb
Normal file
9
app/views/kaminari/_page.html.erb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<% if page.current? %>
|
||||||
|
<li class='active'>
|
||||||
|
<%= content_tag :a, page, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)) %>
|
||||||
|
</li>
|
||||||
|
<% else %>
|
||||||
|
<li>
|
||||||
|
<%= link_to page, url, remote: remote, rel: (page.next? ? 'next' : (page.prev? ? 'prev' : nil)) %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
15
app/views/kaminari/_paginator.html.erb
Normal file
15
app/views/kaminari/_paginator.html.erb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<%= paginator.render do -%>
|
||||||
|
<ul class="pagination">
|
||||||
|
<%= first_page_tag unless current_page.first? %>
|
||||||
|
<%= prev_page_tag unless current_page.first? %>
|
||||||
|
<% each_page do |page| -%>
|
||||||
|
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
|
||||||
|
<%= page_tag page %>
|
||||||
|
<% elsif !page.was_truncated? -%>
|
||||||
|
<%= gap_tag %>
|
||||||
|
<% end -%>
|
||||||
|
<% end -%>
|
||||||
|
<%= next_page_tag unless current_page.last? %>
|
||||||
|
<%= last_page_tag unless current_page.last? %>
|
||||||
|
</ul>
|
||||||
|
<% end -%>
|
3
app/views/kaminari/_prev_page.html.erb
Normal file
3
app/views/kaminari/_prev_page.html.erb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<li>
|
||||||
|
<%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
|
||||||
|
</li>
|
@ -9,7 +9,9 @@
|
|||||||
<p>No Recipes</p>
|
<p>No Recipes</p>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
||||||
|
<% if current_user? %>
|
||||||
<%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %><br/>
|
<%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %><br/>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<%= paginate @recipes %>
|
<%= paginate @recipes %>
|
||||||
|
|
||||||
@ -69,7 +71,9 @@
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %>
|
<% if current_user? %>
|
||||||
|
<%= link_to 'New Recipe', new_recipe_path, class: 'btn btn-default' %><br/>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue
Block a user