Orgas filtering can now use the near scope
This commit is contained in:
parent
12ba0c42dd
commit
01ae744c7b
@ -9,7 +9,7 @@ class OrgasController < ApplicationController
|
||||
unless: :check_secret
|
||||
|
||||
def index
|
||||
@unfiltered_orgas = apply_scopes(Orga.moderated).includes(:kind, :region)
|
||||
@unfiltered_orgas = apply_scopes(Orga.moderated)
|
||||
@search = @unfiltered_orgas.search params[:q]
|
||||
@search.sorts = 'updated_at desc' if @search.sorts.empty?
|
||||
@orgas = @search.result.page params[:page]
|
||||
|
@ -2,16 +2,17 @@
|
||||
- p = params[:q].clone
|
||||
|
||||
%ul.counters
|
||||
- Kind.all.each do |kind|
|
||||
-# The reorder and specific count are required for the "near" scope
|
||||
- @unfiltered_orgas.reorder('').group(:kind).count(:id).each do |kind, count|
|
||||
- p[:kind_id_eq] = kind.id
|
||||
%li{ title: Kind.human_attribute_name("name_#{kind.name}") }
|
||||
= link_to orgas_url(q: p) do
|
||||
%em.fa{ class: "fa-#{kind.icon}" }
|
||||
= @unfiltered_orgas.kind(kind).count
|
||||
= count
|
||||
|
||||
%li
|
||||
- p[:kind_id_eq] = params[:q][:kind_id_eq]
|
||||
- p[:active_eq] = true
|
||||
= link_to orgas_url(q: p) do
|
||||
%em.fa.fa-heartbeat
|
||||
= @unfiltered_orgas.active.count
|
||||
= @unfiltered_orgas.active.count :id
|
||||
|
@ -5,84 +5,89 @@
|
||||
:markdown
|
||||
#{t '.helper'}
|
||||
|
||||
= form_tag events_url, method: :get do
|
||||
.field.near_location
|
||||
= label_tag 'near[location]', t('.near_location')
|
||||
= text_field_tag 'near[location]', params['near[location]'],
|
||||
placeholder: t('.near_location_helper')
|
||||
%fieldset
|
||||
= form_tag events_url, method: :get do
|
||||
.field.near_location
|
||||
= label_tag 'near[location]', t('.near_location')
|
||||
= text_field_tag 'near[location]', params['near[location]'],
|
||||
placeholder: t('.near_location_helper')
|
||||
|
||||
.field.near_distance
|
||||
= label_tag 'near[distance]', t('.near_distance')
|
||||
= number_field_tag 'near[distance]', params['near[distance]'],
|
||||
placeholder: t('.near_distance_helper')
|
||||
km
|
||||
.field.near_distance
|
||||
= label_tag 'near[distance]', t('.near_distance')
|
||||
= number_field_tag 'near[distance]', params['near[distance]'],
|
||||
placeholder: t('.near_distance_helper')
|
||||
km
|
||||
|
||||
.field.region
|
||||
= label_tag :region, t('.region')
|
||||
= select_tag :region,
|
||||
options_from_collection_for_select(Region.all, :id, :name,
|
||||
session[:region]),
|
||||
include_blank: true
|
||||
.field.region
|
||||
= label_tag :region, t('.region')
|
||||
= select_tag :region,
|
||||
options_from_collection_for_select(Region.all, :id, :name,
|
||||
session[:region]),
|
||||
include_blank: true
|
||||
|
||||
.helper
|
||||
:markdown
|
||||
#{t '.period_year_helper'}
|
||||
.field.period_year
|
||||
= label_tag 'period[year]', t('.period_year')
|
||||
= number_field_tag 'period[year]', params['period[year]'],
|
||||
placeholder: "Ex: #{(Time.zone.today + 7.days).year}"
|
||||
.field.period_week
|
||||
= label_tag 'period[week]', t('.period_week')
|
||||
= number_field_tag 'period[week]', params['period[week]'],
|
||||
placeholder: "Ex: #{(Time.zone.today + 7.days).cweek}"
|
||||
.field.tags
|
||||
= label_tag :tag, t('.tag')
|
||||
= text_field_tag :tag
|
||||
|
||||
.field.tags
|
||||
= label_tag :tag, t('.tag')
|
||||
= text_field_tag :tag
|
||||
.field.future
|
||||
= label_tag :future, t('.past')
|
||||
= check_box_tag :future, :false
|
||||
= t '.past_helper'
|
||||
|
||||
.field.future
|
||||
= label_tag :future, t('.past')
|
||||
= check_box_tag :future, :false
|
||||
= t '.past_helper'
|
||||
.field.iframe
|
||||
= label_tag :iframe, t('.iframe')
|
||||
= check_box_tag :iframe, :false
|
||||
= t '.iframe_helper'
|
||||
|
||||
.field.iframe
|
||||
= label_tag :iframe, t('.iframe')
|
||||
= check_box_tag :iframe, :false
|
||||
= t '.iframe_helper'
|
||||
.actions
|
||||
= button_tag do
|
||||
%em.fa.fa-calendar
|
||||
= t '.events'
|
||||
|
||||
.actions
|
||||
= button_tag do
|
||||
%em.fa.fa-calendar
|
||||
= t '.events'
|
||||
= button_tag formaction: maps_url do
|
||||
%em.fa.fa-map-marker
|
||||
= t '.map'
|
||||
|
||||
= button_tag formaction: maps_url do
|
||||
%em.fa.fa-map-marker
|
||||
= t '.map'
|
||||
= button_tag formaction: maps_url(format: :json) do
|
||||
%em.fa.fa-map-pin
|
||||
= t '.geojson'
|
||||
|
||||
= button_tag formaction: maps_url(format: :json) do
|
||||
%em.fa.fa-map-pin
|
||||
= t '.geojson'
|
||||
= button_tag formaction: events_url(format: :json) do
|
||||
%em.fa {}
|
||||
= t '.json'
|
||||
|
||||
= button_tag formaction: events_url(format: :json) do
|
||||
%em.fa {}
|
||||
= t '.json'
|
||||
= button_tag formaction: events_url(format: :rss) do
|
||||
%em.fa.fa-rss
|
||||
= t '.rss'
|
||||
|
||||
= button_tag formaction: events_url(format: :rss) do
|
||||
%em.fa.fa-rss
|
||||
= t '.rss'
|
||||
= button_tag formaction: events_url(format: :ics) do
|
||||
%em.fa.fa-calendar-check-o
|
||||
= t '.ics'
|
||||
|
||||
= button_tag formaction: events_url(format: :ics) do
|
||||
%em.fa.fa-calendar-check-o
|
||||
= t '.ics'
|
||||
= button_tag formaction: events_url(format: :xml) do
|
||||
%em.fa.fa-code
|
||||
= t '.xml'
|
||||
|
||||
= button_tag formaction: events_url(format: :xml) do
|
||||
%em.fa.fa-code
|
||||
= t '.xml'
|
||||
= button_tag formaction: orgas_url do
|
||||
%em.fa.fa-users
|
||||
= t '.orgas'
|
||||
|
||||
= button_tag formaction: orgas_url do
|
||||
%em.fa.fa-users
|
||||
= t '.orgas'
|
||||
%fieldset
|
||||
= form_tag events_url, method: :get do
|
||||
.helper
|
||||
:markdown
|
||||
#{t '.period_year_helper'}
|
||||
.field.period_year
|
||||
= label_tag 'period[year]', t('.period_year')
|
||||
= number_field_tag 'period[year]', params['period[year]'],
|
||||
placeholder: "Ex: #{(Time.zone.today + 7.days).year}"
|
||||
.field.period_week
|
||||
= label_tag 'period[week]', t('.period_week')
|
||||
= number_field_tag 'period[week]', params['period[week]'],
|
||||
placeholder: "Ex: #{(Time.zone.today + 7.days).cweek}"
|
||||
|
||||
.actions
|
||||
= button_tag formaction: digest_url(:markdown) do
|
||||
%em.fa.fa-hashtag
|
||||
= t '.digest'
|
||||
|
||||
= button_tag formaction: digest_url(:markdown) do
|
||||
%em.fa.fa-hashtag
|
||||
= t '.digest'
|
||||
|
Loading…
Reference in New Issue
Block a user