diff --git a/app/controllers/server/blocks_controller.rb b/app/controllers/server/blocks_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..08be78e16f8cc6c2e6440bf390c5cfa6d724f608 --- /dev/null +++ b/app/controllers/server/blocks_controller.rb @@ -0,0 +1,22 @@ +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 diff --git a/app/views/server/blocks/index.html.erb b/app/views/server/blocks/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..c19fa8b04903938eeef8dc33fb7e048f186a3564 --- /dev/null +++ b/app/views/server/blocks/index.html.erb @@ -0,0 +1,18 @@ +<% 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> diff --git a/app/views/server/blocks/show.html.erb b/app/views/server/blocks/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..d1427ef971d6a35047c86cb85a065054aefcff60 --- /dev/null +++ b/app/views/server/blocks/show.html.erb @@ -0,0 +1,20 @@ +<% 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> diff --git a/config/routes.rb b/config/routes.rb index 5e9f0af119a7ec261e2d338a89ae71c11d8b3d96..2e983de6e2545700ecf2711812e285f5b4c5995c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/config/routes/server.rb b/config/routes/server.rb new file mode 100644 index 0000000000000000000000000000000000000000..adb099dfd43582406d8620fa769858fe9cb45295 --- /dev/null +++ b/config/routes/server.rb @@ -0,0 +1,6 @@ +namespace :server do + resources :universities, :languages + get 'blocks' => 'blocks#index', as: :blocks + get 'blocks/:id' => 'blocks#show', as: :block + root to: 'dashboard#index' +end diff --git a/config/server_navigation.rb b/config/server_navigation.rb index 4881a4db1b6b8f287c52d8ece930ed2d8fb7abc2..06113b460e72c3a4dde82d910699efd74c738de9 100644 --- a/config/server_navigation.rb +++ b/config/server_navigation.rb @@ -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