Import XLSX support: add collection fields and migration script
This commit is contained in:
24
app.js
24
app.js
@@ -20,10 +20,14 @@ const gameForm = document.getElementById("gameForm");
|
||||
const brandInput = document.getElementById("brandInput");
|
||||
const consoleInput = document.getElementById("consoleInput");
|
||||
const titleInput = document.getElementById("titleInput");
|
||||
const versionInput = document.getElementById("versionInput");
|
||||
const genreInput = document.getElementById("genreInput");
|
||||
const publisherInput = document.getElementById("publisherInput");
|
||||
const yearInput = document.getElementById("yearInput");
|
||||
const valueInput = document.getElementById("valueInput");
|
||||
const purchasePriceInput = document.getElementById("purchasePriceInput");
|
||||
const conditionInput = document.getElementById("conditionInput");
|
||||
const isDuplicateInput = document.getElementById("isDuplicateInput");
|
||||
const loanedToInput = document.getElementById("loanedToInput");
|
||||
const gameSubmitBtn = document.getElementById("gameSubmitBtn");
|
||||
const cancelEditBtn = document.getElementById("cancelEditBtn");
|
||||
@@ -127,10 +131,14 @@ gameForm.addEventListener("submit", async (event) => {
|
||||
brand: state.selectedBrand,
|
||||
consoleName: state.selectedConsole,
|
||||
title,
|
||||
version: versionInput.value.trim(),
|
||||
genre: genreInput.value.trim(),
|
||||
publisher: publisherInput.value.trim(),
|
||||
isDuplicate: isDuplicateInput.checked,
|
||||
year: yearInput.value ? Number(yearInput.value) : null,
|
||||
purchasePrice: purchasePriceInput.value ? Number(purchasePriceInput.value) : null,
|
||||
value: valueInput.value ? Number(valueInput.value) : null,
|
||||
condition: conditionInput.value ? Number(conditionInput.value) : null,
|
||||
loanedTo: loanedToInput.value.trim(),
|
||||
};
|
||||
|
||||
@@ -165,10 +173,14 @@ gameForm.addEventListener("submit", async (event) => {
|
||||
games[idx] = {
|
||||
...games[idx],
|
||||
title,
|
||||
version: versionInput.value.trim(),
|
||||
genre: genreInput.value.trim(),
|
||||
publisher: publisherInput.value.trim(),
|
||||
isDuplicate: isDuplicateInput.checked,
|
||||
year: yearInput.value ? Number(yearInput.value) : null,
|
||||
purchasePrice: purchasePriceInput.value ? Number(purchasePriceInput.value) : null,
|
||||
value: valueInput.value ? Number(valueInput.value) : null,
|
||||
condition: conditionInput.value ? Number(conditionInput.value) : null,
|
||||
loanedTo: loanedToInput.value.trim(),
|
||||
};
|
||||
}
|
||||
@@ -176,10 +188,14 @@ gameForm.addEventListener("submit", async (event) => {
|
||||
const game = {
|
||||
id: crypto.randomUUID(),
|
||||
title,
|
||||
version: versionInput.value.trim(),
|
||||
genre: genreInput.value.trim(),
|
||||
publisher: publisherInput.value.trim(),
|
||||
isDuplicate: isDuplicateInput.checked,
|
||||
year: yearInput.value ? Number(yearInput.value) : null,
|
||||
purchasePrice: purchasePriceInput.value ? Number(purchasePriceInput.value) : null,
|
||||
value: valueInput.value ? Number(valueInput.value) : null,
|
||||
condition: conditionInput.value ? Number(conditionInput.value) : null,
|
||||
loanedTo: loanedToInput.value.trim(),
|
||||
createdAt: new Date().toISOString(),
|
||||
};
|
||||
@@ -504,10 +520,14 @@ function renderGames() {
|
||||
card.querySelector(".game-title").textContent = game.title;
|
||||
|
||||
const metaParts = [
|
||||
game.version ? `Version: ${game.version}` : null,
|
||||
game.genre ? `Genre: ${game.genre}` : null,
|
||||
game.publisher ? `Editeur: ${game.publisher}` : null,
|
||||
game.isDuplicate ? "Double: OUI" : null,
|
||||
game.year ? `Annee: ${game.year}` : null,
|
||||
game.purchasePrice != null ? `Prix achat: ${game.purchasePrice.toFixed(2)} EUR` : null,
|
||||
game.value != null ? `Cote: ${game.value.toFixed(2)} EUR` : null,
|
||||
game.condition != null ? `Etat: ${game.condition}` : null,
|
||||
].filter(Boolean);
|
||||
|
||||
card.querySelector(".game-meta").textContent = metaParts.join(" | ") || "Aucune information complementaire";
|
||||
@@ -533,10 +553,14 @@ function renderGames() {
|
||||
function startEditMode(game) {
|
||||
editingGameId = game.id;
|
||||
titleInput.value = game.title || "";
|
||||
versionInput.value = game.version || "";
|
||||
genreInput.value = game.genre || "";
|
||||
publisherInput.value = game.publisher || "";
|
||||
isDuplicateInput.checked = Boolean(game.isDuplicate);
|
||||
yearInput.value = game.year || "";
|
||||
purchasePriceInput.value = game.purchasePrice != null ? game.purchasePrice : "";
|
||||
valueInput.value = game.value != null ? game.value : "";
|
||||
conditionInput.value = game.condition != null ? game.condition : "";
|
||||
loanedToInput.value = game.loanedTo || "";
|
||||
|
||||
gameSubmitBtn.textContent = "Mettre a jour le jeu";
|
||||
|
||||
Reference in New Issue
Block a user