Include admin/API/banner nativi, form contatti e reset copertina standard con layout edit più ampio. Co-authored-by: Cursor <cursoragent@cursor.com>
83 lines
3.4 KiB
ERB
83 lines
3.4 KiB
ERB
<% record = local_assigns[:record] %>
|
|
<% show_inherit_hint = local_assigns[:show_inherit_hint] %>
|
|
<% can_upload = local_assigns.fetch(:can_upload, false) %>
|
|
<% default_cover = Streams::CoverResolver::DEFAULT_COVER_URL %>
|
|
<% cover_src = record.effective_cover_url.presence || default_cover %>
|
|
<% remove_id = "remove_cover_#{record.model_name.param_key}" %>
|
|
|
|
<fieldset class="branding-fields cover-fields">
|
|
<legend><%= t("club.branding.cover_legend") %></legend>
|
|
|
|
<% if show_inherit_hint %>
|
|
<p class="branding-hint"><%= t("club.branding.cover_inherit_hint") %></p>
|
|
<% end %>
|
|
|
|
<p class="branding-hint"><%= t("club.branding.cover_hint") %></p>
|
|
|
|
<div class="branding-logo-block cover-preview-block">
|
|
<%= label_tag "branding[cover_image]", t("club.branding.cover_file_label") %>
|
|
<div class="branding-logo-preview branding-cover-preview" data-branding-cover-preview>
|
|
<%= image_tag cover_src,
|
|
alt: t("club.branding.cover_preview_alt"),
|
|
class: "branding-cover-preview__img",
|
|
data: { branding_cover_img: true } %>
|
|
</div>
|
|
|
|
<% if can_upload %>
|
|
<div class="cover-actions">
|
|
<%= file_field_tag "branding[cover_image]",
|
|
accept: "image/png,image/jpeg,image/webp",
|
|
data: { branding_cover_file: true },
|
|
class: "branding-file-input" %>
|
|
<% if record.cover_image_attached? %>
|
|
<%= hidden_field_tag "remove_cover", "0", id: remove_id, data: { branding_cover_remove: true } %>
|
|
<button type="button"
|
|
class="btn btn-secondary cover-reset-btn"
|
|
data-branding-cover-reset
|
|
data-default-cover="<%= default_cover %>"
|
|
data-remove-input="#<%= remove_id %>">
|
|
<%= t("club.branding.cover_reset_button") %>
|
|
</button>
|
|
<p class="branding-hint cover-reset-hint" data-branding-cover-reset-hint hidden>
|
|
<%= t("club.branding.cover_reset_pending_hint") %>
|
|
</p>
|
|
<% end %>
|
|
</div>
|
|
<% else %>
|
|
<p class="muted"><%= t("club.branding.cover_requires_full") %></p>
|
|
<%= link_to t("club.branding.cover_see_plans"), public_prezzi_path, class: "btn btn-secondary btn-sm" %>
|
|
<% end %>
|
|
</div>
|
|
</fieldset>
|
|
|
|
<script>
|
|
(function () {
|
|
var input = document.querySelector("[data-branding-cover-file]");
|
|
var img = document.querySelector("[data-branding-cover-img]");
|
|
var resetBtn = document.querySelector("[data-branding-cover-reset]");
|
|
var removeInput = document.querySelector("[data-branding-cover-remove]");
|
|
var resetHint = document.querySelector("[data-branding-cover-reset-hint]");
|
|
if (input && img) {
|
|
input.addEventListener("change", function () {
|
|
var file = input.files && input.files[0];
|
|
if (!file) return;
|
|
if (removeInput) removeInput.value = "0";
|
|
if (resetHint) resetHint.hidden = true;
|
|
if (resetBtn) resetBtn.disabled = false;
|
|
var reader = new FileReader();
|
|
reader.onload = function (e) { img.src = e.target.result; };
|
|
reader.readAsDataURL(file);
|
|
});
|
|
}
|
|
if (resetBtn && img && removeInput) {
|
|
resetBtn.addEventListener("click", function () {
|
|
removeInput.value = "1";
|
|
img.src = resetBtn.getAttribute("data-default-cover");
|
|
if (input) input.value = "";
|
|
if (resetHint) resetHint.hidden = false;
|
|
resetBtn.disabled = true;
|
|
});
|
|
}
|
|
})();
|
|
</script>
|