diff --git a/app/assets/images/communication/blocks/templates/contact.jpg b/app/assets/images/communication/blocks/templates/contact.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fc5b66a30e0513eee757ccf3123870dee2d14219 Binary files /dev/null and b/app/assets/images/communication/blocks/templates/contact.jpg differ diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index ed2a58be0fcdc11991209a21ef9281f3a321b895..6ffb173734666dddf478efe39f3b00c56b61670d 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -51,13 +51,14 @@ class Communication::Block < ApplicationRecord partners: 200, posts: 500, pages: 600, + contact: 601, } CATEGORIES = { basic: [:chapter, :image, :video, :datatable], storytelling: [:key_figures, :gallery, :call_to_action, :testimonials, :timeline], references: [:pages, :posts, :organization_chart, :partners], - utilities: [:files, :definitions, :embed] + utilities: [:files, :definitions, :embed, :contact] } scope :published, -> { where(published: true) } diff --git a/app/models/communication/block/component/time_slot.rb b/app/models/communication/block/component/time_slot.rb new file mode 100644 index 0000000000000000000000000000000000000000..4b1a65555ed4b656070249255fcd7422a55e0cec --- /dev/null +++ b/app/models/communication/block/component/time_slot.rb @@ -0,0 +1,10 @@ +class Communication::Block::Component::TimeSlot < Communication::Block::Component::Base + + def default_data + { + 'from' => '0', + 'to' => '0' + } + end + +end diff --git a/app/models/communication/block/template/contact.rb b/app/models/communication/block/template/contact.rb new file mode 100644 index 0000000000000000000000000000000000000000..fa65262b9739ec71ba960ce8a3b7e417d39f5501 --- /dev/null +++ b/app/models/communication/block/template/contact.rb @@ -0,0 +1,10 @@ +class Communication::Block::Template::Contact < Communication::Block::Template::Base + + has_component :name, :string + has_component :phone_numbers, :array + has_component :emails, :array + has_component :address, :text + + has_elements + +end diff --git a/app/models/communication/block/template/contact/element.rb b/app/models/communication/block/template/contact/element.rb new file mode 100644 index 0000000000000000000000000000000000000000..5129866e0df3429d0ea7e04ec9ca36a135183a0d --- /dev/null +++ b/app/models/communication/block/template/contact/element.rb @@ -0,0 +1,5 @@ +class Communication::Block::Template::Contact::Element < Communication::Block::Template::Base + has_component :title, :string + has_component :time_slot_morning, :time_slot + has_component :time_slot_afternoon, :time_slot +end diff --git a/app/views/admin/communication/blocks/components/time_slot/_edit.html.erb b/app/views/admin/communication/blocks/components/time_slot/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..f5b321c6b7fc67aa0692dadbf6a9c17d1d4b27fa --- /dev/null +++ b/app/views/admin/communication/blocks/components/time_slot/_edit.html.erb @@ -0,0 +1,21 @@ +<% rows ||= 3 %> + +<div class="d-flex align-items-center mb-2"> + <label class="form-label me-1 mb-0" + aria-label="<%= label %>"> + <%= label %> De + </label> + <input class="form-control me-1" + v-model="<%= model %>.<%= property %>.from" + placeholder="<%= placeholder %> from" + type="time" /> + + <label class="form-label me-1 mb-0" + aria-label="<%= label %>"> + <%= label %> à + </label> + <input class="form-control" + v-model="<%= model %>.<%= property %>.to" + placeholder="<%= placeholder %> to" + type="time" /> +</div> \ No newline at end of file diff --git a/app/views/admin/communication/blocks/components/time_slot/_preview.html.erb b/app/views/admin/communication/blocks/components/time_slot/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..b8c9c330c537f5928d296e26c0093e1da1d3eca6 --- /dev/null +++ b/app/views/admin/communication/blocks/components/time_slot/_preview.html.erb @@ -0,0 +1 @@ +<%= simple_format value %> diff --git a/app/views/admin/communication/blocks/components/time_slot/_static.html.erb b/app/views/admin/communication/blocks/components/time_slot/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/edit.html.erb b/app/views/admin/communication/blocks/edit.html.erb index 940c473ec23af60f7dbb6806b0974377a349e4b5..5d11b444f68ee9f06d2f21f011a3420a81f4c850 100644 --- a/app/views/admin/communication/blocks/edit.html.erb +++ b/app/views/admin/communication/blocks/edit.html.erb @@ -24,7 +24,7 @@ <%= render 'admin/application/a11y/widget', about: @block %> </div> </div> - <textarea name="communication_block[data]" rows="20" cols="200" class="d-none"> + <textarea name="communication_block[data]" rows="20" cols="200" class="d-non"> {{ JSON.stringify(data) }} </textarea> <% content_for :action_bar_left do %> diff --git a/app/views/admin/communication/blocks/templates/contact/_edit.html.erb b/app/views/admin/communication/blocks/templates/contact/_edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..4153e8cc49f3b18d41542abd0018b39f4491483b --- /dev/null +++ b/app/views/admin/communication/blocks/templates/contact/_edit.html.erb @@ -0,0 +1,78 @@ +<%# TODO: traduction %> + +<h3 class="h4">Contact</h3> + +<div class="row"> + <div class="col-md-4"> + <%= block_component_edit :name, + label: "Nom (personne, établissement...)", + placeholder: t('admin.communication.blocks.components.text.placeholder') %> + + <%= block_component_edit :address, + label: "Adresse", + placeholder: t('admin.communication.blocks.components.text.placeholder') %> + + </div> + <div class="col-md-4"> + <h3 class="h4">Téléphones</h3> + + <div v-for="(element, index) in data.phone_numbers" class="list-group-item"> + <div class="d-flex"> + <input type="tel" + class="form-control" + maxlength="12" + v-model="data.phone_numbers[index]"> + <a class="btn btn-danger ms-2" + v-on:click="data.phone_numbers.splice(index, 1)"> + <i class="fas fa-times"></i> + </a> + </div> + </div> + + <a class="btn btn-primary mt-1" + v-on:click="data.phone_numbers.push('')"> + <i class="fas fa-plus"></i> ajouter une numéro de téléphone + </a> + </div> + <div class="col-md-4"> + <h3 class="h4">Emails</h3> + + <div v-for="(element, index) in data.emails" class="list-group-item"> + <div class="d-flex"> + <input type="email" + class="form-control" + v-model="data.emails[index]"> + <a class="btn btn-danger ms-2" + v-on:click="data.emails.splice(index, 1)"> + <i class="fas fa-times"></i> + </a> + </div> + </div> + + <a class="btn btn-primary mt-1" + v-on:click="data.emails.push('')"> + <i class="fas fa-plus"></i> ajouter un email + </a> + + </div> +</div> + +<h3 class="h4 mt-5">Horaires</h3> + +<div class="row"> + <div v-for="(element, index) in data.elements" class="col-md-4"> + <div class="card"> + <a class="btn btn-sm btn-danger position-absolute top-0 end-0" + v-on:click="data.elements.splice(index, 1)"> + <i class="fas fa-times"></i> + </a> + <div class="card-body"> + <%= block_component_edit :title, template: @element, label: 'Jour' %> + <%# TODO: Refactor des créneaux horaires %> + <%= block_component_edit :time_slot_morning, template: @element %> + <%= block_component_edit :time_slot_afternoon, template: @element %> + </div> + </div> + </div> +</div> +<%= block_component_add_element 'Ajouter un créneau horaire' %> diff --git a/app/views/admin/communication/blocks/templates/contact/_preview.html.erb b/app/views/admin/communication/blocks/templates/contact/_preview.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/app/views/admin/communication/blocks/templates/contact/_static.html.erb b/app/views/admin/communication/blocks/templates/contact/_static.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391