22@using Cfo .Cats .Application .Features .Assessments .Commands
33@using Cfo .Cats .Application .Features .Locations .DTOs
44@using Cfo .Cats .Domain .Common .Enums
5+ @using Cfo .Cats .Server .UI .Components .Locations
56@using Cfo .Cats .Server .UI .Pages .Activities .Components
67
78@inherits CatsComponentBase
1617 <MudForm @ref =" form" Model =" Model" Validation =" @(Validator.ValidateValue(Model))" >
1718 <MudGrid >
1819 <MudItem xs =" 12" >
19- <MudSelect @bind-Value =" Model.Location"
20- Label =" @Model.GetMemberDescription(x => x.Location)"
21- For =" () => Model.Location"
22- Clearable =" true"
23- ToStringFunc =" location => location?.Name" >
24- @foreach ( var location in locations )
25- {
26- <MudSelectItem Value =" location" >@location.Name </MudSelectItem >
27- }
28- </MudSelect >
20+ <LocationSelectComponent
21+ TenantId =" @(CurrentUser.TenantId!)"
22+ Label =" @Model.GetMemberDescription(x => x.Location)"
23+ @bind-Value =" Model.Location"
24+ For =" () => Model.Location" />
2925 </MudItem >
3026 </MudGrid >
3127 </MudForm >
3733 </DialogActions >
3834</MudDialog >
3935
40- @code {
41- MudForm form = new ();
42- bool saving ;
43-
44- [CascadingParameter ]
45- public required IMudDialogInstance Dialog { get ; set ; }
46-
47- [Parameter , EditorRequired ]
48- public required BeginAssessment .Command Model { get ; set ; }
49-
50- IEnumerable <LocationDto > locations = [];
51-
52- protected override void OnInitialized ()
53- {
54- locations = Locations
55- .GetVisibleLocations (CurrentUser .TenantId ! )
56- .ToList ();
57-
58- base .OnInitialized ();
59- }
60-
61- async Task Submit ()
62- {
63- try
64- {
65- saving = true ;
66-
67- await form .ValidateAsync ();
68-
69- if (form .IsValid is false )
70- {
71- return ;
72- }
73-
74- var result = await GetNewMediator ().Send (Model );
75-
76- if (result .Succeeded )
77- {
78- Dialog .Close (DialogResult .Ok (result .Data ));
79- Snackbar .Add (ConstantString .SaveSuccess , Severity .Info );
80- }
81- else
82- {
83- Snackbar .Add (result .ErrorMessage , Severity .Error );
84- }
85-
86- }
87- finally
88- {
89- saving = false ;
90- }
91- }
92-
93- }
0 commit comments