diff --git a/app/assets/images/communication/blocks/templates/datatable.jpg b/app/assets/images/communication/blocks/templates/datatable.jpg new file mode 100644 index 0000000000000000000000000000000000000000..de66f462ccf6e2ca5a376e7c32a6da9919036d5b Binary files /dev/null and b/app/assets/images/communication/blocks/templates/datatable.jpg differ diff --git a/app/assets/images/communication/blocks/templates/embed.jpg b/app/assets/images/communication/blocks/templates/embed.jpg new file mode 100644 index 0000000000000000000000000000000000000000..de66f462ccf6e2ca5a376e7c32a6da9919036d5b Binary files /dev/null and b/app/assets/images/communication/blocks/templates/embed.jpg differ diff --git a/app/assets/images/communication/blocks/templates/files.jpg b/app/assets/images/communication/blocks/templates/files.jpg new file mode 100644 index 0000000000000000000000000000000000000000..de66f462ccf6e2ca5a376e7c32a6da9919036d5b Binary files /dev/null and b/app/assets/images/communication/blocks/templates/files.jpg differ diff --git a/app/assets/images/communication/blocks/templates/image.jpg b/app/assets/images/communication/blocks/templates/image.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2655d4549f569d44d5ef2f38d143f04d28a4c8f4 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/image.jpg differ diff --git a/app/assets/images/communication/blocks/templates/video.jpg b/app/assets/images/communication/blocks/templates/video.jpg new file mode 100644 index 0000000000000000000000000000000000000000..de66f462ccf6e2ca5a376e7c32a6da9919036d5b Binary files /dev/null and b/app/assets/images/communication/blocks/templates/video.jpg differ diff --git a/app/controllers/admin/communication/blocks_controller.rb b/app/controllers/admin/communication/blocks_controller.rb index 37978e45799d3f99b8c3275075551d920d89c37f..325c5c14f9bc888f335805f8bdb04858272413ab 100644 --- a/app/controllers/admin/communication/blocks_controller.rb +++ b/app/controllers/admin/communication/blocks_controller.rb @@ -11,10 +11,6 @@ class Admin::Communication::BlocksController < Admin::Communication::Application end end - def show - breadcrumb - end - def new @block.about_type = params[:about_type] @block.about_id = params[:about_id] @@ -23,13 +19,13 @@ class Admin::Communication::BlocksController < Admin::Communication::Application def edit breadcrumb - add_breadcrumb t('edit') end def create @block.university = current_university if @block.save - redirect_to [:edit, :admin, @block], notice: t('admin.successfully_created_html', model: @block.to_s) + redirect_to [:edit, :admin, @block], + notice: t('admin.successfully_created_html', model: @block.to_s) else breadcrumb render :new, status: :unprocessable_entity @@ -38,7 +34,8 @@ class Admin::Communication::BlocksController < Admin::Communication::Application def update if @block.update(block_params) - redirect_to about_path, 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 breadcrumb add_breadcrumb t('edit') @@ -49,7 +46,8 @@ class Admin::Communication::BlocksController < Admin::Communication::Application def destroy path = about_path @block.destroy - redirect_to path, notice: t('admin.successfully_destroyed_html', model: @block.to_s) + redirect_to path, + notice: t('admin.successfully_destroyed_html', model: @block.to_s) end protected @@ -71,7 +69,7 @@ class Admin::Communication::BlocksController < Admin::Communication::Application if @block.new_record? add_breadcrumb t('communication.block.choose_template') else - add_breadcrumb @block, [:admin, @block] + add_breadcrumb @block end end diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index fa0d1fbfbbaa197d520206e949ef1599b81d69ea..733a971a2bcca774877080b7b140ffcebccc930c 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -32,15 +32,20 @@ class Communication::Block < ApplicationRecord enum template_kind: { chapter: 50, - organization_chart: 100, - partners: 200, + image: 51, gallery: 300, + video: 52, + datatable: 54, + files: 55, + embed: 53, + call_to_action: 900, testimonials: 400, - posts: 500, - pages: 600, timeline: 700, definitions: 800, - call_to_action: 900, + organization_chart: 100, + partners: 200, + posts: 500, + pages: 600, } before_save :update_template_images diff --git a/app/models/communication/block/template.rb b/app/models/communication/block/template.rb index 2eed4643d11775c3ae08abde14ce3cf2f5c03790..66cae4fd3495e62136e85f2ececa232d1f6e9621 100644 --- a/app/models/communication/block/template.rb +++ b/app/models/communication/block/template.rb @@ -37,6 +37,20 @@ class Communication::Block::Template university.active_storage_blobs.find id end + def extract_image_alt_and_credit(source, variable) + blob = find_blob source, variable + return if blob.nil? + alt = source["alt"] || source["#{variable}_alt"] + credit = source["credit"] || source["#{variable}_credit"] + text = source["text"] || source["#{variable}_text"] + { + blob: blob, + alt: alt, + credit: credit, + text: text + }.to_dot + end + def data block.data || {} end diff --git a/app/models/communication/block/template/call_to_action.rb b/app/models/communication/block/template/call_to_action.rb index bd780c941bed761e6d46db1dbf0ba595d7fb287a..57ea19c92cd70a957c2b7933313e429fe0672f34 100644 --- a/app/models/communication/block/template/call_to_action.rb +++ b/app/models/communication/block/template/call_to_action.rb @@ -23,19 +23,15 @@ class Communication::Block::Template::CallToAction < Communication::Block::Templ "#{data['button_secondary']}" end - def image - image_with_alt_and_credit + def url_tertiary + "#{data['url_tertiary']}" end - protected + def button_tertiary + "#{data['button_tertiary']}" + end - def image_with_alt_and_credit - blob = find_blob data, 'image' - return if blob.nil? - { - blob: blob, - alt: data['image_alt'], - credit: data['image_credit'], - }.to_dot + def image + extract_image_alt_and_credit data, 'image' end end diff --git a/app/models/communication/block/template/chapter.rb b/app/models/communication/block/template/chapter.rb index e51d0996619ff2807e9cafcb79d2dfd4f1da58fb..992a493a05bd55ab7eeb8cfab90b440ebb2f9d2a 100644 --- a/app/models/communication/block/template/chapter.rb +++ b/app/models/communication/block/template/chapter.rb @@ -1,6 +1,10 @@ class Communication::Block::Template::Chapter < Communication::Block::Template def build_git_dependencies - # pas d'images dans summernote, donc rien à déclarer ! + add_dependency image&.blob + end + + def image + extract_image_alt_and_credit data, 'image' end def text diff --git a/app/models/communication/block/template/datatable.rb b/app/models/communication/block/template/datatable.rb new file mode 100644 index 0000000000000000000000000000000000000000..6a764e8e1c88262b9f56d80585b4b937e4a92f38 --- /dev/null +++ b/app/models/communication/block/template/datatable.rb @@ -0,0 +1,4 @@ +class Communication::Block::Template::Datatable < Communication::Block::Template + def build_git_dependencies + end +end diff --git a/app/models/communication/block/template/embed.rb b/app/models/communication/block/template/embed.rb new file mode 100644 index 0000000000000000000000000000000000000000..c7075906320f1ca72df2262cc8759b3ed5052362 --- /dev/null +++ b/app/models/communication/block/template/embed.rb @@ -0,0 +1,4 @@ +class Communication::Block::Template::Embed < Communication::Block::Template + def build_git_dependencies + end +end diff --git a/app/models/communication/block/template/file.rb b/app/models/communication/block/template/file.rb new file mode 100644 index 0000000000000000000000000000000000000000..0c27e046a361be35560d44cff26f737e611d2ff3 --- /dev/null +++ b/app/models/communication/block/template/file.rb @@ -0,0 +1,4 @@ +class Communication::Block::Template::File < Communication::Block::Template + def build_git_dependencies + end +end diff --git a/app/models/communication/block/template/gallery.rb b/app/models/communication/block/template/gallery.rb index 9a208ac5dea1fa041f4ba534e112f502f6eca99d..76fab8c27b4dfdb27e5f353f22512187f3dcc26c 100644 --- a/app/models/communication/block/template/gallery.rb +++ b/app/models/communication/block/template/gallery.rb @@ -3,26 +3,14 @@ class Communication::Block::Template::Gallery < Communication::Block::Template add_dependency active_storage_blobs end - def images_with_data - @images_with_data ||= elements.map { |element| image_with_data(element) } - .compact + def images_with_alt + @images_with_alt ||= elements.map { |element| + extract_image_alt_and_credit element, 'file' + }.compact end def active_storage_blobs @active_storage_blobs ||= images_with_data.map { |hash| hash.blob } .compact end - - protected - - def image_with_data(element) - blob = find_blob element, 'file' - return if blob.nil? - { - blob: blob, - alt: element['alt'], - credit: element['credit'], - text: element['text'], - }.to_dot - end end diff --git a/app/models/communication/block/template/image.rb b/app/models/communication/block/template/image.rb new file mode 100644 index 0000000000000000000000000000000000000000..a306ec700532e92f1d0e2284d8e453c4edd0a0a3 --- /dev/null +++ b/app/models/communication/block/template/image.rb @@ -0,0 +1,14 @@ +class Communication::Block::Template::Image < Communication::Block::Template + def build_git_dependencies + add_dependency image&.blob + end + + def image + extract_image_alt_and_credit data, 'image' + end + + def text + "#{data['text']}" + end + +end diff --git a/app/models/communication/block/template/page.rb b/app/models/communication/block/template/page.rb index dd60b571e3c046c63e06f055ddbece03b4b1b140..fd9d66966cf14ddfff7c5ca29192f88883a75a24 100644 --- a/app/models/communication/block/template/page.rb +++ b/app/models/communication/block/template/page.rb @@ -9,33 +9,39 @@ class Communication::Block::Template::Page < Communication::Block::Template end def selected_pages - @selected_pages ||= elements.map { |element| - p = page(element['id']) - next if p.nil? - hash_from_page(p, element) - }.compact + # kind could be: selection (default), children + @selected_pages ||= send "selected_pages_#{kind}" end def main_page @main_page ||= page(data['page_id']) end - def show_description - data['show_description'] || false + def show_descriptions + data['show_descriptions'] || false end - def show_image - data['show_image'] || false + def show_images + data['show_images'] || false end protected - def hash_from_page(page, element) - { - page: page, - show_description: element['show_description'] || false, - show_image: element['show_image'] || false - }.to_dot + def kind + @kind ||= data['kind'] || 'selection' + end + + def selected_pages_selection + elements.map { |element| + page element['id'] + }.compact + end + + def selected_pages_children + return [] unless main_page + main_page.children + .published + .ordered end def page(id) diff --git a/app/models/communication/block/template/partner.rb b/app/models/communication/block/template/partner.rb index 930e858e956f48b73502fcf49a0186adcf221962..7a30863eac08dca4f45c93373a3f2eda3c878d40 100644 --- a/app/models/communication/block/template/partner.rb +++ b/app/models/communication/block/template/partner.rb @@ -8,20 +8,23 @@ class Communication::Block::Template::Partner < Communication::Block::Template end def partners - @partners ||= elements.map { |element| partner(element) } - .compact + @partners ||= elements.map { |element| + partner(element) + }.compact end def active_storage_blobs - @active_storage_blobs ||= partners.map { |partner| partner.blob } - .compact + @active_storage_blobs ||= partners.map { |partner| + partner.blob + }.compact end protected def organizations - @organizations ||= partners.map { |partner| partner.organization } - .compact + @organizations ||= partners.map { |partner| + partner.organization + }.compact end def partner(element) diff --git a/app/models/communication/block/template/post.rb b/app/models/communication/block/template/post.rb index 90df81731bc1dc28b994b73cc4540f5fddf9ef44..b25c07e1a0efdbe1d21c8fd8a618e937380ea4c7 100644 --- a/app/models/communication/block/template/post.rb +++ b/app/models/communication/block/template/post.rb @@ -49,8 +49,9 @@ class Communication::Block::Template::Post < Communication::Block::Template end def selected_posts_selection - elements.map { |element| post(element['id']) } - .compact + elements.map { |element| + post(element['id']) + }.compact end def post(id) diff --git a/app/models/communication/block/template/video.rb b/app/models/communication/block/template/video.rb new file mode 100644 index 0000000000000000000000000000000000000000..1f3d5d7dd746493ac8cfc53b9d1495ab174fb8ea --- /dev/null +++ b/app/models/communication/block/template/video.rb @@ -0,0 +1,4 @@ +class Communication::Block::Template::Video < Communication::Block::Template + def build_git_dependencies + end +end diff --git a/app/views/admin/communication/blocks/_list.html.erb b/app/views/admin/communication/blocks/_list.html.erb index 57474428928ba829e1b05f3a2a9cdfd7cfc9de57..88ca81f61493955bfba96b2d5acfea3ffbb6ebaa 100644 --- a/app/views/admin/communication/blocks/_list.html.erb +++ b/app/views/admin/communication/blocks/_list.html.erb @@ -28,11 +28,10 @@ <% end %> <td><%= link_to_if can?(:read, block), block.to_s.truncate(50), - admin_communication_block_path(block) %></td> + edit_admin_communication_block_path(block, website_id: nil) %></td> <td><%= block.template_kind_i18n %></td> <td class="text-end"> <div class="btn-group" role="group"> - <%= edit_link block %> <%= destroy_link block %> </div> </td> diff --git a/app/views/admin/communication/blocks/_preview.html.erb b/app/views/admin/communication/blocks/_preview.html.erb index 72d57e3ae7ad6244f32e791ac6204ec3af38cd3a..40d11ae7eaa06d15231a62d9f5a8b52c989891f0 100644 --- a/app/views/admin/communication/blocks/_preview.html.erb +++ b/app/views/admin/communication/blocks/_preview.html.erb @@ -3,4 +3,4 @@ @block = block @preview = true %> -<%= render "admin/communication/blocks/templates/#{@block.template_kind}/show" %> +<%= render "admin/communication/blocks/templates/#{@block.template_kind}/preview" %> diff --git a/app/views/admin/communication/blocks/show.html.erb b/app/views/admin/communication/blocks/show.html.erb deleted file mode 100644 index 8ae4009e2bc14f54b5c3151f7b3b488b911dc51b..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/show.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% content_for :title, @block %> - -<%= render "admin/communication/blocks/templates/#{@block.template_kind}/show" %> - -<% content_for :action_bar_right do %> - <%= edit_link @block %> -<% end %> diff --git a/app/views/admin/communication/blocks/templates/call_to_action/_edit.html.erb b/app/views/admin/communication/blocks/templates/call_to_action/_edit.html.erb index bf6f51c2668dd0f77112b59a034b98ac1e07e042..7e345611486ffd1be18277cdd5599e7b4ec2c1d8 100644 --- a/app/views/admin/communication/blocks/templates/call_to_action/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/call_to_action/_edit.html.erb @@ -19,7 +19,7 @@ for="image"> <%= t '.image_title' %> </label> - <input class="form-control mb-2" + <input class="form-control mb-3" type="file" accept="image/*" @change="onFileImageChange( $event, data, 'image' )" @@ -84,7 +84,7 @@ <div class="col-xxl-4 col-md-6"> <h3 class="h4"><%= t '.button_2' %></h3> - <label class="form-label" for="button"> + <label class="form-label" for="button_secondary"> <%= t '.button_label' %> </label> <input id="button_secondary" @@ -102,4 +102,25 @@ v-model="data.url_secondary" placeholder="<%= t '.url_placeholder' %>" /> </div> + <div class="col-xxl-4 col-md-6"> + <h3 class="h4"><%= t '.button_3' %></h3> + + <label class="form-label" for="button_tertiary"> + <%= t '.button_label' %> + </label> + <input id="button_tertiary" + type="text" + class="form-control" + v-model="data.button_tertiary" + placeholder="<%= t '.button_placeholder' %>" /> + + <label class="form-label mt-3" for="url_tertiary"> + <%= t '.url_label' %> + </label> + <input id="url_tertiary" + type="url" + class="form-control" + v-model="data.url_tertiary" + placeholder="<%= t '.url_placeholder' %>" /> + </div> </div> diff --git a/app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb b/app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e3fda0a16515dbaa7c135ebb8d869b5b8c959be0 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb @@ -0,0 +1,39 @@ +<div class="card"> + <div class="card-body"> + <% if @block.template.image %> + <div style= "max-width: 200px;" class="me-3"> + <%= kamifusen_tag @block.template.image.blob, + width: 200, + alt: @block.template.image.alt, + class: 'img-fluid' %> + <caption><%= @block.template.image.alt %></caption> + </div> + <hr> + <% end %> + <%= @block.template.text.html_safe %> + <% unless @block.template.url.blank? %> + <a href="<%= @block.template.url %>" + class="btn btn-primary" + target="_blank" + rel="noopener"> + <%= @block.template.button %> + </a> + <% end %> + <% unless @block.template.url_secondary.blank? %> + <a href="<%= @block.template.url_secondary %>" + class="btn btn-primary" + target="_blank" + rel="noopener"> + <%= @block.template.button_secondary %> + </a> + <% end %> + <% unless @block.template.url_tertiary.blank? %> + <a href="<%= @block.template.url_tertiary %>" + class="btn btn-primary" + target="_blank" + rel="noopener"> + <%= @block.template.button_tertiary %> + </a> + <% end %> + </div> +</div> diff --git a/app/views/admin/communication/blocks/templates/call_to_action/_show.html.erb b/app/views/admin/communication/blocks/templates/call_to_action/_show.html.erb deleted file mode 100644 index bb36af7503343bb9e10a3630df0e96522018e057..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/call_to_action/_show.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -<div class="<%= 'row' unless @preview %>"> - <div class="<%= 'col-md-8 col-xl-6' unless @preview %>"> - <div class="card"> - <div class="card-body"> - <% if @block.template.image %> - <div style= "max-width: 200px;" class="me-3"> - <%= kamifusen_tag @block.template.image.blob, - width: 200, - alt: @block.template.image.alt, - class: 'img-fluid' %> - <caption><%= @block.template.image.alt %></caption> - </div> - <hr> - <% end %> - <%= @block.template.text.html_safe %> - <% unless @block.template.url.blank? %> - <a href="<%= @block.template.url %>" - class="btn btn-primary" - target="_blank" - rel="noopener"> - <%= @block.template.button %> - </a> - <% end %> - <% unless @block.template.url_secondary.blank? %> - <a href="<%= @block.template.url_secondary %>" - class="btn btn-secondary" - target="_blank" - rel="noopener"> - <%= @block.template.button_secondary %> - </a> - <% end %> - </div> - </div> - </div> -</div> diff --git a/app/views/admin/communication/blocks/templates/call_to_action/_static.html.erb b/app/views/admin/communication/blocks/templates/call_to_action/_static.html.erb index 8840c734bdfcc114f5b0f01d22ec7a4ab66c450e..718f464498e8fc4b74935ee1e7a52908e5433d60 100644 --- a/app/views/admin/communication/blocks/templates/call_to_action/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/call_to_action/_static.html.erb @@ -16,3 +16,8 @@ <%= prepare_text_for_static block.template.button_secondary %> url: >- <%= prepare_text_for_static block.template.url_secondary %> + button_tertiary: + text: >- + <%= prepare_text_for_static block.template.button_tertiary %> + url: >- + <%= prepare_text_for_static block.template.url_tertiary %> diff --git a/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb b/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb index f9af3e9f1f779e9f5545b946b570b0abc9d331da..860e81f9048569a1d23b038547b15e12f5aafc30 100644 --- a/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/chapter/_edit.html.erb @@ -4,17 +4,13 @@ for="text"> <%= t '.text_label' %> </label> - <div class="summernote"> + <div class="summernote mb-3"> <textarea id="text" class="form-control summernote-vue" v-model="data.text" data-summernote-config="mini-list" placeholder="<%= t '.text_placeholder' %>"></textarea> </div> - </div> -</div> -<div class="row"> - <div class="col-md-6"> <label class="form-label" for="notes"> <%= t '.notes_label' %> @@ -27,4 +23,50 @@ placeholder="<%= t '.notes_placeholder' %>"></textarea> </div> </div> + <div class="col-md-6"> + <div class="mb-3"> + <div v-if="!data.image"> + <label class="form-label" + for="image"> + <%= t 'admin.communication.blocks.components.image.input.label' %> + </label> + <input class="form-control" + type="file" + accept="image/*" + @change="onFileImageChange( $event, data, 'image' )" + id="image"> + </div> + <div v-if="data.image"> + <img :src="getImageUrl(data.image)" + class="img-fluid" + style="max-height: 80px" + /> + <br> + <a class="btn btn-sm btn-danger mt-2" + v-on:click="data.image=null"> + <i class="fas fa-times"></i> + <%= t 'admin.communication.blocks.components.image.input.remove' %> + </a> + </div> + </div> + <label class="form-label" + for="image_alt"> + <%= t 'admin.communication.blocks.components.image.alt.label' %> + </label> + <input id="image_alt" + type="text" + class="form-control mb-3" + v-model="data.image_alt" + placeholder="<%= t 'admin.communication.blocks.components.image.alt.placeholder' %>" /> + + <label class="form-label" + for="image_credit"> + <%= t 'admin.communication.blocks.components.image.credit.label' %> + </label> + <input id="image_alt" + type="text" + class="form-control" + v-model="data.image_credit" + placeholder="<%= t 'admin.communication.blocks.components.image.credit.placeholder' %>" /> + </div> </div> diff --git a/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb b/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..8b63ba0183fff679fcf0721ee4d78009c26f20c3 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb @@ -0,0 +1,8 @@ +<% if @block.template.image %> + <%= kamifusen_tag @block.template.image.blob, + width: 600, + alt: @block.template.image.alt, + class: 'img-fluid' %> +<% end %> +<%= @block.template.text.html_safe %> +<%= @block.template.notes.html_safe %> diff --git a/app/views/admin/communication/blocks/templates/chapter/_show.html.erb b/app/views/admin/communication/blocks/templates/chapter/_show.html.erb deleted file mode 100644 index 868577d6eff62a0ce96921d9b56a4195f5eaaf2e..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/chapter/_show.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<%= @block.template.text.html_safe %> -<%= @block.template.notes.html_safe %> diff --git a/app/views/admin/communication/blocks/templates/chapter/_static.html.erb b/app/views/admin/communication/blocks/templates/chapter/_static.html.erb index 1dcbc92180d28edca1d4f8f2b2dec4fface6340e..edd06fa88408aa4afae92256f7625d51b50c8a05 100644 --- a/app/views/admin/communication/blocks/templates/chapter/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/chapter/_static.html.erb @@ -2,3 +2,9 @@ <%= prepare_html_for_static block.template.text, about.university %> notes: >- <%= prepare_html_for_static block.template.notes, about.university %> + <% if block.template.image %> + image: + file: "<%= block.template.image.blob.id %>" + alt: <%= prepare_text_for_static block.template.image.alt %> + credit: <%= prepare_text_for_static block.template.image.credit %> + <% end %> diff --git a/app/views/admin/communication/blocks/templates/datatable/_edit.html.erb b/app/views/admin/communication/blocks/templates/datatable/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/datatable/_preview.html.erb b/app/views/admin/communication/blocks/templates/datatable/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/datatable/_static.html.erb b/app/views/admin/communication/blocks/templates/datatable/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/definitions/_edit.html.erb b/app/views/admin/communication/blocks/templates/definitions/_edit.html.erb index 08b6904d07cd7bda91fc900bf8bb1ec07456b0fe..8e3741feaed7a720d61a62d7b2b7ec32e989cf52 100644 --- a/app/views/admin/communication/blocks/templates/definitions/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/definitions/_edit.html.erb @@ -16,7 +16,7 @@ <div class="flex-fill"> <label class="form-label" :for="'definition-' + index + '-title'"><%= t '.title_label' %></label> - <input class="form-control mb-2" + <input class="form-control mb-3" v-model="definition.title" placeholder="<%= t '.title_placeholder' %>" type="text" @@ -24,7 +24,7 @@ <label class="form-label" :for="'definition-' + index + '-text'"><%= t '.text_label' %></label> - <textarea class="form-control mb-2" + <textarea class="form-control mb-3" rows="3" v-model="definition.text" placeholder="<%= t '.text_placeholder' %>" diff --git a/app/views/admin/communication/blocks/templates/definitions/_show.html.erb b/app/views/admin/communication/blocks/templates/definitions/_preview.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/definitions/_show.html.erb rename to app/views/admin/communication/blocks/templates/definitions/_preview.html.erb diff --git a/app/views/admin/communication/blocks/templates/embed/_edit.html.erb b/app/views/admin/communication/blocks/templates/embed/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/embed/_preview.html.erb b/app/views/admin/communication/blocks/templates/embed/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/embed/_static.html.erb b/app/views/admin/communication/blocks/templates/embed/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/files/_edit.html.erb b/app/views/admin/communication/blocks/templates/files/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/files/_preview.html.erb b/app/views/admin/communication/blocks/templates/files/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/files/_static.html.erb b/app/views/admin/communication/blocks/templates/files/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb b/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb index 3358548c2f6b768a120ff9efd03ee60f16538891..8ac88883e05e4594248bbe503f7a90fd1a114945 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb @@ -25,7 +25,7 @@ :for="'image-file-' + imageIndex"> <%= t '.image_label' %> </label> - <input class="form-control mb-2" + <input class="form-control mb-3" type="file" accept="image/*" @change="onFileImageChange( $event, image, 'file' )" diff --git a/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb b/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..baa661e3c126e45e493b906aa00c6cbb47fbcff5 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/gallery/_preview.html.erb @@ -0,0 +1,11 @@ +<% @block.template.images_with_alt.each do |image| %> + <article class="card"> + <% if image.blob %> + <%= kamifusen_tag image.blob, width: 500, class: 'img-fluid mb-3' %> + <% end %> + <div class="card-body"> + <p class="mb-0"><%= image.alt %></p> + <p class="mb-0 small"><%= image.text %></p> + </div> + </article> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/gallery/_show.html.erb b/app/views/admin/communication/blocks/templates/gallery/_show.html.erb deleted file mode 100644 index 85b3ef064ef15f41b44eeade08097b24746e3299..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/gallery/_show.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<div class="<%= 'row' unless @preview %>"> - <% @block.template.images_with_alt.each do |image| %> - <div class="<%= 'col-xxl-2 col-xl-3 col-6' unless @preview %>"> - <article class="card"> - <% if image.blob %> - <%= kamifusen_tag image.blob, width: 500, class: 'img-fluid mb-2' %> - <% end %> - <div class="card-body"> - <p class="mb-0"><%= image.alt %></p> - <p class="mb-0 small"><%= image.text %></p> - </div> - </article> - </div> - <% end %> -</div> diff --git a/app/views/admin/communication/blocks/templates/image/_edit.html.erb b/app/views/admin/communication/blocks/templates/image/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..6641fe1922cc468b520ac247479f20c7d45e024a --- /dev/null +++ b/app/views/admin/communication/blocks/templates/image/_edit.html.erb @@ -0,0 +1,60 @@ +<div class="row mb-5"> + <div class="col-xxl-4 col-md-6"> + <div v-if="!data.image"> + <label class="form-label" + for="image"> + <%= t 'admin.communication.blocks.components.image.input.label' %> + </label> + <input class="form-control mb-4" + type="file" + accept="image/*" + @change="onFileImageChange( $event, data, 'image' )" + id="image"> + </div> + <div v-if="data.image"> + <img :src="getImageUrl(data.image)" + class="img-fluid" + style="max-height: 80px" + /> + <br> + <a class="btn btn-sm btn-danger mt-2" + v-on:click="data.image=null"> + <i class="fas fa-times"></i> + <%= t 'admin.communication.blocks.components.image.input.remove' %> + </a> + </div> + </div> + <div class="col-xxl-4 col-md-6"> + <label class="form-label" + for="image_alt"> + <%= t 'admin.communication.blocks.components.image.alt.label' %> + </label> + <input id="image_alt" + type="text" + class="form-control mb-3" + v-model="data.image_alt" + placeholder="<%= t 'admin.communication.blocks.components.image.alt.placeholder' %>" /> + + <label class="form-label" + for="image_credit"> + <%= t 'admin.communication.blocks.components.image.credit.label' %> + </label> + <input id="image_alt" + type="text" + class="form-control mb-3" + v-model="data.image_credit" + placeholder="<%= t 'admin.communication.blocks.components.image.credit.placeholder' %>" /> + + <label class="form-label" + for="text"> + <%= t 'admin.communication.blocks.components.text.label' %> + </label> + <div class="summernote"> + <textarea id="text" + class="form-control summernote-vue" + v-model="data.text" + data-summernote-config="mini" + placeholder="<%= t 'admin.communication.blocks.components.text.placeholder' %>"></textarea> + </div> + </div> +</div> diff --git a/app/views/admin/communication/blocks/templates/image/_preview.html.erb b/app/views/admin/communication/blocks/templates/image/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..bd8956bf2c34ebac1235edc452114b456195695b --- /dev/null +++ b/app/views/admin/communication/blocks/templates/image/_preview.html.erb @@ -0,0 +1,9 @@ +<% if @block.template.image&.blob %> + <%= kamifusen_tag @block.template.image.blob, + width: 600, + alt: @block.template.image.alt, + class: 'img-fluid' if @block.template.image %> + <caption><%= @block.template.image.alt %></caption> + <p class="small"><%= @block.template.image.credit %></p> + <%= @block.template.text.html_safe %> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/image/_static.html.erb b/app/views/admin/communication/blocks/templates/image/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..440546caaf6e321450051f35812cb8ad823afe55 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/image/_static.html.erb @@ -0,0 +1,8 @@ + text: >- + <%= prepare_html_for_static block.template.text, about.university %> + <% if block.template.image %> + image: + file: "<%= block.template.image.blob.id %>" + alt: <%= prepare_text_for_static block.template.image.alt %> + credit: <%= prepare_text_for_static block.template.image.credit %> + <% end %> diff --git a/app/views/admin/communication/blocks/templates/organization_chart/_preview.html.erb b/app/views/admin/communication/blocks/templates/organization_chart/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..1ba8ba5a07ea9f15432677b2ab1db74cf3521431 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/organization_chart/_preview.html.erb @@ -0,0 +1,15 @@ +<% @block.template.persons_with_role.each do |person_with_role| + person = person_with_role.person %> + <article class="card"> + <div class="card-body"> + <% if person.best_picture.attached? %> + <div style="max-width: 80px" class="float-end"> + <%= kamifusen_tag person.best_picture, + class: 'img-fluid rounded-circle' %> + </div> + <% end %> + <h3 class="card-title h5"><%= link_to person, [:admin, person] %></h3> + <p class="mb-0"><%= person_with_role.role %></p> + </div> + </article> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb b/app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb deleted file mode 100644 index f0181c8f801110e335636fdf6937065c9b3c0b5c..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb +++ /dev/null @@ -1,19 +0,0 @@ -<div class="<%= 'row' unless @preview %>"> - <% @block.template.persons_with_role.each do |person_with_role| - person = person_with_role.person %> - <div class="<%= 'col-md-3' unless @preview %>"> - <article class="card"> - <div class="card-body"> - <% if person.best_picture.attached? %> - <div style="max-width: 80px" class="float-end"> - <%= kamifusen_tag person.best_picture, - class: 'img-fluid rounded-circle' %> - </div> - <% end %> - <h3 class="card-title h5"><%= link_to person, [:admin, person] %></h3> - <p class="mb-0"><%= person_with_role.role %></p> - </div> - </article> - </div> - <% end %> -</div> diff --git a/app/views/admin/communication/blocks/templates/pages/_edit.html.erb b/app/views/admin/communication/blocks/templates/pages/_edit.html.erb index 8ac8909e21b1df8673b76a3a33f7539b34186f32..8e2989b01e2f18ded56d48e154e13d0170850ffc 100644 --- a/app/views/admin/communication/blocks/templates/pages/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/pages/_edit.html.erb @@ -1,8 +1,59 @@ <% pages = collection_tree(@block.about&.website.pages) %> -<h2 class="mt-5">Page principale</h2> -<div class="row mb-1"> +<div class="row mb-4"> <div class="col-md-6"> + <h2 class="h3">Type de liste</h2> + <div class="form-check form-check-inline mb-3"> + <input class="form-check-input" + type="radio" + name="kind" + v-model="data.kind" + value="children" + id="kind-children"> + <label class="form-check-label" for="kind-children"> + La page principale et ses enfants + </label> + </div> + <div class="form-check form-check-inline"> + <input class="form-check-input" + type="radio" + name="kind" + v-model="data.kind" + value="selection" + id="kind-selection"> + <label class="form-check-label" for="kind-selection"> + Une sélection spécifique de pages + </label> + </div> + </div> + <div class="col-md-6"> + <h2 class="h3">Options d'affichage</h2> + <div class="form-check"> + <input v-model="data.show_description" + class="form-check-input boolean optional" + id="show_descriptions" + type="checkbox"> + <label class="form-check-label boolean optional" + for="show_descriptions"> + Afficher les descriptions courtes des pages + </label> + </div> + <div class="form-check"> + <input v-model="data.show_image" + class="form-check-input boolean optional" + id="show_images" + type="checkbox"> + <label class="form-check-label boolean optional" + for="show_images"> + Afficher les images des pages + </label> + </div> + </div> +</div> + +<div class="row"> + <div class="col-md-6"> + <h2 class="h3">Page principale</h2> <label class="form-label" for="page_id">Sélectionnez une page principale</label> <select id="page_id" @@ -13,69 +64,40 @@ <option value="<%= page[:id] %>"><%= page[:label].html_safe %></option> <% end %> </select> + <div class="form-text">Cette page principale définira le titre et le lien du bloc. Si vous choisissez une page sans remplir le titre ci-dessus, le titre de la page sera utilisé. Si le titre est rempli, il remplacera le titre de la page sélectionnée, en utilisant le lien de la page.</div> </div> - <div class="col-md-6"> - <label class="form-label">Option d'affichage</label> - <div class="form-check"> - <input v-model="data.show_description" class="form-check-input boolean optional" id="show_description" type="checkbox"> - <label class="form-check-label boolean optional" - for="show_description">Afficher la description courte</label> - </div> - <div class="form-check"> - <input v-model="data.show_image" class="form-check-input boolean optional" :id="'show_image'" type="checkbox"> - <label class="form-check-label boolean optional" - :for="'show_image'">Afficher l'image</label> - </div> - </div> - <div v-if="!data.category_id" class="col-md-12 mt-5"> - <h2>Ajouter des pages</h2> - <a class="<%= button_classes('mb-4') %>" + <div class="col-md-6" v-if="data.kind == 'selection'"> + <h2 class="h3">Pages sélectionnées</h2> + <a class="<%= button_classes('mb-3') %>" v-on:click="data.elements.push({id: ''})"> <%= t '.add_page' %> </a> - <draggable :list="data.elements" handle=".dragHandle"> - <div v-for="(page, index) in data.elements"> - <div class="card"> - <div class="card-body"> - <div class="row"> - <div class="mb-2"> - <a class="btn btn-sm btn-danger float-end" - v-on:click="data.elements.splice(data.elements.indexOf(page), 1)" - title="Delete"> - <i class="fas fa-times"></i> - </a> - <a class="btn ps-0 pt-0 dragHandle" title="Drag and drop"> - <i class="fa fa-bars handle"></i> - </a> - </div> - <div class="col-6"> - <label class="form-label" - :for="'page-' + index + '-name'">Page secondaire</label> - <select :id="'page-' + index + '-name'" - class="form-select select" - v-model="page.id"> - <option value="" disabled>Aucune page</option> - <% pages.each_with_index do |page, index| %> - <option value="<%= page[:id] %>"><%= page[:label].html_safe %></option> - <% end %> - </select> - </div> - <div class="col-6"> - <div class="col-md-6"> - <label class="form-label">Options d'affichage</label> - <div class="form-check"> - <input v-model="page.show_description" class="form-check-input boolean optional" :id="'page-' + index + '-show_short_description'" type="checkbox"> - <label class="form-check-label boolean optional" - :for="'page-' + index + '-show_short_description'">Afficher la description courte</label> - </div> - <div class="form-check"> - <input v-model="page.show_image" class="form-check-input boolean optional" :id="'page-' + index + '-show_image'" type="checkbox"> - <label class="form-check-label boolean optional" - :for="'page-' + index + '-show_image'">Afficher l'image</label> - </div> - </div> - </div> - </div> + <draggable :list="data.elements" handle=".dragHandle" class="list-group"> + <div v-for="(page, index) in data.elements" class="list-group-item"> + <div class="d-flex"> + <div> + <a class="btn ps-0 pt-0 dragHandle" title="Drag and drop"> + <i class="fa fa-bars handle"></i> + </a> + </div> + <div class="flex-fill"> + <label class="form-label d-none" + :for="'page-' + index + '-name'">Page</label> + <select :id="'page-' + index + '-name'" + class="form-select select" + v-model="page.id"> + <option value="" disabled>Aucune page</option> + <% pages.each_with_index do |page, index| %> + <option value="<%= page[:id] %>"><%= page[:label].html_safe %></option> + <% end %> + </select> + </div> + <div> + <a class="btn btn-sm btn-danger ms-3" + v-on:click="data.elements.splice(data.elements.indexOf(page), 1)" + title="Supprimer"> + <i class="fas fa-times"></i> + </a> </div> </div> </div> diff --git a/app/views/admin/communication/blocks/templates/pages/_preview.html.erb b/app/views/admin/communication/blocks/templates/pages/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..15a464e316bbacd3147d29639224bfb7cdbe2a37 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/pages/_preview.html.erb @@ -0,0 +1,21 @@ +<% if @block.data %> + <% if @block.template.main_page %> + <h2 class="h5 mb-4"><%= @block.template.main_page.slug %></h2> + <% end %> + <% @block.template.selected_pages.each do |element| %> + <div class="card mb-4"> + <div class="card-header"> + <h3 class="card-title h5"><%= element %></h3> + </div> + <div class="card-body"> + <% if @block.template.show_images && element.page.featured_image.attached? %> + <%= kamifusen_tag element.featured_image, + class: 'img-fluid mb-3' %> + <% end %> + <% if @block.template.show_descriptions %> + <p><%= element.page.description_short %></p> + <% end %> + </div> + </div> + <% end %> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/pages/_show.html.erb b/app/views/admin/communication/blocks/templates/pages/_show.html.erb deleted file mode 100644 index 2175cc87a7b1a018eda00daa0059ecf2c3d2a79f..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/pages/_show.html.erb +++ /dev/null @@ -1,27 +0,0 @@ -<% if @block.data %> - <% if @block.template.main_page %> - <h2 class="mb-4"><%= @block.template.main_page.slug %></h2> - <% end %> - <% if @block.template.selected_pages.any? %> - <div class="<%= 'row' unless @preview %>"> - <% @block.template.selected_pages.each do |element| %> - <div class="<%= 'col-md-4' unless @preview %>"> - <div class="card"> - <div class="card-header"> - <h3 class="card-title h5"><%= element.page %></h3> - </div> - <div class="card-body"> - <div class="mb-3"> - <% if element.show_image %> - <%= kamifusen_tag element.page.featured_image, - class: 'img-fluid' if element.page.featured_image.attached? && element.page.featured_image.variable? %> - <% end %> - </div> - <p><%= element.page.description_short if element.show_description %></p> - </div> - </div> - </div> - <% end %> - </div> - <% end %> -<% end %> diff --git a/app/views/admin/communication/blocks/templates/pages/_static.html.erb b/app/views/admin/communication/blocks/templates/pages/_static.html.erb index 1790aede14bbeb5e652dd91905b280b06eb703ea..87788b6ac59a4d3e302a8092c7b8c625729ba1d8 100644 --- a/app/views/admin/communication/blocks/templates/pages/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/pages/_static.html.erb @@ -1,11 +1,9 @@ <% if block.template.main_page %> page: <%= block.template.main_page.generated_path %> - show_description: <%= block.template.show_description %> - show_image: <%= block.template.show_image %> <% end %> + show_descriptions: <%= block.template.show_descriptions %> + show_images: <%= block.template.show_images %> pages: <% block.template.selected_pages.each do |element| %> - - slug: <%= element.page.generated_path %> - show_description: <%= element.show_description %> - show_image: <%= element.show_image %> + - <%= element.generated_path %> <% end %> diff --git a/app/views/admin/communication/blocks/templates/partners/_edit.html.erb b/app/views/admin/communication/blocks/templates/partners/_edit.html.erb index 476799fa01a5adf804428f42625b1c5c1dfc51ac..cd3b51853de9304519b47bad410fc7437f67c18f 100644 --- a/app/views/admin/communication/blocks/templates/partners/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/partners/_edit.html.erb @@ -11,7 +11,7 @@ </a> </div> <div class="flex-fill"> - <div class="row mb-3"> + <div class="row"> <div class="col-lg-4"> <select :id="'organization-' + index + '-id'" class="form-select select" @@ -23,12 +23,12 @@ </select> </div> </div> - <div class="row" v-if="!partner.id"> + <div class="row mt-3" v-if="!partner.id"> <div class="col-lg-4"> <label class="form-label" :for="'partner-' + index + '-name'"><%= t '.partner_name_label' %></label> - <input class="form-control mb-2" + <input class="form-control mb-3" type="text" v-model="partner.name" placeholder="<%= t '.partner_name_placeholder' %>" @@ -39,7 +39,7 @@ :for="'partner-' + index + '-url'"> <%= t '.partner_url_label' %> </label> - <input class="form-control mb-2" + <input class="form-control mb-3" type="url" v-model="partner.url" placeholder="<%= t '.partner_url_placeholder' %>" @@ -52,7 +52,7 @@ :for="'partner-' + index + '-logo'"> <%= t '.partner_logo_label' %> </label> - <input class="form-control mb-2" + <input class="form-control mb-3" type="file" accept="image/*" @change="onFileImageChange( $event, partner, 'logo' )" diff --git a/app/views/admin/communication/blocks/templates/partners/_preview.html.erb b/app/views/admin/communication/blocks/templates/partners/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..989a14a51f02d21ed622135ce2120ebecea75d71 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/partners/_preview.html.erb @@ -0,0 +1,11 @@ +<% @block.template.partners.each do |partner| %> + <article class="card"> + <%= kamifusen_tag partner.blob, + width: 300, + class: 'img-fluid mb-3' unless partner.blob.nil? %> + <div class="card-body"> + <h3 class="card-title h5"><%= partner.name %></h3> + <p class="mb-0"><%= partner.url %></p> + </div> + </article> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/partners/_show.html.erb b/app/views/admin/communication/blocks/templates/partners/_show.html.erb deleted file mode 100644 index 6c9a10ff598b736478c2963eee42186f3c0a2194..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/partners/_show.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<div class="<%= 'row' unless @preview %>"> - <% @block.template.partners.each do |partner| %> - <div class="<%= 'col-md-2' unless @preview %>"> - <article class="card"> - <%= kamifusen_tag partner.blob, - width: 300, - class: 'img-fluid mb-2' unless partner.blob.nil? %> - <div class="card-body"> - <h3 class="card-title h5"><%= partner.name %></h3> - <p class="mb-0"><%= partner.url %></p> - </div> - </article> - </div> - <% end %> -</div> diff --git a/app/views/admin/communication/blocks/templates/posts/_edit.html.erb b/app/views/admin/communication/blocks/templates/posts/_edit.html.erb index a85581f9f7979ee75b50cc3938fd51f8ffd19feb..fc343bc2c34e1cadd52935c0af4062365ee271d2 100644 --- a/app/views/admin/communication/blocks/templates/posts/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/posts/_edit.html.erb @@ -24,8 +24,8 @@ </label> </div> </div> - - <div v-if="data.kind === 'category'" class="mb-2"> + + <div v-if="data.kind === 'category'" class="mb-3"> <label class="form-label" for="category_id">Sélectionnez une catégorie</label> <select id="category_id" @@ -49,7 +49,7 @@ </div> </div> <div v-if="data.kind === 'selection'"> - <a class="<%= button_classes('mb-2') %>" + <a class="<%= button_classes('mb-3') %>" v-on:click="data.elements.push({id: ''})"> <%= t '.add_post' %> </a> @@ -57,7 +57,7 @@ <div v-for="(post, index) in data.elements" class="col-xxl-3 col-lg-4"> <div class="card"> <div class="card-body"> - <div class="mb-2"> + <div class="mb-3"> <a class="btn btn-sm btn-danger float-end" v-on:click="data.elements.splice(data.elements.indexOf(post), 1)" title="Delete"> diff --git a/app/views/admin/communication/blocks/templates/posts/_preview.html.erb b/app/views/admin/communication/blocks/templates/posts/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..1f264f7d24473f489902919f986275c803850c9b --- /dev/null +++ b/app/views/admin/communication/blocks/templates/posts/_preview.html.erb @@ -0,0 +1,15 @@ +<% if @block.data %> + <% if @block.template.category %> + <h2 class="mb-4"><%= @block.template.category %></h2> + <% end %> + <% @block.template.selected_posts.each do |post| %> + <div class="card"> + <div class="card-header"> + <h3 class="card-title h5"><%= post %></h3> + </div> + <div class="card-body"> + <%= post.description_short %> + </div> + </div> + <% end %> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/posts/_show.html.erb b/app/views/admin/communication/blocks/templates/posts/_show.html.erb deleted file mode 100644 index 7f6d68cf166042ca1dddb307bacb87b7910d598e..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/posts/_show.html.erb +++ /dev/null @@ -1,21 +0,0 @@ -<% if @block.data %> - <% if @block.template.category %> - <h2 class="mb-4"><%= @block.template.category %></h2> - <% end %> - <% if @block.template.selected_posts.any? %> - <div class="<%= 'row' unless @preview %>"> - <% @block.template.selected_posts.each do |post| %> - <div class="<%= 'col-md-4' unless @preview %>"> - <div class="card"> - <div class="card-header"> - <h3 class="card-title h5"><%= post %></h3> - </div> - <div class="card-body"> - <%= post.description_short %> - </div> - </div> - </div> - <% end %> - </div> - <% end %> -<% end %> diff --git a/app/views/admin/communication/blocks/templates/testimonials/_edit.html.erb b/app/views/admin/communication/blocks/templates/testimonials/_edit.html.erb index 7cebbc2d6ba4038d7a9997403d9b2bc2c5d528af..7a5666854d549272d51eda15bcd6a1436f650231 100644 --- a/app/views/admin/communication/blocks/templates/testimonials/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/testimonials/_edit.html.erb @@ -16,7 +16,7 @@ <div class="col-lg-4"> <label class="form-label" :for="'testimonial-' + index + '-text'"><%= t '.text_label' %></label> - <textarea class="form-control mb-2" + <textarea class="form-control mb-3" rows="3" v-model="testimonial.text" placeholder="<%= t '.text_placeholder' %>" @@ -27,7 +27,7 @@ :for="'testimonial-' + index + '-author'"> <%= t '.author_label' %> </label> - <input class="form-control mb-2" + <input class="form-control mb-3" type="text" v-model="testimonial.author" placeholder="<%= t '.author_placeholder' %>" @@ -36,7 +36,7 @@ :for="'testimonial-' + index + '-job'"> <%= t '.job_label' %> </label> - <input class="form-control mb-2" + <input class="form-control mb-3" type="text" v-model="testimonial.job" placeholder="<%= t '.job_placeholder' %>" @@ -49,7 +49,7 @@ :for="'testimonial-' + index + '-photo'"> <%= t '.photo_label' %> </label> - <input class="form-control mb-2" + <input class="form-control mb-3" type="file" accept="image/*" @change="onFileImageChange( $event, testimonial, 'photo' )" diff --git a/app/views/admin/communication/blocks/templates/testimonials/_preview.html.erb b/app/views/admin/communication/blocks/templates/testimonials/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e12a4fc2630069d82954b3322538a01cd43c40e8 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/testimonials/_preview.html.erb @@ -0,0 +1,22 @@ +<% @block.template.testimonials.each do |testimonial| %> + <article class="card"> + <div class="card-body"> + <p class="lead"> + <%= testimonial.text %> + </p> + <div class="d-flex align-items-center"> + <% if testimonial.blob %> + <div style="max-width: 80px;" class="me-3"> + <%= kamifusen_tag testimonial.blob, + width: 80, + class: 'img-fluid rounded-circle img-circle' %> + </div> + <% end %> + <p class="flex-fill mb-0"> + <b><%= testimonial.author %></b><br> + <%= testimonial.job %> + </p> + </div> + </div> + </article> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/testimonials/_show.html.erb b/app/views/admin/communication/blocks/templates/testimonials/_show.html.erb deleted file mode 100644 index 1237e4918d078c790a58ec14957646e7a873242d..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/testimonials/_show.html.erb +++ /dev/null @@ -1,26 +0,0 @@ -<div class="<%= 'row' unless @preview %>"> - <% @block.template.testimonials.each do |testimonial| %> - <div class="<%= 'col-xxl-4 col-xl-6' unless @preview %>"> - <article class="card"> - <div class="card-body"> - <p class="lead"> - <%= testimonial.text %> - </p> - <div class="d-flex align-items-center"> - <% if testimonial.blob %> - <div style="max-width: 80px;" class="me-3"> - <%= kamifusen_tag testimonial.blob, - width: 80, - class: 'img-fluid rounded-circle img-circle' %> - </div> - <% end %> - <p class="flex-fill mb-0"> - <b><%= testimonial.author %></b><br> - <%= testimonial.job %> - </p> - </div> - </div> - </article> - </div> - <% end %> -</div> diff --git a/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb b/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb index 6a9f54f1c4fddc6b0d979dfe9dc53ca6af078af4..924cd55f7d073f6fead00a8c79c10b7963b38f2b 100644 --- a/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb @@ -1,10 +1,3 @@ -<label for="description"><%= t '.description_placeholder' %></label> -<textarea class="form-control mb-2" - rows="3" - v-model="data.description" - placeholder="<%= t '.description_placeholder' %>" - id="description"></textarea> - <a class="<%= button_classes('mb-4') %>" v-on:click="data.elements.push({title: '', text: ''})"> <%= t '.add_event' %> @@ -23,7 +16,7 @@ <div class="flex-fill"> <label class="form-label" :for="'event-' + index + '-title'"><%= t '.title_label' %></label> - <input class="form-control mb-2" + <input class="form-control mb-3" v-model="event.title" placeholder="<%= t '.title_placeholder' %>" type="text" @@ -31,7 +24,7 @@ <label class="form-label" :for="'event-' + index + '-text'"><%= t '.text_label' %></label> - <textarea class="form-control mb-2" + <textarea class="form-control mb-3" rows="3" v-model="event.text" placeholder="<%= t '.text_placeholder' %>" diff --git a/app/views/admin/communication/blocks/templates/timeline/_preview.html.erb b/app/views/admin/communication/blocks/templates/timeline/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..aa27fd7a3c72f1b18bb83a59655494ad72fe80cf --- /dev/null +++ b/app/views/admin/communication/blocks/templates/timeline/_preview.html.erb @@ -0,0 +1,8 @@ +<% @block.template.events.each do |event| %> + <article class="card"> + <div class="card-body"> + <p class="lead"><%= event.title %></p> + <p><%= event.text %></p> + </div> + </article> +<% end %> diff --git a/app/views/admin/communication/blocks/templates/timeline/_show.html.erb b/app/views/admin/communication/blocks/templates/timeline/_show.html.erb deleted file mode 100644 index 0bbdf7c177564249e2b38b7bf99ccb84bce72848..0000000000000000000000000000000000000000 --- a/app/views/admin/communication/blocks/templates/timeline/_show.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<p><%= @block.template.description %></p> -<div class="<%= 'row' unless @preview %>"> - <% @block.template.events.each do |event| %> - <div class="<%= 'col-xxl-4 col-xl-6' unless @preview %>"> - <article class="card"> - <div class="card-body"> - <p class="lead"><%= event.title %></p> - <p><%= event.text %></p> - </div> - </article> - </div> - <% end %> -</div> diff --git a/app/views/admin/communication/blocks/templates/timeline/_static.html.erb b/app/views/admin/communication/blocks/templates/timeline/_static.html.erb index dd1e3dd4d9134d6532ccb6f2f8adc9367f4d9a77..4f6e0d2fca529289a3ae0a882a7c8a9b22b8a5b2 100644 --- a/app/views/admin/communication/blocks/templates/timeline/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/timeline/_static.html.erb @@ -1,5 +1,3 @@ - description: >- - <%= prepare_text_for_static block.template.description, 4 %> events: <% block.template.events.each do |event| %> - title: >- diff --git a/app/views/admin/communication/blocks/templates/video/_edit.html.erb b/app/views/admin/communication/blocks/templates/video/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/video/_preview.html.erb b/app/views/admin/communication/blocks/templates/video/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/video/_static.html.erb b/app/views/admin/communication/blocks/templates/video/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 5b1a947f574e05dcfdf6f85b1ca9c8b2b560887a..d7c097cf924abdfe39b50ee4ce172f8cc20b9a10 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -123,6 +123,20 @@ en: admin: communication: blocks: + components: + text: + label: Text + placeholder: Enter text + image: + input: + label: Image (.png, .jpg, .svg) + remove: Remove image + alt: + label: Alternative text + placeholder: Enter alternative text + credit: + label: Credit + placeholder: Enter credit template_kinds: chapter: edit: @@ -130,6 +144,24 @@ en: notes_placeholder: Enter notes text_label: Text text_placeholder: Enter text + call_to_action: + edit: + button_1: Primary button + button_2: Secondary button + button_label: Text + button_placeholder: Enter the button text here + buttons: Action buttons + image_alt_label: Alternative text + image_alt_placeholder: Enter image's alternative text here + image_credit_label: Credit + image_credit_placeholder: Enter image's credit here + image_label: File + image_title: Image + remove_image: Delete image + text_label: Text + text_placeholder: Enter text here + url_label: Link + url_placeholder: Enter the URL with "https://..." gallery: edit: add_image: Add image @@ -150,6 +182,9 @@ en: role_placeholder: Enter person's role drag_title: Drag and drop to organize persons delete_title: Remove person + pages: + edit: + add_page: Select a page partners: edit: add_partner: Add partner @@ -157,7 +192,7 @@ en: partner_name_placeholder: Enter partner's name partner_url_label: Website partner_url_placeholder: https:// - partner_image_label: Logo + partner_logo_label: Logo remove_logo: Remove logo remove_partner: Remove partner testimonials: @@ -188,24 +223,6 @@ en: title_placeholder: Enter title here text_label: Text text_placeholder: Enter text here - call_to_action: - edit: - button_1: Primary button - button_2: Secondary button - button_label: Text - button_placeholder: Enter the button text here - buttons: Action buttons - image_alt_label: Alternative text - image_alt_placeholder: Enter image's alternative text here - image_credit_label: Credit - image_credit_placeholder: Enter image's credit here - image_label: File - image_title: Image - remove_image: Delete image - text_label: Text - text_placeholder: Enter text here - url_label: Link - url_placeholder: Enter the URL with "https://..." website: pages: delete_special_page_notice: Can't delete this page @@ -321,14 +338,19 @@ en: template: call_to_action: Call to action chapter: Chapter + datatable: Table definitions: Definitions + embed: HTML embed + files: Files gallery: Gallery + image: Image organization_chart: Organization chart pages: Pages partners: Partners posts: Posts testimonials: Testimonials timeline: Timeline + video: Video website: menu: item: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index a75921fb7b5b3eb9add5f97b35221bc8d2d2192b..821e146528e359c391bd076db42019f3cc37d669 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -123,6 +123,20 @@ fr: admin: communication: blocks: + components: + text: + label: Texte + placeholder: Entrer le texte + image: + input: + label: Image (.png, .jpg, .svg) + remove: Enlever l'image + alt: + label: Texte alternatif + placeholder: Entrer la description textuelle + credit: + label: Crédit + placeholder: Entrer le crédit templates: chapter: edit: @@ -150,6 +164,9 @@ fr: role_placeholder: Indiquer le rôle de la personne drag_title: Glisser-déposer pour organiser les personnes delete_title: Enlever la personne + pages: + edit: + add_page: Sélectionner une page partners: edit: add_partner: Ajouter un partenaire @@ -157,7 +174,7 @@ fr: partner_name_placeholder: Entrer le nom du partenaire partner_url_label: Site Web partner_url_placeholder: https:// - partner_image_label: Logo + partner_logo_label: Logo remove_logo: Enlever le logo remove_partner: Enlever le partenaire testimonials: @@ -323,14 +340,19 @@ fr: template_kind: call_to_action: Appel à actions chapter: Chapitre + datatable: Tableau definitions: Définitions + embed: Intégration HTML + files: Fichiers gallery: Galerie + image: Image organization_chart: Organigramme pages: Liste de pages partners: Partenaires posts: Liste d'actualités testimonials: Témoignages timeline: Frise chronologique + video: Vidéo website: menu: item: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index c6716a4fe9cfc57e0a62e2d51c3fe126525317af..58edbf606457c88bb651032e53c430ce5529a107 100644 --- a/config/routes/admin/communication.rb +++ b/config/routes/admin/communication.rb @@ -52,7 +52,7 @@ namespace :communication do patch 'structure' => 'website/structure#update' end - resources :blocks, controller: 'blocks', except: :index do + resources :blocks, controller: 'blocks', except: [:index, :show] do collection do post :reorder end