From 7929828396f4130c4d47dcb7e459ffafc14868c5 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Wed, 11 May 2022 12:36:11 +0200 Subject: [PATCH] blocks show -> preview --- .../admin/communication/blocks_controller.rb | 16 ++++----- .../admin/communication/blocks/_list.html.erb | 3 +- .../communication/blocks/_preview.html.erb | 2 +- .../admin/communication/blocks/show.html.erb | 7 ---- .../templates/call_to_action/_edit.html.erb | 2 +- .../call_to_action/_preview.html.erb | 31 ++++++++++++++++ .../templates/call_to_action/_show.html.erb | 35 ------------------- .../{_show.html.erb => _preview.html.erb} | 0 .../{_show.html.erb => _preview.html.erb} | 0 .../templates/definitions/_edit.html.erb | 4 +-- .../{_show.html.erb => _preview.html.erb} | 0 .../{_show.html.erb => _preview.html.erb} | 0 .../{_show.html.erb => _preview.html.erb} | 0 .../blocks/templates/gallery/_edit.html.erb | 2 +- .../templates/gallery/_preview.html.erb | 11 ++++++ .../blocks/templates/gallery/_show.html.erb | 15 -------- .../blocks/templates/image/_preview.html.erb | 7 ++++ .../blocks/templates/image/_show.html.erb | 17 --------- .../organization_chart/_preview.html.erb | 15 ++++++++ .../organization_chart/_show.html.erb | 19 ---------- .../blocks/templates/pages/_edit.html.erb | 2 +- .../{_show.html.erb => _preview.html.erb} | 0 .../blocks/templates/partners/_edit.html.erb | 10 +++--- .../templates/partners/_preview.html.erb | 11 ++++++ .../blocks/templates/partners/_show.html.erb | 15 -------- .../blocks/templates/posts/_edit.html.erb | 8 ++--- .../blocks/templates/posts/_preview.html.erb | 15 ++++++++ .../blocks/templates/posts/_show.html.erb | 21 ----------- .../templates/testimonials/_edit.html.erb | 8 ++--- .../templates/testimonials/_preview.html.erb | 22 ++++++++++++ .../templates/testimonials/_show.html.erb | 26 -------------- .../blocks/templates/timeline/_edit.html.erb | 4 +-- .../templates/timeline/_preview.html.erb | 8 +++++ .../blocks/templates/timeline/_show.html.erb | 12 ------- .../{_show.html.erb => _preview.html.erb} | 0 config/locales/communication/en.yml | 2 +- config/locales/communication/fr.yml | 2 +- config/routes/admin/communication.rb | 2 +- 38 files changed, 152 insertions(+), 202 deletions(-) delete mode 100644 app/views/admin/communication/blocks/show.html.erb create mode 100644 app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb delete mode 100644 app/views/admin/communication/blocks/templates/call_to_action/_show.html.erb rename app/views/admin/communication/blocks/templates/chapter/{_show.html.erb => _preview.html.erb} (100%) rename app/views/admin/communication/blocks/templates/datatable/{_show.html.erb => _preview.html.erb} (100%) rename app/views/admin/communication/blocks/templates/definitions/{_show.html.erb => _preview.html.erb} (100%) rename app/views/admin/communication/blocks/templates/embed/{_show.html.erb => _preview.html.erb} (100%) rename app/views/admin/communication/blocks/templates/files/{_show.html.erb => _preview.html.erb} (100%) create mode 100644 app/views/admin/communication/blocks/templates/gallery/_preview.html.erb delete mode 100644 app/views/admin/communication/blocks/templates/gallery/_show.html.erb create mode 100644 app/views/admin/communication/blocks/templates/image/_preview.html.erb delete mode 100644 app/views/admin/communication/blocks/templates/image/_show.html.erb create mode 100644 app/views/admin/communication/blocks/templates/organization_chart/_preview.html.erb delete mode 100644 app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb rename app/views/admin/communication/blocks/templates/pages/{_show.html.erb => _preview.html.erb} (100%) create mode 100644 app/views/admin/communication/blocks/templates/partners/_preview.html.erb delete mode 100644 app/views/admin/communication/blocks/templates/partners/_show.html.erb create mode 100644 app/views/admin/communication/blocks/templates/posts/_preview.html.erb delete mode 100644 app/views/admin/communication/blocks/templates/posts/_show.html.erb create mode 100644 app/views/admin/communication/blocks/templates/testimonials/_preview.html.erb delete mode 100644 app/views/admin/communication/blocks/templates/testimonials/_show.html.erb create mode 100644 app/views/admin/communication/blocks/templates/timeline/_preview.html.erb delete mode 100644 app/views/admin/communication/blocks/templates/timeline/_show.html.erb rename app/views/admin/communication/blocks/templates/video/{_show.html.erb => _preview.html.erb} (100%) diff --git a/app/controllers/admin/communication/blocks_controller.rb b/app/controllers/admin/communication/blocks_controller.rb index 37978e457..325c5c14f 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/views/admin/communication/blocks/_list.html.erb b/app/views/admin/communication/blocks/_list.html.erb index 574744289..88ca81f61 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 72d57e3ae..40d11ae7e 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 8ae4009e2..000000000 --- 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 74caee4a0..64a93f392 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' )" 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 000000000..5b63da6c7 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/call_to_action/_preview.html.erb @@ -0,0 +1,31 @@ +<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> 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 bb36af750..000000000 --- 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/chapter/_show.html.erb b/app/views/admin/communication/blocks/templates/chapter/_preview.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/chapter/_show.html.erb rename to app/views/admin/communication/blocks/templates/chapter/_preview.html.erb diff --git a/app/views/admin/communication/blocks/templates/datatable/_show.html.erb b/app/views/admin/communication/blocks/templates/datatable/_preview.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/datatable/_show.html.erb rename to app/views/admin/communication/blocks/templates/datatable/_preview.html.erb 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 08b6904d0..8e3741fea 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/_show.html.erb b/app/views/admin/communication/blocks/templates/embed/_preview.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/embed/_show.html.erb rename to app/views/admin/communication/blocks/templates/embed/_preview.html.erb diff --git a/app/views/admin/communication/blocks/templates/files/_show.html.erb b/app/views/admin/communication/blocks/templates/files/_preview.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/files/_show.html.erb rename to app/views/admin/communication/blocks/templates/files/_preview.html.erb 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 bb2d880de..54adeec53 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_edit.html.erb @@ -24,7 +24,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 000000000..baa661e3c --- /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 85b3ef064..000000000 --- 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/_preview.html.erb b/app/views/admin/communication/blocks/templates/image/_preview.html.erb new file mode 100644 index 000000000..6649deb29 --- /dev/null +++ b/app/views/admin/communication/blocks/templates/image/_preview.html.erb @@ -0,0 +1,7 @@ +<%= 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 %> diff --git a/app/views/admin/communication/blocks/templates/image/_show.html.erb b/app/views/admin/communication/blocks/templates/image/_show.html.erb deleted file mode 100644 index df9643788..000000000 --- a/app/views/admin/communication/blocks/templates/image/_show.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -<div class="<%= 'row' unless @preview %>"> - <div class="<%= 'col-lg-3' unless @preview %>"> - <% if @block.template.image %> - <%= kamifusen_tag @block.template.image.blob, - width: 600, - alt: @block.template.image.alt, - class: 'img-fluid' %> - <% end %> - </div> - <div class="<%= 'col-lg-3' unless @preview %>"> - <caption><%= @block.template.image.alt %></caption> - <p class="small"><%= @block.template.image.credit %></p> - </div> - <div class="<%= 'col-lg-4' unless @preview %>"> - <%= @block.template.text.html_safe %> - </div> -</div> 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 000000000..1ba8ba5a0 --- /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 f0181c8f8..000000000 --- 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 8ac8909e2..9696bd493 100644 --- a/app/views/admin/communication/blocks/templates/pages/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/pages/_edit.html.erb @@ -38,7 +38,7 @@ <div class="card"> <div class="card-body"> <div class="row"> - <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(page), 1)" title="Delete"> diff --git a/app/views/admin/communication/blocks/templates/pages/_show.html.erb b/app/views/admin/communication/blocks/templates/pages/_preview.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/pages/_show.html.erb rename to app/views/admin/communication/blocks/templates/pages/_preview.html.erb 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 476799fa0..cd3b51853 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 000000000..989a14a51 --- /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 6c9a10ff5..000000000 --- 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 a85581f9f..fc343bc2c 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 000000000..1f264f7d2 --- /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 7f6d68cf1..000000000 --- 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 7cebbc2d6..7a5666854 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 000000000..e12a4fc26 --- /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 1237e4918..000000000 --- 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 a646b4816..924cd55f7 100644 --- a/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb +++ b/app/views/admin/communication/blocks/templates/timeline/_edit.html.erb @@ -16,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" @@ -24,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 000000000..aa27fd7a3 --- /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 1094e2dde..000000000 --- a/app/views/admin/communication/blocks/templates/timeline/_show.html.erb +++ /dev/null @@ -1,12 +0,0 @@ -<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/video/_show.html.erb b/app/views/admin/communication/blocks/templates/video/_preview.html.erb similarity index 100% rename from app/views/admin/communication/blocks/templates/video/_show.html.erb rename to app/views/admin/communication/blocks/templates/video/_preview.html.erb diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 37761ef54..0688acbd3 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -185,7 +185,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: diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index d669262f3..23401dacf 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -155,7 +155,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: diff --git a/config/routes/admin/communication.rb b/config/routes/admin/communication.rb index c6716a4fe..58edbf606 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 -- GitLab