Skip to content

Commit e4a131f

Browse files
committed
Skip delete dialog if shift key is held down
1 parent 9a8d2ea commit e4a131f

File tree

3 files changed

+37
-20
lines changed

3 files changed

+37
-20
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*.mjs,*.ts]
4+
indent_style = space
5+
indent_size = 4
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
max_line_length = 100

.prettierrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 4
4+
}

module/clock-panel.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
1010
#sortable = null;
1111

1212
constructor(db, options) {
13-
super(options)
13+
super(options);
1414
this.db = db;
1515
}
1616

@@ -25,7 +25,7 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
2525
addPoints: ClockPanel.#onAddPoints,
2626
editEntry: ClockPanel.#onEditEntry,
2727
deleteEntry: ClockPanel.#onDeleteEntry,
28-
}
28+
},
2929
};
3030

3131
static PARTS = {
@@ -47,7 +47,7 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
4747

4848
async _prepareContext() {
4949
const clocks = await this.prepareClocks();
50-
50+
5151
return {
5252
options: {
5353
editable: game.user.isGM,
@@ -71,7 +71,7 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
7171
backgroundColor,
7272
color: clockColors.find((c) => c.id === data.colorId)?.color ?? defaultColor,
7373
spokes: data.max > maxSpokes ? [] : Array(data.max).keys(),
74-
}))
74+
}));
7575
}
7676

7777
_onRender(context, options) {
@@ -109,16 +109,16 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
109109
const clockId = event.target.closest("[data-id]").dataset.id;
110110
const clock = this.db.get(clockId);
111111
if (!clock) return;
112-
112+
113113
clock.value = clock.value >= clock.max ? 0 : clock.value + 1;
114114
this.db.update(clock);
115115
});
116-
116+
117117
clock.addEventListener("contextmenu", (event) => {
118118
const clockId = event.target.closest("[data-id]").dataset.id;
119119
const clock = this.db.get(clockId);
120120
if (!clock) return;
121-
121+
122122
clock.value = clock.value <= 0 ? clock.max : clock.value - 1;
123123
this.db.update(clock);
124124
});
@@ -140,21 +140,21 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
140140
const newIndex = event.newDraggableIndex;
141141
const numItems = html.querySelectorAll(".clock-entry").length;
142142
this.db.move(id, this.verticalEdge === "top" ? newIndex : numItems - newIndex - 1);
143-
}
143+
},
144144
});
145145
}
146146
}
147147

148148
static #onAddClock() {
149149
new ClockAddDialog({
150-
complete: (data) => this.db.addClock(data)
150+
complete: (data) => this.db.addClock(data),
151151
}).render({ force: true });
152152
}
153153

154154
static #onAddPoints() {
155155
new ClockAddDialog({
156156
type: "points",
157-
complete: (data) => this.db.addClock(data)
157+
complete: (data) => this.db.addClock(data),
158158
}).render({ force: true });
159159
}
160160

@@ -164,8 +164,8 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
164164
if (!entry) return;
165165

166166
new ClockAddDialog({
167-
entry,
168-
complete: (data) => this.db.update(data)
167+
entry,
168+
complete: (data) => this.db.update(data),
169169
}).render({ force: true });
170170
}
171171

@@ -174,15 +174,18 @@ export class ClockPanel extends fapi.HandlebarsApplicationMixin(fapi.Application
174174
const clock = this.db.get(clockId);
175175
if (!clock) return;
176176

177-
const deleting = await foundry.applications.api.Dialog.confirm({
178-
window: {
179-
title: game.i18n.localize("GlobalProgressClocks.DeleteDialog.Title"),
180-
},
181-
content: game.i18n.format("GlobalProgressClocks.DeleteDialog.Message", { name: clock.name }),
182-
});
183-
177+
const skipDialog = event.shiftKey;
178+
const deleting =
179+
skipDialog ||
180+
(await foundry.applications.api.Dialog.confirm({
181+
window: {
182+
title: game.i18n.localize("GlobalProgressClocks.DeleteDialog.Title"),
183+
},
184+
content: game.i18n.format("GlobalProgressClocks.DeleteDialog.Message", { name: clock.name }),
185+
}));
186+
184187
if (deleting) {
185188
this.db.delete(clockId);
186189
}
187190
}
188-
}
191+
}

0 commit comments

Comments
 (0)