Adds view mode on budget investments
This commit is contained in:
@@ -147,6 +147,10 @@ module Budgets
|
|||||||
TagCloud.new(Budget::Investment, params[:search])
|
TagCloud.new(Budget::Investment, params[:search])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_view
|
||||||
|
@view = (params[:view] == "minimal") ? "minimal" : "default"
|
||||||
|
end
|
||||||
|
|
||||||
def investments
|
def investments
|
||||||
if @current_order == 'random'
|
if @current_order == 'random'
|
||||||
@investments.apply_filters_and_search(@budget, params, @current_filter)
|
@investments.apply_filters_and_search(@budget, params, @current_filter)
|
||||||
|
|||||||
30
app/views/budgets/investments/_view_mode.html.erb
Normal file
30
app/views/budgets/investments/_view_mode.html.erb
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<div class="float-right view-mode <%= @view %>">
|
||||||
|
<button class="button" type="button" data-toggle="view_mode">
|
||||||
|
<span class="show-for-sr"><%= t("shared.view_mode.title") %></span>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div class="dropdown-pane" id="view_mode" data-dropdown data-hover="true" data-hover-pane="true">
|
||||||
|
<span class="uppercase">
|
||||||
|
<strong>
|
||||||
|
<%= t("shared.view_mode.title") %>
|
||||||
|
</strong>
|
||||||
|
</span>
|
||||||
|
<ul class="no-bullet">
|
||||||
|
<% if investments_default_view? %>
|
||||||
|
<li class="view-card active">
|
||||||
|
<%= t("shared.view_mode.cards") %>
|
||||||
|
</li>
|
||||||
|
<li class="view-list">
|
||||||
|
<%= link_to t("shared.view_mode.list"), investments_minimal_view_path %>
|
||||||
|
</li>
|
||||||
|
<% else %>
|
||||||
|
<li class="view-card">
|
||||||
|
<%= link_to t("shared.view_mode.cards"), investments_minimal_view_path %>
|
||||||
|
</li>
|
||||||
|
<li class="view-list active">
|
||||||
|
<%= t("shared.view_mode.list") %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -50,6 +50,7 @@
|
|||||||
<% elsif @heading.present? %>
|
<% elsif @heading.present? %>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
|
<%= render "view_mode" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -43,6 +43,37 @@ feature 'Budget Investments' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario 'Index view mode' do
|
||||||
|
investments = [create(:budget_investment, heading: heading),
|
||||||
|
create(:budget_investment, heading: heading),
|
||||||
|
create(:budget_investment, heading: heading)]
|
||||||
|
|
||||||
|
visit budget_path(budget)
|
||||||
|
click_link 'Health'
|
||||||
|
|
||||||
|
click_button 'View mode'
|
||||||
|
|
||||||
|
click_link 'List'
|
||||||
|
|
||||||
|
investments.each do |investment|
|
||||||
|
within('#budget-investments') do
|
||||||
|
expect(page).to have_link investment.title
|
||||||
|
expect(page).to_not have_content(investment.description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
click_button 'View mode'
|
||||||
|
|
||||||
|
click_link 'Cards'
|
||||||
|
|
||||||
|
investments.each do |investment|
|
||||||
|
within('#budget-investments') do
|
||||||
|
expect(page).to have_link investment.title
|
||||||
|
expect(page).to have_content(investment.description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
scenario 'Index should show investment descriptive image only when is defined' do
|
scenario 'Index should show investment descriptive image only when is defined' do
|
||||||
investment = create(:budget_investment, heading: heading)
|
investment = create(:budget_investment, heading: heading)
|
||||||
investment_with_image = create(:budget_investment, heading: heading)
|
investment_with_image = create(:budget_investment, heading: heading)
|
||||||
|
|||||||
Reference in New Issue
Block a user