Added front-end "Set English Tag Name" logic.
This commit is contained in:
19
JSMR.UI.Blazor/Components/Modals/TagEnglishNameModal.razor
Normal file
19
JSMR.UI.Blazor/Components/Modals/TagEnglishNameModal.razor
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
@inherits FeedbackComponent<SetEnglishTagNameModel>
|
||||||
|
|
||||||
|
@using AntDesign
|
||||||
|
@using JSMR.UI.Blazor.Models
|
||||||
|
|
||||||
|
<Form Model="@Options">
|
||||||
|
<Input @bind-Value="@Options.UpdatedEnglishTagName" Placeholder="English Name" AutoFocus />
|
||||||
|
</Form>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[CascadingParameter]
|
||||||
|
public ModalRef ModalRef { get; set; } = default!;
|
||||||
|
|
||||||
|
public override async Task OnFeedbackOkAsync(ModalClosingEventArgs args)
|
||||||
|
{
|
||||||
|
await base.OnFeedbackOkAsync(args);
|
||||||
|
await CloseFeedbackAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
8
JSMR.UI.Blazor/Models/SetEnglishTagNameModel.cs
Normal file
8
JSMR.UI.Blazor/Models/SetEnglishTagNameModel.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace JSMR.UI.Blazor.Models;
|
||||||
|
|
||||||
|
public class SetEnglishTagNameModel
|
||||||
|
{
|
||||||
|
public required string TagName { get; set; }
|
||||||
|
public string? CurrentEnglishTagName { get; set; }
|
||||||
|
public string? UpdatedEnglishTagName { get; set; }
|
||||||
|
}
|
||||||
@@ -3,12 +3,15 @@
|
|||||||
@inject IJSRuntime JS
|
@inject IJSRuntime JS
|
||||||
@using AntDesign
|
@using AntDesign
|
||||||
@using JSMR.Application.Common.Search
|
@using JSMR.Application.Common.Search
|
||||||
|
@using JSMR.Application.Tags.Commands.SetEnglishName
|
||||||
@using JSMR.Application.Tags.Commands.UpdateTagStatus
|
@using JSMR.Application.Tags.Commands.UpdateTagStatus
|
||||||
@using JSMR.Application.Tags.Contracts
|
@using JSMR.Application.Tags.Contracts
|
||||||
@using JSMR.Application.Tags.Queries.Search
|
@using JSMR.Application.Tags.Queries.Search
|
||||||
@using JSMR.Application.Tags.Queries.Search.Contracts
|
@using JSMR.Application.Tags.Queries.Search.Contracts
|
||||||
@using JSMR.UI.Blazor.Components
|
@using JSMR.UI.Blazor.Components
|
||||||
|
@using JSMR.UI.Blazor.Components.Modals
|
||||||
@using JSMR.UI.Blazor.Filters
|
@using JSMR.UI.Blazor.Filters
|
||||||
|
@using JSMR.UI.Blazor.Models
|
||||||
@using JSMR.UI.Blazor.Services
|
@using JSMR.UI.Blazor.Services
|
||||||
@using Microsoft.AspNetCore.WebUtilities
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
|
|
||||||
@@ -55,18 +58,21 @@
|
|||||||
<Dropdown Trigger="@([Trigger.Click])">
|
<Dropdown Trigger="@([Trigger.Click])">
|
||||||
<Overlay>
|
<Overlay>
|
||||||
<Menu Selectable="false">
|
<Menu Selectable="false">
|
||||||
@if (!context.Favorite)
|
<SubMenu Title="Set Status" Placement="@AntDesign.Placement.LeftTop">
|
||||||
{
|
@if (!context.Favorite)
|
||||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Favorite)">Set as Favorite</MenuItem>
|
{
|
||||||
}
|
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Favorite)">Favorite</MenuItem>
|
||||||
@if (!context.Blacklisted)
|
}
|
||||||
{
|
@if (!context.Blacklisted)
|
||||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Blacklisted)">Set as Blacklisted</MenuItem>
|
{
|
||||||
}
|
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Blacklisted)">Blacklisted</MenuItem>
|
||||||
@if (context.Favorite || context.Blacklisted)
|
}
|
||||||
{
|
@if (context.Favorite || context.Blacklisted)
|
||||||
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Neutral)">Set as Neutral</MenuItem>
|
{
|
||||||
}
|
<MenuItem OnClick="(e) => SetStatus(context, TagStatus.Neutral)">Neutral</MenuItem>
|
||||||
|
}
|
||||||
|
</SubMenu>
|
||||||
|
<MenuItem OnClick="(e) => OpenSetEnglishNameModal(context)">Set English Name...</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
<ChildContent>
|
<ChildContent>
|
||||||
@@ -145,6 +151,12 @@
|
|||||||
[Inject]
|
[Inject]
|
||||||
INotificationService NotificationService { get; set; } = default!;
|
INotificationService NotificationService { get; set; } = default!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
IMessageService MessageService { get; set; } = default!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
ModalService ModalService { get; set; } = default!;
|
||||||
|
|
||||||
public string? Keywords { get; set; }
|
public string? Keywords { get; set; }
|
||||||
public int PageNumber { get; set; } = 1;
|
public int PageNumber { get; set; } = 1;
|
||||||
public int PageSize { get; set; } = 100;
|
public int PageSize { get; set; } = 100;
|
||||||
@@ -328,4 +340,52 @@
|
|||||||
|
|
||||||
await NotificationService.Open(config);
|
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
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using JSMR.Application.Circles.Queries.Search;
|
using JSMR.Application.Circles.Queries.Search;
|
||||||
using JSMR.Application.Creators.Commands.UpdateCreatorStatus;
|
using JSMR.Application.Creators.Commands.UpdateCreatorStatus;
|
||||||
using JSMR.Application.Creators.Queries.Search;
|
using JSMR.Application.Creators.Queries.Search;
|
||||||
|
using JSMR.Application.Tags.Commands.SetEnglishName;
|
||||||
using JSMR.Application.Tags.Commands.UpdateTagStatus;
|
using JSMR.Application.Tags.Commands.UpdateTagStatus;
|
||||||
using JSMR.Application.Tags.Queries.Search;
|
using JSMR.Application.Tags.Queries.Search;
|
||||||
using JSMR.Application.VoiceWorks.Queries.Search;
|
using JSMR.Application.VoiceWorks.Queries.Search;
|
||||||
@@ -50,6 +51,12 @@ public class VoiceWorksClient(HttpClient http)
|
|||||||
return await resp.Content.ReadFromJsonAsync<UpdateTagStatusResponse>(JsonOptions, cancellationToken: ct);
|
return await resp.Content.ReadFromJsonAsync<UpdateTagStatusResponse>(JsonOptions, cancellationToken: ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<SetTagEnglishNameResponse?> SetTagEnglishNameAsync(SetTagEnglishNameRequest request, CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
using var resp = await http.PostAsJsonAsync("/api/tags/set-english-name", request, ct);
|
||||||
|
return await resp.Content.ReadFromJsonAsync<SetTagEnglishNameResponse>(JsonOptions, cancellationToken: ct);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<UpdateCreatorStatusResponse?> UpdateCreatorStatusAsync(UpdateCreatorStatusRequest request, CancellationToken ct = default)
|
public async Task<UpdateCreatorStatusResponse?> UpdateCreatorStatusAsync(UpdateCreatorStatusRequest request, CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
using var resp = await http.PostAsJsonAsync("/api/creators/update-status", request, ct);
|
using var resp = await http.PostAsJsonAsync("/api/creators/update-status", request, ct);
|
||||||
|
|||||||
Reference in New Issue
Block a user