5 Commits

Author SHA1 Message Date
b27800bfdf Added more descriptive inline documentations 2026-01-23 22:11:35 +01:00
12c86bcb16 Added ability to use ignored tables in relation picker 2026-01-19 19:51:41 +01:00
a826ddbfb1 Fixed #37 2026-01-19 19:44:25 +01:00
297cf00891 Fixed #38 2026-01-19 19:39:25 +01:00
d393ae787d Code cleanup + new pipeline setup 2026-01-18 17:42:37 +01:00
22 changed files with 433 additions and 118 deletions

View File

@@ -60,10 +60,8 @@ publish:
publish-help:
stage: publish-help
image: docker:latest
services:
- name: docker:dind
alias: docker
tags:
- docker
script:
- export VERSION=$(echo $CI_COMMIT_TAG | sed 's/^v//')
- cd docs

View File

@@ -11,7 +11,24 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="0648788e-7696-4e60-bf12-5d5601f33d8c" name="Changes" comment="" />
<list default="true" id="0648788e-7696-4e60-bf12-5d5601f33d8c" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.HopFrame/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.HopFrame/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Core/Config/HopFrameConfig.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Core/Config/HopFrameConfig.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Core/Config/PropertyConfig.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Core/Config/PropertyConfig.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Core/Config/TableConfig.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Core/Config/TableConfig.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Core/Repositories/IHopFrameRepository.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Core/Repositories/IHopFrameRepository.cs" afterDir="false" />
<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/Annotations/EventHandlerAttribute.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Annotations/EventHandlerAttribute.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/EntryEvent.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/EntryEvent.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/HopFrameEventArgs.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/HopFrameEventArgs.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/PageChangeEvent.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/PageChangeEvent.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/ReloadEvent.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/ReloadEvent.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/SearchEvent.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/SearchEvent.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/TableInitializedEvent.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/TableInitializedEvent.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/ValidationEvent.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/ValidationEvent.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/ServiceCollectionExtensions.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/ServiceCollectionExtensions.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Services/ISearchSuggestionProvider.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Services/ISearchSuggestionProvider.cs" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -34,6 +51,7 @@
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="RESET_MODE" value="HARD" />
</component>
<component name="GitLabMergeRequestFiltersHistory">{
&quot;lastFilter&quot;: {
@@ -48,7 +66,7 @@
<component name="GitLabMergeRequestsSettings">{
&quot;selectedUrlAndAccountId&quot;: {
&quot;first&quot;: &quot;https://git.leon-hoppe.de/leon.hoppe/hopframe.git&quot;,
&quot;second&quot;: &quot;2d65fdcb-5f13-45ad-a7ba-91dd4a88d6e4&quot;
&quot;second&quot;: &quot;f58c9371-9f54-454e-a0db-5b4bc1187bad&quot;
}
}</component>
<component name="HighlightingSettingsPerFile">
@@ -117,40 +135,42 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
".NET Launch Settings Profile.HopFrame.Testing.Api: https.executor": "Run",
".NET Launch Settings Profile.HopFrame.Testing.executor": "Run",
".NET Launch Settings Profile.HopFrame.Testing: https.executor": "Run",
".NET Project.HopFrame.Testing.executor": "Run",
"72b118b0-a6fc-4561-acdf-74f0b454dbb8.executor": "Debug",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"b5f11219-dfc4-47a1-b02c-90ab603034fb.executor": "Debug",
"dcdf1689-dc07-47e4-8824-2e60a4fbf301.executor": "Debug",
"git-widget-placeholder": "feature/test-reports",
"list.type.of.created.stylesheet": "CSS",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "preferences.pluginManager",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;.NET Launch Settings Profile.HopFrame.Testing.Api: https.executor&quot;: &quot;Run&quot;,
&quot;.NET Launch Settings Profile.HopFrame.Testing.executor&quot;: &quot;Run&quot;,
&quot;.NET Launch Settings Profile.HopFrame.Testing: https.executor&quot;: &quot;Run&quot;,
&quot;.NET Project.HopFrame.Testing.executor&quot;: &quot;Run&quot;,
&quot;72b118b0-a6fc-4561-acdf-74f0b454dbb8.executor&quot;: &quot;Debug&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;RunOnceActivity.typescript.service.memoryLimit.init&quot;: &quot;true&quot;,
&quot;b5f11219-dfc4-47a1-b02c-90ab603034fb.executor&quot;: &quot;Debug&quot;,
&quot;dcdf1689-dc07-47e4-8824-2e60a4fbf301.executor&quot;: &quot;Debug&quot;,
&quot;git-widget-placeholder&quot;: &quot;dev&quot;,
&quot;list.type.of.created.stylesheet&quot;: &quot;CSS&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RunManager" selected=".NET Launch Settings Profile.HopFrame.Testing: https">
<configuration name="HopFrame.Testing: http" type="LaunchSettings" factoryName=".NET Launch Settings Profile">
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/testing/HopFrame.Testing/HopFrame.Testing.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="http" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2">
<option name="Build" />
</method>
@@ -159,13 +179,14 @@
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/testing/HopFrame.Testing/HopFrame.Testing.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="https" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2">
<option name="Build" />
</method>
@@ -174,13 +195,14 @@
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/testing/HopFrame.Testing.Api/HopFrame.Testing.Api.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="http" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2">
<option name="Build" />
</method>
@@ -189,13 +211,14 @@
<option name="LAUNCH_PROFILE_PROJECT_FILE_PATH" value="$PROJECT_DIR$/testing/HopFrame.Testing.Api/HopFrame.Testing.Api.csproj" />
<option name="LAUNCH_PROFILE_TFM" value="net9.0" />
<option name="LAUNCH_PROFILE_NAME" value="https" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="GENERATE_APPLICATIONHOST_CONFIG" value="1" />
<option name="SHOW_IIS_EXPRESS_OUTPUT" value="0" />
<option name="SEND_DEBUG_REQUEST" value="1" />
<option name="ADDITIONAL_IIS_EXPRESS_ARGUMENTS" value="" />
<option name="AUTO_ATTACH_CHILDREN" value="0" />
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2">
<option name="Build" />
</method>
@@ -267,38 +290,11 @@
<workItem from="1744966207145" duration="5231000" />
<workItem from="1751713720880" duration="8243000" />
<workItem from="1751741813788" duration="4623000" />
</task>
<task id="LOCAL-00016" summary="Added documentation for the configurators and service extensions methods">
<option name="closed" value="true" />
<created>1737208088933</created>
<option name="number" value="00016" />
<option name="presentableId" value="LOCAL-00016" />
<option name="project" value="LOCAL" />
<updated>1737208088933</updated>
</task>
<task id="LOCAL-00017" summary="Created tests for the core module">
<option name="closed" value="true" />
<created>1737212497960</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1737212497960</updated>
</task>
<task id="LOCAL-00018" summary="Added more tests">
<option name="closed" value="true" />
<created>1737285123218</created>
<option name="number" value="00018" />
<option name="presentableId" value="LOCAL-00018" />
<option name="project" value="LOCAL" />
<updated>1737285123218</updated>
</task>
<task id="LOCAL-00019" summary="Added web module tests">
<option name="closed" value="true" />
<created>1737298835225</created>
<option name="number" value="00019" />
<option name="presentableId" value="LOCAL-00019" />
<option name="project" value="LOCAL" />
<updated>1737298835225</updated>
<workItem from="1768753475773" duration="455000" />
<workItem from="1768753946559" duration="690000" />
<workItem from="1768756619311" duration="94000" />
<workItem from="1768847832546" duration="1238000" />
<workItem from="1769196883500" duration="5779000" />
</task>
<task id="LOCAL-00020" summary="Tested login functionality">
<option name="closed" value="true" />
@@ -660,7 +656,39 @@
<option name="project" value="LOCAL" />
<updated>1751750495636</updated>
</task>
<option name="localTasksCounter" value="65" />
<task id="LOCAL-00065" summary="Code cleanup + new pipeline setup">
<option name="closed" value="true" />
<created>1768754560236</created>
<option name="number" value="00065" />
<option name="presentableId" value="LOCAL-00065" />
<option name="project" value="LOCAL" />
<updated>1768754560236</updated>
</task>
<task id="LOCAL-00066" summary="Fixed #38">
<option name="closed" value="true" />
<created>1768847968844</created>
<option name="number" value="00066" />
<option name="presentableId" value="LOCAL-00066" />
<option name="project" value="LOCAL" />
<updated>1768847968844</updated>
</task>
<task id="LOCAL-00067" summary="Fixed #37">
<option name="closed" value="true" />
<created>1768848267710</created>
<option name="number" value="00067" />
<option name="presentableId" value="LOCAL-00067" />
<option name="project" value="LOCAL" />
<updated>1768848267710</updated>
</task>
<task id="LOCAL-00068" summary="Added ability to use ignored tables in relation picker">
<option name="closed" value="true" />
<created>1768848702981</created>
<option name="number" value="00068" />
<option name="presentableId" value="LOCAL-00068" />
<option name="project" value="LOCAL" />
<updated>1768848702981</updated>
</task>
<option name="localTasksCounter" value="69" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@@ -688,12 +716,19 @@
</component>
<component name="UnityCheckinConfiguration" checkUnsavedScenes="true" />
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
<MESSAGE value="Added default button removal feature" />
<MESSAGE value="Added custom search functionality" />
<MESSAGE value="Added fully virtual properties" />
<MESSAGE value="Added basic export and import feature" />
<MESSAGE value="Finished converter plugin" />
<MESSAGE value="Patched CI" />
<MESSAGE value="Prepared CI for v3.2.0" />
@@ -715,6 +750,10 @@
<MESSAGE value="Updated coverage extraction" />
<MESSAGE value="fixed coverage percentage printing" />
<MESSAGE value="fixed echo cmd" />
<option name="LAST_COMMIT_MESSAGE" value="fixed echo cmd" />
<MESSAGE value="Code cleanup + new pipeline setup" />
<MESSAGE value="Fixed #38" />
<MESSAGE value="Fixed #37" />
<MESSAGE value="Added ability to use ignored tables in relation picker" />
<option name="LAST_COMMIT_MESSAGE" value="Added ability to use ignored tables in relation picker" />
</component>
</project>

View File

@@ -24,6 +24,10 @@ public sealed class HopFrameConfigurator(HopFrameConfig config, IServiceCollecti
/// </summary>
public HopFrameConfig InnerConfig { get; } = config;
/// <summary>
/// The <see cref="ServiceCollection"/> of the application.
/// WARNING: Only use this during application building phase
/// </summary>
public IServiceCollection ServiceCollection { get; } = collection;
/// <summary>

View File

@@ -36,7 +36,9 @@ public class PropertyConfig(PropertyInfo info, TableConfig table, int nthPropert
}
}
/// <inheritdoc />
public sealed class VirtualPropertyConfig(TableConfig table, int nthProperty) : PropertyConfig(GetDummyProperty(), table, nthProperty) {
public string? DummyProperty { get; set; } = null;
public Func<object, string, IServiceProvider, Task>? VirtualParser { get; set; }
@@ -69,6 +71,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Sets the title displayed in the table header and edit dialog
/// </summary>
/// <param name="displayName">The new name of the property</param>
public PropertyConfigurator<TProp> SetDisplayName(string displayName) {
InnerConfig.Name = displayName;
return this;
@@ -77,6 +80,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines if the property should appear in the table, if not the property is also set to be not searchable
/// </summary>
/// <param name="list">The toggle for the option</param>
/// <seealso cref="IsSearchable"/>
public PropertyConfigurator<TProp> List(bool list) {
InnerConfig.List = list;
@@ -87,6 +91,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines if the table can be sorted by the property
/// </summary>
/// <param name="sortable">The toggle for the option</param>
public PropertyConfigurator<TProp> IsSortable(bool sortable) {
InnerConfig.Sortable = sortable;
return this;
@@ -95,6 +100,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines if the property get taken into account for search results
/// </summary>
/// <param name="searchable">The toggle for the option</param>
public PropertyConfigurator<TProp> IsSearchable(bool searchable) {
InnerConfig.Searchable = searchable;
return this;
@@ -103,6 +109,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines if the value that should be displayed instead of the string representation of the type
/// </summary>
/// <param name="propertyExpression">The expression that points at the property that should be used</param>
public PropertyConfigurator<TProp> SetDisplayedProperty<TInnerProp>(Expression<Func<TProp, TInnerProp>> propertyExpression) {
InnerConfig.DisplayedProperty = TableConfigurator<TProp>.GetPropertyInfo(propertyExpression);
return this;
@@ -111,6 +118,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines the value that's displayed in the admin ui
/// </summary>
/// <param name="formatter">The function that formats the given entity</param>
/// <seealso cref="SetDisplayedProperty{TInnerProp}"/>
public PropertyConfigurator<TProp> Format(Func<TProp, IServiceProvider, string> formatter) {
InnerConfig.Formatter = (obj, provider) => Task.FromResult(formatter.Invoke((TProp)obj, provider));
@@ -126,6 +134,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines the value that's displayed for each entry in the list
/// </summary>
/// <param name="formatter">The function that formats each given element</param>
public PropertyConfigurator<TProp> FormatEach<TInnerProp>(Func<TInnerProp, IServiceProvider, string> formatter) {
InnerConfig.EnumerableFormatter = (obj, provider) => Task.FromResult(formatter.Invoke((TInnerProp)obj, provider));
return this;
@@ -140,6 +149,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines the function used for parsing the value provided in the editor dialog to the actual property value
/// </summary>
/// <param name="parser">The function that converts the user input to the desired type</param>
public PropertyConfigurator<TProp> SetParser(Func<string, IServiceProvider, TProp> parser) {
InnerConfig.Parser = (str, provider) => Task.FromResult<object>(parser.Invoke(str, provider)!);
return this;
@@ -154,6 +164,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines if the value can be edited in the admin ui. If true, the value can still be initially set, but not modified
/// </summary>
/// <param name="editable">The toggle for the option</param>
/// <seealso cref="SetCreatable"/>
public PropertyConfigurator<TProp> SetEditable(bool editable) {
InnerConfig.Editable = editable;
@@ -163,6 +174,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines if the initial value can be edited in the admin ui. If true the value will not be visible in the create dialog
/// </summary>
/// <param name="creatable">The toggle for the option</param>
/// <seealso cref="SetEditable"/>
public PropertyConfigurator<TProp> SetCreatable(bool creatable) {
InnerConfig.Creatable = creatable;
@@ -172,6 +184,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines if the value should be displayed in the admin ui (useful for secrets like passwords etc.)
/// </summary>
/// <param name="display">The toggle for the option</param>
public PropertyConfigurator<TProp> DisplayValue(bool display) {
InnerConfig.DisplayValue = display;
return this;
@@ -180,6 +193,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines if the admin ui should use a text area for modifying the value
/// </summary>
/// <param name="textField">The toggle for the option</param>
/// <seealso cref="SetTextAreaRows"/>
public PropertyConfigurator<TProp> IsTextArea(bool textField) {
InnerConfig.TextArea = textField;
@@ -189,6 +203,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines the initial size of the text area field
/// </summary>
/// <param name="rows">The number of rows (height) the text area field should have</param>
/// <seealso cref="IsTextArea"/>
public PropertyConfigurator<TProp> SetTextAreaRows(int rows) {
InnerConfig.TextAreaRows = rows;
@@ -198,14 +213,18 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines the validator used for the property value before saving
/// </summary>
/// <param name="validator">
/// The function that validates the given input.
///
/// It takes in the parsed property and an <see cref="IServiceProvider"/>
/// and returns an error list. If the list is empty, the property passes the check.
/// </param>
public PropertyConfigurator<TProp> SetValidator(Func<TProp?, IServiceProvider, IEnumerable<string>> validator) {
InnerConfig.Validator = (obj, provider) => Task.FromResult(validator.Invoke((TProp?)obj, provider));
return this;
}
/// <summary>
/// Determines the validator used for the property value before saving
/// </summary>
/// <inheritdoc cref="SetValidator(System.Func{TProp?,System.IServiceProvider,System.Collections.Generic.IEnumerable{string}})"/>
public PropertyConfigurator<TProp> SetValidator(Func<TProp?, IServiceProvider, Task<IEnumerable<string>>> validator) {
InnerConfig.Validator = (obj, provider) => validator.Invoke((TProp?)obj, provider);
return this;
@@ -214,6 +233,7 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
/// <summary>
/// Determines the order index for the property in the admin ui
/// </summary>
/// <param name="index">The value for the option</param>
/// <seealso cref="TableConfigurator{TModel}.SetOrderIndex"/>
public PropertyConfigurator<TProp> SetOrderIndex(int index) {
InnerConfig.Order = index;
@@ -242,10 +262,12 @@ public class PropertyConfigurator<TProp>(PropertyConfig config) {
}
}
/// <inheritdoc/>
public sealed class VirtualPropertyConfigurator<TModel>(VirtualPropertyConfig config) : PropertyConfigurator<string>(config) {
/// <summary>
/// Determines the function used for parsing the value provided in the editor dialog to the actual model value
/// </summary>
/// <param name="parser">The function that takes in the parent object and the user input and applies all necessary changes</param>
public VirtualPropertyConfigurator<TModel> SetVirtualParser(Action<TModel, string, IServiceProvider> parser) {
var cfg = InnerConfig as VirtualPropertyConfig;
@@ -257,7 +279,7 @@ public sealed class VirtualPropertyConfigurator<TModel>(VirtualPropertyConfig co
return this;
}
/// <inheritdoc cref="SetVirtualParser{TModel}(System.Action{TModel,string,System.IServiceProvider})"/>
/// <inheritdoc cref="SetVirtualParser(System.Action{TModel, System.String, System.IServiceProvider})" />
public VirtualPropertyConfigurator<TModel> SetVirtualParser(Func<TModel, string, IServiceProvider, Task> parser) {
var cfg = InnerConfig as VirtualPropertyConfig;

View File

@@ -63,13 +63,15 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
/// <summary>
/// Determines if the table should be ignored in the admin ui
/// </summary>
public TableConfigurator<TModel> Ignore(bool ignore) {
/// <param name="ignore">The toggle for the option</param>
public TableConfigurator<TModel> Ignore(bool ignore = true) {
InnerConfig.Ignored = ignore;
return this;
}
/// <summary>
/// Determines if search suggestions should be displayed in the ui (Advanced Search)
/// </summary>
/// <param name="show">The toggle for the option</param>
public TableConfigurator<TModel> ShowSearchSuggestions(bool show = true) {
InnerConfig.ShowSearchSuggestions = show;
return this;
@@ -144,6 +146,7 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
/// <summary>
/// Determines the name for the table used in the admin ui and url for the table page
/// </summary>
/// <param name="name">The value for the option</param>
public TableConfigurator<TModel> SetDisplayName(string name) {
InnerConfig.DisplayName = name;
return this;
@@ -152,6 +155,7 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
/// <summary>
/// Determines the description displayed in the admin ui
/// </summary>
/// <param name="description">The value for the option</param>
public TableConfigurator<TModel> SetDescription(string description) {
InnerConfig.Description = description;
return this;
@@ -160,6 +164,7 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
/// <summary>
/// Determines the order index for the table in the admin ui
/// </summary>
/// <param name="index">The value for the option</param>
/// <seealso cref="PropertyConfigurator{TProp}.SetOrderIndex"/>
public TableConfigurator<TModel> SetOrderIndex(int index) {
InnerConfig.Order = index;
@@ -169,6 +174,8 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
/// <summary>
/// Determines the policy needed by a user in order to view the table
/// </summary>
/// <param name="policy">The value for the option</param>
/// <seealso cref="SetCombinedPolicy"/>
public TableConfigurator<TModel> SetViewPolicy(string policy) {
InnerConfig.ViewPolicy = policy;
return this;
@@ -177,6 +184,8 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
/// <summary>
/// Determines the policy needed by a user in order to edit the entries
/// </summary>
/// <param name="policy">The value for the option</param>
/// <seealso cref="SetCombinedPolicy"/>
public TableConfigurator<TModel> SetUpdatePolicy(string policy) {
InnerConfig.UpdatePolicy = policy;
return this;
@@ -185,6 +194,8 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
/// <summary>
/// Determines the policy needed by a user in order to create entries
/// </summary>
/// <param name="policy">The value for the option</param>
/// <seealso cref="SetCombinedPolicy"/>
public TableConfigurator<TModel> SetCreatePolicy(string policy) {
InnerConfig.CreatePolicy = policy;
return this;
@@ -193,11 +204,25 @@ public sealed class TableConfigurator<TModel>(TableConfig config) {
/// <summary>
/// Determines the policy needed by a user in order to delete entries
/// </summary>
/// <param name="policy">The value for the option</param>
/// <seealso cref="SetCombinedPolicy"/>
public TableConfigurator<TModel> SetDeletePolicy(string policy) {
InnerConfig.DeletePolicy = policy;
return this;
}
/// <summary>
/// Sets the view, update, create and delete policies to the same value
/// </summary>
/// <param name="policy">The value for the options</param>
public TableConfigurator<TModel> SetCombinedPolicy(string policy) {
InnerConfig.ViewPolicy = policy;
InnerConfig.UpdatePolicy = policy;
InnerConfig.CreatePolicy = policy;
InnerConfig.DeletePolicy = policy;
return this;
}
/// <summary>
/// Adds a callback handler of the provided type
/// </summary>

View File

@@ -9,6 +9,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageId>HopFrame.Core</PackageId>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,24 +1,78 @@
namespace HopFrame.Core.Repositories;
/// <summary>
/// The middleware used to access data for custom repositories
/// </summary>
/// <typeparam name="TModel">The type of the entity that is managed by this repository</typeparam>
/// <typeparam name="TKey">The type of the primary key of the entity that is managed by this repository</typeparam>
public interface IHopFrameRepository<TModel, in TKey> where TModel : class {
/// <summary>
/// Gets used to load all entities of the current page to display
/// </summary>
/// <param name="page">The page the user is currently on (starts at 0)</param>
/// <param name="perPage">The maximum number of elements that should be returned</param>
/// <returns>The entries for the requested page</returns>
Task<IEnumerable<TModel>> LoadPage(int page, int perPage);
/// <summary>
/// Gets used to filter the entries by the entered search term
/// </summary>
/// <param name="searchTerm">The search text that was entered by the user</param>
/// <param name="page">The page the user is currently on (starts at 0)</param>
/// <param name="perPage">The maximum number of elements that should be returned</param>
/// <returns>A list of the filtered entries on the current page with the total number of pages</returns>
/// <seealso cref="SearchResult{TModel}"/>
Task<SearchResult<TModel>> Search(string searchTerm, int page, int perPage);
/// <summary>
/// Gets used to determine the total number of pages
/// </summary>
/// <param name="perPage">The maximum number of elements per page</param>
/// <returns>The total number of pages</returns>
Task<int> GetTotalPageCount(int perPage);
/// <summary>
/// Gets used when an entry is created through the UI
/// </summary>
/// <param name="item">The entry that needs to be saved</param>
Task CreateItem(TModel item);
/// <summary>
/// Gets used when an entry is modified through the UI
/// </summary>
/// <param name="item">The modified entry that needs to be saved</param>
Task EditItem(TModel item);
/// <summary>
/// Gets used when an entry is deleted through the UI
/// </summary>
/// <param name="item">The entry that should be deleted</param>
Task DeleteItem(TModel item);
/// <summary>
/// Gets used to receive information about a specific entry from the dataset
/// </summary>
/// <param name="key">The primary key of the desired entry</param>
/// <returns>Either the entry if one is found or <c>null</c></returns>
Task<TModel?> GetOne(TKey key);
}
/// <summary>
/// The object that is passed to the UI to display the search results
/// </summary>
/// <param name="items">The found entries on the current page</param>
/// <param name="pageCount">The total number of pages that the search contains</param>
/// <typeparam name="TModel">The type of the entity</typeparam>
public readonly struct SearchResult<TModel>(IEnumerable<TModel> items, int pageCount) {
/// <summary>
/// The found entries on the current page
/// </summary>
public IEnumerable<TModel> Items { get; init; } = items;
/// <summary>
/// The total number of pages that the search contains
/// </summary>
public int PageCount { get; init; } = pageCount;
}

View File

@@ -18,7 +18,9 @@ internal sealed class ContextExplorer(HopFrameConfig config, IServiceProvider pr
public TableConfig? GetTable(string tableDisplayName) {
foreach (var context in config.Contexts) {
var table = context.Tables.FirstOrDefault(table => table.DisplayName.Equals(tableDisplayName, StringComparison.CurrentCultureIgnoreCase));
var table = context.Tables
.Where(t => !t.Ignored)
.FirstOrDefault(table => table.DisplayName.Equals(tableDisplayName, StringComparison.CurrentCultureIgnoreCase));
if (table is null) continue;
SeedTableData(table);
@@ -30,7 +32,8 @@ internal sealed class ContextExplorer(HopFrameConfig config, IServiceProvider pr
public TableConfig? GetTable(Type tableEntity) {
foreach (var context in config.Contexts) {
var table = context.Tables.FirstOrDefault(table => table.TableType == tableEntity);
var table = context.Tables
.FirstOrDefault(table => table.TableType == tableEntity);
if (table is null) continue;
SeedTableData(table);

View File

@@ -39,11 +39,11 @@
</div>
<div style="display: flex; gap: 5px; margin-bottom: 4px">
@if (!property.IsRequired) {
<FluentButton OnClick="async () => await SetPropertyValue(property, null, InputType.Relation)" Disabled="@(_currentlyEditing && !property.Editable)">
<FluentButton OnClick="@(async () => await SetPropertyValue(property, null, InputType.Relation))" Disabled="@(_currentlyEditing && !property.Editable)">
<FluentIcon Value="@(new Icons.Regular.Size20.Dismiss())" Color="Color.Neutral" />
</FluentButton>
}
<FluentButton OnClick="async () => await OpenRelationalPicker(property)" Disabled="@(_currentlyEditing && !property.Editable)">
<FluentButton OnClick="@(async () => await OpenRelationalPicker(property))" Disabled="@(_currentlyEditing && !property.Editable)">
<FluentIcon Value="@(new Icons.Regular.Size20.Open())" Color="Color.Neutral" />
</FluentButton>
</div>
@@ -131,7 +131,7 @@
ValueChanged="@(async v => await SetPropertyValue(property, v, InputType.Enum))" />
</div>
<div style="display: flex; gap: 5px">
<FluentButton OnClick="async () => await SetPropertyValue(property, null, InputType.Enum)" Disabled="@(_currentlyEditing && !property.Editable)">
<FluentButton OnClick="@(async () => await SetPropertyValue(property, null, InputType.Enum))" Disabled="@(_currentlyEditing && !property.Editable)">
<FluentIcon Value="@(new Icons.Regular.Size20.Dismiss())" Color="Color.Neutral" />
</FluentButton>
</div>

View File

@@ -9,6 +9,7 @@
DisplayActions="false"
DisplaySelection="true"
TableDisplayName="@Content.SourceTable.DisplayName"
TableType="@Content.SourceTable.TableType"
PerPage="15"
DialogData="Content"
SelectionMode="@(Content.AllowMultiple ? DataGridSelectMode.Multiple : DataGridSelectMode.Single)"/>

View File

@@ -24,7 +24,7 @@
@if (!DisplaySelection && _buttonToggles.ShowRefreshButton) {
<FluentButton
IconStart="@(new Icons.Regular.Size16.ArrowClockwise())"
OnClick="Reload"
OnClick="@(Reload)"
Loading="_loading"
Style="margin-left: 10px">
Refresh
@@ -34,7 +34,7 @@
@foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.TopLeft)) {
<FluentButton
IconStart="@(button.Icon?.GetInstance())"
OnClick="() => button.Handler.Invoke(null!, _config!)">
OnClick="@(() => button.Handler.Invoke(null!, _config!))">
@button.Title
</FluentButton>
}
@@ -44,32 +44,33 @@
style="position: relative; height: 32px"
class="hopframe-search">
@* ReSharper disable once CSharpWarnings::CS4014 *@
<FluentSearch
@ref="_searchBox"
@oninput="OnSearch"
@onchange="OnSearch"
@onfocusin="() => { SearchFocus(); UpdateSearchSuggestions(); }"
@onfocusout="SearchUnfocus"
@onfocusout="@(SearchUnfocus)"
Style="width: 500px"/>
@if (_isSearchActive && _searchSuggestions.Count > 0) {
<FluentListbox
TOption="string"
Items="_searchSuggestions"
SelectedOptionChanged="SearchSuggestionSelected"
@onfocusin="SearchFocus"
@onfocusout="SearchUnfocus"/>
SelectedOptionChanged="@(SearchSuggestionSelected)"
@onfocusin="@(SearchFocus)"
@onfocusout="@(SearchUnfocus)"/>
}
</div>
@if (_hasCreatePolicy && DisplayActions && _buttonToggles.ShowAddEntityButton) {
<FluentButton OnClick="async () => { await CreateOrEdit(null); }">Add Entity</FluentButton>
<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)) {
<FluentButton
IconStart="@(button.Icon?.GetInstance())"
OnClick="() => button.Handler.Invoke(null!, _config!)">
OnClick="@(() => button.Handler.Invoke(null!, _config!))">
@button.Title
</FluentButton>
}
@@ -84,7 +85,7 @@
TGridItem="object"
SelectMode="SelectionMode"
SelectFromEntireRow="true"
OnSelect="data => SelectItem(data.Item, data.Selected)"
OnSelect="@(data => SelectItem(data.Item, data.Selected))"
SelectAllDisabled="true"
Property="o => DialogData!.SelectedObjects.Contains(o)"
Style="min-width: max-content; height: 44px; display: grid; align-items: center" />
@@ -97,22 +98,22 @@
Sortable="@property.Sortable"/>
}
@if (DisplayActions && (_hasDeletePolicy || _hasUpdatePolicy)) {
@if (DisplayActions && (_hasDeletePolicy || _hasUpdatePolicy || _pluginButtons.Where(pb => pb.IsForTable(_config)).Any(pb => pb.Position == PluginButtonPosition.OnEntry))) {
<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!)">
<FluentButton OnClick="@(() => button.Handler.Invoke(context, _config!))">
<FluentIcon Value="@(button.Icon!.GetInstance())" />
</FluentButton>
}
@if (_hasUpdatePolicy && _buttonToggles.ShowEditButton) {
<FluentButton aria-label="Edit entry" OnClick="async () => { await CreateOrEdit(context); }">
<FluentButton aria-label="Edit entry" OnClick="@(async () => { await CreateOrEdit(context); })">
<FluentIcon Value="@(new Icons.Regular.Size16.Edit())"/>
</FluentButton>
}
@if (_hasDeletePolicy && _buttonToggles.ShowDeleteButton) {
<FluentButton aria-label="Delete entry" OnClick="async () => { await DeleteEntry(context); }">
<FluentButton aria-label="Delete entry" OnClick="@(async () => { await DeleteEntry(context); })">
<FluentIcon Value="@(new Icons.Regular.Size16.Delete())" Color="Color.Warning"/>
</FluentButton>
}
@@ -124,7 +125,7 @@
@if (_totalPages > 1) {
<div class="hopframe-paginator">
<FluentButton BackgroundColor="transparent" OnClick="async () => await ChangePage(_currentPage - 1)">
<FluentButton BackgroundColor="transparent" OnClick="@(async () => await ChangePage(_currentPage - 1))">
<FluentIcon Value="@(new Icons.Regular.Size20.ArrowPrevious())" Color="Color.Neutral" />
</FluentButton>
@@ -134,12 +135,12 @@
Items="Enumerable.Range(0, _totalPages)"
OptionValue="@(p => p.ToString())"
OptionText="@(p => (p + 1).ToString())"
ValueChanged="async s => await ChangePage(Convert.ToInt32(s))"
ValueChanged="@(async s => await ChangePage(Convert.ToInt32(s)))"
Width="max-content" SelectedOption="@_currentPage"/>
<span>of @_totalPages</span>
<FluentButton BackgroundColor="transparent" OnClick="async () => await ChangePage(_currentPage + 1)">
<FluentButton BackgroundColor="transparent" OnClick="@(async () => await ChangePage(_currentPage + 1))">
<FluentIcon Value="@(new Icons.Regular.Size20.ArrowNext())" Color="Color.Neutral" />
</FluentButton>
</div>
@@ -173,7 +174,7 @@
<FluentToastProvider MaxToastCount="10" />
<InputFile style="display: none" @ref="FileInputElement" OnChange="OnInputFiles"></InputFile>
<InputFile style="display: none" @ref="FileInputElement" OnChange="@(OnInputFiles)"></InputFile>
@inject IContextExplorer Explorer
@inject NavigationManager Navigator
@@ -187,7 +188,10 @@
@code {
[Parameter]
public required string TableDisplayName { get; set; }
public string TableDisplayName { get; set; } = null!;
[Parameter]
public Type? TableType { get; set; }
[Parameter]
public bool DisplaySelection { get; set; }
@@ -220,8 +224,6 @@
private bool _hasDeletePolicy;
private bool _hasCreatePolicy;
private bool _allSelected;
private readonly CancellationTokenSource _tokenSource = new();
private List<PluginButton> _pluginButtons = new();
private DefaultButtonToggles _buttonToggles = new();
@@ -230,6 +232,11 @@
protected override void OnInitialized() {
CurrentInstance = this;
if (TableType is not null) {
_config ??= Explorer.GetTable(TableType);
}
_config ??= Explorer.GetTable(TableDisplayName);
if (_config is null || (_config.Ignored && DialogData is null)) {
@@ -443,14 +450,6 @@
else DialogData!.SelectedObjects.Add(item);
}
private void SelectAll() {
var selected = CurrentlyDisplayedModels.All(DialogData!.SelectedObjects.Contains);
foreach (var displayedModel in CurrentlyDisplayedModels) {
SelectItem(displayedModel, !selected);
}
_allSelected = selected;
}
private async Task<string> DisplayProperty(PropertyConfig config, object entry) {
var display = await _manager!.DisplayProperty(entry, config);

View File

@@ -9,6 +9,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageId>HopFrame.Web</PackageId>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,4 +1,7 @@
namespace HopFrame.Web.Plugins.Annotations;
/// <summary>
/// Indicates, that the method is a handler for an event
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class EventHandlerAttribute : Attribute;

View File

@@ -2,17 +2,42 @@
namespace HopFrame.Web.Plugins.Events;
/// <summary>
/// Raised before an entry should be deleted
/// </summary>
public sealed class DeleteEntryEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
/// <summary>
/// The entry that is about to be deleted
/// </summary>
public required object Entity { get; init; }
}
/// <summary>
/// Raised before a new entry gets saved to the dataset
/// </summary>
public sealed class CreateEntryEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender);
/// <summary>
/// Raised before any changes are saved to the dataset
/// </summary>
public sealed class UpdateEntryEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
/// <summary>
/// The entry that is about to be updated
/// </summary>
public required object Entity { get; init; }
}
/// <summary>
/// Raised when an entity is selected or deselected in the relation picker dialog
/// </summary>
public sealed class SelectEntryEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
/// <summary>
/// The entry that is being selected
/// </summary>
public required object Entity { get; init; }
/// <summary>
/// Indicates whether the entry is selected (true) or deselected (false)
/// </summary>
public required bool Selected { get; set; }
}

View File

@@ -4,24 +4,47 @@ using HopFrame.Web.Components.Pages;
namespace HopFrame.Web.Plugins.Events;
/// <summary>
/// The base event with parameters for every event
/// </summary>
public abstract class HopFrameEventArgs(object internalSender) {
internal object InternalSender { get; } = internalSender;
/// <summary>
/// Indicates if the event got canceled by any event handler
/// </summary>
public bool IsCanceled { get; protected set; }
/// <summary>
/// Determines if the action that is about to be executed should be canceled
/// </summary>
public void SetCancelled(bool canceled) => IsCanceled = canceled;
}
/// <inheritdoc/>
public abstract class HopFrameEventArgs<TSender>(TSender sender) : HopFrameEventArgs(sender) where TSender : class {
/// <summary>
/// The element that raised the event
/// </summary>
public TSender Sender => (TSender)InternalSender;
}
public abstract class HopFrameTablePageEventArgs(HopFrameTablePage sender)
: HopFrameEventArgs<HopFrameTablePage>(sender) {
/// <summary>
/// The base event with parameters for every event raised by a <see cref="HopFrameTablePage"/>
/// </summary>
public abstract class HopFrameTablePageEventArgs(HopFrameTablePage sender) : HopFrameEventArgs<HopFrameTablePage>(sender) {
/// <summary>
/// The configuration of the table page that raised the event
/// </summary>
public required TableConfig Table { get; init; }
}
public abstract class HopFrameEditorEventArgs(HopFrameEditor sender)
: HopFrameEventArgs<HopFrameEditor>(sender) {
/// <summary>
/// The base event with parameters for every event raised by a <see cref="HopFrameEditor"/>
/// </summary>
public abstract class HopFrameEditorEventArgs(HopFrameEditor sender) : HopFrameEventArgs<HopFrameEditor>(sender) {
/// <summary>
/// The configuration of the parent table of the editor that raised the event
/// </summary>
public required TableConfig Table { get; init; }
}

View File

@@ -2,8 +2,22 @@
namespace HopFrame.Web.Plugins.Events;
/// <summary>
/// Raised when the user is about to change the page he is currently on
/// </summary>
public sealed class PageChangeEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
/// <summary>
/// The page he is currently on
/// </summary>
public required int CurrentPage { get; init; }
/// <summary>
/// The total number of pages his table can currently display
/// </summary>
public required int TotalPages { get; init; }
/// <summary>
/// The new page he tries to access
/// </summary>
public required int NewPage { get; set; }
}

View File

@@ -2,6 +2,7 @@
namespace HopFrame.Web.Plugins.Events;
public sealed class ReloadEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
}
/// <summary>
/// Raised before the table is about to reload its data
/// </summary>
public sealed class ReloadEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender);

View File

@@ -3,9 +3,21 @@ using HopFrame.Web.Components.Pages;
namespace HopFrame.Web.Plugins.Events;
/// <summary>
/// Raised before the search results are loaded
/// </summary>
/// <param name="sender"></param>
public sealed class SearchEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
/// <summary>
/// The search term the user entered
/// </summary>
public required string SearchTerm { get; set; }
/// <summary>
/// The page the user is currently on
/// </summary>
public required int CurrentPage { get; init; }
internal IEnumerable<object>? SearchResult { get; set; }
internal int TotalPages { get; set; }

View File

@@ -4,10 +4,28 @@ using Microsoft.FluentUI.AspNetCore.Components;
namespace HopFrame.Web.Plugins.Events;
/// <summary>
/// Raised when a table is initialized
/// </summary>
/// <param name="sender"></param>
public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
/// <summary>
/// List of all buttons added by the plugins
/// </summary>
public List<PluginButton> PluginButtons { get; } = new();
/// <summary>
/// Toggles for the native buttons on the page
/// </summary>
public DefaultButtonToggles DefaultButtons { get; set; } = new();
/// <summary>
/// Adds a custom button to the top bar of the page
/// </summary>
/// <param name="title">The text displayed on the button</param>
/// <param name="callback">The function that is invoked when the button is pressed</param>
/// <param name="pushRight">Determines if the button should be displayed on the right</param>
/// <param name="icon">Optional: The icon displayed next to the title</param>
public void AddPageButton(string title, Func<Task> callback, bool pushRight = false, IconInfo? icon = null) {
PluginButtons.Add(new() {
Title = title,
@@ -17,6 +35,7 @@ public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePage
});
}
/// <inheritdoc cref="AddPageButton(string,System.Func{System.Threading.Tasks.Task},bool,Microsoft.FluentUI.AspNetCore.Components.IconInfo?)"/>
public void AddPageButton(string title, Action callback, bool pushRight = false, IconInfo? icon = null) {
AddPageButton(title, () => {
callback.Invoke();
@@ -24,6 +43,11 @@ public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePage
}, pushRight, icon);
}
/// <summary>
/// Adds a custom button to the Actions column next to every entry
/// </summary>
/// <param name="icon">The icon displayed in the button</param>
/// <param name="callback">The function that is invoked when the button is pressed</param>
public void AddEntityButton(IconInfo icon, Func<object, TableConfig, Task> callback) {
PluginButtons.Add(new() {
Icon = icon,
@@ -32,6 +56,7 @@ public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePage
});
}
/// <inheritdoc cref="AddEntityButton(IconInfo,System.Func{object,TableConfig,System.Threading.Tasks.Task})"/>
public void AddEntityButton(IconInfo icon, Action<object, TableConfig> callback) {
AddEntityButton(icon, (obj, cfg) => {
callback.Invoke(obj, cfg);
@@ -39,6 +64,8 @@ public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePage
});
}
/// <typeparam name="TEntity">The entity type of the table that should display this button</typeparam>
/// <inheritdoc cref="AddEntityButton(IconInfo,System.Func{object,TableConfig,System.Threading.Tasks.Task})"/>
public void AddEntityButton<TEntity>(IconInfo icon, Func<TEntity, TableConfig, Task> callback) {
PluginButtons.Add(new() {
Icon = icon,
@@ -48,6 +75,8 @@ public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePage
});
}
/// <typeparam name="TEntity">The entity type of the table that should display this button</typeparam>
/// <inheritdoc cref="AddEntityButton(IconInfo,System.Func{object,TableConfig,System.Threading.Tasks.Task})"/>
public void AddEntityButton<TEntity>(IconInfo icon, Action<TEntity, TableConfig> callback) {
AddEntityButton<TEntity>(icon, (obj, cfg) => {
callback.Invoke(obj, cfg);
@@ -55,6 +84,8 @@ public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePage
});
}
/// <typeparam name="TEntity">The entity type of the table that should display this button</typeparam>
/// <inheritdoc cref="AddPageButton(string,System.Func{System.Threading.Tasks.Task},bool,Microsoft.FluentUI.AspNetCore.Components.IconInfo?)"/>
public void AddPageButton<TEntity>(string title, Func<Task> callback, bool pushRight = false, IconInfo? icon = null) {
PluginButtons.Add(new() {
Title = title,
@@ -65,6 +96,8 @@ public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePage
});
}
/// <typeparam name="TEntity">The entity type of the table that should display this button</typeparam>
/// <inheritdoc cref="AddPageButton(string,System.Func{System.Threading.Tasks.Task},bool,Microsoft.FluentUI.AspNetCore.Components.IconInfo?)"/>
public void AddPageButton<TEntity>(string title, Action callback, bool pushRight = false, IconInfo? icon = null) {
AddPageButton<TEntity>(title, () => {
callback.Invoke();
@@ -73,11 +106,33 @@ public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePage
}
}
/// <summary>
/// A wrapper object containing all information about a custom button
/// </summary>
public struct PluginButton {
/// <summary>
/// The position of the button
/// </summary>
public PluginButtonPosition Position { get; set; }
/// <summary>
/// The function that is invoked when the button is pressed
/// </summary>
public Func<object, TableConfig, Task> Handler { get; set; }
/// <summary>
/// The text on the button if supported
/// </summary>
public string? Title { get; set; }
/// <summary>
/// The icon displayed on the button
/// </summary>
public IconInfo? Icon { get; set; }
/// <summary>
/// The entity type of the table that should display this button
/// </summary>
public Type? TableFilter { get; set; }
internal bool IsForTable(TableConfig? config) {
@@ -87,12 +142,18 @@ public struct PluginButton {
}
}
/// <summary>
/// All available positions for a custom button
/// </summary>
public enum PluginButtonPosition {
TopLeft = 0,
TopRight = 1,
OnEntry = 2
}
/// <summary>
/// Toggles for the native buttons on the page
/// </summary>
public struct DefaultButtonToggles() {
public bool ShowRefreshButton { get; set; } = true;
public bool ShowAddEntityButton { get; set; } = true;

View File

@@ -3,7 +3,17 @@ using HopFrame.Web.Components.Dialogs;
namespace HopFrame.Web.Plugins.Events;
/// <summary>
/// Raised when a property in the editor is validated
/// </summary>
public sealed class ValidationEvent(HopFrameEditor sender) : HopFrameEditorEventArgs(sender) {
/// <summary>
/// All errors found by the validators. Can be modified to display more (or less) errors
/// </summary>
public required IList<string> Errors { get; init; }
/// <summary>
/// The property that is validated
/// </summary>
public required PropertyConfig Property { get; init; }
}

View File

@@ -59,7 +59,7 @@ public static class ServiceCollectionExtensions {
/// Adds the HopFrame admin ui endpoints
/// </summary>
/// <seealso cref="AddHopFramePages"/>
[Obsolete($"Use '{nameof(AddHopFramePages)}' instead")]
[Obsolete($"Use {nameof(AddHopFramePages)} instead")]
public static RazorComponentsEndpointConventionBuilder MapHopFramePages(this RazorComponentsEndpointConventionBuilder builder) {
return AddHopFramePages(builder);
}
@@ -74,6 +74,9 @@ public static class ServiceCollectionExtensions {
return builder;
}
/// <summary>
/// Adds the HopFrame admin ui endpoints
/// </summary>
public static WebApplication MapHopFrame(this WebApplication app) {
app.UseAntiforgery();
app.MapStaticAssets();

View File

@@ -2,10 +2,26 @@
namespace HopFrame.Web.Services;
/// <summary>
/// Accessor for the advanced search suggestion feature
/// </summary>
public interface ISearchSuggestionProvider {
/// <summary>
/// Generates a list of search suggestions based on the current search term
/// </summary>
/// <param name="table">The current table for context</param>
/// <param name="searchText">The partial input by the user</param>
/// <returns></returns>
public IEnumerable<string> GenerateSearchSuggestions(TableConfig table, string searchText);
/// <summary>
/// Generates the new search term by appending the generated text of the selected suggestion
/// </summary>
/// <param name="table">The current table for context</param>
/// <param name="searchText">The partial input by the user</param>
/// <param name="selectedSuggestion">The suggestion that was selected</param>
/// <returns></returns>
public string CompleteSearchSuggestion(TableConfig table, string searchText, string selectedSuggestion);
}