Fix: Games and Game page save and navigation.
This commit is contained in:
@@ -17,13 +17,13 @@ export default class PageMtgGames extends TableBasePage {
|
||||
this.hookupTcgGames();
|
||||
}
|
||||
hookupTcgGames() {
|
||||
PageMtgGames.initGamesPage();
|
||||
this.initGamesPage();
|
||||
}
|
||||
static initGamesPage() {
|
||||
initGamesPage() {
|
||||
// Initialize form submission
|
||||
const newGameForm = document.getElementById('newGameForm');
|
||||
if (newGameForm) {
|
||||
newGameForm.addEventListener('submit', PageMtgGames.handleNewGameSubmit);
|
||||
newGameForm.addEventListener('submit', this.handleNewGameSubmit.bind(this)); // () => { this.handleNewGameSubmit.bind(this); });
|
||||
}
|
||||
|
||||
// Initialize filter form
|
||||
@@ -92,7 +92,7 @@ export default class PageMtgGames extends TableBasePage {
|
||||
}
|
||||
}
|
||||
}
|
||||
static async handleNewGameSubmit(e) {
|
||||
async handleNewGameSubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const form = e.target;
|
||||
@@ -119,6 +119,7 @@ export default class PageMtgGames extends TableBasePage {
|
||||
const games = [gameData];
|
||||
const comment = 'Create new game';
|
||||
debugger;
|
||||
// const self = this;
|
||||
API.saveGame(games, form, comment)
|
||||
.then(data => {
|
||||
if (data[flagStatus] == flagSuccess) {
|
||||
@@ -126,7 +127,11 @@ export default class PageMtgGames extends TableBasePage {
|
||||
Utils.consoleLogIfNotProductionEnvironment('Records saved!');
|
||||
Utils.consoleLogIfNotProductionEnvironment('Data received:', data);
|
||||
}
|
||||
this.callFilterTableContent(gameData.game_id);
|
||||
// this.callFilterTableContent(data[attrGameId]); // gameData.game_id
|
||||
const gamePageHash = `${hashPageGame}/${data[attrGameId]}`;
|
||||
let filtersJson = {};
|
||||
this.leave();
|
||||
API.goToHash(gamePageHash, filtersJson);
|
||||
}
|
||||
else {
|
||||
Utils.consoleLogIfNotProductionEnvironment("error: " + data[flagMessage]);
|
||||
@@ -144,13 +149,6 @@ export default class PageMtgGames extends TableBasePage {
|
||||
});
|
||||
|
||||
}
|
||||
callFilterTableContent(gameId) {
|
||||
const gamePageHash = `${hashPageGame}/${gameId}`;
|
||||
let filtersJson = {};
|
||||
Utils.consoleLogIfNotProductionEnvironment("callFilterTableContent");
|
||||
this.leave();
|
||||
API.goToHash(gamePageHash, filtersJson);
|
||||
}
|
||||
static handleFilterSubmit(e) {
|
||||
// Let the form submit normally - it will reload with query params
|
||||
// You can add client-side filtering here if needed
|
||||
|
||||
Reference in New Issue
Block a user