Skip to content
Snippets Groups Projects
Unverified Commit e667dba6 authored by Arnaud Levy's avatar Arnaud Levy Committed by GitHub
Browse files

Merge pull request #1271 from noesya/block-agenda

Options de mise en page pour le bloc agenda
parents dfcfa9d1 b215657d
No related branches found
No related tags found
No related merge requests found
app/assets/images/communication/blocks/templates/agenda.jpg

21.4 KiB | W: | H:

app/assets/images/communication/blocks/templates/agenda.jpg

37.7 KiB | W: | H:

app/assets/images/communication/blocks/templates/agenda.jpg
app/assets/images/communication/blocks/templates/agenda.jpg
app/assets/images/communication/blocks/templates/agenda.jpg
app/assets/images/communication/blocks/templates/agenda.jpg
  • 2-up
  • Swipe
  • Onion skin
app/assets/images/communication/blocks/templates/agenda/grid.png

213 KiB

app/assets/images/communication/blocks/templates/agenda/list.png

61.2 KiB

class Communication::Block::Template::Agenda < Communication::Block::Template::Base
has_layouts [:grid, :list]
has_component :description, :rich_text
has_component :events_quantity, :number, options: 3
has_component :quantity, :number, options: 3
has_component :time, :option, options: [:future_or_present, :future, :present, :archive]
def selected_events
@selected_events ||= block.about&.website
.events
.for_language(block.language)
.published
.ordered
.limit(events_quantity)
@selected_events ||= events_with_time_scope
end
def allowed_for_about?
website.present?
end
protected
def events_with_time_scope
events = block.about&.website
.events
.for_language(block.language)
.published
.limit(quantity)
# Whitelist for security
# (not very elegant though)
case time
when 'future_or_present'
events.future_or_present
when 'future'
events.future
when 'present'
events.present
when 'archive'
events.archive
else
events
end
end
end
......@@ -57,10 +57,17 @@ class Communication::Website::Agenda::Event < ApplicationRecord
class_name: 'Communication::Website::Agenda::Event',
optional: true
scope :ordered, -> { order(from_day: :desc, from_hour: :desc) }
scope :recent, -> { ordered.limit(5) }
scope :ordered_desc, -> { order(from_day: :desc, from_hour: :desc) }
scope :ordered_asc, -> { order(:from_day, :from_hour) }
scope :ordered, -> { ordered_asc }
scope :recent, -> { order(:updated_at).limit(5) }
scope :published, -> { where(published: true) }
scope :draft, -> { where(published: false) }
scope :future, -> { where('from_day > :today', today: Date.today).ordered_asc }
scope :future_or_present, -> { where('from_day >= :today', today: Date.today).ordered_asc }
scope :present, -> { where('(from_day >= :today AND to_day IS NULL) OR (from_day >= :today AND to_day <= :today)', today: Date.today).ordered_asc }
scope :archive, -> { where('to_day < :today', today: Date.today).ordered_desc }
scope :past, -> { archive }
validates_presence_of :from_day, :title
validate :to_day_after_from_day, :to_hour_after_from_hour_on_same_day
......
<%= block_component_edit block, :layout %>
<div class="row pure__row--small">
<div class="col-xl-6">
<%= block_component_edit block, :description %>
</div>
<div class="col-xl-6">
<%= block_component_edit block, :events_quantity %>
<%= block_component_edit block, :quantity %>
</div>
</div>
<%= block_component_edit block, :time %>
\ No newline at end of file
layout: <%= block.template.layout %>
<%= block_component_static block, :description %>
elements:
<% block.template.selected_events.each do |element| %>
......
......@@ -53,10 +53,26 @@ en:
templates:
agenda:
description: A list of upcoming events.
layouts:
grid:
label: Grid
description: Events are presented as a grid, from left to right and top to bottom, with constant size cropped images.
list:
label: List
description: A list of posts with small images the same width.
edit:
events_quantity:
description:
label: Description
quantity:
label: Quantity of events to show
placeholder: Enter quantity
time:
label: Which events?
options:
future_or_present: Now and in the future
future: In the future, not started yet
present: Running now
archive: Past, archives
call_to_action:
description: A title, a text, an optional image and up to 3 call to action buttons.
edit:
......
......@@ -53,10 +53,26 @@ fr:
templates:
agenda:
description: Une liste d'événements à venir.
layouts:
grid:
label: Grille
description: Les événements sont présentées en grille, avec les images toutes de la même taille.
list:
label: Liste
description: Une liste d'événements avec de petites images à la même largeur.
edit:
events_quantity:
description:
label: Description
quantity:
label: Quantité d'événements à afficher
placeholder: Entrer la quantité
time:
label: Quels événements afficher ?
options:
future_or_present: En cours et à venir
future: À venir, pas encore en cours
present: En cours en ce moment
archive: Terminés, archivés
call_to_action:
description: Un titre, un texte, un visuel et 3 boutons pour inviter les personnes à agir.
edit:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment