mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-13 15:53:48 +00:00
Refactor components (#80)
This commit is contained in:
1 parent
a18cb22263
commit
1d1af91f3e
137 files changed
+220
-220
No files matched your search
@@ -0,0 +1,40 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace AIStudio.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration component for any boolean option.
|
||||
/// </summary>
|
||||
public partial class ConfigurationOption : ConfigurationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Text to display when the option is true.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string LabelOn { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Text to display when the option is false.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string LabelOff { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The boolean state of the option.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Func<bool> State { get; set; } = () => false;
|
||||
|
||||
/// <summary>
|
||||
/// An action which is called when the option is changed.
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public Action<bool> StateUpdate { get; set; } = _ => { };
|
||||
|
||||
private async Task OptionChanged(bool updatedState)
|
||||
{
|
||||
this.StateUpdate(updatedState);
|
||||
await this.SettingsManager.StoreSettings();
|
||||
await this.InformAboutChange();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user