Organisations counter per kind can also filtered by selected region

This commit is contained in:
echarp 2017-07-02 15:40:13 +02:00
parent a4446df2f6
commit b7beb0b5fa
11 changed files with 91968 additions and 6 deletions

View File

@ -5,7 +5,7 @@
float: left float: left
ul ul
margin: 0 margin: 0
z-index: 500 z-index: 1500
list-style: none list-style: none
text-align: left text-align: left
border-bottom-left-radius: 0.4em border-bottom-left-radius: 0.4em

View File

@ -9,8 +9,8 @@ class OrgasController < ApplicationController
unless: :check_secret unless: :check_secret
def index def index
@search = apply_scopes(Orga).moderated.includes(:kind, @search = apply_scopes(Orga.moderated).includes(:kind, :region)
:region).search params[:q] .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]
end end

View File

@ -31,9 +31,11 @@ class Orga < ApplicationRecord
scope :future, -> {} scope :future, -> {}
scope :period, ->(_year, _week) {} scope :period, ->(_year, _week) {}
scope :kind, ->(kind) { where kind: kind }
scope :region, ->(region) { where region: region unless region == 'all' } scope :region, ->(region) { where region: region unless region == 'all' }
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

View File

@ -7,11 +7,11 @@
%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}" }
= Orga.where(kind: kind).count = Orga.moderated.region(params[:region] || 'all').kind(kind).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
= Orga.where(active: true).count = Orga.moderated.active.region(params[:region] || 'all').count

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,23 @@
(function() {
$(document).on('turbolinks:load', function() {
return tinyMCE.init({
schema: 'html5',
height: '40em',
menubar: false,
branding: false,
language: 'fr_FR',
selector: 'input.description',
content_css: '/assets/application-3b96b828456bf029c46d8f6d17585e4ac5696f84bccd5b24a70a52205132b629.css',
entity_encoding: 'raw',
add_unload_trigger: true,
browser_spellcheck: true,
toolbar: [' cut copy paste | undo redo | searchreplace | link image media charmap table | code visualblocks preview fullscreen', ' removeformat | bold italic strikethrough | superscript subscript | bullist numlist | alignleft aligncenter alignright alignjustify alignnone | outdent indent'],
plugins: 'lists, advlist, autolink, link, image, charmap, paste, print, preview, table, fullscreen, searchreplace, media, insertdatetime, visualblocks, wordcount, contextmenu, code'
});
});
$(document).on('turbolinks:before-cache', function() {
return tinymce.remove();
});
}).call(this);