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

blocks

parent 3dc11466
No related branches found
No related tags found
No related merge requests found
class Server::BlocksController < Server::ApplicationController
def index
@templates = Communication::Block.template_kinds.keys
breadcrumb
end
def show
@template = params[:id]
@blocks = Communication::Block.send(@template)
breadcrumb
add_breadcrumb t("enums.communication.block.template_kind.#{@template}")
end
protected
def breadcrumb
super
add_breadcrumb Communication::Block.model_name.human(count: 2), server_blocks_path
end
end
<% content_for :title, Communication::Block.model_name.human(count: 2) %>
<table class="<%= table_classes %>">
<thead>
<tr>
<th><%= Communication::Block.human_attribute_name('name') %></th>
<th><%= Communication::Block.human_attribute_name('quantity') %></th>
</tr>
</thead>
<tbody>
<% @templates.each do |template| %>
<tr>
<td><%= link_to t("enums.communication.block.template_kind.#{template}"), server_block_path(template) %></td>
<td><%= Communication::Block.send(template).count %></td>
</tr>
<% end %>
</tbody>
</table>
<% content_for :title, Communication::Block.model_name.human(count: 2) %>
<table class="<%= table_classes %>">
<thead>
<tr>
<th><%= Communication::Block.human_attribute_name('name') %></th>
<th><%= Communication::Block.human_attribute_name('about') %></th>
<th><%= Communication::Block.human_attribute_name('university') %></th>
</tr>
</thead>
<tbody>
<% @blocks.each do |block| %>
<tr>
<td><%= link_to block, edit_admin_communication_block_url(block), target: :_blank %></td>
<td><%= block.about %></td>
<td><%= block.about.university %></td>
</tr>
<% end %>
</tbody>
</table>
......@@ -28,15 +28,11 @@ Rails.application.routes.draw do
root to: 'dashboard#index'
end
namespace :server do
resources :universities
resources :languages
root to: 'dashboard#index'
end
get '/media/:signed_id/:filename_with_transformations' => 'media#show', as: :medium
draw 'api'
draw 'extranet'
draw 'server'
# Root is in extranet
end
namespace :server do
resources :universities, :languages
get 'blocks' => 'blocks#index', as: :blocks
get 'blocks/:id' => 'blocks#show', as: :block
root to: 'dashboard#index'
end
......@@ -4,8 +4,20 @@ SimpleNavigation::Configuration.run do |navigation|
navigation.highlight_on_subpath = true
navigation.selected_class = 'active'
navigation.items do |primary|
primary.item :dashboard, t('dashboard'), server_root_path, { icon: 'tachometer-alt', highlights_on: %r{server$} }
primary.item :universities, University.model_name.human(count: 2), server_universities_path, { icon: 'university' } if can?(:read, University)
primary.item :languages, Language.model_name.human(count: 2), server_languages_path, { icon: 'flag' } if can?(:read, Language)
primary.item :dashboard,
t('dashboard'),
server_root_path,
{ icon: 'tachometer-alt', highlights_on: %r{server$} }
primary.item :universities,
University.model_name.human(count: 2),
server_universities_path, { icon: 'university' } if can?(:read, University)
primary.item :languages,
Language.model_name.human(count: 2),
server_languages_path,
{ icon: 'flag' } if can?(:read, Language)
primary.item :blocks,
Communication::Block.model_name.human(count: 2),
server_blocks_path,
{ icon: 'puzzle-piece' } if can?(:read, Communication::Block)
end
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