diff --git a/app/assets/images/communication/websites/blocks/templates/organization_chart.jpg b/app/assets/images/communication/blocks/templates/organization_chart.jpg similarity index 100% rename from app/assets/images/communication/websites/blocks/templates/organization_chart.jpg rename to app/assets/images/communication/blocks/templates/organization_chart.jpg diff --git a/app/assets/images/communication/websites/blocks/templates/partners.jpg b/app/assets/images/communication/blocks/templates/partners.jpg similarity index 100% rename from app/assets/images/communication/websites/blocks/templates/partners.jpg rename to app/assets/images/communication/blocks/templates/partners.jpg diff --git a/app/controllers/admin/communication/website/blocks_controller.rb b/app/controllers/admin/communication/blocks_controller.rb similarity index 55% rename from app/controllers/admin/communication/website/blocks_controller.rb rename to app/controllers/admin/communication/blocks_controller.rb index c87686c55ef5ac0fe0b34f513684e7b114dbe43a..3b6bd66e7fe16d3e0185d0010ec1e4c4308ff51f 100644 --- a/app/controllers/admin/communication/website/blocks_controller.rb +++ b/app/controllers/admin/communication/blocks_controller.rb @@ -1,11 +1,10 @@ -class Admin::Communication::Website::BlocksController < Admin::Communication::Website::ApplicationController - load_and_authorize_resource class: Communication::Website::Block, through: :website +class Admin::Communication::BlocksController < Admin::Communication::ApplicationController + load_and_authorize_resource class: Communication::Block def reorder ids = params[:ids] || [] - first_page = nil ids.each.with_index do |id, index| - block = @website.blocks.find(id) + block = current_university.communication_blocks.find(id) block.update position: index + 1 end end @@ -25,8 +24,7 @@ class Admin::Communication::Website::BlocksController < Admin::Communication::We end def create - @block.university = @website.university - @block.website = @website + @block.university = current_university if @block.save redirect_to [:edit, :admin, @block], notice: t('admin.successfully_created_html', model: @block.to_s) else @@ -37,7 +35,7 @@ class Admin::Communication::Website::BlocksController < Admin::Communication::We def update if @block.update(block_params) @block.about.save_and_sync - redirect_to [:admin, @block.about], notice: t('admin.successfully_updated_html', model: @block.to_s) + redirect_to about_path, notice: t('admin.successfully_updated_html', model: @block.to_s) else render :edit, status: :unprocessable_entity end @@ -51,20 +49,30 @@ class Admin::Communication::Website::BlocksController < Admin::Communication::We protected + def website_id + params[:website_id] || @block.about&.website.id + rescue + end + + def about_path + # La formation ou la page concernée + path_method = "admin_#{@block.about.class.to_s.parameterize.underscore}_path" + send path_method, id: @block.about_id, website_id: website_id + end + def breadcrumb - super - add_breadcrumb @block.about.model_name.human(count: 2), [:admin, @block.about.class] - add_breadcrumb @block.about, [:admin, @block.about] + short_breadcrumb + add_breadcrumb @block.about, about_path + # Le block if @block.new_record? - add_breadcrumb t('communication.website.block.choose_template') + add_breadcrumb t('communication.block.choose_template') else add_breadcrumb @block end end - def block_params - params.require(:communication_website_block) + params.require(:communication_block) .permit(:about_id, :about_type, :template, :data) end end diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb new file mode 100644 index 0000000000000000000000000000000000000000..15608ac47a15510c71d958a415ea43c30e7ff527 --- /dev/null +++ b/app/models/communication/block.rb @@ -0,0 +1,69 @@ +# == Schema Information +# +# Table name: communication_blocks +# +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# data :jsonb +# position :integer default(0), not null +# template :integer default(NULL), not null +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_blocks_on_university_id (university_id) +# index_communication_website_blocks_on_about (about_type,about_id) +# +# Foreign Keys +# +# fk_rails_18291ef65f (university_id => universities.id) +# +class Communication::Block < ApplicationRecord + include WithPosition + + belongs_to :university + belongs_to :about, polymorphic: true + + enum template: { + organization_chart: 100, + partners: 200 + } + + def data=(value) + value = JSON.parse value if value.is_a? String + super(value) + end + + def git_dependencies + m = "git_dependencies_for_#{template}" + respond_to?(m, true) ? send(m) : [] + end + + def last_ordered_element + about.blocks.ordered.last + end + + def to_s + "Bloc #{position}" + end + + protected + + def git_dependencies_for_organization_chart + dependencies = [] + data['elements'].each do |element| + element['persons'].each do |person| + id = person['id'] + next if id.blank? + person = university.people.find id + next if person.nil? + dependencies += [person] + dependencies += person.active_storage_blobs + end + end + dependencies.uniq + end +end diff --git a/app/models/communication/website/block.rb b/app/models/communication/website/block.rb deleted file mode 100644 index abf3e5e6e5032e7e53993d73861a0b28cb4c7b3b..0000000000000000000000000000000000000000 --- a/app/models/communication/website/block.rb +++ /dev/null @@ -1,73 +0,0 @@ -# == Schema Information -# -# Table name: communication_website_blocks -# -# id :uuid not null, primary key -# about_type :string indexed => [about_id] -# data :jsonb -# position :integer default(0), not null -# template :integer default(NULL), not null -# created_at :datetime not null -# updated_at :datetime not null -# about_id :uuid indexed => [about_type] -# communication_website_id :uuid not null, indexed -# university_id :uuid not null, indexed -# -# Indexes -# -# index_communication_website_blocks_on_about (about_type,about_id) -# index_communication_website_blocks_on_communication_website_id (communication_website_id) -# index_communication_website_blocks_on_university_id (university_id) -# -# Foreign Keys -# -# fk_rails_18291ef65f (university_id => universities.id) -# fk_rails_75bd7c8d6c (communication_website_id => communication_websites.id) -# -class Communication::Website::Block < ApplicationRecord - include WithPosition - - belongs_to :university - belongs_to :website, foreign_key: :communication_website_id - belongs_to :about, polymorphic: true - - enum template: { - organization_chart: 100, - partners: 200 - } - - def data=(value) - value = JSON.parse value if value.is_a? String - super(value) - end - - def git_dependencies - m = "git_dependencies_for_#{template}" - respond_to?(m, true) ? send(m) : [] - end - - def last_ordered_element - about.blocks.ordered.last - end - - def to_s - "Bloc #{position}" - end - - protected - - def git_dependencies_for_organization_chart - dependencies = [] - data['elements'].each do |element| - element['persons'].each do |person| - id = person['id'] - next if id.blank? - person = university.people.find id - next if person.nil? - dependencies += [person] - dependencies += person.active_storage_blobs - end - end - dependencies.uniq - end -end diff --git a/app/models/communication/website/configs/base_url.rb b/app/models/communication/website/configs/base_url.rb index 890fbc8cb241de1298193606a4f231cb110eb8af..dfaa1d5cb24c1d90ea681ab5812ab083515972cb 100644 --- a/app/models/communication/website/configs/base_url.rb +++ b/app/models/communication/website/configs/base_url.rb @@ -1,3 +1,37 @@ +# == Schema Information +# +# Table name: communication_websites +# +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# git_provider :integer default("github") +# name :string +# repository :string +# static_pathname_administrators :string default("administrators") +# static_pathname_authors :string default("authors") +# static_pathname_posts :string default("posts") +# static_pathname_programs :string default("programs") +# static_pathname_research_articles :string default("articles") +# static_pathname_research_volumes :string default("volumes") +# static_pathname_researchers :string default("researchers") +# static_pathname_staff :string default("staff") +# static_pathname_teachers :string default("teachers") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_websites_on_about (about_type,about_id) +# index_communication_websites_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_bb6a496c08 (university_id => universities.id) +# class Communication::Website::Configs::BaseUrl < Communication::Website def self.polymorphic_name diff --git a/app/models/communication/website/configs/permalinks.rb b/app/models/communication/website/configs/permalinks.rb index 64df73301bd1a9072a069a65ce55419ea41119e1..13ffdd2c68a36f26ed2afb61cf1abcd108a085b1 100644 --- a/app/models/communication/website/configs/permalinks.rb +++ b/app/models/communication/website/configs/permalinks.rb @@ -1,3 +1,37 @@ +# == Schema Information +# +# Table name: communication_websites +# +# id :uuid not null, primary key +# about_type :string indexed => [about_id] +# access_token :string +# git_provider :integer default("github") +# name :string +# repository :string +# static_pathname_administrators :string default("administrators") +# static_pathname_authors :string default("authors") +# static_pathname_posts :string default("posts") +# static_pathname_programs :string default("programs") +# static_pathname_research_articles :string default("articles") +# static_pathname_research_volumes :string default("volumes") +# static_pathname_researchers :string default("researchers") +# static_pathname_staff :string default("staff") +# static_pathname_teachers :string default("teachers") +# url :string +# created_at :datetime not null +# updated_at :datetime not null +# about_id :uuid indexed => [about_type] +# university_id :uuid not null, indexed +# +# Indexes +# +# index_communication_websites_on_about (about_type,about_id) +# index_communication_websites_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_bb6a496c08 (university_id => universities.id) +# class Communication::Website::Configs::Permalinks < Communication::Website def self.polymorphic_name diff --git a/app/models/concerns/with_blocks.rb b/app/models/concerns/with_blocks.rb index 3c27dc981b0e94e75091e773749c485ae44db4fd..d3576da62159981be0141dd72e0bd38cff99779e 100644 --- a/app/models/concerns/with_blocks.rb +++ b/app/models/concerns/with_blocks.rb @@ -2,7 +2,7 @@ module WithBlocks extend ActiveSupport::Concern included do - has_many :blocks, as: :about + has_many :blocks, as: :about, class_name: 'Communication::Block' end def git_block_dependencies diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 4d16201b61a0b7b9eca6a5b6aed1fc4024d9cdf1..df8358182e8d40edb6f925bfdce622d04b6756e9 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -51,6 +51,7 @@ class Education::Program < ApplicationRecord include WithTree include WithInheritance include WithPosition + include WithBlocks rich_text_areas_with_inheritance :accessibility, :contacts, diff --git a/app/models/university/with_communication.rb b/app/models/university/with_communication.rb index 3278224b6e6c9748fe652e396b8cd82a7e7089e3..01ae9f54b8a413f1e7e9bf21eb913d9e8e9a6238 100644 --- a/app/models/university/with_communication.rb +++ b/app/models/university/with_communication.rb @@ -3,5 +3,6 @@ module University::WithCommunication included do has_many :communication_websites, class_name: 'Communication::Website', dependent: :destroy + has_many :communication_blocks, class_name: 'Communication::Block', dependent: :destroy end end diff --git a/app/views/admin/communication/website/blocks/_list.html.erb b/app/views/admin/communication/blocks/_list.html.erb similarity index 63% rename from app/views/admin/communication/website/blocks/_list.html.erb rename to app/views/admin/communication/blocks/_list.html.erb index e215b67157d89447740fae3b0cab2d657bb63439..5600bb047c83e8a5862efbae48a64e111ff25f97 100644 --- a/app/views/admin/communication/website/blocks/_list.html.erb +++ b/app/views/admin/communication/blocks/_list.html.erb @@ -2,27 +2,27 @@ <div class="card-header"> <div class="float-end"> <%= link_to t('add'), - new_admin_communication_website_block_path(about_id: about.id, about_type: about.class.name), + new_admin_communication_block_path(about_id: about.id, about_type: about.class.name), class: button_classes %> </div> <h2 class="card-title mb-0 h5"> - <%= Communication::Website::Block.model_name.human(count: 2) %> + <%= Communication::Block.model_name.human(count: 2) %> </h2> </div> <table class="<%= table_classes %>"> <thead> <tr> <th width="20" class="ps-0"> </th> - <th><%= Communication::Website::Block.human_attribute_name('name') %></th> - <th><%= Communication::Website::Block.human_attribute_name('template') %></th> + <th><%= Communication::Block.human_attribute_name('name') %></th> + <th><%= Communication::Block.human_attribute_name('template') %></th> <th></th> </tr> </thead> - <tbody data-sortable data-sort-url="<%= reorder_admin_communication_website_blocks_path %>"> + <tbody data-sortable data-sort-url="<%= reorder_admin_communication_blocks_path %>"> <% about.blocks.ordered.each do |block| %> <tr data-id="<%= block.id %>"> <td><i class="fa fa-bars handle"></i></td> - <td><%= link_to block, admin_communication_website_block_path(block) %></td> + <td><%= link_to block, admin_communication_block_path(block) %></td> <td><%= block.template_i18n %></td> <td class="text-end"> <%= edit_link block %> diff --git a/app/views/admin/communication/website/blocks/_static.html.erb b/app/views/admin/communication/blocks/_static.html.erb similarity index 50% rename from app/views/admin/communication/website/blocks/_static.html.erb rename to app/views/admin/communication/blocks/_static.html.erb index 2b5dbed63c6d3d0f53312df54e68bcdd3fdcccb4..2542ca4f26bf06f90c3463c3073d4240a0ecd77f 100644 --- a/app/views/admin/communication/website/blocks/_static.html.erb +++ b/app/views/admin/communication/blocks/_static.html.erb @@ -3,5 +3,5 @@ blocks: <% about.blocks.each do |block| %> - template: <%= block.template %> data: -<%= render "admin/communication/website/blocks/templates/#{block.template}/static", block: block if block.data %><% end %> +<%= render "admin/communication/blocks/templates/#{block.template}/static", block: block if block.data %><% end %> <% end %> diff --git a/app/views/admin/communication/website/blocks/edit.html.erb b/app/views/admin/communication/blocks/edit.html.erb similarity index 90% rename from app/views/admin/communication/website/blocks/edit.html.erb rename to app/views/admin/communication/blocks/edit.html.erb index 73e849a0026f5ad785f722e57b9c947fab0aa15a..56e47eaa93da35e33bc23f0dae26a5449a899d86 100644 --- a/app/views/admin/communication/website/blocks/edit.html.erb +++ b/app/views/admin/communication/blocks/edit.html.erb @@ -5,8 +5,8 @@ %> <div id="app"> <%= simple_form_for [:admin, @block] do |f| %> - <%= render "admin/communication/website/blocks/templates/#{@block.template}/edit", f: f %> - <textarea name="communication_website_block[data]" rows="20" cols="200" class="d-none"> + <%= render "admin/communication/blocks/templates/#{@block.template}/edit", f: f %> + <textarea name="communication_block[data]" rows="20" cols="200" class="d-none"> {{ JSON.stringify(data) }} </textarea> <% content_for :action_bar_right do %> @@ -24,7 +24,7 @@ draggable: VueDraggableNext.VueDraggableNext, }, data() { - return { + return { directUpload: { url: "<%= rails_direct_uploads_url.html_safe %>", blobUrlTemplate: "<%= rails_service_blob_url(":signed_id", ":filename").html_safe %>" diff --git a/app/views/admin/communication/website/blocks/new.html.erb b/app/views/admin/communication/blocks/new.html.erb similarity index 59% rename from app/views/admin/communication/website/blocks/new.html.erb rename to app/views/admin/communication/blocks/new.html.erb index 220dbac7b039c951eee780399fcde923bcaa54eb..6e08ed14bdc6d360f0c3876b424478c425169cc6 100644 --- a/app/views/admin/communication/website/blocks/new.html.erb +++ b/app/views/admin/communication/blocks/new.html.erb @@ -1,19 +1,19 @@ -<% content_for :title, t('communication.website.block.choose_template') %> +<% content_for :title, t('communication.block.choose_template') %> <div class="row"> - <% Communication::Website::Block.templates.keys.each do |template| %> + <% Communication::Block.templates.keys.each do |template| %> <% @block.template = template %> <div class="col-lg-3 col-md-4"> <div class="card"> - <% asset = "communication/websites/blocks/templates/#{template}.jpg" %> + <% asset = "communication/blocks/templates/#{template}.jpg" %> <%= image_tag asset, alt: '' if Rails.application.assets.find_asset(asset) %> <div class="card-body"> - <h5 class="card-title"><%= t "enums.communication.website.block.template.#{template}" %></h5> + <h5 class="card-title"><%= t "enums.communication.block.template.#{template}" %></h5> <%= simple_form_for [:admin, @block] do |f| %> <%= f.input :about_type, as: :hidden %> <%= f.input :about_id, as: :hidden %> <%= f.input :template, as: :hidden %> - <%= f.submit t('communication.website.block.choose'), + <%= f.submit t('communication.block.choose'), class: button_classes('stretched-link') %> <% end %> </div> diff --git a/app/views/admin/communication/website/blocks/show.html.erb b/app/views/admin/communication/blocks/show.html.erb similarity index 56% rename from app/views/admin/communication/website/blocks/show.html.erb rename to app/views/admin/communication/blocks/show.html.erb index abb88f0df4d096f307b3890a81dfbbc466b084ba..7fdb8f5698fd04c47305392eaaf9ce70ba1a0592 100644 --- a/app/views/admin/communication/website/blocks/show.html.erb +++ b/app/views/admin/communication/blocks/show.html.erb @@ -1,6 +1,6 @@ <% content_for :title, @block %> -<%= render "admin/communication/website/blocks/templates/#{@block.template}/show" %> +<%= render "admin/communication/blocks/templates/#{@block.template}/show" %> <% content_for :action_bar_right do %> <%= edit_link @block %> diff --git a/app/views/admin/communication/website/blocks/templates/organization_chart/_edit.html.erb b/app/views/admin/communication/blocks/templates/organization_chart/_edit.html.erb similarity index 96% rename from app/views/admin/communication/website/blocks/templates/organization_chart/_edit.html.erb rename to app/views/admin/communication/blocks/templates/organization_chart/_edit.html.erb index 680fddee0ef261515961c4c0def692c7c21d0370..fd33bc97789a78e39f3c00633219785e5ef6385a 100644 --- a/app/views/admin/communication/website/blocks/templates/organization_chart/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/organization_chart/_edit.html.erb @@ -46,7 +46,7 @@ </div> <div class="col-md-5"> <select class="form-select select" v-model="person.id"> - <% @website.university.people.ordered.each_with_index do |person, index| %> + <% current_university.people.ordered.each_with_index do |person, index| %> <option value="<%= person.id %>"><%= person.last_name %>, <%= person.first_name %></option> <% end %> </select> diff --git a/app/views/admin/communication/website/blocks/templates/organization_chart/_show.html.erb b/app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb similarity index 100% rename from app/views/admin/communication/website/blocks/templates/organization_chart/_show.html.erb rename to app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb diff --git a/app/views/admin/communication/website/blocks/templates/organization_chart/_static.html.erb b/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb similarity index 100% rename from app/views/admin/communication/website/blocks/templates/organization_chart/_static.html.erb rename to app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb diff --git a/app/views/admin/communication/website/blocks/templates/partners/_edit.html.erb b/app/views/admin/communication/blocks/templates/partners/_edit.html.erb similarity index 100% rename from app/views/admin/communication/website/blocks/templates/partners/_edit.html.erb rename to app/views/admin/communication/blocks/templates/partners/_edit.html.erb diff --git a/app/views/admin/communication/website/blocks/templates/partners/_show.html.erb b/app/views/admin/communication/blocks/templates/partners/_show.html.erb similarity index 100% rename from app/views/admin/communication/website/blocks/templates/partners/_show.html.erb rename to app/views/admin/communication/blocks/templates/partners/_show.html.erb diff --git a/app/views/admin/communication/website/blocks/templates/partners/_static.html.erb b/app/views/admin/communication/blocks/templates/partners/_static.html.erb similarity index 100% rename from app/views/admin/communication/website/blocks/templates/partners/_static.html.erb rename to app/views/admin/communication/blocks/templates/partners/_static.html.erb diff --git a/app/views/admin/communication/website/pages/show.html.erb b/app/views/admin/communication/website/pages/show.html.erb index 8d4b8a8c0bd3d52c396d3e6879cfb53af93bbefd..eb1059a31dcff8f629726b24debcedaff75f9958 100644 --- a/app/views/admin/communication/website/pages/show.html.erb +++ b/app/views/admin/communication/website/pages/show.html.erb @@ -13,7 +13,7 @@ <%= render 'admin/application/property/text', object: @page, property: :text %> </div> </div> - <%= render 'admin/communication/website/blocks/list', about: @page %> + <%= render 'admin/communication/blocks/list', about: @page %> </div> <div class="col-md-4"> <div class="card flex-fill w-100"> diff --git a/app/views/admin/communication/website/pages/static.html.erb b/app/views/admin/communication/website/pages/static.html.erb index 2462dbddf9372ba5a934263ffc317ca5053b439a..23c3d9aae117fc66c73ccb9fd4ed0f3553834ebc 100644 --- a/app/views/admin/communication/website/pages/static.html.erb +++ b/app/views/admin/communication/website/pages/static.html.erb @@ -12,6 +12,6 @@ category: "<%= @about.related_category.path %>/" <% end %> description: > <%= prepare_text_for_static @about.description %> -<%= render 'admin/communication/website/blocks/static', about: @about %> +<%= render 'admin/communication/blocks/static', about: @about %> --- <%= prepare_html_for_static @about.text, @about.university %> diff --git a/app/views/admin/education/programs/_form.html.erb b/app/views/admin/education/programs/_form.html.erb index efb7293ccc3bd348198e679f6d07fa5b6b15e9ee..b116804b83f80f2cbed56646f0e84bdd84e91c9d 100644 --- a/app/views/admin/education/programs/_form.html.erb +++ b/app/views/admin/education/programs/_form.html.erb @@ -27,8 +27,23 @@ value_method: ->(p) { p[:id] } %> </div> </div> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('activerecord.attributes.education/program.featured_image') %></h5> + </div> + <div class="card-body"> + <%= f.input :featured_image, + as: :single_deletable_file, + direct_upload: true, + label: false, + input_html: { accept: '.jpg,.jpeg,.png' }, + preview: true + %> + <%= f.input :featured_image_alt %> + </div> + </div> </div> - <div class="col-md-6"> + <div class="col-md-9"> <div class="card flex-fill w-100"> <div class="card-header"> <h5 class="card-title mb-0"><%= t('education.program.useful_informations') %></h5> @@ -42,52 +57,46 @@ <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :other %> </div> </div> - </div> - <div class="col-md-3"> + <div class="card flex-fill w-100"> <div class="card-header"> - <h5 class="card-title mb-0"><%= t('activerecord.attributes.education/program.featured_image') %></h5> + <h5 class="card-title mb-0"><%= t('education.program.educational_informations') %></h5> </div> <div class="card-body"> - <%= f.input :featured_image, - as: :single_deletable_file, - direct_upload: true, - label: false, - input_html: { accept: '.jpg,.jpeg,.png' }, - preview: true - %> - <%= f.input :featured_image_alt %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :objectives %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :content %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :prerequisites %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pedagogy %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :evaluation %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :opportunities %> + <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :results %> </div> </div> - </div> - </div> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= t('activerecord.attributes.education/program.team') %></h5> - </div> - <div class="card-body"> - <div class="row"> - <div class="col-md-4"> + + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('activerecord.attributes.education/program.team') %></h5> + </div> + <div class="card-body"> <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :contacts %> </div> - <div class="col-md-8 clearfix"> + <div class="card-body"> <div class="row mb-2"> <div class="col-md-8"> <label class="form-label"><%= Education::Program.human_attribute_name('teachers') %></label> </div> <div class="col-md-4 text-end"> <%= link_to_add_association t('add'), - f, - :university_person_involvements, - class: button_classes, - partial: 'admin/education/programs/involvement_fields', - data: { - 'association-insertion-method': 'append', - 'association-insertion-node': '#involvements', - } %> + f, + :university_person_involvements, + class: button_classes, + partial: 'admin/education/programs/involvement_fields', + data: { + 'association-insertion-method': 'append', + 'association-insertion-node': '#involvements', + } %> </div> </div> - <div id="involvements"> <% sorted_involvements = program.university_person_involvements.sort_by { |involvement| @@ -95,30 +104,9 @@ } %> <%= f.simple_fields_for :university_person_involvements, sorted_involvements, include_id: false do |involvement_f| %> - <%= render 'admin/education/programs/involvement_fields', f: involvement_f, include_id: true %> + <%= render 'admin/education/programs/involvement_fields', f: involvement_f, include_id: true %> <% end %> </div> - - </div> - </div> - </div> - </div> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= t('education.program.educational_informations') %></h5> - </div> - <div class="card-body"> - <div class="row"> - <div class="col-md-6"> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :objectives %> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :content %> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :prerequisites %> - </div> - <div class="col-md-6"> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :pedagogy %> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :evaluation %> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :opportunities %> - <%= render 'admin/education/programs/forms/input_with_inheritance', f: f, property: :results %> </div> </div> </div> diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb index 55bdad46684e365ed4a300371117968a47230238..8d9ed285e17282ca5affe5b67c070ac10b7cdae0 100644 --- a/app/views/admin/education/programs/show.html.erb +++ b/app/views/admin/education/programs/show.html.erb @@ -39,7 +39,7 @@ </div> <% end %> </div> - <div class="col-md-4"> + <div class="col-md-9"> <div class="card flex-fill w-100"> <div class="card-header"> <h5 class="card-title mb-0"><%= t('education.program.useful_informations') %></h5> @@ -58,56 +58,49 @@ <% end %> </div> </div> - </div> - <div class="col-md-5"> - <div class="card flex-fill w-100"> <div class="card-header"> <h5 class="card-title mb-0"><%= t('education.program.educational_informations') %></h5> </div> <div class="card-body"> <% [ - :objectives, - :content, - :prerequisites, - :pedagogy, - :evaluation, - :opportunities, - :results - ].each do |property| %> - <%= render 'admin/application/property/text', object: @program, property: property %> + :objectives, + :content, + :prerequisites, + :pedagogy, + :evaluation, + :opportunities, + :results + ].each do |property| %> + <%= render 'admin/application/property/text', object: @program, property: property %> <% end %> </div> </div> - </div> -</div> -<div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= Education::Program.human_attribute_name('team') %></h5> - </div> - <div class="card-body"> - <div class="row"> - <div class="col-md-6"> + <%= render 'admin/communication/blocks/list', about: @program %> + + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= Education::Program.human_attribute_name('team') %></h5> + </div> + <div class="card-body"> <%= render 'admin/education/programs/show/roles', roles: @roles %> </div> - <div class="col-md-6"> + <div class="card-body"> <%= render 'admin/education/programs/show/teachers', involvements: @teacher_involvements %> </div> </div> - </div> -</div> -<% if @program.children.any? %> - <div class="card flex-fill w-100"> - <div class="card-header"> - <h5 class="card-title mb-0"><%= Education::Program.model_name.human(count: 2) %></h5> - </div> - <div class="card-body"> - <%= render 'admin/education/programs/list', programs: @program.children %> - </div> + <% if @program.children.any? %> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= Education::Program.model_name.human(count: 2) %></h5> + </div> + <%= render 'admin/education/programs/list', programs: @program.children %> + </div> + <% end %> </div> -<% end %> +</div> <% content_for :preview do %> <% [ diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb index f734fa00a812e85718041f413977a2a310a0cf94..b2ab4137ed1950f6a2f40c3444f52115228b722c 100644 --- a/app/views/admin/education/programs/static.html.erb +++ b/app/views/admin/education/programs/static.html.erb @@ -64,4 +64,5 @@ ects: <%= @about.ects %> <%= property.to_s %>: > <%= prepare_html_for_static @about.send("best_#{property}"), @about.university %> <% end %> +<%= render 'admin/communication/blocks/static', about: @about %> --- diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 257d635cdebef046cd0e0e3604458d5a30d00980..d51b68a5d531e0f4e9c034be34eeb447bd8d193c 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -4,12 +4,12 @@ en: communication: Communication activerecord: models: + communication/block: + one: Content block + other: Content blocks communication/website: one: Website other: Websites - communication/website/block: - one: Content block - other: Content blocks communication/website/category: one: Category other: Categories @@ -42,7 +42,7 @@ en: about_type: About name: Name url: URL - communication/website/block: + communication/block: name: Name template: Kind of block communication/website/category: @@ -97,12 +97,12 @@ en: authors: one: Author other: Authors + block: + choose_template: Choose the kind of block to add + choose: Choose manage_authors: Manage authors number_of_posts: Nunber of posts website: - block: - choose_template: Choose the kind of block to add - choose: Choose git: Git imported: from: Imported from @@ -122,11 +122,11 @@ en: see_all: See the full list (%{number} elements) enums: communication: + block: + template: + organization_chart: Organization chart + partners: Partners website: - block: - template: - organization_chart: Organization chart - partners: Partners menu: item: kind: @@ -147,3 +147,7 @@ en: staff: Staff teachers: Educational staff url: URL + simple_form: + hints: + communication_website_index_page: + breadcrumb_title: If the field is empty, page title will be used in the breadcrumbs. diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index ab6348c31005b3a532358b6d93770f39daab2d27..397faa04acfc3bd5f9dee3493b10fa130580fcfb 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -4,12 +4,12 @@ fr: communication: Communication activerecord: models: + communication/block: + one: Bloc de contenu + other: Blocs de contenu communication/website: one: Site Web other: Sites Web - communication/website/block: - one: Bloc de contenu - other: Blocs de contenu communication/website/category: one: Catégorie other: Catégories @@ -45,7 +45,7 @@ fr: about_type: Sujet du site name: Nom url: URL - communication/website/block: + communication/block: name: Nom template: Type de bloc communication/website/category: @@ -109,12 +109,12 @@ fr: authors: one: Auteur·rice other: Auteur·rice·s + block: + choose_template: Choisir le type de bloc à ajouter + choose: Choisir manage_authors: Gérer les auteur·rice·s number_of_posts: Nombre d'actualités website: - block: - choose_template: Choisir le type de bloc à ajouter - choose: Choisir git: Git imported: from: Importé depuis @@ -176,11 +176,11 @@ fr: see_all: Voir la liste complète (%{number} éléments) enums: communication: + block: + template: + organization_chart: Organigramme + partners: Partenaires website: - block: - template: - organization_chart: Organigramme - partners: Partenaires menu: item: kind: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index d92061b04874bd372f8479317eee16d38927fe8a..a0af0b14eff9793948dd4147e4cc5ade146cb5c9 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -31,11 +31,6 @@ namespace :communication do as: :post_curations, controller: 'website/posts/curations', only: [:new, :create] - resources :blocks, controller: 'website/blocks', except: :index do - collection do - post :reorder - end - end resources :menus, controller: 'website/menus' do resources :items, controller: 'website/menu/items', except: :index do collection do @@ -56,4 +51,9 @@ namespace :communication do patch 'indexes/:kind' => 'website/index_pages#update' put 'indexes/:kind' => 'website/index_pages#update' end + resources :blocks, controller: 'blocks', except: :index do + collection do + post :reorder + end + end end diff --git a/db/migrate/20220224131614_rename_blocks.rb b/db/migrate/20220224131614_rename_blocks.rb new file mode 100644 index 0000000000000000000000000000000000000000..66061ca6ca7f4879e7c9976340ee5a122bde0dd6 --- /dev/null +++ b/db/migrate/20220224131614_rename_blocks.rb @@ -0,0 +1,5 @@ +class RenameBlocks < ActiveRecord::Migration[6.1] + def change + rename_table :communication_website_blocks, :communication_blocks + end +end diff --git a/db/migrate/20220224140838_remove_communication_website_id_from_communication_blocks.rb b/db/migrate/20220224140838_remove_communication_website_id_from_communication_blocks.rb new file mode 100644 index 0000000000000000000000000000000000000000..6d48bfe7c725b52d6dad003dda65be9894d3a1b5 --- /dev/null +++ b/db/migrate/20220224140838_remove_communication_website_id_from_communication_blocks.rb @@ -0,0 +1,5 @@ +class RemoveCommunicationWebsiteIdFromCommunicationBlocks < ActiveRecord::Migration[6.1] + def change + remove_column :communication_blocks, :communication_website_id + end +end diff --git a/db/schema.rb b/db/schema.rb index fc6fe5f52075c27fad39ac30310c5fe887ed1f2f..544615fe4ec72e96e8ac2abc5d35ce44f6277ad3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_02_23_193608) do +ActiveRecord::Schema.define(version: 2022_02_24_140838) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -79,9 +79,8 @@ ActiveRecord::Schema.define(version: 2022_02_23_193608) do t.index ["criterion_id"], name: "index_administration_qualiopi_indicators_on_criterion_id" end - create_table "communication_website_blocks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + create_table "communication_blocks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.uuid "university_id", null: false - t.uuid "communication_website_id", null: false t.string "about_type" t.uuid "about_id" t.integer "template", default: 0, null: false @@ -90,8 +89,7 @@ ActiveRecord::Schema.define(version: 2022_02_23_193608) do t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.index ["about_type", "about_id"], name: "index_communication_website_blocks_on_about" - t.index ["communication_website_id"], name: "index_communication_website_blocks_on_communication_website_id" - t.index ["university_id"], name: "index_communication_website_blocks_on_university_id" + t.index ["university_id"], name: "index_communication_blocks_on_university_id" end create_table "communication_website_categories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| @@ -656,8 +654,7 @@ ActiveRecord::Schema.define(version: 2022_02_23_193608) do add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "administration_qualiopi_indicators", "administration_qualiopi_criterions", column: "criterion_id" - add_foreign_key "communication_website_blocks", "communication_websites" - add_foreign_key "communication_website_blocks", "universities" + add_foreign_key "communication_blocks", "universities" add_foreign_key "communication_website_categories", "communication_website_categories", column: "parent_id" add_foreign_key "communication_website_categories", "communication_websites" add_foreign_key "communication_website_categories", "education_programs", column: "program_id" diff --git a/docs/communication/websites/blocks.md b/docs/communication/websites/blocks.md index b31e672a8e773953d32be70eb8583969642bc3de..343eac83a80f4fcd77e6ca34f9fbf29727f6d8df 100644 --- a/docs/communication/websites/blocks.md +++ b/docs/communication/websites/blocks.md @@ -12,7 +12,6 @@ Il faut lister les dépendances des blocs et les ajouter à l'objet about. ``` communication/website/Block - university:references -- website:references - about:references (polymorphic) - template:integer (enum) - position:integer @@ -30,19 +29,19 @@ Un partial que l'on peut ajouter à un show d'objet, avec : - un bouton pour ajouter un bloc ``` -views/admin/communication/website/blocks/_list.html.erb +views/admin/communication/blocks/_list.html.erb ``` ### Show Le show du bloc utilise le partial de son template ``` -views/admin/communication/website/blocks/templates/partners/_show.html.erb +views/admin/communication/blocks/templates/partners/_show.html.erb ``` ### Edit L'edit du bloc utilise le partial de son template ``` -views/admin/communication/website/blocks/templates/partners/_edit.html.erb +views/admin/communication/blocks/templates/partners/_edit.html.erb ``` ### Concern @@ -51,7 +50,7 @@ Tous les objets ayant des blocs utilisent le concern `WithBlocks`, qui ajoute la ### Export statique Les blocs sont exportés dans le frontmatter grâce au partial ``` -views/admin/communication/website/blocks/_static.html.erb +views/admin/communication/blocks/_static.html.erb ``` qui donne ce type de résultat ``` @@ -64,7 +63,7 @@ blocks: ``` Les générateurs de chaque type suivent l'organisation : ``` -views/admin/communication/website/blocks/templates/partners/_static.html.erb +views/admin/communication/blocks/templates/partners/_static.html.erb ``` Attention, il faut 6 espaces pour respecter l'indentation du front-matter : ```