| | | 1 | | <div class="tool-ask-options"> |
| | | 2 | | <div class="tool-ask-question rz-mb-2"> |
| | 0 | 3 | | <strong>@Question</strong> |
| | | 4 | | </div> |
| | | 5 | | |
| | 0 | 6 | | @if (Options.Count > 0) |
| | | 7 | | { |
| | | 8 | | <div class="tool-ask-buttons rz-d-flex rz-flex-wrap rz-gap-2"> |
| | 0 | 9 | | @foreach (var option in Options) |
| | | 10 | | { |
| | | 11 | | <RadzenButton |
| | | 12 | | Text="@option" |
| | | 13 | | ButtonStyle="ButtonStyle.Base" |
| | | 14 | | Size="ButtonSize.Small" |
| | 0 | 15 | | Click="@(() => OnOptionSelected(option))" /> |
| | | 16 | | } |
| | | 17 | | </div> |
| | | 18 | | } |
| | | 19 | | |
| | | 20 | | <div class="tool-ask-custom rz-mt-2 rz-d-flex rz-gap-2"> |
| | | 21 | | <RadzenTextBox @bind-Value="_customOption" Placeholder="@SharedResource.YourOption" Style="flex: 1;" /> |
| | | 22 | | <RadzenButton |
| | | 23 | | Text="@SharedResource.SendMessage" |
| | | 24 | | ButtonStyle="ButtonStyle.Primary" |
| | | 25 | | Size="ButtonSize.Small" |
| | | 26 | | Disabled="@string.IsNullOrWhiteSpace(_customOption)" |
| | 0 | 27 | | Click="@(() => OnOptionSelected(_customOption))" /> |
| | | 28 | | </div> |
| | | 29 | | </div> |
| | | 30 | | |
| | | 31 | | @code { |
| | 0 | 32 | | [Parameter] public List<string> Lines { get; set; } = []; |
| | 0 | 33 | | [Parameter] public EventCallback<string> OnOptionSelectedCallback { get; set; } |
| | | 34 | | |
| | 0 | 35 | | private string _customOption = string.Empty; |
| | | 36 | | |
| | 0 | 37 | | private string Question => Lines.Count > 0 ? Lines[0] : string.Empty; |
| | | 38 | | |
| | 0 | 39 | | private List<string> Options => Lines.Count > 1 ? Lines.Skip(1).ToList() : []; |
| | | 40 | | |
| | | 41 | | private async Task OnOptionSelected(string selectedOption) |
| | | 42 | | { |
| | 0 | 43 | | if (string.IsNullOrWhiteSpace(selectedOption)) |
| | 0 | 44 | | return; |
| | | 45 | | |
| | 0 | 46 | | if (OnOptionSelectedCallback.HasDelegate) |
| | | 47 | | { |
| | 0 | 48 | | await OnOptionSelectedCallback.InvokeAsync(selectedOption); |
| | | 49 | | } |
| | 0 | 50 | | } |
| | | 51 | | } |