mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 13:11:08 +01:00
Sync countdown current with max when equal
This commit is contained in:
parent
5fc04909de
commit
9b8875db59
3 changed files with 17 additions and 2 deletions
|
|
@ -110,6 +110,18 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
||||||
|
|
||||||
static async updateData(_event, _, formData) {
|
static async updateData(_event, _, formData) {
|
||||||
const { hideNewCountdowns, ...settingsData } = foundry.utils.expandObject(formData.object);
|
const { hideNewCountdowns, ...settingsData } = foundry.utils.expandObject(formData.object);
|
||||||
|
|
||||||
|
// Sync current and max if max is changing and they were equal before
|
||||||
|
for (const [id, countdown] of Object.entries(settingsData.countdowns ?? {})) {
|
||||||
|
const existing = this.data.countdowns[id];
|
||||||
|
const wasEqual = existing && existing.progress.current === existing.progress.max;
|
||||||
|
if (wasEqual && countdown.progress.max !== existing.progress.max) {
|
||||||
|
countdown.progress.current = countdown.progress.max;
|
||||||
|
} else {
|
||||||
|
countdown.progress.current = Math.min(countdown.progress.current, countdown.progress.max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.hideNewCountdowns = hideNewCountdowns;
|
this.hideNewCountdowns = hideNewCountdowns;
|
||||||
this.updateSetting(settingsData);
|
this.updateSetting(settingsData);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,9 @@
|
||||||
|
|
||||||
&.tiny {
|
&.tiny {
|
||||||
flex: 0;
|
flex: 0;
|
||||||
|
input {
|
||||||
|
min-width: 2.5rem;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
input,
|
input,
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,11 @@
|
||||||
<div class="countdown-edit-subrow">
|
<div class="countdown-edit-subrow">
|
||||||
<div class="countdown-edit-input tiny">
|
<div class="countdown-edit-input tiny">
|
||||||
<label>{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.current"}}</label>
|
<label>{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.current"}}</label>
|
||||||
<input type="text" name="{{concat "countdowns." id ".progress.current"}}" value="{{countdown.progress.current}}" />
|
<input type="number" name="{{concat "countdowns." id ".progress.current"}}" value="{{countdown.progress.current}}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="countdown-edit-input tiny">
|
<div class="countdown-edit-input tiny">
|
||||||
<label>{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.max"}}</label>
|
<label>{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.max"}}</label>
|
||||||
<input type="text" name="{{concat "countdowns." id ".progress.max"}}" value="{{countdown.progress.max}}" />
|
<input type="number" name="{{concat "countdowns." id ".progress.max"}}" value="{{countdown.progress.max}}" />
|
||||||
</div>
|
</div>
|
||||||
<div class="countdown-edit-input">
|
<div class="countdown-edit-input">
|
||||||
<label>{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.category"}}</label>
|
<label>{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.category"}}</label>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue