Organisations' filter display active one by default, inactive on after a click
Closes #130
This commit is contained in:
parent
913534abd4
commit
ad0c37e467
@ -2,6 +2,7 @@
|
|||||||
class OrgasController < ApplicationController
|
class OrgasController < ApplicationController
|
||||||
has_scope :region, :tag
|
has_scope :region, :tag
|
||||||
has_scope :near, type: :hash, using: %i[location distance]
|
has_scope :near, type: :hash, using: %i[location distance]
|
||||||
|
has_scope :active, type: :boolean, default: true, allow_blank: true
|
||||||
|
|
||||||
before_action :set_orga, except: %i[index new create]
|
before_action :set_orga, except: %i[index new create]
|
||||||
before_action :set_mailer_host
|
before_action :set_mailer_host
|
||||||
|
@ -21,7 +21,7 @@ class Orga < ApplicationRecord
|
|||||||
# after_validation :geocode, if: -> (obj) { obj.saved_change_to_address? }
|
# after_validation :geocode, if: -> (obj) { obj.saved_change_to_address? }
|
||||||
after_validation :geocode
|
after_validation :geocode
|
||||||
|
|
||||||
scope :active, -> { where active: true }
|
scope :active, ->(value = true) { where active: value }
|
||||||
scope :moderated, -> { where moderated: true }
|
scope :moderated, -> { where moderated: true }
|
||||||
scope :unmoderated, -> { where moderated: false }
|
scope :unmoderated, -> { where moderated: false }
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ class Orga < ApplicationRecord
|
|||||||
end)
|
end)
|
||||||
scope :tag, ->(tag) { tagged_with tag }
|
scope :tag, ->(tag) { tagged_with tag }
|
||||||
scope :geo, -> { where 'latitude is not null and longitude is not null' }
|
scope :geo, -> { where 'latitude is not null and longitude is not null' }
|
||||||
scope :active, -> { where active: true }
|
|
||||||
|
|
||||||
before_validation do
|
before_validation do
|
||||||
# Populate submitter using contact info if absent
|
# Populate submitter using contact info if absent
|
||||||
|
@ -6,14 +6,16 @@
|
|||||||
- @unfiltered_orgas.reorder('').group(:kind).count(:all).each do |kind, count|
|
- @unfiltered_orgas.reorder('').group(:kind).count(:all).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, active: params[:active]) do
|
||||||
%em.fa{ class: "fa-#{kind.icon}" }
|
%em.fa{ class: "fa-#{kind.icon}" }
|
||||||
= count
|
= count
|
||||||
|
|
||||||
%li{ title: Kind.human_attribute_name('active').pluralize }
|
%li{ title: Kind.human_attribute_name('active').pluralize + '?' }
|
||||||
- p[:kind_id_eq] = params[:q][:kind_id_eq]
|
- p[:kind_id_eq] = params[:q][:kind_id_eq]
|
||||||
- p[:active_eq] = true
|
\/
|
||||||
|
|
= link_to orgas_url(q: p, active: params[:active].present? && params[:active] != 'true') do
|
||||||
= link_to orgas_url(q: p) do
|
- if params[:active].nil? || params[:active] == 'true'
|
||||||
%em.fa.fa-heartbeat
|
%em.fa.fa-heartbeat
|
||||||
= @unfiltered_orgas.active.count :all
|
- else
|
||||||
|
%em.fa.fa-heart-broken
|
||||||
|
= @unfiltered_orgas.count
|
||||||
|
Loading…
Reference in New Issue
Block a user