Refactor Users page: update Autocomplete selection mode and fix user service methods to use OldItem for adding and updating users
This commit is contained in:
@@ -92,9 +92,9 @@
|
|||||||
Data="@UserGroups"
|
Data="@UserGroups"
|
||||||
TextField="@(( item ) => item.ToString())"
|
TextField="@(( item ) => item.ToString())"
|
||||||
ValueField="@(( item ) => item)"
|
ValueField="@(( item ) => item)"
|
||||||
Multiple="true"
|
SelectionMode="AutocompleteSelectionMode.Multiple"
|
||||||
SelectedValues="@((List<UserGroup>) context.CellValue)"
|
SelectedValues="@((List<UserGroup>) context.CellValue)"
|
||||||
SelectedValuesChanged="@(v => context.CellValue = v)"
|
SelectedValuesChanged="@(v => { context.CellValue = v.ToList(); })"
|
||||||
@bind-SelectedTexts="SelectedCompanyTexts">
|
@bind-SelectedTexts="SelectedCompanyTexts">
|
||||||
</Autocomplete>
|
</Autocomplete>
|
||||||
<small>Verfügbar: @string.Join(", ", Enum.GetValues<UserGroup>())</small>
|
<small>Verfügbar: @string.Join(", ", Enum.GetValues<UserGroup>())</small>
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
/// <param name="arg">The arg</param>
|
/// <param name="arg">The arg</param>
|
||||||
private async Task RowInserted(SavedRowItem<User, Dictionary<string, object>> arg)
|
private async Task RowInserted(SavedRowItem<User, Dictionary<string, object>> arg)
|
||||||
{
|
{
|
||||||
var addUserR = await UserService.AddUserAsync(arg.Item);
|
var addUserR = await UserService.AddUserAsync(arg.OldItem);
|
||||||
if (!addUserR.Success)
|
if (!addUserR.Success)
|
||||||
await Notification.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!;
|
await Notification.Error($"Fehler beim Anlegen: {addUserR.ErrorMessage}")!;
|
||||||
else
|
else
|
||||||
@@ -151,9 +151,9 @@ namespace FoodsharingSiegen.Server.Pages
|
|||||||
/// <param name="arg">The arg</param>
|
/// <param name="arg">The arg</param>
|
||||||
private async Task RowUpdated(SavedRowItem<User, Dictionary<string, object>> arg)
|
private async Task RowUpdated(SavedRowItem<User, Dictionary<string, object>> arg)
|
||||||
{
|
{
|
||||||
if (arg.Item?.Id == null || arg.Item.Id.Equals(Guid.Empty) || arg.Values?.Any() != true) return;
|
if (arg.OldItem?.Id == null || arg.OldItem.Id.Equals(Guid.Empty) || arg.Values?.Any() != true) return;
|
||||||
|
|
||||||
var updateR = await UserService.Update(arg.Item);
|
var updateR = await UserService.Update(arg.OldItem);
|
||||||
if (!updateR.Success)
|
if (!updateR.Success)
|
||||||
await Notification.Error($"Fehler beim Speichern: {updateR.ErrorMessage}")!;
|
await Notification.Error($"Fehler beim Speichern: {updateR.ErrorMessage}")!;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,5 +24,5 @@
|
|||||||
</NotAuthorized>
|
</NotAuthorized>
|
||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
|
|
||||||
<NotificationAlert/>
|
<NotificationProvider/>
|
||||||
<MessageAlert/>
|
<MessageProvider/>
|
||||||
Reference in New Issue
Block a user