mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-29 15:51:39 +00:00
encapsulated render logic into a function to be able to call it recursively
This commit is contained in:
parent
dbdcdef83c
commit
4f836e2dfb
@ -1,4 +1,4 @@
|
||||
@attribute [Route(Routes.ASSISTANT_DYNAMIC)]
|
||||
@attribute [Route(Routes.ASSISTANT_DYNAMIC)]
|
||||
@using AIStudio.Components
|
||||
@using AIStudio.Settings
|
||||
@using AIStudio.Tools.PluginSystem.Assistants.DataModel
|
||||
@ -6,6 +6,18 @@
|
||||
|
||||
@foreach (var component in this.RootComponent!.Children)
|
||||
{
|
||||
@this.RenderComponent(component)
|
||||
}
|
||||
|
||||
@code {
|
||||
private RenderFragment RenderChildren(IEnumerable<IAssistantComponent> children) => @<text>
|
||||
@foreach (var child in children)
|
||||
{
|
||||
@this.RenderComponent(child)
|
||||
}
|
||||
</text>;
|
||||
|
||||
private RenderFragment RenderComponent(IAssistantComponent component) => @<text>
|
||||
@switch (component.Type)
|
||||
{
|
||||
case AssistantComponentType.TEXT_AREA:
|
||||
@ -31,8 +43,7 @@
|
||||
AutoGrow="@true"
|
||||
MaxLines="12"
|
||||
Class='@MergeClass(textArea.Class, "mb-3")'
|
||||
Style="@this.GetOptionalStyle(textArea.Style)"
|
||||
/>
|
||||
Style="@this.GetOptionalStyle(textArea.Style)" />
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.IMAGE:
|
||||
@ -72,7 +83,6 @@
|
||||
</div>
|
||||
}
|
||||
break;
|
||||
|
||||
case AssistantComponentType.DROPDOWN:
|
||||
if (component is AssistantDropdown assistantDropdown)
|
||||
{
|
||||
@ -103,7 +113,8 @@
|
||||
Class='@MergeClass(button.Class, "mb-3")'
|
||||
Style="@this.GetOptionalStyle(button.Style)">
|
||||
@button.Text
|
||||
</MudButton></div>
|
||||
</MudButton>
|
||||
</div>
|
||||
}
|
||||
break;
|
||||
case AssistantComponentType.BUTTON_GROUP:
|
||||
@ -118,26 +129,7 @@
|
||||
DropShadow="@buttonGroup.DropShadow"
|
||||
Class='@MergeClass(buttonGroup.Class, "mb-3")'
|
||||
Style="@this.GetOptionalStyle(buttonGroup.Style)">
|
||||
@foreach (var child in buttonGroup.Children)
|
||||
{
|
||||
if (child is AssistantButton childButton)
|
||||
{
|
||||
<MudButton Variant="@childButton.GetButtonVariant()"
|
||||
Color="@AssistantComponentPropHelper.GetColor(childButton.Color, Color.Default)"
|
||||
OnClick="@(() => this.ExecuteButtonActionAsync(childButton))"
|
||||
Size="@AssistantComponentPropHelper.GetComponentSize(childButton.Size, Size.Medium)"
|
||||
FullWidth="@childButton.IsFullWidth"
|
||||
StartIcon="@AssistantComponentPropHelper.GetIconSvg(childButton.StartIcon)"
|
||||
EndIcon="@AssistantComponentPropHelper.GetIconSvg(childButton.EndIcon)"
|
||||
IconColor="@AssistantComponentPropHelper.GetColor(childButton.IconColor, Color.Inherit)"
|
||||
IconSize="@AssistantComponentPropHelper.GetComponentSize(childButton.IconSize, Size.Medium)"
|
||||
Disabled="@this.IsButtonActionRunning(childButton.Name)"
|
||||
Class="@childButton.Class"
|
||||
Style="@this.GetOptionalStyle(childButton.Style)">
|
||||
@childButton.Text
|
||||
</MudButton>
|
||||
}
|
||||
}
|
||||
@this.RenderChildren(buttonGroup.Children)
|
||||
</MudButtonGroup>
|
||||
}
|
||||
break;
|
||||
@ -251,4 +243,5 @@
|
||||
}
|
||||
break;
|
||||
}
|
||||
</text>;
|
||||
}
|
||||
|
||||
@ -571,5 +571,4 @@ public partial class AssistantDynamic : AssistantBaseCore<SettingsDialogDynamic>
|
||||
var time = this.AddUserRequest(await this.CollectUserPromptAsync());
|
||||
await this.AddAIResponseAsync(time);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user