5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 21:26:21 +00:00
panel/app/views/posts/_new_related_post.haml

32 lines
1.4 KiB
Text
Raw Normal View History

:ruby
image = nil
description = nil
card_id = random_id
if post.post.attribute?(:image) && (image = post.post.image.static_file)
description = post.post.image.value['description']
end
.col.mb-3.p-1{ id: card_id, data: { controller: 'modal' } }
= render('bootstrap/card', image: image, description: description, title: post.title, class: 'h-100') do
- if post.post.attribute?(:description)
%p.card-text= post.post.description.value
-#
Si pasamos el ID del modal, asumimos que hay uno que ya existe y
lo llamamos. Sino, tenemos que abrir el modal genérico y cargarle
el formulario vía "HTMX".
- if local_assigns[:modal_id].present?
= render 'bootstrap/btn', content: t('.edit'), data: { action: 'modal#showAnother', 'modal-show-value': local_assigns[:modal_id] }, id: random_id
- else
- form_params = {}
- form_params[:layout] = post.layout
- form_params[:uuid] = post.post_id
- form_params[:modal_id] = form_params[:show] = modal_id = random_id
-# Asociar un modal con una tarjeta
- form_params[:result_id] = card_id
-# @todo Poder indicar en qué elemento queremos asociar lo descargado
= render 'bootstrap/btn', content: t('.edit'), data: { controller: 'htmx', action: 'modal#showAnother htmx#getUrlOnce', 'modal-show-value': modal_id, 'htmx-get-url-param': site_posts_modal_path(post.site, **form_params) }, id: random_id