diff --git a/.idea/.idea.HopFrame/.idea/workspace.xml b/.idea/.idea.HopFrame/.idea/workspace.xml
index 041222e..fe37142 100644
--- a/.idea/.idea.HopFrame/.idea/workspace.xml
+++ b/.idea/.idea.HopFrame/.idea/workspace.xml
@@ -11,12 +11,11 @@
-
+
+
-
-
-
+
@@ -95,6 +94,7 @@
+
@@ -240,7 +240,7 @@
-
+
@@ -538,7 +538,15 @@
1738519603597
-
+
+
+ 1738770468949
+
+
+
+ 1738770468949
+
+
@@ -589,7 +597,6 @@
-
@@ -614,6 +621,7 @@
-
+
+
\ No newline at end of file
diff --git a/src/HopFrame.Web/Components/Pages/HopFrameTablePage.razor b/src/HopFrame.Web/Components/Pages/HopFrameTablePage.razor
index 63fc4c0..628f380 100644
--- a/src/HopFrame.Web/Components/Pages/HopFrameTablePage.razor
+++ b/src/HopFrame.Web/Components/Pages/HopFrameTablePage.razor
@@ -31,18 +31,34 @@
}
+ @foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.TopLeft)) {
+
+ @button.Title
+
+ }
+
@if (_hasCreatePolicy && DisplayActions) {
Add Entry
}
+
+ @foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.TopRight)) {
+
+ @button.Title
+
+ }
-
+
@if (DisplaySelection) {
+ @foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.OnEntry)) {
+
+
+
+ }
+
@if (_hasUpdatePolicy) {
@@ -146,7 +168,7 @@
private TableConfig? _config;
private ITableManager? _manager;
- private object[] _currentlyDisplayedModels = [];
+ public object[] CurrentlyDisplayedModels = [];
private int _currentPage;
private int _totalPages;
private string? _searchTerm;
@@ -159,6 +181,7 @@
private bool _allSelected;
private readonly CancellationTokenSource _tokenSource = new();
+ private List _pluginButtons = new();
protected override void OnInitialized() {
_config ??= Explorer.GetTable(TableDisplayName);
@@ -174,12 +197,18 @@
return;
}
+ var eventResult = await PluginOrchestrator.DispatchEvent(new PageInitializedEvent(this) {
+ Table = _config!
+ });
+ if (eventResult.IsCanceled) return;
+ _pluginButtons = eventResult.PluginButtons;
+
_hasUpdatePolicy = await Handler.IsAuthenticatedAsync(_config?.UpdatePolicy);
_hasDeletePolicy = await Handler.IsAuthenticatedAsync(_config?.DeletePolicy);
_hasCreatePolicy = await Handler.IsAuthenticatedAsync(_config?.CreatePolicy);
_manager ??= Explorer.GetTableManager(_config!.PropertyName);
- _currentlyDisplayedModels = await _manager!.LoadPage(_currentPage, PerPage).ToArrayAsync();
+ CurrentlyDisplayedModels = await _manager!.LoadPage(_currentPage, PerPage).ToArrayAsync();
_totalPages = await _manager.TotalPages(PerPage);
}
@@ -228,7 +257,7 @@
if (!string.IsNullOrEmpty(_searchTerm)) {
(var query, _totalPages) = await _manager!.Search(_searchTerm, 0, PerPage);
- _currentlyDisplayedModels = query.ToArray();
+ CurrentlyDisplayedModels = query.ToArray();
}
else {
await OnInitializedAsync();
@@ -329,8 +358,8 @@
}
private void SelectAll() {
- var selected = _currentlyDisplayedModels.All(DialogData!.SelectedObjects.Contains);
- foreach (var displayedModel in _currentlyDisplayedModels) {
+ var selected = CurrentlyDisplayedModels.All(DialogData!.SelectedObjects.Contains);
+ foreach (var displayedModel in CurrentlyDisplayedModels) {
SelectItem(displayedModel, !selected);
}
_allSelected = selected;
diff --git a/src/HopFrame.Web/Plugins/Events/PageInitializedEvent.cs b/src/HopFrame.Web/Plugins/Events/PageInitializedEvent.cs
new file mode 100644
index 0000000..bdcf8c9
--- /dev/null
+++ b/src/HopFrame.Web/Plugins/Events/PageInitializedEvent.cs
@@ -0,0 +1,93 @@
+using HopFrame.Core.Config;
+using HopFrame.Web.Components.Pages;
+using Microsoft.FluentUI.AspNetCore.Components;
+
+namespace HopFrame.Web.Plugins.Events;
+
+public class PageInitializedEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
+ public List PluginButtons { get; } = new();
+
+ public void AddPageButton(string title, Func callback, bool pushRight = false, IconInfo? icon = null) {
+ PluginButtons.Add(new() {
+ Title = title,
+ Icon = icon,
+ Position = pushRight ? PluginButtonPosition.TopRight : PluginButtonPosition.TopLeft,
+ Handler = (_, _) => callback.Invoke()
+ });
+ }
+
+ public void AddPageButton(string title, Action callback, bool pushRight = false, IconInfo? icon = null) {
+ AddPageButton(title, () => {
+ callback.Invoke();
+ return Task.CompletedTask;
+ }, pushRight, icon);
+ }
+
+ public void AddEntityButton(IconInfo icon, Func