|
@@ -22,11 +22,10 @@ export class CharacterPickerComponent {
|
|
public currentCharacter: string = '';
|
|
public currentCharacter: string = '';
|
|
private modalService = inject(NgbModal);
|
|
private modalService = inject(NgbModal);
|
|
|
|
|
|
|
|
+ @ViewChild('warning') warning!: TemplateRef<any>;
|
|
@ViewChildren(CharacterCardComponent)
|
|
@ViewChildren(CharacterCardComponent)
|
|
characterCards!: QueryList<CharacterCardComponent>;
|
|
characterCards!: QueryList<CharacterCardComponent>;
|
|
|
|
|
|
- @ViewChild('warning') warning!: TemplateRef<any>;
|
|
|
|
-
|
|
|
|
public constructor(
|
|
public constructor(
|
|
public dataService: DataService,
|
|
public dataService: DataService,
|
|
private Router: Router,
|
|
private Router: Router,
|
|
@@ -42,10 +41,18 @@ export class CharacterPickerComponent {
|
|
this.showWarning(this.warning);
|
|
this.showWarning(this.warning);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Navigates to the character creator page.
|
|
|
|
+ */
|
|
public addCharacter() {
|
|
public addCharacter() {
|
|
this.Router.navigate(['character/creator']);
|
|
this.Router.navigate(['character/creator']);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Opens the modal to ask the user if they really want to delete the character.
|
|
|
|
+ * @param content The content that is to be displayed in the modal.
|
|
|
|
+ * @param index The index of the character that is to be deleted.
|
|
|
|
+ */
|
|
open(content: TemplateRef<any>, index: number) {
|
|
open(content: TemplateRef<any>, index: number) {
|
|
this.currentCharacter = this.characters[index].name;
|
|
this.currentCharacter = this.characters[index].name;
|
|
this.modalService
|
|
this.modalService
|
|
@@ -60,10 +67,15 @@ export class CharacterPickerComponent {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Deletes a character from the list of characters.
|
|
|
|
+ * @param index The index of the character to be deleted.
|
|
|
|
+ */
|
|
public deleteCharacter(index: number) {
|
|
public deleteCharacter(index: number) {
|
|
this.characters.splice(index, 1);
|
|
this.characters.splice(index, 1);
|
|
this.dataService.deleteCollection(this.currentCharacter);
|
|
this.dataService.deleteCollection(this.currentCharacter);
|
|
this.dataService.deleteCollection('characters');
|
|
this.dataService.deleteCollection('characters');
|
|
|
|
+ // TODO: Find a better solution that looks smoother.
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
this.dataService.setCollection('characters', this.characters);
|
|
this.dataService.setCollection('characters', this.characters);
|
|
}, 200);
|
|
}, 200);
|
|
@@ -74,12 +86,19 @@ export class CharacterPickerComponent {
|
|
}, 500);
|
|
}, 500);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Sets the character name in the session storage and navigates to character tracker itself.
|
|
|
|
+ * @param character The character name
|
|
|
|
+ */
|
|
public selectCharacter(character: any) {
|
|
public selectCharacter(character: any) {
|
|
- console.log(character);
|
|
|
|
sessionStorage.setItem('characterName', character.name);
|
|
sessionStorage.setItem('characterName', character.name);
|
|
this.Router.navigate(['journal']);
|
|
this.Router.navigate(['journal']);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Show a warning to the user if they have not acknowledged it yet.
|
|
|
|
+ * The warning
|
|
|
|
+ */
|
|
showWarning(warning: TemplateRef<any>) {
|
|
showWarning(warning: TemplateRef<any>) {
|
|
let warningWasAcknowledged = sessionStorage.getItem(
|
|
let warningWasAcknowledged = sessionStorage.getItem(
|
|
'warningWasAcknowledged',
|
|
'warningWasAcknowledged',
|
|
@@ -89,6 +108,9 @@ export class CharacterPickerComponent {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The user has acknowledged the warning, so it will not be shown again in this session.
|
|
|
|
+ */
|
|
public acknowledgeWarning() {
|
|
public acknowledgeWarning() {
|
|
sessionStorage.setItem('warningWasAcknowledged', 'true');
|
|
sessionStorage.setItem('warningWasAcknowledged', 'true');
|
|
}
|
|
}
|