|
76 | 76 | <RadzenDatePicker @bind-Value="quotationDate" Name="QuotationDate" Style="width: 200px;" DateFormat="d MMMM yyyy" ShowTime="false" /> |
77 | 77 |
|
78 | 78 | <RadzenLabel Text="@Localizer["customer"]" /> |
79 | | - <RadzenDropDownDataGrid AllowClear="true" |
80 | | - IsLoading="@isLoadingCustomers" |
81 | | - @bind-Value="@selectedCustomerId" |
82 | | - LoadData="@LoadCustomers" |
83 | | - AllowFiltering="true" |
84 | | - Style="width: 350px;" |
85 | | - Data="@_filteredCustomers" |
86 | | - TextProperty="@nameof(CustomerResponse.Name)" |
87 | | - ValueProperty="@nameof(CustomerResponse.Id)" |
88 | | - Placeholder="@Localizer["select_customer"]"> |
89 | | - <Columns> |
90 | | - <RadzenDropDownDataGridColumn Property="@nameof(CustomerResponse.Id)" Title="ID" Width="80px" /> |
91 | | - <RadzenDropDownDataGridColumn Property="@nameof(CustomerResponse.Name)" Title="@Localizer["name"]" Width="220px" /> |
92 | | - </Columns> |
93 | | - </RadzenDropDownDataGrid> |
| 79 | + <RadzenStack Orientation="Radzen.Orientation.Horizontal" Gap="0.5rem" AlignItems="Radzen.AlignItems.Center"> |
| 80 | + <RadzenDropDownDataGrid AllowClear="true" |
| 81 | + IsLoading="@isLoadingCustomers" |
| 82 | + @bind-Value="@selectedCustomerId" |
| 83 | + LoadData="@LoadCustomers" |
| 84 | + AllowFiltering="true" |
| 85 | + Style="width: 350px;" |
| 86 | + Data="@_filteredCustomers" |
| 87 | + TextProperty="@nameof(CustomerResponse.Name)" |
| 88 | + ValueProperty="@nameof(CustomerResponse.Id)" |
| 89 | + Placeholder="@Localizer["select_customer"]"> |
| 90 | + <Columns> |
| 91 | + <RadzenDropDownDataGridColumn Property="@nameof(CustomerResponse.Id)" Title="ID" Width="80px" /> |
| 92 | + <RadzenDropDownDataGridColumn Property="@nameof(CustomerResponse.Name)" Title="@Localizer["name"]" Width="220px" /> |
| 93 | + </Columns> |
| 94 | + </RadzenDropDownDataGrid> |
| 95 | + <RadzenButton Icon="add" |
| 96 | + ButtonStyle="ButtonStyle.Success" |
| 97 | + Variant="Variant.Flat" |
| 98 | + Size="ButtonSize.Medium" |
| 99 | + Click="@CreateNewCustomer" |
| 100 | + Title="@Localizer["AddClient"]" |
| 101 | + AriaLabel="@Localizer["AddClient"]" /> |
| 102 | + </RadzenStack> |
94 | 103 |
|
95 | 104 | @if (!string.IsNullOrEmpty(quotationNumber)) |
96 | 105 | { |
@@ -564,6 +573,38 @@ else |
564 | 573 | await InvokeAsync(StateHasChanged); |
565 | 574 | } |
566 | 575 |
|
| 576 | + async Task CreateNewCustomer() |
| 577 | + { |
| 578 | + var result = await DialogService.OpenAsync<AddOrUpdateCustomerDialog>( |
| 579 | + Localizer["AddClient"], |
| 580 | + new Dictionary<string, object>(), |
| 581 | + new DialogOptions |
| 582 | + { |
| 583 | + Width = "600px", |
| 584 | + Resizable = true, |
| 585 | + Draggable = true |
| 586 | + }); |
| 587 | + |
| 588 | + if (result is int newCustomerId) |
| 589 | + { |
| 590 | + await LoadCustomers(new LoadDataArgs()); |
| 591 | + selectedCustomerId = newCustomerId; |
| 592 | + |
| 593 | + var customer = await customersApiClient.GetCustomerByIdAsync(newCustomerId, _cancellationTokenSource.Token); |
| 594 | + if (customer != null && !_filteredCustomers.Any(c => c.Id == customer.Id)) |
| 595 | + { |
| 596 | + _filteredCustomers.Add(customer); |
| 597 | + } |
| 598 | + |
| 599 | + NotificationService.Notify(new NotificationMessage |
| 600 | + { |
| 601 | + Severity = NotificationSeverity.Success, |
| 602 | + Summary = Localizer["success"], |
| 603 | + Detail = $"{Localizer["customer"]} {Localizer["created_with_success"]}" |
| 604 | + }); |
| 605 | + } |
| 606 | + } |
| 607 | + |
567 | 608 | async Task OnProductSelectedHandler(QuotationDetailResponse order) |
568 | 609 | { |
569 | 610 | UpdateTotals(); |
|
0 commit comments