Files
fizzy/app/helpers/cards_helper.rb
T
Jorge Manrubia 19051aec3e Append dropped cards instead of relying on server-side rendering to refresh the columns
This implements a simple strategy to optimistically insert cards in columns without waiting for the column refresh. Cards will be placed at the top respecting golden cards.

This uses sorting by "created at" with sorting by "updated at" for the _Not now_ column, so that the treatment everywhere is homogenous.
2025-12-04 18:31:23 +01:00

56 lines
1.9 KiB
Ruby

module CardsHelper
def card_article_tag(card, id: dom_id(card, :article), data: {}, **options, &block)
classes = [
options.delete(:class),
("golden-effect" if card.golden?),
("card--postponed" if card.postponed?),
("card--active" if card.active?)
].compact.join(" ")
data[:drag_and_drop_top] = true if card.golden? && !card.closed? && !card.postponed?
tag.article \
id: id,
style: "--card-color: #{card.color}; view-transition-name: #{id}",
class: classes,
data: data,
**options,
&block
end
def button_to_delete_card(card)
button_to card_path(card),
method: :delete, class: "btn txt-negative borderless txt-small", data: { turbo_frame: "_top", turbo_confirm: "Are you sure you want to permanently delete this card?" } do
concat(icon_tag("trash"))
concat(tag.span("Delete this card"))
end
end
def card_title_tag(card)
title = [
card.title,
"added by #{card.creator.name}",
"in #{card.board.name}"
]
title << "assigned to #{card.assignees.map(&:name).to_sentence}" if card.assignees.any?
title.join(" ")
end
def card_drafted_or_added(card)
card.drafted? ? "Drafted" : "Added"
end
def card_social_tags(card)
tag.meta(property: "og:title", content: "#{card.title} | #{card.board.name}") +
tag.meta(property: "og:description", content: format_excerpt(card&.description, length: 200)) +
tag.meta(property: "og:image", content: card.image.attached? ? "#{request.base_url}#{url_for(card.image)}" : "#{request.base_url}/opengraph.png") +
tag.meta(property: "og:url", content: card_url(card))
end
def button_to_remove_card_image(card)
button_to(card_image_path(card), method: :delete, class: "btn", data: { controller: "tooltip", action: "dialog#close" }) do
icon_tag("trash") + tag.span("Remove background image", class: "for-screen-reader")
end
end
end