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
|
unless: :check_secret
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@unfiltered_orgas = apply_scopes(Orga.moderated).includes(:kind, :region)
|
@unfiltered_orgas = apply_scopes(Orga.moderated)
|
||||||
@search = @unfiltered_orgas.search params[:q]
|
@search = @unfiltered_orgas.search params[:q]
|
||||||
@search.sorts = 'updated_at desc' if @search.sorts.empty?
|
@search.sorts = 'updated_at desc' if @search.sorts.empty?
|
||||||
@orgas = @search.result.page params[:page]
|
@orgas = @search.result.page params[:page]
|
||||||
|
|
|
@ -2,16 +2,17 @@
|
||||||
- p = params[:q].clone
|
- p = params[:q].clone
|
||||||
|
|
||||||
%ul.counters
|
%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
|
- p[:kind_id_eq] = kind.id
|
||||||
%li{ title: Kind.human_attribute_name("name_#{kind.name}") }
|
%li{ title: Kind.human_attribute_name("name_#{kind.name}") }
|
||||||
= link_to orgas_url(q: p) do
|
= link_to orgas_url(q: p) do
|
||||||
%em.fa{ class: "fa-#{kind.icon}" }
|
%em.fa{ class: "fa-#{kind.icon}" }
|
||||||
= @unfiltered_orgas.kind(kind).count
|
= count
|
||||||
|
|
||||||
%li
|
%li
|
||||||
- p[:kind_id_eq] = params[:q][:kind_id_eq]
|
- p[:kind_id_eq] = params[:q][:kind_id_eq]
|
||||||
- p[:active_eq] = true
|
- p[:active_eq] = true
|
||||||
= link_to orgas_url(q: p) do
|
= link_to orgas_url(q: p) do
|
||||||
%em.fa.fa-heartbeat
|
%em.fa.fa-heartbeat
|
||||||
= @unfiltered_orgas.active.count
|
= @unfiltered_orgas.active.count :id
|
||||||
|
|
|
@ -5,84 +5,89 @@
|
||||||
:markdown
|
:markdown
|
||||||
#{t '.helper'}
|
#{t '.helper'}
|
||||||
|
|
||||||
= form_tag events_url, method: :get do
|
%fieldset
|
||||||
.field.near_location
|
= form_tag events_url, method: :get do
|
||||||
= label_tag 'near[location]', t('.near_location')
|
.field.near_location
|
||||||
= text_field_tag 'near[location]', params['near[location]'],
|
= label_tag 'near[location]', t('.near_location')
|
||||||
placeholder: t('.near_location_helper')
|
= text_field_tag 'near[location]', params['near[location]'],
|
||||||
|
placeholder: t('.near_location_helper')
|
||||||
|
|
||||||
.field.near_distance
|
.field.near_distance
|
||||||
= label_tag 'near[distance]', t('.near_distance')
|
= label_tag 'near[distance]', t('.near_distance')
|
||||||
= number_field_tag 'near[distance]', params['near[distance]'],
|
= number_field_tag 'near[distance]', params['near[distance]'],
|
||||||
placeholder: t('.near_distance_helper')
|
placeholder: t('.near_distance_helper')
|
||||||
km
|
km
|
||||||
|
|
||||||
.field.region
|
.field.region
|
||||||
= label_tag :region, t('.region')
|
= label_tag :region, t('.region')
|
||||||
= select_tag :region,
|
= select_tag :region,
|
||||||
options_from_collection_for_select(Region.all, :id, :name,
|
options_from_collection_for_select(Region.all, :id, :name,
|
||||||
session[:region]),
|
session[:region]),
|
||||||
include_blank: true
|
include_blank: true
|
||||||
|
|
||||||
.helper
|
.field.tags
|
||||||
:markdown
|
= label_tag :tag, t('.tag')
|
||||||
#{t '.period_year_helper'}
|
= text_field_tag :tag
|
||||||
.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
|
.field.future
|
||||||
= label_tag :tag, t('.tag')
|
= label_tag :future, t('.past')
|
||||||
= text_field_tag :tag
|
= check_box_tag :future, :false
|
||||||
|
= t '.past_helper'
|
||||||
|
|
||||||
.field.future
|
.field.iframe
|
||||||
= label_tag :future, t('.past')
|
= label_tag :iframe, t('.iframe')
|
||||||
= check_box_tag :future, :false
|
= check_box_tag :iframe, :false
|
||||||
= t '.past_helper'
|
= t '.iframe_helper'
|
||||||
|
|
||||||
.field.iframe
|
.actions
|
||||||
= label_tag :iframe, t('.iframe')
|
= button_tag do
|
||||||
= check_box_tag :iframe, :false
|
%em.fa.fa-calendar
|
||||||
= t '.iframe_helper'
|
= t '.events'
|
||||||
|
|
||||||
.actions
|
= button_tag formaction: maps_url do
|
||||||
= button_tag do
|
%em.fa.fa-map-marker
|
||||||
%em.fa.fa-calendar
|
= t '.map'
|
||||||
= t '.events'
|
|
||||||
|
|
||||||
= button_tag formaction: maps_url do
|
= button_tag formaction: maps_url(format: :json) do
|
||||||
%em.fa.fa-map-marker
|
%em.fa.fa-map-pin
|
||||||
= t '.map'
|
= t '.geojson'
|
||||||
|
|
||||||
= button_tag formaction: maps_url(format: :json) do
|
= button_tag formaction: events_url(format: :json) do
|
||||||
%em.fa.fa-map-pin
|
%em.fa {}
|
||||||
= t '.geojson'
|
= t '.json'
|
||||||
|
|
||||||
= button_tag formaction: events_url(format: :json) do
|
= button_tag formaction: events_url(format: :rss) do
|
||||||
%em.fa {}
|
%em.fa.fa-rss
|
||||||
= t '.json'
|
= t '.rss'
|
||||||
|
|
||||||
= button_tag formaction: events_url(format: :rss) do
|
= button_tag formaction: events_url(format: :ics) do
|
||||||
%em.fa.fa-rss
|
%em.fa.fa-calendar-check-o
|
||||||
= t '.rss'
|
= t '.ics'
|
||||||
|
|
||||||
= button_tag formaction: events_url(format: :ics) do
|
= button_tag formaction: events_url(format: :xml) do
|
||||||
%em.fa.fa-calendar-check-o
|
%em.fa.fa-code
|
||||||
= t '.ics'
|
= t '.xml'
|
||||||
|
|
||||||
= button_tag formaction: events_url(format: :xml) do
|
= button_tag formaction: orgas_url do
|
||||||
%em.fa.fa-code
|
%em.fa.fa-users
|
||||||
= t '.xml'
|
= t '.orgas'
|
||||||
|
|
||||||
= button_tag formaction: orgas_url do
|
%fieldset
|
||||||
%em.fa.fa-users
|
= form_tag events_url, method: :get do
|
||||||
= t '.orgas'
|
.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