Added audit log
This commit is contained in:
@@ -97,7 +97,7 @@
|
||||
Sortable="@property.Sortable"/>
|
||||
}
|
||||
|
||||
@if (DisplayActions && (_hasDeletePolicy || _hasUpdatePolicy)) {
|
||||
@if (DisplayActions && (_hasDeletePolicy || _hasUpdatePolicy) && (_buttonToggles.ShowEditButton || _buttonToggles.ShowDeleteButton && _pluginButtons.Any(pb => pb.IsForTable(_config)))) {
|
||||
<TemplateColumn Title="Actions" Align="@Align.End" Style="min-height: 44px; min-width: max-content">
|
||||
@foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.OnEntry)) {
|
||||
<FluentButton OnClick="() => button.Handler.Invoke(context, _config!)">
|
||||
@@ -226,10 +226,9 @@
|
||||
private List<PluginButton> _pluginButtons = new();
|
||||
private DefaultButtonToggles _buttonToggles = new();
|
||||
|
||||
internal static HopFrameTablePage? CurrentInstance { get; private set; }
|
||||
private string? _currentUser;
|
||||
|
||||
protected override void OnInitialized() {
|
||||
CurrentInstance = this;
|
||||
_config ??= Explorer.GetTable(TableDisplayName);
|
||||
|
||||
if (_config is null || (_config.Ignored && DialogData is null)) {
|
||||
@@ -242,8 +241,10 @@
|
||||
Navigator.NavigateTo("/admin", true);
|
||||
return;
|
||||
}
|
||||
|
||||
_currentUser = await Handler.GetCurrentUserDisplayNameAsync();
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new TableInitializedEvent(this) {
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new TableInitializedEvent(this, _currentUser!) {
|
||||
Table = _config!
|
||||
});
|
||||
if (eventResult.IsCanceled) return;
|
||||
@@ -283,7 +284,7 @@
|
||||
|
||||
await Task.Delay(500, _searchCancel.Token);
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new SearchEvent(this) {
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new SearchEvent(this, _currentUser!) {
|
||||
SearchTerm = _searchTerm,
|
||||
Table = _config!,
|
||||
CurrentPage = _currentPage
|
||||
@@ -333,7 +334,7 @@
|
||||
public async Task Reload() {
|
||||
_loading = true;
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new ReloadEvent(this) {
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new ReloadEvent(this, _currentUser!) {
|
||||
Table = _config!
|
||||
}, _tokenSource.Token);
|
||||
if (eventResult.IsCanceled) {
|
||||
@@ -352,7 +353,7 @@
|
||||
}
|
||||
|
||||
public async Task ChangePage(int page) {
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new PageChangeEvent(this) {
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new PageChangeEvent(this, _currentUser!) {
|
||||
CurrentPage = _currentPage,
|
||||
NewPage = page,
|
||||
TotalPages = _totalPages,
|
||||
@@ -371,17 +372,17 @@
|
||||
Navigator.NavigateTo("/admin", true);
|
||||
return;
|
||||
}
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new DeleteEntryEvent(this) {
|
||||
Entity = element,
|
||||
Table = _config!
|
||||
}, _tokenSource.Token);
|
||||
if (eventResult.IsCanceled) return;
|
||||
|
||||
var dialog = await Dialogs.ShowConfirmationAsync("Do you really want to delete this entry?");
|
||||
var result = await dialog.Result;
|
||||
if (result.Cancelled) return;
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(new DeleteEntryEvent(this, _currentUser!) {
|
||||
Entity = element,
|
||||
Table = _config!
|
||||
}, _tokenSource.Token);
|
||||
if (eventResult.IsCanceled) return;
|
||||
|
||||
await _manager!.DeleteItem(element);
|
||||
await Emitter.DispatchCallback(CallbackTypes.DeleteEntry(_config!), element);
|
||||
await Reload();
|
||||
@@ -392,22 +393,6 @@
|
||||
Navigator.NavigateTo("/admin", true);
|
||||
return;
|
||||
}
|
||||
|
||||
HopFrameTablePageEventArgs eventArgs;
|
||||
if (element is null) {
|
||||
eventArgs = new CreateEntryEvent(this) {
|
||||
Table = _config!
|
||||
};
|
||||
}
|
||||
else {
|
||||
eventArgs = new UpdateEntryEvent(this) {
|
||||
Table = _config!,
|
||||
Entity = element
|
||||
};
|
||||
}
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(eventArgs, _tokenSource.Token);
|
||||
if (eventResult.IsCanceled) return;
|
||||
|
||||
var panel = await Dialogs.ShowPanelAsync<HopFrameEditor>(new EditorDialogData(_config!, element), new DialogParameters {
|
||||
TrapFocus = false
|
||||
@@ -416,6 +401,23 @@
|
||||
var data = result.Data as EditorDialogData;
|
||||
|
||||
if (result.Cancelled) return;
|
||||
|
||||
HopFrameTablePageEventArgs eventArgs;
|
||||
if (element is null) {
|
||||
eventArgs = new CreateEntryEvent(this, _currentUser!) {
|
||||
Table = _config!,
|
||||
Entity = data!.CurrentObject!
|
||||
};
|
||||
}
|
||||
else {
|
||||
eventArgs = new UpdateEntryEvent(this, _currentUser!) {
|
||||
Table = _config!,
|
||||
Entity = data!.CurrentObject!
|
||||
};
|
||||
}
|
||||
|
||||
var eventResult = await PluginOrchestrator.DispatchEvent(eventArgs, _tokenSource.Token);
|
||||
if (eventResult.IsCanceled) return;
|
||||
|
||||
if (element is null) {
|
||||
await _manager!.AddItem(data!.CurrentObject!);
|
||||
@@ -430,7 +432,7 @@
|
||||
}
|
||||
|
||||
private void SelectItem(object item, bool selected) {
|
||||
var eventResult = PluginOrchestrator.DispatchEvent(new SelectEntryEvent(this) {
|
||||
var eventResult = PluginOrchestrator.DispatchEvent(new SelectEntryEvent(this, _currentUser!) {
|
||||
Entity = item,
|
||||
Selected = selected,
|
||||
Table = _config!
|
||||
|
||||
Reference in New Issue
Block a user