-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allows to edit hidden abilities
- Loading branch information
Arley Pádua
authored and
Arley Pádua
committed
Oct 15, 2024
1 parent
6a491e4
commit c7fb974
Showing
4 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@using PKHeX.Facade.Repositories | ||
|
||
<Select TItem="AbilityDefinition" | ||
TItemValue="int?" | ||
DataSource="@_items" | ||
@bind-Value="@SelectedAbilityId" | ||
OnSelectedItemChanged="SelectedAbilityChangedInternal" | ||
LabelName="@nameof(AbilityDefinition.Name)" | ||
ValueName="@nameof(AbilityDefinition.Id)" | ||
Placeholder="Form" | ||
DefaultActiveFirstOption="false" | ||
EnableSearch | ||
EnableVirtualization> | ||
<LabelTemplate> | ||
@context.Name | ||
</LabelTemplate> | ||
<ItemTemplate> | ||
@context.Name | ||
</ItemTemplate> | ||
</Select> | ||
|
||
@code { | ||
[Parameter] public int? SelectedAbilityId { get; set; } | ||
[Parameter] public EventCallback<AbilityDefinition> SelectedAbilityChanged { get; set; } | ||
[Parameter] public bool IgnoreRenderingEvents { get; set; } | ||
|
||
private bool _dataSourceJustLoaded = true; | ||
|
||
private readonly IEnumerable<AbilityDefinition> _items = AbilityRepository.Instance.All; | ||
|
||
private Task SelectedAbilityChangedInternal(AbilityDefinition arg) | ||
{ | ||
if (_dataSourceJustLoaded) | ||
{ | ||
_dataSourceJustLoaded = false; | ||
return Task.CompletedTask; | ||
} | ||
|
||
return SelectedAbilityChanged.InvokeAsync(arg); | ||
} | ||
|
||
protected override void OnInitialized() | ||
{ | ||
_dataSourceJustLoaded = IgnoreRenderingEvents; | ||
} | ||
|
||
} |