Skip to content

Commit 37594e3

Browse files
committed
remove unused fields and add a refresh. Need to check if the API actually changes the org data when modified though.
1 parent 1cdae79 commit 37594e3

1 file changed

Lines changed: 41 additions & 51 deletions

File tree

RegistrationWebApp/Components/Pages/Admin.razor

Lines changed: 41 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,7 @@
206206
<thead class="table-success">
207207
<tr>
208208
<th>Organisation Name</th>
209-
<th>Contact Name</th>
210-
<th>Contact Email</th>
211-
<th>Contact Phone</th>
212-
<th>Contact Address</th>
209+
<th>Emails</th>
213210
<th>Licence Pathway</th>
214211
<th>Annual Turnover</th>
215212
<th>Application Date</th>
@@ -222,10 +219,7 @@
222219
{
223220
<tr>
224221
<td>@organisation.Name</td>
225-
<td>@organisation.ContactName</td>
226-
<td>@organisation.ContactEmail</td>
227-
<td>@organisation.ContactPhone</td>
228-
<td>@organisation.ContactAddress</td>
222+
<td>@string.Join(",", organisation.Emails )</td>
229223
<td>@organisation.LicencePathway.GetDescription()</td>
230224
<td>@organisation.AnnualTurnover.GetDescription()</td>
231225
<td>@organisation.DateCreated.ToShortDateString()</td>
@@ -250,27 +244,28 @@
250244
<div class="member-org-panel h-100">
251245
<h3>Add New Member Organisation</h3>
252246
<EditForm Model="MemberOrganisation" OnValidSubmit="HandleNewMemberOrganisationSubmit">
253-
<DataAnnotationsValidator />
254-
<ValidationSummary />
255247
<label for="organisationName" class="form-label">Organisation Name</label>
256248
<InputText id="organisationName" class="form-control" @bind-Value="MemberOrganisation.Name"
257249
placeholder="Enter organisation name e.g. CSIRO" />
258-
<InputText id="contactName" class="form-control mt-2" @bind-Value="MemberOrganisation.ContactName"
259-
placeholder="Enter contact name e.g. John Doe" />
260-
<InputText id="contactEmail" class="form-control mt-2" @bind-Value="MemberOrganisation.ContactEmail"
261-
placeholder="Enter contact email e.g. john.doe@example.com" />
262-
<InputText id="contactPhone" class="form-control mt-2" @bind-Value="MemberOrganisation.ContactPhone"
263-
placeholder="Enter contact phone e.g. +61 123 456 789" />
264-
<InputText id="contactAddress" class="form-control mt-2" @bind-Value="MemberOrganisation.ContactAddress"
265-
placeholder="Enter contact address e.g. 123 Main St, City, Country" />
266250
<InputSelect id="licencePathway" class="form-select mt-2" @bind-Value="MemberOrganisation.LicencePathway">
267-
<option value="@LicencePathway.APSIMInitiativeMember" selected>@LicencePathway.APSIMInitiativeMember.GetDescription()</option>
251+
@foreach (var licencePathway in Enum.GetValues<LicencePathway>())
252+
{
253+
<option value="@licencePathway">@licencePathway.GetDescription()</option>
254+
}
268255
</InputSelect>
269256
<InputSelect id="annualTurnover" class="form-select mt-2" @bind-Value="MemberOrganisation.AnnualTurnover">
270257
<option value="@AnnualTurnover.BelowTwoMillion" selected>@AnnualTurnover.BelowTwoMillion.GetDescription()</option>
258+
@foreach (var annualTurnover in Enum.GetValues<AnnualTurnover>())
259+
{
260+
<option value="@annualTurnover">@annualTurnover.GetDescription()</option>
261+
}
271262
</InputSelect>
272263
<InputSelect id="licenceStatus" class="form-select mt-2" @bind-Value="MemberOrganisation.LicenceStatus">
273264
<option value="@OrganisationLicenceStatus.Active" selected>@OrganisationLicenceStatus.Active.GetDescription()</option>
265+
@foreach (var licenceStatus in Enum.GetValues<OrganisationLicenceStatus>())
266+
{
267+
<option value="@licenceStatus">@licenceStatus.GetDescription()</option>
268+
}
274269
</InputSelect>
275270
<button type="submit" class="btn btn-success rounded-pill pill-button mt-4">Add Member Organisation</button>
276271
</EditForm>
@@ -325,21 +320,9 @@
325320
@if (SpecialOrganisation is not null)
326321
{
327322
<EditForm Model="SpecialOrganisation" OnValidSubmit="HandleSpecialOrganisationSubmit" class="mt-4">
328-
<DataAnnotationsValidator />
329-
<ValidationSummary />
330-
331323
<label for="specialOrganisationName" class="form-label">Organisation Name</label>
332324
<InputText id="specialOrganisationName" class="form-control" @bind-Value="SpecialOrganisation.Name" placeholder="Organisation name" />
333325

334-
<label for="specialContactName" class="form-label mt-2">Contact Name</label>
335-
<InputText id="specialContactName" class="form-control" @bind-Value="SpecialOrganisation.ContactName" placeholder="Contact name" />
336-
<label for="specialContactEmail" class="form-label mt-2">Contact Email</label>
337-
<InputText id="specialContactEmail" class="form-control" @bind-Value="SpecialOrganisation.ContactEmail" placeholder="Contact email" />
338-
<label for="specialContactPhone" class="form-label mt-2">Contact Phone</label>
339-
<InputText id="specialContactPhone" class="form-control" @bind-Value="SpecialOrganisation.ContactPhone" placeholder="Contact phone" />
340-
<label for="specialContactAddress" class="form-label mt-2">Contact Address</label>
341-
<InputText id="specialContactAddress" class="form-control" @bind-Value="SpecialOrganisation.ContactAddress" placeholder="Contact address" />
342-
343326
<label for="specialOrganisationEmails" class="form-label mt-3">Organisation Emails/Domains</label>
344327
<InputTextArea id="specialOrganisationEmails" class="form-control" rows="3" @bind-Value="specialOrganisationEmailsText" />
345328
<div class="form-text">Use comma, semicolon, or newline separators (example: *@@domain.org).</div>
@@ -507,7 +490,7 @@
507490
LicenceStatus = OrganisationLicenceStatus.Active
508491
};
509492
ShowModal("Success", "Member organisation added successfully.");
510-
await LoadAdminDataAsync();
493+
await RefreshUsersAndOrganisationsAsync();
511494
}
512495
else
513496
{
@@ -534,24 +517,8 @@
534517
try
535518
{
536519
Logger.LogInformation("Admin page authenticated. Fetching registrations and member organisations.");
537-
users = await WebApiUtility.GetUsersAsync();
538-
organisations = await WebApiUtility.GetOrganisationsAsync();
520+
await RefreshUsersAndOrganisationsAsync();
539521
await LoadDownloadMetricsAsync();
540-
541-
if (!string.IsNullOrWhiteSpace(selectedSpecialOrganisationId))
542-
{
543-
var selected = organisations.FirstOrDefault(o => o.Id.ToString() == selectedSpecialOrganisationId);
544-
SpecialOrganisation = selected is null ? null : CloneOrganisation(selected);
545-
if (selected is null)
546-
{
547-
selectedSpecialOrganisationId = string.Empty;
548-
specialOrganisationEmailsText = string.Empty;
549-
}
550-
else
551-
{
552-
specialOrganisationEmailsText = string.Join(Environment.NewLine, SpecialOrganisation!.Emails);
553-
}
554-
}
555522
}
556523
catch (Exception ex)
557524
{
@@ -560,6 +527,29 @@
560527
}
561528
}
562529

