Added front-end "Set English Tag Name" logic.
This commit is contained in:
@@ -3,12 +3,15 @@
|
||||
@inject IJSRuntime JS
|
||||
@using AntDesign
|
||||
@using JSMR.Application.Common.Search
|
||||
@using JSMR.Application.Tags.Commands.SetEnglishName
|
||||
@using JSMR.Application.Tags.Commands.UpdateTagStatus
|
||||
@using JSMR.Application.Tags.Contracts
|
||||
@using JSMR.Application.Tags.Queries.Search
|
||||
@using JSMR.Application.Tags.Queries.Search.Contracts
|
||||
@using JSMR.UI.Blazor.Components
|
||||
@using JSMR.UI.Blazor.Components.Modals
|
||||
@using JSMR.UI.Blazor.Filters
|
||||
@using JSMR.UI.Blazor.Models
|
||||
@using JSMR.UI.Blazor.Services
|
||||
@using Microsoft.AspNetCore.WebUtilities
|
||||
|
||||
@@ -55,18 +58,21 @@
|
||||
<Dropdown Trigger="@([Trigger.Click])">
|
||||
<Overlay>
|
||||
<Menu Selectable="false">
|
||||
@if (!context.Favorite)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Favorite)">Set as Favorite</MenuItem>
|
||||
}
|
||||
@if (!context.Blacklisted)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Blacklisted)">Set as Blacklisted</MenuItem>
|
||||
}
|
||||
@if (context.Favorite || context.Blacklisted)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Neutral)">Set as Neutral</MenuItem>
|
||||
}
|
||||
<SubMenu Title="Set Status" Placement="@AntDesign.Placement.LeftTop">
|
||||
@if (!context.Favorite)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Favorite)">Favorite</MenuItem>
|
||||
}
|
||||
@if (!context.Blacklisted)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Blacklisted)">Blacklisted</MenuItem>
|
||||
}
|
||||
@if (context.Favorite || context.Blacklisted)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Neutral)">Neutral</MenuItem>
|
||||
}
|
||||
</SubMenu>
|
||||
<MenuItem OnClick="(e) => OpenSetEnglishNameModal(context)">Set English Name...</MenuItem>
|
||||
</Menu>
|
||||
</Overlay>
|
||||
<ChildContent>
|
||||
@@ -145,6 +151,12 @@
|
||||
[Inject]
|
||||
INotificationService NotificationService { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
IMessageService MessageService { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
ModalService ModalService { get; set; } = default!;
|
||||
|
||||
public string? Keywords { get; set; }
|
||||
public int PageNumber { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 100;
|
||||
@@ -328,4 +340,52 @@
|
||||
|
||||
await NotificationService.Open(config);
|
||||
}
|
||||
|
||||
private async Task OpenSetEnglishNameModal(TagSearchItem item)
|
||||
{
|
||||
SetEnglishTagNameModel model = new()
|
||||
{
|
||||
TagName = item.Name,
|
||||
CurrentEnglishTagName = item.EnglishName,
|
||||
UpdatedEnglishTagName = item.EnglishName
|
||||
};
|
||||
|
||||
ModalOptions modalOptions = new()
|
||||
{
|
||||
Title = $"Set English Name: {item.Name}",
|
||||
MaskClosable = false,
|
||||
Centered = true,
|
||||
OkText = "Save",
|
||||
OnOk = async (args) =>
|
||||
{
|
||||
await SetEnglishName(item, model.UpdatedEnglishTagName);
|
||||
}
|
||||
};
|
||||
|
||||
ModalService.CreateModal<TagEnglishNameModal, SetEnglishTagNameModel>(modalOptions, model);
|
||||
}
|
||||
|
||||
private async Task SetEnglishName(TagSearchItem item, string? englishName)
|
||||
{
|
||||
SetTagEnglishNameRequest request = new(
|
||||
TagId: item.TagId,
|
||||
EnglishName: englishName ?? string.Empty
|
||||
);
|
||||
|
||||
SetTagEnglishNameResponse? response = await Client.SetTagEnglishNameAsync(request);
|
||||
|
||||
if (response is null)
|
||||
return;
|
||||
|
||||
item.EnglishName = response.EnglishName;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
await NotificationService.Open(new NotificationConfig
|
||||
{
|
||||
Message = "Tag English Name Updated",
|
||||
Description = $"Tag '{item.Name}' English name set to '{response.EnglishName}'.",
|
||||
Placement = NotificationPlacement.Top
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user