9 changed files with 197 additions and 0 deletions
@ -0,0 +1,17 @@ |
|||
using LINGYUN.Abp.ElsaNext.Notifications; |
|||
using LINGYUN.Abp.ElsaNext.Studio.Blazor; |
|||
using LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor.Extensions; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpElsaNextNotificationsModule), |
|||
typeof(AbpElsaNextStudioBlazorModule))] |
|||
public class AbpElsaNextStudioNotificationsBlazorModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddNotificationsUIHintHandlers(); |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
@using Elsa.Api.Client.Shared.UIHints.DropDown |
|||
@inject ILocalizer Localizer |
|||
|
|||
@inherits StudioComponentBase |
|||
@{ |
|||
var inputDescriptor = EditorContext.InputDescriptor; |
|||
var displayName = inputDescriptor.DisplayName; |
|||
var description = inputDescriptor.Description; |
|||
var selectedValue = GetSelectedValue(); |
|||
} |
|||
|
|||
<ExpressionInput EditorContext="@EditorContext"> |
|||
<ChildContent> |
|||
<MudSelectExtended |
|||
T="SelectListItem" |
|||
Label="@Localizer[displayName]" |
|||
Variant="Variant.Outlined" |
|||
HelperText="@Localizer[description]" |
|||
Margin="Margin.Dense" |
|||
Value="@selectedValue" |
|||
SearchBox="true" |
|||
OnSearchStringChange="OnSearch" |
|||
ItemCollection="@_items" |
|||
ToStringFunc="@(item => item?.Text ?? "")" |
|||
ValueChanged="OnValueChanged" |
|||
ReadOnly="EditorContext.IsReadOnly" |
|||
Disabled="EditorContext.IsReadOnly"> |
|||
</MudSelectExtended> |
|||
</ChildContent> |
|||
</ExpressionInput> |
|||
@ -0,0 +1,54 @@ |
|||
using Elsa.Api.Client.Shared.UIHints.DropDown; |
|||
using Elsa.Studio.Models; |
|||
using LINGYUN.Abp.Notifications; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Microsoft.Extensions.Localization; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor.Components; |
|||
|
|||
public partial class NotificationPicker |
|||
{ |
|||
private ICollection<SelectListItem> _items = []; |
|||
private IReadOnlyList<SelectListItem> _notifications = []; |
|||
|
|||
[Parameter] public DisplayInputEditorContext EditorContext { get; set; } = null!; |
|||
|
|||
[Inject] private IStringLocalizerFactory StringLocalizerFactory { get; set; } = null!; |
|||
[Inject] private INotificationDefinitionManager NotificationDefinitionManager { get; set; } = null!; |
|||
|
|||
private SelectListItem? GetSelectedValue() |
|||
{ |
|||
var value = EditorContext.GetLiteralValueOrDefault(); |
|||
return _items.FirstOrDefault(x => x.Value == value); |
|||
} |
|||
|
|||
private void OnSearch(string? filter) |
|||
{ |
|||
_items = _notifications |
|||
.WhereIf(!string.IsNullOrWhiteSpace(filter), x => x.Text.Contains(filter!)) |
|||
.Take(10) |
|||
.ToList(); |
|||
} |
|||
|
|||
private async Task OnValueChanged(SelectListItem? value) |
|||
{ |
|||
await EditorContext.UpdateValueOrLiteralExpressionAsync(value?.Value ?? ""); |
|||
} |
|||
|
|||
protected async override Task OnInitializedAsync() |
|||
{ |
|||
var notifications = await NotificationDefinitionManager.GetNotificationsAsync(); |
|||
|
|||
_notifications = notifications |
|||
.Select(notification => |
|||
new SelectListItem( |
|||
notification.DisplayName.Localize(StringLocalizerFactory), notification.Name)) |
|||
.OrderBy(x => x.Text) |
|||
.ToList(); |
|||
|
|||
_items = _notifications.Take(10).ToList(); |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using Elsa.Studio.Extensions; |
|||
using LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor.Handlers; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor.Extensions; |
|||
|
|||
public static class ServiceCollectionExtensions |
|||
{ |
|||
public static IServiceCollection AddNotificationsUIHintHandlers(this IServiceCollection services) |
|||
{ |
|||
return services.AddUIHintHandler<NotificationPickerHandler>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,25 @@ |
|||
using Elsa.Studio; |
|||
using Elsa.Studio.Contracts; |
|||
using Elsa.Studio.Models; |
|||
using LINGYUN.Abp.ElsaNext.Notifications.UIHints; |
|||
using LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor.Components; |
|||
using Microsoft.AspNetCore.Components; |
|||
|
|||
namespace LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor.Handlers; |
|||
|
|||
public class NotificationPickerHandler : IUIHintHandler |
|||
{ |
|||
public bool GetSupportsUIHint(string uiHint) => uiHint is NotificationsUIHints.NotificationPicker; |
|||
|
|||
public string UISyntax => WellKnownSyntaxNames.Object; |
|||
|
|||
public RenderFragment DisplayInputEditor(DisplayInputEditorContext context) |
|||
{ |
|||
return builder => |
|||
{ |
|||
builder.OpenComponent(0, typeof(NotificationPicker)); |
|||
builder.AddAttribute(1, nameof(NotificationPicker.EditorContext), context); |
|||
builder.CloseComponent(); |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Razor"> |
|||
|
|||
<Import Project="..\..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net10.0</TargetFramework> |
|||
<AssemblyName>LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor</AssemblyName> |
|||
<PackageId>LINGYUN.Abp.ElsaNext.Studio.Notifications.Blazor</PackageId> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.ElsaNext.Notifications\LINGYUN.Abp.ElsaNext.Notifications.csproj" /> |
|||
<ProjectReference Include="..\LINGYUN.Abp.ElsaNext.Studio.Blazor\LINGYUN.Abp.ElsaNext.Studio.Blazor.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,5 @@ |
|||
@using Microsoft.AspNetCore.Components.Web |
|||
@using Elsa.Studio.Components |
|||
@using Elsa.Studio.Localization |
|||
@using MudBlazor |
|||
@using MudExtensions |
|||
Loading…
Reference in new issue