Use a view helper to remove branching from the bubbles controller
This commit is contained in:
@@ -48,4 +48,12 @@ module CardsHelper
|
||||
title << "assigned to #{card.assignees.map(&:name).to_sentence}" if card.assignees.any?
|
||||
title.join(" ")
|
||||
end
|
||||
|
||||
def card_entropy_action(card)
|
||||
if card.doing?
|
||||
"Falls Back"
|
||||
elsif card.considering?
|
||||
"Closes"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,8 +4,8 @@ import { signedDifferenceInDays } from "helpers/date_helpers"
|
||||
const REFRESH_INTERVAL = 3_600_000 // 1 hour (in milliseconds)
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = [ "closingTop", "consideringTop", "days", "bottom" ]
|
||||
static values = { "closesAt": String, "reminderBefore": Number }
|
||||
static targets = [ "top", "days", "bottom" ]
|
||||
static values = { "closesAt": String, "reminderBefore": Number, "entropyAction": String }
|
||||
|
||||
#timer
|
||||
|
||||
@@ -26,12 +26,7 @@ export default class extends Controller {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.hasClosingTopTarget) {
|
||||
this.closingTopTarget.innerHTML = closesInDays < 1 ? "Closes" : "Closes in"
|
||||
}
|
||||
if (this.hasConsideringTopTarget) {
|
||||
this.consideringTopTarget.innerHTML = closesInDays < 1 ? "Falls Back" : "Falls Back in"
|
||||
}
|
||||
this.topTarget.innerHTML = closesInDays < 1 ? this.entropyActionValue : `${this.entropyActionValue} in`
|
||||
this.daysTarget.innerHTML = closesInDays < 1 ? "!" : closesInDays
|
||||
this.bottomTarget.innerHTML = closesInDays < 1 ? "Today" : (closesInDays === 1 ? "day" : "days")
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<div hidden class="bubble bubble--<%= style %>"
|
||||
data-controller="bubble" data-action="turbo:morph-element->bubble#update"
|
||||
data-bubble-reminder-before-value="<%= Card::AUTO_CLOSE_REMINDER_BEFORE.in_days.to_i %>"
|
||||
data-bubble-closes-at-value="<%= card.auto_close_at.iso8601 %>">
|
||||
data-bubble-closes-at-value="<%= card.auto_close_at.iso8601 %>"
|
||||
data-bubble-entropy-action-value="<%= card_entropy_action(card) %>">
|
||||
<svg viewBox="0 0 200 100">
|
||||
<path id="top-half" fill="transparent" d="M 20,100 A 80,80 0 0,1 180,100" />
|
||||
<text text-anchor="middle" fill="currentColor">
|
||||
<textPath href="#top-half" startOffset="50%" dominant-baseline="middle" data-bubble-target="<%= style %>Top"></textPath>
|
||||
<textPath href="#top-half" startOffset="50%" dominant-baseline="middle" data-bubble-target="top"></textPath>
|
||||
</text>
|
||||
</svg>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user