Replace additional date by optional description
This commit is contained in:
@@ -11,13 +11,27 @@ module BridgeHelper
|
||||
}
|
||||
end
|
||||
|
||||
def bridged_share_button(type = nil)
|
||||
def bridged_share_button(description = nil)
|
||||
tag.button "Share", hidden: true, data: {
|
||||
controller: "bridge--share",
|
||||
action: "bridge--share#share",
|
||||
bridge__overflow_menu_target: "item",
|
||||
bridge_title: "Share",
|
||||
bridge_share_type: type
|
||||
bridge_share_description: description
|
||||
}
|
||||
end
|
||||
|
||||
def bridge_share_card_description(card)
|
||||
date_added = card.created_at.strftime("%b %e")
|
||||
date_updated = card.last_active_at.strftime("%b %e")
|
||||
author = card.creator.familiar_name
|
||||
assignees = card.assignees.any? ? "assigned to #{card.assignees.map { |assignee| h assignee.familiar_name }.to_sentence}" : "not assigned"
|
||||
"Added #{date_added} by #{author} and #{assignees}. Updated #{date_updated}"
|
||||
end
|
||||
|
||||
def bridge_share_board_description(board)
|
||||
count_open = board.cards.active.count
|
||||
count_in_stream = board.cards.awaiting_triage.count
|
||||
"#{count_open} open cards, #{count_in_stream} in MAYBE?"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,42 +4,11 @@ export default class extends BridgeComponent {
|
||||
static component = "share"
|
||||
|
||||
share() {
|
||||
const type = this.bridgeElement.bridgeAttribute("share-type")
|
||||
switch (type) {
|
||||
case "card-url":
|
||||
this.send("shareCardUrl", this.#data(type))
|
||||
break
|
||||
default:
|
||||
this.send("shareUrl", this.#data(type))
|
||||
}
|
||||
}
|
||||
|
||||
#data(type) {
|
||||
return {
|
||||
const description = this.bridgeElement.bridgeAttribute("share-description")
|
||||
this.send("share", {
|
||||
title: document.title,
|
||||
url: window.location.href,
|
||||
...this.#additionalDataFor(type)
|
||||
}
|
||||
}
|
||||
|
||||
#additionalDataFor(type) {
|
||||
switch (type) {
|
||||
case "card-url":
|
||||
return {
|
||||
author: this.#author,
|
||||
dateAdded: this.#dateAdded
|
||||
}
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
get #author() {
|
||||
return document.querySelector(".card__meta-text--author strong")?.textContent?.trim() ?? null
|
||||
}
|
||||
|
||||
get #dateAdded() {
|
||||
const timestamp = document.querySelector(".card__meta-text--added time")?.dateTime
|
||||
return parseInt(timestamp) || null
|
||||
description
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,4 +31,4 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= bridged_share_button() %>
|
||||
<%= bridged_share_button(bridge_share_board_description(@board)) %>
|
||||
|
||||
@@ -24,4 +24,4 @@
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= bridged_share_button("card-url") %>
|
||||
<%= bridged_share_button(bridge_share_card_description(@card)) %>
|
||||
|
||||
Reference in New Issue
Block a user