Skip to content
Snippets Groups Projects
Commit 445991d8 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

wip

parent 0a710ea1
No related branches found
No related tags found
No related merge requests found
Showing
with 99 additions and 97 deletions
......@@ -42,6 +42,8 @@ class Admin::Communication::BlocksController < Admin::Communication::Application
def create
@block.university = current_university
headings = @block.about.headings
@block.heading = headings.last if headings.any?
if @block.save
# No need to sync as content is empty
redirect_to [:edit, :admin, @block],
......
......@@ -27,8 +27,8 @@
# fk_rails_90ac986fab (heading_id => communication_block_headings.id)
#
class Communication::Block < ApplicationRecord
include Accessible
include Sanitizable
include WithAccessibility
include WithUniversity
include WithPosition
......
class Communication::Block::Component::Base
include Accessible
include WithAccessibility
attr_reader :property, :template
......
......@@ -41,7 +41,8 @@ class Communication::Block::Heading < ApplicationRecord
DEFAULT_LEVEL = 2
scope :root, -> { where(level: DEFAULT_LEVEL) }
default_scope { order(:position) }
scope :ordered, -> { order(:position) }
default_scope { ordered }
before_validation :compute_level
......
class Communication::Block::Template::Base
include Accessible
include WithAccessibility
class_attribute :components_descriptions,
:layouts,
......
......@@ -46,8 +46,8 @@
class Communication::Website::Page < ApplicationRecord
self.ignored_columns = %w(path)
include Accessible
include Sanitizable
include WithAccessibility
include WithBlobs
include WithBlocks
include WithDuplication
......
......@@ -39,6 +39,7 @@
#
class Communication::Website::Post < ApplicationRecord
include Sanitizable
include WithAccessibility
include WithBlobs
include WithBlocks
include WithDuplication
......@@ -156,6 +157,10 @@ class Communication::Website::Post < ApplicationRecord
protected
def check_accessibility
accessibility_merge_array blocks
end
def slug_unavailable?(slug)
self.class.unscoped
.where(communication_website_id: self.communication_website_id, language_id: language_id, slug: slug)
......
module Accessible
module WithAccessibility
extend ActiveSupport::Concern
def accessible?
......
<%
horizontal ||= false
color = about.accessible? ? 'text-success' : 'text-danger'
action = "<i class=\"#{ Icon::A11Y } fa-2x float-end #{ color}\"></i>"
%>
<%= osuny_panel t('accessibility.label'), action: action do %>
<%= osuny_panel t('accessibility.label') do %>
<% if horizontal %>
<div class="row"><div class="offset-lg-4 col-lg-8">
<div class="row"><div class="offset-lg-4 col-lg-8 pt-n4">
<% end %>
<% if about.accessibility_errors.any? %>
<%= osuny_label t('accessibility.errors', count: about.accessibility_errors.count), classes: 'text-danger' %>
<p class="text-danger">
<i class="<%= Icon::A11Y %>"></i>
<%= t('accessibility.errors', count: about.accessibility_errors.count) %>
</p>
<ol class="list-unstyled">
<% about.accessibility_errors.each do |key| %>
<li>
......@@ -18,7 +19,10 @@ action = "<i class=\"#{ Icon::A11Y } fa-2x float-end #{ color}\"></i>"
<% end %>
</ol>
<% else %>
<p><%= t 'accessibility.errors', count: 0 %></p>
<p>
<i class="<%= Icon::A11Y %> text-success"></i>
<%= t 'accessibility.errors', count: 0 %>
</p>
<% end %>
<% if about.accessibility_warnings.any? %>
<%= osuny_label t('accessibility.warnings', count: about.accessibility_warnings.count) %>
......
<div class="row" data-id="block_<%= block.id %>">
<div data-id="block_<%= block.id %>" class="row">
<div class="offset-lg-4 col-lg-8">
<article class="blocks__list__element mt-5 <%= 'draft' unless block.published? %>">
<div class="mb-1">
......
<%= osuny_panel Communication::Block.model_name.human(count: 2) do %>
<div class="blocks" data-sortable data-sort-url="<%= reorder_admin_communication_blocks_path %>">
<% about.blocks.with_no_heading.ordered.each do |block| %>
<%= render 'admin/communication/blocks/block', block: block %>
<% end %>
<% about.headings.root.each do |heading| %>
<%= render 'admin/communication/blocks/headings/heading', heading: heading %>
<% end %>
<div class="blocks" data-sortable data-sort-url="<%= reorder_admin_communication_blocks_path %>">
<% about.blocks.with_no_heading.ordered.each do |block| %>
<%= render 'admin/communication/blocks/block', block: block %>
<% end %>
<% about.headings.root.each do |heading| %>
<%= render 'admin/communication/blocks/headings/heading', heading: heading %>
<% end %>
</div>
<div class="row mt-5">
<div class="col-lg-4">
<%= link_to t('admin.communication.blocks.headings.add'),
new_admin_communication_heading_path(about_id: about.id, about_type: about.class.name),
class: 'py-5 px-2 d-block bg-light text-center h4' if can? :create, Communication::Block::Heading%>
</div>
<div class="row mt-5">
<div class="col-lg-4">
<%= link_to t('admin.communication.blocks.headings.add'),
new_admin_communication_heading_path(about_id: about.id, about_type: about.class.name),
class: 'py-5 px-2 d-block bg-light text-center h4' if can? :create, Communication::Block::Heading%>
</div>
<div class="col-lg-8">
<%= link_to t('admin.communication.blocks.add'),
new_admin_communication_block_path(about_id: about.id, about_type: about.class.name),
class: 'py-5 px-2 d-block bg-light text-center h4' if can? :create, Communication::Block%>
</div>
<div class="col-lg-8">
<%= link_to t('admin.communication.blocks.add'),
new_admin_communication_block_path(about_id: about.id, about_type: about.class.name),
class: 'py-5 px-2 d-block bg-light text-center h4' if can? :create, Communication::Block%>
</div>
<% end %>
</div>
......@@ -8,12 +8,14 @@ url = heading.persisted? ? admin_communication_heading_path(heading)
<%= f.input :title %>
<%= f.input :about_type, as: :hidden %>
<%= f.input :about_id, as: :hidden %>
<% content_for :action_bar_left do %>
<%= link_to t('delete'),
admin_communication_heading_path(heading),
method: :delete,
data: { confirm: t('please_confirm') },
class: button_classes_danger if can? :destroy, heading %>
<% if heading.persisted?%>
<% content_for :action_bar_left do %>
<%= link_to t('delete'),
admin_communication_heading_path(heading),
method: :delete,
data: { confirm: t('please_confirm') },
class: button_classes_danger if can? :destroy, heading %>
<% end %>
<% end %>
<% content_for :action_bar_right do %>
<%= submit f %>
......
......@@ -6,3 +6,7 @@
<% @heading.blocks.published.ordered.each do |block| @block = block %>
<%= render 'admin/communication/blocks/block_static' %>
<% end %>
<% children = @heading.children %>
<% children.ordered.each do |heading| @heading = heading %>
<%= render 'admin/communication/blocks/headings/heading_static' %>
<% end %>
<% content_for :title, @menu %>
<%= render 'admin/communication/websites/sidebar' do %>
<div class="row">
<div class="col-md-8">
<h2 class="h3">
<%= "#{Communication::Website::Menu::Item.model_name.human(count: 2)} (#{@root_items.size})" %>
</h2>
<%
action = ''
action += link_to t('create'),
new_admin_communication_website_menu_item_path(website_id: @website, menu_id: @menu.id),
class: button_classes if can?(:create, Communication::Website::Menu::Item) %>
<%= osuny_panel Communication::Website::Menu::Item.model_name.human(count: 2), action: action do %>
<%= render 'admin/communication/websites/menus/items/list', items: @root_items if @items.any? %>
<%= link_to t('create'),
new_admin_communication_website_menu_item_path(website_id: @website, menu_id: @menu.id),
class: button_classes if can?(:create, Communication::Website::Menu::Item) %>
</div>
<div class="col-md-4">
<%= render 'admin/application/i18n/widget', about: @menu %>
<%= osuny_panel t('metadata') do %>
<%= osuny_label Communication::Website::Menu.human_attribute_name('identifier') %>
<p><%= @menu.identifier %></p>
<% end %>
</div>
<% end %>
<% end %>
<% content_for :action_bar_left do %>
......
......@@ -2,53 +2,29 @@
<%= render 'admin/communication/websites/sidebar' do %>
<div class="row">
<div class="col-xl-8">
<%= render 'admin/application/summary/show', about: @post %>
<%= render 'admin/communication/blocks/index_edit', about: @post %>
</div>
<div class="col-xl-4">
<%= render 'admin/application/i18n/widget', about: @post %>
<%
action = ''
action += link_to t('open'),
@post.url,
target: :_blank,
class: 'btn btn-light btn-xs' if @post.url
%>
<%= osuny_panel t('metadata'), action: action do %>
<div class="row pure__row--small">
<div class="col-6">
<%= osuny_label Communication::Website::Post.human_attribute_name('published') %>
<p>
<%= t @post.published %><% if @post.published & @post.published_at %>,
<%= l @post.published_at.to_date, format: :long if @post.published_at %>
<% end %>
</p>
</div>
<div class="col-6">
<%= osuny_label Communication::Website::Post.human_attribute_name('pinned') %>
<p><%= t @post.pinned %></p>
</div>
</div>
<% if @post.author %>
<%= osuny_label Communication::Website::Post.human_attribute_name('author') %>
<p><%= link_to_if can?(:read, @post.author), @post.author, admin_communication_website_author_path(@post.author) %></p>
<% end %>
<% if @post.categories.any? %>
<%= osuny_label Communication::Website::Post.human_attribute_name('categories') %>
<ul class="list-unstyled">
<% @post.categories.each do |category| %>
<li><%= link_to_if can?(:read, category), category, [:admin, category] %></li>
<% end %>
</ul>
<% end %>
<%= osuny_label Communication::Website::Post.human_attribute_name('slug') %>
<p><%= @post.slug %></p>
<div class="col-lg-7">
<%= osuny_panel Communication::Website::Post.human_attribute_name(:title) do %>
<p class="lead"><%= @post.title %></p>
<% end %>
</div>
<div class="offset-lg-1 col-lg-4">
<%= render 'admin/application/featured_image/show', about: @post %>
</div>
</div>
<hr class="my-5">
<%= render 'admin/application/a11y/widget', about: @post, horizontal: true %>
<hr class="my-5">
<div class="row">
<div class="col-lg-4">
<%= render 'admin/communication/websites/posts/show/metadata' %>
<%= render 'admin/application/i18n/widget', about: @post %>
</div>
<div class="col-lg-8">
<%= render 'admin/application/summary/show', about: @post %>
<%= render 'admin/application/meta_description/show', about: @post %>
</div>
</div>
<%= render 'admin/communication/blocks/index_edit', about: @post %>
<% end %>
<% content_for :action_bar_left do %>
......@@ -58,6 +34,10 @@
<% end %>
<% content_for :action_bar_right do %>
<%= link_to t('open'),
@post.url,
target: :_blank,
class: 'btn btn-light btn-xs' if @post.url %>
<%= preview_link %>
<%= edit_link @post %>
<% end %>
<%= osuny_label t('metadata') %><br>
<% if @post.published %>
Publié le <%= l @post.published_at.to_date %>
<% if @post.pinned %>
et mis en avant
<% end %>
<% else %>
Brouillon
<% end %>
<% if @post.author %>
<br>par <%= @post.author %>
<% end %>
<% if @post.categories.any? %>
<br>dans <%= @post.categories.collect(&:to_s).join(', ') %>
<% end %>
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