530+
private async Task RefreshUsersAndOrganisationsAsync()
531+
{
532+
users = await WebApiUtility.GetUsersAsync();
533+
organisations = await WebApiUtility.GetOrganisationsAsync();
534+
535+
if (!string.IsNullOrWhiteSpace(selectedSpecialOrganisationId))
536+
{
537+
var selected = organisations.FirstOrDefault(o => o.Id.ToString() == selectedSpecialOrganisationId);
538+
SpecialOrganisation = selected is null ? null : CloneOrganisation(selected);
539+
if (selected is null)
540+
{
541+
selectedSpecialOrganisationId = string.Empty;
542+
specialOrganisationEmailsText = string.Empty;
543+
}
544+
else
545+
{
546+
specialOrganisationEmailsText = string.Join(Environment.NewLine, SpecialOrganisation!.Emails);
547+
}
548+
}
549+
550+
await InvokeAsync(StateHasChanged);
551+
}
552+
563553
private async Task LoadDownloadMetricsAsync()
564554
{
565555
isDownloadMetricsLoading = true;
@@ -740,7 +730,7 @@
740730
if (response.IsSuccessStatusCode)
741731
{
742732
ShowModal("Success", $"Organisation '{SpecialOrganisation.Name}' updated successfully.");
743-
await LoadAdminDataAsync();
733+
await RefreshUsersAndOrganisationsAsync();
744734
return;
745735
}
746736

@@ -754,7 +744,7 @@
754744
if (response.IsSuccessStatusCode)
755745
{
756746
ShowModal("Success", $"User '{user.Email}' deleted successfully.");
757-
await LoadAdminDataAsync();
747+
await RefreshUsersAndOrganisationsAsync();
758748
return;
759749
}
760750

0 commit comments

Comments
 (0)