mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-03-29 21:51:37 +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.Components
|
||||||
@using AIStudio.Settings
|
@using AIStudio.Settings
|
||||||
@using AIStudio.Tools.PluginSystem.Assistants.DataModel
|
@using AIStudio.Tools.PluginSystem.Assistants.DataModel
|
||||||
@ -6,6 +6,18 @@
|
|||||||
|
|
||||||
@foreach (var component in this.RootComponent!.Children)
|
@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)
|
@switch (component.Type)
|
||||||
{
|
{
|
||||||
case AssistantComponentType.TEXT_AREA:
|
case AssistantComponentType.TEXT_AREA:
|
||||||
@ -31,8 +43,7 @@
|
|||||||
AutoGrow="@true"
|
AutoGrow="@true"
|
||||||
MaxLines="12"
|
MaxLines="12"
|
||||||
Class='@MergeClass(textArea.Class, "mb-3")'
|
Class='@MergeClass(textArea.Class, "mb-3")'
|
||||||
Style="@this.GetOptionalStyle(textArea.Style)"
|
Style="@this.GetOptionalStyle(textArea.Style)" />
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AssistantComponentType.IMAGE:
|
case AssistantComponentType.IMAGE:
|
||||||
@ -72,7 +83,6 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AssistantComponentType.DROPDOWN:
|
case AssistantComponentType.DROPDOWN:
|
||||||
if (component is AssistantDropdown assistantDropdown)
|
if (component is AssistantDropdown assistantDropdown)
|
||||||
{
|
{
|
||||||
@ -103,7 +113,8 @@
|
|||||||
Class='@MergeClass(button.Class, "mb-3")'
|
Class='@MergeClass(button.Class, "mb-3")'
|
||||||
Style="@this.GetOptionalStyle(button.Style)">
|
Style="@this.GetOptionalStyle(button.Style)">
|
||||||
@button.Text
|
@button.Text
|
||||||
</MudButton></div>
|
</MudButton>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AssistantComponentType.BUTTON_GROUP:
|
case AssistantComponentType.BUTTON_GROUP:
|
||||||
@ -118,26 +129,7 @@
|
|||||||
DropShadow="@buttonGroup.DropShadow"
|
DropShadow="@buttonGroup.DropShadow"
|
||||||
Class='@MergeClass(buttonGroup.Class, "mb-3")'
|
Class='@MergeClass(buttonGroup.Class, "mb-3")'
|
||||||
Style="@this.GetOptionalStyle(buttonGroup.Style)">
|
Style="@this.GetOptionalStyle(buttonGroup.Style)">
|
||||||
@foreach (var child in buttonGroup.Children)
|
@this.RenderChildren(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>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</MudButtonGroup>
|
</MudButtonGroup>
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -251,4 +243,5 @@
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
</text>;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -571,5 +571,4 @@ public partial class AssistantDynamic : AssistantBaseCore<SettingsDialogDynamic>
|
|||||||
var time = this.AddUserRequest(await this.CollectUserPromptAsync());
|
var time = this.AddUserRequest(await this.CollectUserPromptAsync());
|
||||||
await this.AddAIResponseAsync(time);
|
await this.AddAIResponseAsync(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user