Parties enregistrées, branches et export SGF (étape 1b) #37
@@ -822,7 +822,6 @@ export function startApp(options: AppOptions): void {
|
||||
},
|
||||
remove: options.games.remove,
|
||||
exportSgf: options.games.exportSgf,
|
||||
confirm: (question) => window.confirm(question),
|
||||
});
|
||||
|
||||
/** Joue un demi-coup du joueur ; le coup attend ensuite sa suite ou sa
|
||||
|
||||
@@ -31,7 +31,7 @@ export const GAMES_TEXTS = {
|
||||
resumeBranch: "Reprendre cette branche",
|
||||
exportSgf: "Exporter (SGF)",
|
||||
remove: "Supprimer",
|
||||
confirmRemove: "Supprimer définitivement cette partie et toutes ses branches ?",
|
||||
confirmRemove: "Supprimer pour de bon (branches comprises)",
|
||||
shown: "partie affichée",
|
||||
busy: "Attendez la fin du coup en cours.",
|
||||
failed: (message: string) => `Erreur : ${message}`,
|
||||
|
||||
@@ -28,7 +28,6 @@ export interface GamesViewOptions {
|
||||
readonly remove: (id: string) => Promise<void>;
|
||||
/** Le fichier SGF d'une partie : son nom et son contenu. */
|
||||
readonly exportSgf: (id: string) => Promise<{ fileName: string; text: string }>;
|
||||
readonly confirm: (question: string) => boolean;
|
||||
}
|
||||
|
||||
export interface GamesView {
|
||||
@@ -132,13 +131,21 @@ export function createGamesView(options: GamesViewOptions): GamesView {
|
||||
"secondary",
|
||||
"export",
|
||||
),
|
||||
// Supprimer se fait en deux touchers, sans boîte du navigateur :
|
||||
// le premier change le bouton en demande de confirmation.
|
||||
button(
|
||||
GAMES_TEXTS.remove,
|
||||
run(async () => {
|
||||
if (options.confirm(GAMES_TEXTS.confirmRemove)) {
|
||||
await options.remove(game.id);
|
||||
await render();
|
||||
const remove = item.querySelector<HTMLElement>('[data-action="remove"]');
|
||||
if (remove?.dataset.armed !== "true") {
|
||||
if (remove !== null) {
|
||||
remove.dataset.armed = "true";
|
||||
remove.textContent = GAMES_TEXTS.confirmRemove;
|
||||
}
|
||||
return;
|
||||
}
|
||||
await options.remove(game.id);
|
||||
await render();
|
||||
}),
|
||||
"secondary",
|
||||
"remove",
|
||||
|
||||
Reference in New Issue
Block a user