Added default button removal feature
This commit is contained in:
25
.idea/.idea.HopFrame/.idea/workspace.xml
generated
25
.idea/.idea.HopFrame/.idea/workspace.xml
generated
@@ -11,12 +11,11 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="0648788e-7696-4e60-bf12-5d5601f33d8c" name="Changes" comment="Passed cancellation tokens to event handlers if needed">
|
||||
<change afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/PageInitializedEvent.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.HopFrame/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.HopFrame/.idea/workspace.xml" afterDir="false" />
|
||||
<list default="true" id="0648788e-7696-4e60-bf12-5d5601f33d8c" name="Changes" comment="Added plugin buttons">
|
||||
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Components/Pages/HopFrameTablePage.razor" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Components/Pages/HopFrameTablePage.razor" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/HopFramePlugin.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/HopFramePlugin.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/testing/HopFrame.Testing/TestPlugin.cs" beforeDir="false" afterPath="$PROJECT_DIR$/testing/HopFrame.Testing/TestPlugin.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/PageInitializedEvent.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/TableInitializedEvent.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/IPluginOrchestrator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/IPluginOrchestrator.cs" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Internal/PluginOrchestrator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Internal/PluginOrchestrator.cs" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -240,7 +239,7 @@
|
||||
<workItem from="1738421294144" duration="1651000" />
|
||||
<workItem from="1738422949337" duration="141000" />
|
||||
<workItem from="1738512801911" duration="6776000" />
|
||||
<workItem from="1738769458367" duration="3697000" />
|
||||
<workItem from="1738769458367" duration="4838000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Added basic configuration">
|
||||
<option name="closed" value="true" />
|
||||
@@ -546,7 +545,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1738770468949</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="39" />
|
||||
<task id="LOCAL-00039" summary="Added plugin buttons">
|
||||
<option name="closed" value="true" />
|
||||
<created>1738773315593</created>
|
||||
<option name="number" value="00039" />
|
||||
<option name="presentableId" value="LOCAL-00039" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1738773315593</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="40" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -597,7 +604,6 @@
|
||||
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
|
||||
<component name="VcsManagerConfiguration">
|
||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||
<MESSAGE value="Added text area support and DI support for modifier functions" />
|
||||
<MESSAGE value="Addressed all build warnings" />
|
||||
<MESSAGE value="Added documentation for the configurators and service extensions methods" />
|
||||
<MESSAGE value="Created tests for the core module" />
|
||||
@@ -622,6 +628,7 @@
|
||||
<MESSAGE value="Added custom views" />
|
||||
<MESSAGE value="Added plugin events" />
|
||||
<MESSAGE value="Passed cancellation tokens to event handlers if needed" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Passed cancellation tokens to event handlers if needed" />
|
||||
<MESSAGE value="Added plugin buttons" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Added plugin buttons" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -21,7 +21,7 @@
|
||||
<div style="display: flex; flex-direction: column; height: 100%">
|
||||
<FluentToolbar Class="hopframe-toolbar">
|
||||
<h3>@_config?.DisplayName</h3>
|
||||
@if (!DisplaySelection) {
|
||||
@if (!DisplaySelection && _buttonToggles.ShowRefreshButton) {
|
||||
<FluentButton
|
||||
IconStart="@(new Icons.Regular.Size16.ArrowClockwise())"
|
||||
OnClick="Reload"
|
||||
@@ -42,8 +42,8 @@
|
||||
<FluentSpacer />
|
||||
<FluentSearch @oninput="OnSearch" @onchange="OnSearch" Style="width: 350px" />
|
||||
|
||||
@if (_hasCreatePolicy && DisplayActions) {
|
||||
<FluentButton OnClick="async () => { await CreateOrEdit(null); }">Add Entry</FluentButton>
|
||||
@if (_hasCreatePolicy && DisplayActions && _buttonToggles.ShowAddEntityButton) {
|
||||
<FluentButton OnClick="async () => { await CreateOrEdit(null); }">Add Entity</FluentButton>
|
||||
}
|
||||
|
||||
@foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.TopRight)) {
|
||||
@@ -85,13 +85,13 @@
|
||||
</FluentButton>
|
||||
}
|
||||
|
||||
@if (_hasUpdatePolicy) {
|
||||
@if (_hasUpdatePolicy && _buttonToggles.ShowEditButton) {
|
||||
<FluentButton aria-label="Edit entry" OnClick="async () => { await CreateOrEdit(context); }">
|
||||
<FluentIcon Value="@(new Icons.Regular.Size16.Edit())"/>
|
||||
</FluentButton>
|
||||
}
|
||||
|
||||
@if (_hasDeletePolicy) {
|
||||
@if (_hasDeletePolicy && _buttonToggles.ShowDeleteButton) {
|
||||
<FluentButton aria-label="Delete entry" OnClick="async () => { await DeleteEntry(context); }">
|
||||
<FluentIcon Value="@(new Icons.Regular.Size16.Delete())" Color="Color.Warning"/>
|
||||
</FluentButton>
|
||||
@@ -182,6 +182,7 @@
|
||||
|
||||
private readonly CancellationTokenSource _tokenSource = new();
|
||||
private List<PluginButton> _pluginButtons = new();
|
||||
private DefaultButtonToggles _buttonToggles = new();
|
||||
|
||||
protected override void OnInitialized() {
|
||||
_config ??= Explorer.GetTable(TableDisplayName);
|
||||
@@ -197,11 +198,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new PageInitializedEvent(this) {
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new TableInitializedEvent(this) {
|
||||
Table = _config!
|
||||
});
|
||||
if (eventResult.IsCanceled) return;
|
||||
_pluginButtons = eventResult.PluginButtons;
|
||||
_buttonToggles = eventResult.DefaultButtons;
|
||||
|
||||
_hasUpdatePolicy = await Handler.IsAuthenticatedAsync(_config?.UpdatePolicy);
|
||||
_hasDeletePolicy = await Handler.IsAuthenticatedAsync(_config?.DeletePolicy);
|
||||
@@ -223,6 +225,7 @@
|
||||
|
||||
public void Dispose() {
|
||||
_searchCancel.Dispose();
|
||||
_tokenSource.Dispose();
|
||||
}
|
||||
|
||||
private CancellationTokenSource _searchCancel = new();
|
||||
|
||||
@@ -4,8 +4,9 @@ using Microsoft.FluentUI.AspNetCore.Components;
|
||||
|
||||
namespace HopFrame.Web.Plugins.Events;
|
||||
|
||||
public class PageInitializedEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
|
||||
public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
|
||||
public List<PluginButton> PluginButtons { get; } = new();
|
||||
public DefaultButtonToggles DefaultButtons { get; set; } = new();
|
||||
|
||||
public void AddPageButton(string title, Func<Task> callback, bool pushRight = false, IconInfo? icon = null) {
|
||||
PluginButtons.Add(new() {
|
||||
@@ -91,3 +92,10 @@ public enum PluginButtonPosition {
|
||||
TopRight = 1,
|
||||
OnEntry = 2
|
||||
}
|
||||
|
||||
public struct DefaultButtonToggles() {
|
||||
public bool ShowRefreshButton { get; set; } = true;
|
||||
public bool ShowAddEntityButton { get; set; } = true;
|
||||
public bool ShowDeleteButton { get; set; } = true;
|
||||
public bool ShowEditButton { get; set; } = true;
|
||||
}
|
||||
@@ -54,5 +54,4 @@ internal sealed class PluginOrchestrator(IServiceProvider services) : IPluginOrc
|
||||
|
||||
return @event;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user