Add scope selector value

This commit is contained in:
Adrien Maston
2026-03-17 11:57:59 +01:00
parent 0b29a67e17
commit 2d1e201946
2 changed files with 7 additions and 6 deletions
@@ -2,10 +2,13 @@ import { BridgeComponent } from "@hotwired/hotwire-native-bridge"
export default class extends BridgeComponent {
static component = "stamp"
static values = { scopeSelector: { type: String, default: "body" } }
connect() {
super.connect()
this.notifyBridgeOfConnect()
if (this.element.closest(this.scopeSelectorValue)) {
super.connect()
this.send("connect", this.#data)
}
}
disconnect() {
@@ -13,10 +16,6 @@ export default class extends BridgeComponent {
this.send("disconnect")
}
notifyBridgeOfConnect() {
this.send("connect", this.#data)
}
get #data() {
const bridgeElement = this.bridgeElement
return {
@@ -1,6 +1,7 @@
<% if card.postponed? %>
<%= tag.div class: token_list("card__closed", "card__closed--system": card.postponed_by&.system?), data: {
controller: "bridge--stamp",
bridge__stamp_scope_selector_value: ".card-perma",
bridge_title: "Not Now",
bridge_description: card.postponed_at.strftime("%b %d, %Y")
} do %>
@@ -13,6 +14,7 @@
<% if card.closed? %>
<%= tag.div class: "card__closed", data: {
controller: "bridge--stamp",
bridge__stamp_scope_selector_value: ".card-perma",
bridge_title: "Done",
bridge_description: card.closed_at.strftime("%b %d, %Y")
} do %>