thread-controller -> created-by-current-user-controller

This commit is contained in:
Jose Farias
2024-10-24 16:00:09 -06:00
parent ad88f90302
commit 3543121d3d
3 changed files with 21 additions and 15 deletions
@@ -0,0 +1,18 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = { selector: String }
static classes = [ "differentiator" ]
connect() {
this.#createdElements.forEach(el => el.classList.add(this.differentiatorClass))
}
get #createdElements() {
return this.element.querySelectorAll(this.#selector)
}
get #selector() {
return `${this.selectorValue}[data-creator-id='${Current.user.id}']`
}
}
@@ -1,13 +0,0 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static classes = [ "myComment" ]
connect() {
this.#myComments.forEach(comment => comment.classList.add(this.myCommentClass))
}
get #myComments() {
return this.element.querySelectorAll(`.comment[data-creator-id='${Current.user.id}']`)
}
}