|
|
|
@ -1,4 +1,4 @@ |
|
|
|
import { Component, Input, Output, EventEmitter, ChangeDetectorRef } from '@angular/core'; |
|
|
|
import { Component, Input, Output, EventEmitter, ChangeDetectorRef, SimpleChanges } from '@angular/core'; |
|
|
|
import { CommonModule } from '@angular/common'; |
|
|
|
import { MatExpansionModule } from '@angular/material/expansion'; |
|
|
|
import { MatIconModule } from '@angular/material/icon'; |
|
|
|
@ -45,8 +45,16 @@ interface PokemonStatusEvent { |
|
|
|
<div class="pokemon-info"> |
|
|
|
<div class="pokemon-name"> |
|
|
|
{{ this.representative_pokemon?.Name }} |
|
|
|
<span *ngIf="this.representative_pokemon?.Form" class="form-name"> |
|
|
|
({{ this.representative_pokemon?.Form }}) |
|
|
|
<span class="form-name"> |
|
|
|
<span *ngIf="this.pokemon_family?.Male"> |
|
|
|
<img src="assets/images/Male_symbol_(fixed_width).svg" >: {{ this.pokemon_family.Male }} |
|
|
|
</span> |
|
|
|
<span *ngIf="this.pokemon_family?.Female"> |
|
|
|
<img src="assets/images/Venus_symbol_(fixed_width).svg" >: {{ this.pokemon_family.Female }} |
|
|
|
</span> |
|
|
|
<span *ngIf="this.pokemon_family?.Any"> |
|
|
|
<img src="assets/images/Male_and_female_sign.svg" >: {{ this.pokemon_family.Any }} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
|
|
|
|
@ -87,7 +95,6 @@ interface PokemonStatusEvent { |
|
|
|
</div> |
|
|
|
<mat-chip-listbox> |
|
|
|
<mat-chip>Method _PLACEDHOLDER_</mat-chip> |
|
|
|
<mat-chip color="primary" selected>Need: {{ 1 }}</mat-chip> |
|
|
|
</mat-chip-listbox> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
@ -118,7 +125,6 @@ interface PokemonStatusEvent { |
|
|
|
</div> |
|
|
|
<mat-chip-listbox> |
|
|
|
<mat-chip>Breed</mat-chip> |
|
|
|
<mat-chip color="primary" selected>Need: {{ 1 }}</mat-chip> |
|
|
|
</mat-chip-listbox> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
@ -266,6 +272,11 @@ export class PlanPokemonComponent { |
|
|
|
) {} |
|
|
|
|
|
|
|
ngOnInit() { |
|
|
|
this.representative_pokemon = null; |
|
|
|
this.evolve_to = [] |
|
|
|
this.breed_for = [] |
|
|
|
this.cdr.detectChanges(); |
|
|
|
|
|
|
|
this.pokemonService.getPokemonFromPFIC(this.pokemon_family.representative).subscribe({ |
|
|
|
next: (pokemon) => { |
|
|
|
this.representative_pokemon = pokemon |
|
|
|
@ -303,7 +314,68 @@ export class PlanPokemonComponent { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges) { |
|
|
|
if (changes['pokemon_family']) { |
|
|
|
const currentFamily = changes['pokemon_family'].currentValue; |
|
|
|
const previousFamily = changes['pokemon_family'].previousValue; |
|
|
|
|
|
|
|
// Check if there's a meaningful change
|
|
|
|
if (currentFamily && currentFamily !== previousFamily) { |
|
|
|
// Your logic here, e.g., re-fetch data or reset states
|
|
|
|
this.handlePokemonFamilyChange(currentFamily); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private handlePokemonFamilyChange(newFamily: PokemonFamilyEntry) { |
|
|
|
// This function contains logic to handle the input change.
|
|
|
|
// For example, resetting component states or fetching additional data.
|
|
|
|
console.log('Pokemon family has changed:', newFamily); |
|
|
|
|
|
|
|
this.representative_pokemon = null; |
|
|
|
this.evolve_to = [] |
|
|
|
this.breed_for = [] |
|
|
|
this.cdr.detectChanges(); |
|
|
|
|
|
|
|
this.pokemonService.getPokemonFromPFIC(this.pokemon_family.representative).subscribe({ |
|
|
|
next: (pokemon) => { |
|
|
|
this.representative_pokemon = pokemon |
|
|
|
}, |
|
|
|
error: (error) => { |
|
|
|
console.error('Error loading Pokemon:', error); |
|
|
|
this.cdr.markForCheck(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
for(const target of this.pokemon_family.evolve_to) { |
|
|
|
this.pokemonService.getPokemonFromPFIC(target).subscribe({ |
|
|
|
next: (pokemon) => { |
|
|
|
if(pokemon) { |
|
|
|
this.evolve_to.push(pokemon) |
|
|
|
} |
|
|
|
}, |
|
|
|
error: (error) => { |
|
|
|
console.error('Error loading Pokemon:', error); |
|
|
|
this.cdr.markForCheck(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
for(const target of this.pokemon_family.breed_for) { |
|
|
|
this.pokemonService.getPokemonFromPFIC(target).subscribe({ |
|
|
|
next: (pokemon) => { |
|
|
|
if(pokemon) { |
|
|
|
this.breed_for.push(pokemon) |
|
|
|
} |
|
|
|
}, |
|
|
|
error: (error) => { |
|
|
|
console.error('Error loading Pokemon:', error); |
|
|
|
this.cdr.markForCheck(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
get hasTargets(): boolean { |
|
|
|
|