diff --git a/app/controllers/admin/communication/websites/connections_controller.rb b/app/controllers/admin/communication/websites/connections_controller.rb index ada7d1436dffc930db07d2ac46b7d3d87884d912..02820624b0cdcadc7ec9e59d3c5ca6b3a9165436 100644 --- a/app/controllers/admin/communication/websites/connections_controller.rb +++ b/app/controllers/admin/communication/websites/connections_controller.rb @@ -1,6 +1,4 @@ class Admin::Communication::Websites::ConnectionsController < Admin::Communication::Websites::ApplicationController - before_action :load_from_object, only: [:create, :destroy] - def index @connections = @website.connections.ordered.page params[:page] breadcrumb @@ -13,26 +11,8 @@ class Admin::Communication::Websites::ConnectionsController < Admin::Communicati add_breadcrumb @connection end - # Strange use of create, does not really create a connection - def create - @website.connect @object, @website - head :ok - end - - # Strange use of destroy, does not really create a connection - def destroy - @website.disconnect @object, @website - redirect_back(fallback_location: [:admin, @object]) - end - protected - def load_from_object - object_type = params[:object_type] - object_id = params[:object_id] - @object = object_type.constantize.find object_id - end - def breadcrumb super add_breadcrumb Communication::Website::Connection.model_name.human(count: 2), admin_communication_website_connections_path diff --git a/app/controllers/admin/communication/websites/pages_controller.rb b/app/controllers/admin/communication/websites/pages_controller.rb index aa248025be383f943e9bd4ab5120636a48c9cb9c..eb8db3a617b7888a14cc925efe2a797670183499 100644 --- a/app/controllers/admin/communication/websites/pages_controller.rb +++ b/app/controllers/admin/communication/websites/pages_controller.rb @@ -46,6 +46,18 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We render layout: 'admin/layouts/preview' end + def connect + load_object + @website.connect @object, @page + head :ok + end + + def disconnect + load_object + @website.disconnect @object, @page + redirect_back(fallback_location: [:admin, @object]) + end + def new @page.website = @website breadcrumb @@ -98,6 +110,12 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We protected + def load_object + object_type = params[:object_type] + object_id = params[:object_id] + @object = object_type.constantize.find object_id + end + def breadcrumb super add_breadcrumb t('admin.communication.website.pages.structure'), diff --git a/app/views/admin/application/_connections.html.erb b/app/views/admin/application/_connections.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..d8bc0bbc261e941e392c715ae634f61bc3260faf --- /dev/null +++ b/app/views/admin/application/_connections.html.erb @@ -0,0 +1,23 @@ +<%= osuny_panel Communication::Website::Connection.model_name.human(count: 2) do %> + <% about.websites.each do |website| %> + <div class="mb-4"> + <p class="mb-0"><b><%= link_to website, [:admin, website] %></b></p> + <ul class="list-unstyled small"> + <% Communication::Website::Connection.for_object(about).in_website(website).each do |connection| %> + <% + source = connection.source + begin + path = url_for [:admin, source] + rescue + end + path = edit_admin_communication_block_path(source) if source.is_a?(Communication::Block) + path = admin_communication_website_page_path( website_id: website.id, + lang: website.default_language, + id: source) if source.is_special_page? + %> + <li><%= link_to_if path, source, path %></li> + <% end %> + </ul> + </tr> + <% end %> +<% end if about.websites.any? %> \ No newline at end of file diff --git a/app/views/admin/application/a11y/_widget.html.erb b/app/views/admin/application/a11y/_widget.html.erb index db26884e8fade959e33833d574f80b53d5ed1e35..6601bcd64c705cd94eaeaa85507214fd575d9ca5 100644 --- a/app/views/admin/application/a11y/_widget.html.erb +++ b/app/views/admin/application/a11y/_widget.html.erb @@ -1,6 +1,6 @@ <% color = about.accessible? ? 'text-success' : 'text-danger' -action = "<i class=\"#{ Icon::A11Y } fa-2x float-end #{ color}\"></i>" +action = "<i class=\"#{ Icon::A11Y } #{ if_appstack 'fa-2x' } h4 float-end #{ color}\"></i>" %> <%= osuny_panel t('accessibility.label'), action: action do %> <% if about.accessibility_errors.any? %> diff --git a/app/views/admin/communication/websites/pages/show/special_pages/_organization.html.erb b/app/views/admin/communication/websites/pages/show/special_pages/_organization.html.erb index ed9ed4035907ae9bc66ac5a06f0cd2ac18434778..2001d8934769b937231f5766bf3e0fcca6be76bf 100644 --- a/app/views/admin/communication/websites/pages/show/special_pages/_organization.html.erb +++ b/app/views/admin/communication/websites/pages/show/special_pages/_organization.html.erb @@ -11,7 +11,7 @@ input_html: { data: { type: 'University::Organization', - target: admin_communication_website_connections_path(lang: nil) + target: connect_admin_communication_website_page_path(@page) } } %> @@ -22,9 +22,9 @@ <tr> <td><%= link_to organization, [:admin, organization] %></td> <td><%= link_to 'Déconnecter', - admin_communication_website_connection_path(id: 'no-id', object_id: organization.id, object_type: organization.class), + disconnect_admin_communication_website_page_path(@page, object_id: organization.id, object_type: organization.class), class: button_classes_danger, - method: :delete %></td> + method: :post %></td> </tr> <% end %> </tbody> diff --git a/app/views/admin/layouts/themes/pure/_panel.html.erb b/app/views/admin/layouts/themes/pure/_panel.html.erb index 653f5538dfc93d3659e60b8f760caede7e5589d4..5923610f3a0f6e6cad00de8c1f3601e1546c716f 100644 --- a/app/views/admin/layouts/themes/pure/_panel.html.erb +++ b/app/views/admin/layouts/themes/pure/_panel.html.erb @@ -5,7 +5,7 @@ <h2 class="mb-3"><%= title %></h2> <% end %> <% if action %> - <div class="ms-5"><%= raw action %></div> + <div class="ms-4"><%= raw action %></div> <% end %> </div> <% if subtitle %> diff --git a/app/views/admin/university/organizations/show.html.erb b/app/views/admin/university/organizations/show.html.erb index 5027492914cba0652d46b03d214767c655a1096a..52be2c05d3363640485278eeb0bda7fad9c16980 100644 --- a/app/views/admin/university/organizations/show.html.erb +++ b/app/views/admin/university/organizations/show.html.erb @@ -87,6 +87,8 @@ <% end if @organization.logo.attached? || @organization.logo_on_dark_background.attached? %> <%= render 'admin/application/meta_description/show', about: @organization %> + + <%= render 'admin/application/connections', about: @organization %> </div> </div> @@ -119,39 +121,6 @@ </div> <% end if @organization.experiences.any? %> -<%= osuny_panel Communication::Website::Connection.model_name.human(count: 2) do %> - <table class="table"> - <thead> - <tr> - <th><%= Communication::Website.model_name.human %></th> - <th><%= Communication::Website::Connection.human_attribute_name(:source) %></th> - </tr> - </thead> - <tbody> - <% @organization.websites.each do |website| %> - <tr> - <td><%= link_to website, [:admin, website] %></td> - <td> - <ul class="list-unstyled"> - <% Communication::Website::Connection.for_object(@organization).in_website(website).each do |connection| %> - <% - begin - path = url_for [:admin, connection.source] - if connection.source.is_a? Communication::Block - path = edit_admin_communication_block_path(connection.source) - end - rescue - end - %> - <li><%= link_to connection.source, path %></li> - <% end %> - </ul> - </td> - </tr> - <% end %> - </tbody> - </table> -<% end if @organization.websites.any? %> <% content_for :action_bar_left do %> <%= destroy_link @organization %> diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index 8dd62e40f6097f437edc00686a1aa028704932c8..76dacb059f8c8fb78d35f19cf4d95146d964a49f 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -10,7 +10,7 @@ namespace :communication do get :style get :analytics end - resources :connections, controller: 'websites/connections', except: [:new, :edit] + resources :connections, controller: 'websites/connections', only: [:index, :show] resources :pages, controller: 'websites/pages', path: '/:lang/pages' do collection do post :reorder @@ -21,6 +21,8 @@ namespace :communication do get :preview get "translate" => "websites/pages#translate", as: :translate post :duplicate + post :connect + post :disconnect end end resources :categories, controller: 'websites/categories', path: '/:lang/categories' do