Fix roll dialog CSS + JS: template <div> wrapper, moon-section, selectors

- Remplace <form class='roll-dialog celestopol'> par <div class='roll-dialog-content'>
  pour éviter les formulaires HTML imbriqués invalides (DialogV2 a son propre <form>)
- Corrige le sélecteur CSS de .roll-dialog.celestopol vers .application.roll-dialog .roll-dialog-content
- Remplace .form-group.form-moon par .moon-section (classe custom) pour éviter
  les conflits avec le CSS grid de FoundryVTT standard-form (label 130px de hauteur)
- Met à jour le script JS inline pour utiliser document.querySelector('.roll-dialog-content')
- Ajoute white-space: nowrap sur le label Destin pour éviter le wrapping sur 3 lignes
- Supprime .application.roll-dialog .window-content padding override (remplacé par dialog-content)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-03-28 17:21:18 +01:00
parent a581853f95
commit cff700bd3d
24 changed files with 1133 additions and 283 deletions

View File

@@ -50,9 +50,28 @@ export default class CelestopolActorSheet extends HandlebarsApplicationMixin(fou
this.element.querySelectorAll(".rollable").forEach(el => {
el.addEventListener("click", this._onRoll.bind(this))
})
// Setup sequential checkbox logic for wound tracks
this._setupSequentialCheckboxes()
// Setup sequential checkbox logic for factions
this._setupFactionCheckboxes()
}
/** @override */
_onClick(event) {
// Skip checkbox clicks in edit mode
if (this.isEditMode && event.target.classList.contains('skill-level-checkbox')) {
return
}
super._onClick(event)
}
async _onRoll(event) {
// Don't roll if clicking on a checkbox
if (event.target.classList.contains('skill-level-checkbox')) {
return
}
if (!this.isPlayMode) return
const el = event.currentTarget
const statId = el.dataset.statId
@@ -92,13 +111,12 @@ export default class CelestopolActorSheet extends HandlebarsApplicationMixin(fou
await this.document.createEmbeddedDocuments("Item", [item.toObject()], { renderSheet: false })
}
static async #onEditImage(event, target) {
const attr = target.dataset.edit
const current = foundry.utils.getProperty(this.document, attr)
static async #onEditImage(event, _target) {
const current = this.document.img
const fp = new FilePicker({
current,
type: "image",
callback: (path) => this.document.update({ [attr]: path }),
callback: (path) => this.document.update({ img: path }),
top: this.position.top + 40,
left: this.position.left + 10,
})
@@ -123,4 +141,133 @@ export default class CelestopolActorSheet extends HandlebarsApplicationMixin(fou
const item = await fromUuid(uuid)
await item?.deleteDialog()
}
/**
* Setup sequential checkbox logic for wound/destin/spleen tracks
* Only allows checking the next checkbox in sequence
*/
_setupSequentialCheckboxes() {
this.element.querySelectorAll('.wound-checkbox').forEach(checkbox => {
checkbox.addEventListener('change', (event) => {
this._handleSequentialCheckboxChange(event)
})
})
}
/**
* Handle sequential checkbox change logic
* @param {Event} event - The change event
*/
_handleSequentialCheckboxChange(event) {
const checkbox = event.target
if (!checkbox.classList.contains('wound-checkbox') || checkbox.disabled) return
const track = checkbox.dataset.track
const currentIndex = parseInt(checkbox.dataset.index)
const isChecked = checkbox.checked
// Get all checkboxes in this track
const trackCheckboxes = Array.from(this.element.querySelectorAll(`.wound-checkbox[data-track="${track}"]`))
if (isChecked) {
// Checking a box: uncheck all boxes after this one
for (let i = currentIndex + 1; i < trackCheckboxes.length; i++) {
trackCheckboxes[i].checked = false
}
// Check all boxes before this one
for (let i = 0; i < currentIndex; i++) {
trackCheckboxes[i].checked = true
}
} else {
// Unchecking a box: uncheck all boxes after this one
for (let i = currentIndex; i < trackCheckboxes.length; i++) {
trackCheckboxes[i].checked = false
}
}
// Update the visual state
this._updateTrackVisualState()
}
/**
* Update visual state of track boxes based on checkbox states
*/
_updateTrackVisualState() {
this.element.querySelectorAll('.track-box').forEach(box => {
const checkbox = box.querySelector('.wound-checkbox')
if (checkbox) {
if (checkbox.checked) {
box.classList.add('checked')
} else {
box.classList.remove('checked')
}
}
})
}
/**
* Setup sequential checkbox logic for faction tracks
*/
_setupFactionCheckboxes() {
this.element.querySelectorAll('.faction-checkbox').forEach(checkbox => {
checkbox.addEventListener('change', (event) => {
this._handleFactionCheckboxChange(event)
})
})
}
/**
* Handle faction checkbox change logic
* @param {Event} event - The change event
*/
_handleFactionCheckboxChange(event) {
const checkbox = event.target
if (!checkbox.classList.contains('faction-checkbox') || checkbox.disabled) return
const factionId = checkbox.dataset.faction
const currentLevel = parseInt(checkbox.dataset.level)
const isChecked = checkbox.checked
// Get all checkboxes for this faction
const factionCheckboxes = Array.from(this.element.querySelectorAll(`.faction-checkbox[data-faction="${factionId}"]`))
if (isChecked) {
// Checking a box: check all boxes before this one, uncheck all boxes after this one
for (let i = 0; i < currentLevel; i++) {
factionCheckboxes[i].checked = true
}
for (let i = currentLevel; i < factionCheckboxes.length; i++) {
factionCheckboxes[i].checked = false
}
} else {
// Unchecking a box: uncheck all boxes after this one
for (let i = currentLevel - 1; i < factionCheckboxes.length; i++) {
factionCheckboxes[i].checked = false
}
}
// Update the count display
this._updateFactionCount(factionId)
}
/**
* Update the faction count display based on checked checkboxes
* @param {string} factionId - The faction ID
*/
_updateFactionCount(factionId) {
const checkboxes = Array.from(this.element.querySelectorAll(`.faction-checkbox[data-faction="${factionId}"]:checked`))
const count = checkboxes.length
// Update the hidden input field
const input = this.element.querySelector(`input[name="system.factions.${factionId}.value"]`)
if (input) {
input.value = count
}
// Update the visual count display
const countDisplay = this.element.querySelector(`.faction-row[data-faction="${factionId}"] .faction-count`)
if (countDisplay) {
countDisplay.textContent = count
}
}
}

View File

@@ -39,16 +39,16 @@ export default class CelestopolItemSheet extends HandlebarsApplicationMixin(foun
})
}
static async #onEditImage(event, target) {
const attr = target.dataset.edit
const current = foundry.utils.getProperty(this.document, attr)
static async #onEditImage(event, _target) {
const current = this.document.img
const fp = new FilePicker({
current,
type: "image",
callback: (path) => this.document.update({ [attr]: path }),
callback: (path) => this.document.update({ img: path }),
top: this.position.top + 40,
left: this.position.left + 10,
})
return fp.browse()
}
}