adds a helper to simplify the way selects and filters are rendered
This commit is contained in:
@@ -14,4 +14,10 @@ module ApplicationHelper
|
|||||||
home_page? ? '' : 'results'
|
home_page? ? '' : 'results'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# if current path is /debates current_path_with_query_params(foo: 'bar') returns /debates?foo=bar
|
||||||
|
# notice: if query_params have a param which also exist in current path, it "overrides" (query_params is merged last)
|
||||||
|
def current_path_with_query_params(query_parameters)
|
||||||
|
url_for(request.query_parameters.merge(query_parameters))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<dd class="active"><%= t("admin.comments.index.filters.#{filter}") %></dd>
|
<dd class="active"><%= t("admin.comments.index.filters.#{filter}") %></dd>
|
||||||
<% else %>
|
<% else %>
|
||||||
<dd><%= link_to t("admin.comments.index.filters.#{filter}"),
|
<dd><%= link_to t("admin.comments.index.filters.#{filter}"),
|
||||||
admin_comments_path(filter: filter) %></dd>
|
current_path_with_query_params(filter: filter) %></dd>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<dd class="active"><%= t("admin.debates.index.filters.#{filter}") %></dd>
|
<dd class="active"><%= t("admin.debates.index.filters.#{filter}") %></dd>
|
||||||
<% else %>
|
<% else %>
|
||||||
<dd><%= link_to t("admin.debates.index.filters.#{filter}"),
|
<dd><%= link_to t("admin.debates.index.filters.#{filter}"),
|
||||||
admin_debates_path(filter: filter) %></dd>
|
current_path_with_query_params(filter: filter) %></dd>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<dd class="active"><%= t("admin.organizations.index.filters.#{filter}") %></dd>
|
<dd class="active"><%= t("admin.organizations.index.filters.#{filter}") %></dd>
|
||||||
<% else %>
|
<% else %>
|
||||||
<dd><%= link_to t("admin.organizations.index.filters.#{filter}"),
|
<dd><%= link_to t("admin.organizations.index.filters.#{filter}"),
|
||||||
admin_organizations_path(filter: filter) %></dd>
|
current_path_with_query_params(filter: filter) %></dd>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<dd class="active"><%= t("admin.users.index.filters.#{filter}") %></dd>
|
<dd class="active"><%= t("admin.users.index.filters.#{filter}") %></dd>
|
||||||
<% else %>
|
<% else %>
|
||||||
<dd><%= link_to t("admin.users.index.filters.#{filter}"),
|
<dd><%= link_to t("admin.users.index.filters.#{filter}"),
|
||||||
admin_users_path(filter: filter) %></dd>
|
current_path_with_query_params(filter: filter) %></dd>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<select class="js-location-changer" name="tag-filter">
|
<select class="js-location-changer" name="tag-filter">
|
||||||
<option value="/" selected="selected"><%= t("debates.index.all") %></option>
|
<option value="/" selected="selected"><%= t("debates.index.all") %></option>
|
||||||
<% @tags.each do |tag| %>
|
<% @tags.each do |tag| %>
|
||||||
<option value='<%= url_for(request.query_parameters.merge(tag: tag.name))%>'>
|
<option value='<%= current_path_with_query_params(tag: tag.name) %>'>
|
||||||
<%= tag.name %>
|
<%= tag.name %>
|
||||||
</option>
|
</option>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
<select class="js-location-changer" name="order-selector">
|
<select class="js-location-changer" name="order-selector">
|
||||||
<% @valid_orders.each do |order| %>
|
<% @valid_orders.each do |order| %>
|
||||||
<option <%= 'selected' if order == @order %>
|
<option <%= 'selected' if order == @order %>
|
||||||
value='<%= url_for(request.query_parameters.merge(order: order))%>'>
|
value='<%= current_path_with_query_params(order: order) %>'>
|
||||||
<%= t("debates.index.orders.#{order}") %>
|
<%= t("debates.index.orders.#{order}") %>
|
||||||
</option>
|
</option>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<dd class="active"><%= t("moderation.comments.index.filters.#{filter}") %></dd>
|
<dd class="active"><%= t("moderation.comments.index.filters.#{filter}") %></dd>
|
||||||
<% else %>
|
<% else %>
|
||||||
<dd><%= link_to t("moderation.comments.index.filters.#{filter}"),
|
<dd><%= link_to t("moderation.comments.index.filters.#{filter}"),
|
||||||
moderation_comments_path(filter: filter) %></dd>
|
current_path_with_query_params(filter: filter) %></dd>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<dd class="active"><%= t("moderation.debates.index.filters.#{filter}") %></dd>
|
<dd class="active"><%= t("moderation.debates.index.filters.#{filter}") %></dd>
|
||||||
<% else %>
|
<% else %>
|
||||||
<dd><%= link_to t("moderation.debates.index.filters.#{filter}"),
|
<dd><%= link_to t("moderation.debates.index.filters.#{filter}"),
|
||||||
moderation_debates_path(filter: filter) %></dd>
|
current_path_with_query_params(filter: filter) %></dd>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</dl>
|
</dl>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<select class="js-location-changer locale-switcher" name="locale-switcher">
|
<select class="js-location-changer locale-switcher" name="locale-switcher">
|
||||||
<% I18n.available_locales.map do |loc| %>
|
<% I18n.available_locales.map do |loc| %>
|
||||||
<option <%= 'selected' if loc == I18n.locale %>
|
<option <%= 'selected' if loc == I18n.locale %>
|
||||||
value='<%= url_for(request.query_parameters.merge(locale: loc))%>'>
|
value='<%= current_path_with_query_params(locale: loc) %>'>
|
||||||
<%= I18n.t('locale', locale: loc) %>
|
<%= I18n.t('locale', locale: loc) %>
|
||||||
</option>
|
</option>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user