Add character deletion functionality with confirmation workflow

- Added `handleDeleteCharacter` method to handle character deletion with confirmation prompts.
- Updated `CharacterComponent` and `CharacterDetail` to include delete button and related logic.
- Localized new strings for character deletion (e.g., confirmation prompts, success/error messages).
- Enhanced database repository methods (`deleteCharacter`) to handle character deletion securely.
- Improved synchronization workflows to accommodate character deletion.
This commit is contained in:
natreex
2026-01-22 15:09:04 -05:00
parent 9461eb6120
commit 4e462670a9
16 changed files with 383 additions and 59 deletions

View File

@@ -22,6 +22,9 @@ import {
} from "../repositories/location.repository.js";
import { BookPlotPointsTable } from "../repositories/plotpoint.repository.js";
import { BookWorldElementsTable, BookWorldTable } from "../repositories/world.repository.js";
import { BookSpellsTable } from "../repositories/spell.repo.js";
import { BookSpellTagsTable } from "../repositories/spelltag.repo.js";
import { SyncedSpell, SyncedSpellTag } from "./Spell.js";
import { CompleteChapterContent, SyncedChapter } from "./Chapter.js";
import { SyncedCharacter } from "./Character.js";
import { SyncedLocation } from "./Location.js";
@@ -42,6 +45,7 @@ export interface BookToolsSettings {
characters: boolean;
worlds: boolean;
locations: boolean;
spells: boolean;
}
export interface BookProps {
@@ -79,6 +83,8 @@ export interface CompleteBook {
locationElements: LocationElementTable[];
locationSubElements: LocationSubElementTable[];
bookTools: BookToolsTable[];
spells: BookSpellsTable[];
spellTags: BookSpellTagsTable[];
}
export interface SyncedBook {
@@ -98,6 +104,8 @@ export interface SyncedBook {
guideLine: SyncedGuideLine | null;
aiGuideLine: SyncedAIGuideLine | null;
bookTools: SyncedBookTools | null;
spells: SyncedSpell[];
spellTags: SyncedSpellTag[];
}
export interface BookSyncCompare {
@@ -119,6 +127,8 @@ export interface BookSyncCompare {
guideLine: boolean;
aiGuideLine: boolean;
bookTools: boolean;
spells: string[];
spellTags: string[];
}
export interface CompleteBookData {
@@ -272,7 +282,8 @@ export default class Book {
tools: {
characters: bookTools ? bookTools.characters_enabled === 1 : false,
worlds: bookTools ? bookTools.worlds_enabled === 1 : false,
locations: bookTools ? bookTools.locations_enabled === 1 : false
locations: bookTools ? bookTools.locations_enabled === 1 : false,
spells: bookTools ? bookTools.spells_enabled === 1 : false
}
};
}
@@ -310,8 +321,8 @@ export default class Book {
return BookRepo.deleteBook(userId, bookId, lang);
}
public static updateBookToolSetting(userId: string, bookId: string, toolName: 'characters' | 'worlds' | 'locations', enabled: boolean, lang: 'fr' | 'en' = 'fr'): boolean {
const columnName: 'characters_enabled' | 'worlds_enabled' | 'locations_enabled' = `${toolName}_enabled` as 'characters_enabled' | 'worlds_enabled' | 'locations_enabled';
public static updateBookToolSetting(userId: string, bookId: string, toolName: 'characters' | 'worlds' | 'locations' | 'spells', enabled: boolean, lang: 'fr' | 'en' = 'fr'): boolean {
const columnName: 'characters_enabled' | 'worlds_enabled' | 'locations_enabled' | 'spells_enabled' = `${toolName}_enabled` as 'characters_enabled' | 'worlds_enabled' | 'locations_enabled' | 'spells_enabled';
return BookRepo.updateBookToolSetting(userId, bookId, columnName, enabled, System.timeStampInSeconds(), lang);
}