Add common loading component
This has no specific issue associated, but reduces boilerplate in most page components
This commit is contained in:
parent
7f7eb191fb
commit
a6fd891cc5
@ -6,46 +6,39 @@
|
||||
|
||||
<h3>Welcome, @state.User!.Name!</h3>
|
||||
|
||||
@if (RetrievingData)
|
||||
{
|
||||
<p>Retrieving your employment profile...</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<ErrorList Errors=@ErrorMessages>
|
||||
@if (Profile != null)
|
||||
{
|
||||
<p>
|
||||
Your employment profile was last updated <FullDateTime TheDate=@Profile.LastUpdatedOn />. Your profile currently
|
||||
lists @Profile.Skills.Length skill@(Profile.Skills.Length != 1 ? "s" : "").
|
||||
</p>
|
||||
<p><a href="/profile/view/@state.User.Id">View Your Employment Profile</a></p>
|
||||
@if (Profile.SeekingEmployment)
|
||||
{
|
||||
<p>
|
||||
Your profile indicates that you are seeking employment. Once you find it,
|
||||
<a href="/success-story/add">tell your fellow citizens about it!</a>
|
||||
</p>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>
|
||||
You do not have an employment profile established; click “Edit Profile” in the menu to get
|
||||
started!
|
||||
</p>
|
||||
}
|
||||
<hr>
|
||||
<Loading OnLoad=@LoadProfile Message=@(new MarkupString("Retrieving your employment profile…"))>
|
||||
@if (Profile != null)
|
||||
{
|
||||
<p>
|
||||
There @(ProfileCount == 1 ? "is" : "are") @(ProfileCount == 0 ? "no" : ProfileCount) employment
|
||||
profile@(ProfileCount != 1 ? "s" : "") from citizens of Gitmo Nation.
|
||||
@if (ProfileCount > 0)
|
||||
{
|
||||
<text>Take a look around and see if you can help them find work!</text>
|
||||
}
|
||||
Your employment profile was last updated <FullDateTime TheDate=@Profile.LastUpdatedOn />. Your profile currently
|
||||
lists @Profile.Skills.Length skill@(Profile.Skills.Length != 1 ? "s" : "").
|
||||
</p>
|
||||
</ErrorList>
|
||||
}
|
||||
<p><a href="/profile/view/@state.User.Id">View Your Employment Profile</a></p>
|
||||
@if (Profile.SeekingEmployment)
|
||||
{
|
||||
<p>
|
||||
Your profile indicates that you are seeking employment. Once you find it,
|
||||
<a href="/success-story/add">tell your fellow citizens about it!</a>
|
||||
</p>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>
|
||||
You do not have an employment profile established; click “Edit Profile” in the menu to get
|
||||
started!
|
||||
</p>
|
||||
}
|
||||
<hr>
|
||||
<p>
|
||||
There @(ProfileCount == 1 ? "is" : "are") @(ProfileCount == 0 ? "no" : ProfileCount) employment
|
||||
profile@(ProfileCount != 1 ? "s" : "") from citizens of Gitmo Nation.
|
||||
@if (ProfileCount > 0)
|
||||
{
|
||||
<text>Take a look around and see if you can help them find work!</text>
|
||||
}
|
||||
</p>
|
||||
</Loading>
|
||||
<hr>
|
||||
<h4>
|
||||
<a href="https://github.com/bit-badger/jobs-jobs-jobs/issues/3" target="_blank">Phase 3</a> – What Works
|
||||
|
@ -11,11 +11,6 @@ namespace JobsJobsJobs.Client.Pages.Citizen
|
||||
/// </summary>
|
||||
public partial class Dashboard : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the data is being retrieved
|
||||
/// </summary>
|
||||
private bool RetrievingData { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The user's profile
|
||||
/// </summary>
|
||||
@ -27,11 +22,10 @@ namespace JobsJobsJobs.Client.Pages.Citizen
|
||||
private int ProfileCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Error messages from data access
|
||||
/// Load the user's profile information
|
||||
/// </summary>
|
||||
private IList<string> ErrorMessages { get; } = new List<string>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
/// <param name="errors">A collection to report errors that may be encountered</param>
|
||||
public async Task LoadProfile(ICollection<string> errors)
|
||||
{
|
||||
if (state.User != null)
|
||||
{
|
||||
@ -47,7 +41,7 @@ namespace JobsJobsJobs.Client.Pages.Citizen
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(profileTask.Result.Error);
|
||||
errors.Add(profileTask.Result.Error);
|
||||
}
|
||||
|
||||
if (profileCountTask.Result.IsOk)
|
||||
@ -56,10 +50,8 @@ namespace JobsJobsJobs.Client.Pages.Citizen
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(profileCountTask.Result.Error);
|
||||
errors.Add(profileCountTask.Result.Error);
|
||||
}
|
||||
|
||||
RetrievingData = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,118 +8,111 @@
|
||||
|
||||
<h3>Employment Profile</h3>
|
||||
|
||||
@if (AllLoaded)
|
||||
{
|
||||
<ErrorList Errors=@ErrorMessages>
|
||||
<EditForm Model=@ProfileForm OnValidSubmit=@SaveProfile>
|
||||
<DataAnnotationsValidator />
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="seeking" class="form-check-input" @bind-Value=@ProfileForm.IsSeekingEmployment />
|
||||
<label for="seeking" class="form-check-label">I am currently seeking employment</label>
|
||||
@if (IsSeeking)
|
||||
<Loading OnLoad=@SetUpProfile Message=@(new MarkupString("Loading Your Profile…"))>
|
||||
<EditForm Model=@ProfileForm OnValidSubmit=@SaveProfile>
|
||||
<DataAnnotationsValidator />
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="seeking" class="form-check-input" @bind-Value=@ProfileForm.IsSeekingEmployment />
|
||||
<label for="seeking" class="form-check-label">I am currently seeking employment</label>
|
||||
@if (IsSeeking)
|
||||
{
|
||||
<em> If you have found employment, consider
|
||||
<a href="/success-story/add">telling your fellow citizens about it</a>
|
||||
</em>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col col-xs-12 col-sm-6 col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="continentId" class="jjj-required">Continent</label>
|
||||
<InputSelect id="continentId" @bind-Value=@ProfileForm.ContinentId class="form-control">
|
||||
<option>– Select –</option>
|
||||
@foreach (var (id, name) in Continents)
|
||||
{
|
||||
<em> If you have found employment, consider
|
||||
<a href="/success-story/add">telling your fellow citizens about it</a>
|
||||
</em>
|
||||
<option value="@id">@name</option>
|
||||
}
|
||||
</div>
|
||||
</InputSelect>
|
||||
<ValidationMessage For=@(() => ProfileForm.ContinentId) />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col col-xs-12 col-sm-6 col-md-4">
|
||||
<div class="form-group">
|
||||
<label for="continentId" class="jjj-required">Continent</label>
|
||||
<InputSelect id="continentId" @bind-Value=@ProfileForm.ContinentId class="form-control">
|
||||
<option>– Select –</option>
|
||||
@foreach (var (id, name) in Continents)
|
||||
{
|
||||
<option value="@id">@name</option>
|
||||
}
|
||||
</InputSelect>
|
||||
<ValidationMessage For=@(() => ProfileForm.ContinentId) />
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-xs-12 col-sm-6 col-md-8">
|
||||
<div class="form-group">
|
||||
<label for="region" class="jjj-required">Region</label>
|
||||
<InputText id="region" @bind-Value=@ProfileForm.Region class="form-control"
|
||||
placeholder="Country, state, geographic area, etc." />
|
||||
<ValidationMessage For=@(() => ProfileForm.Region) />
|
||||
</div>
|
||||
<div class="col col-xs-12 col-sm-6 col-md-8">
|
||||
<div class="form-group">
|
||||
<label for="region" class="jjj-required">Region</label>
|
||||
<InputText id="region" @bind-Value=@ProfileForm.Region class="form-control"
|
||||
placeholder="Country, state, geographic area, etc." />
|
||||
<ValidationMessage For=@(() => ProfileForm.Region) />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="bio" class="jjj-required">Professional Biography</label>
|
||||
<MarkdownEditor Id="bio" @bind-Text=@ProfileForm.Biography />
|
||||
<ValidationMessage For=@(() => ProfileForm.Biography) />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="bio" class="jjj-required">Professional Biography</label>
|
||||
<MarkdownEditor Id="bio" @bind-Text=@ProfileForm.Biography />
|
||||
<ValidationMessage For=@(() => ProfileForm.Biography) />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col col-xs-12 col-sm-12 offset-md-2 col-md-4">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="isRemote" class="form-check-input" @bind-Value=@ProfileForm.RemoteWork />
|
||||
<label for="isRemote" class="form-check-label">I am looking for remote work</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col col-xs-12 col-sm-12 col-md-4">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="isFull" class="form-check-input" @bind-Value=@ProfileForm.FullTime />
|
||||
<label for="isFull" class="form-check-label">I am looking for full-time work</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col col-xs-12 col-sm-12 offset-md-2 col-md-4">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="isRemote" class="form-check-input" @bind-Value=@ProfileForm.RemoteWork />
|
||||
<label for="isRemote" class="form-check-label">I am looking for remote work</label>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<h4>
|
||||
Skills
|
||||
<button type="button" class="btn btn-outline-primary" @onclick=@AddNewSkill>Add a Skill</button>
|
||||
</h4>
|
||||
@foreach (var skill in ProfileForm.Skills)
|
||||
{
|
||||
<SkillEdit Skill=@skill OnRemove=@RemoveSkill />
|
||||
}
|
||||
<hr>
|
||||
<h4>Experience</h4>
|
||||
<p>
|
||||
This application does not have a place to individually list your chronological job history; however, you can
|
||||
use this area to list prior jobs, their dates, and anything else you want to include that’s not already a
|
||||
part of your Professional Biography above.
|
||||
</p>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<MarkdownEditor Id="experience" @bind-Text=@ProfileForm.Experience />
|
||||
<div class="col col-xs-12 col-sm-12 col-md-4">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="isFull" class="form-check-input" @bind-Value=@ProfileForm.FullTime />
|
||||
<label for="isFull" class="form-check-label">I am looking for full-time work</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="isPublic" class="form-check-input" @bind-Value=@ProfileForm.IsPublic />
|
||||
<label for="isPublic" class="form-check-label">
|
||||
Allow my profile to be searched publicly (outside NA Social)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<br>
|
||||
<button type="submit" class="btn btn-outline-primary">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
@if (!IsNew)
|
||||
</div>
|
||||
<hr>
|
||||
<h4>
|
||||
Skills
|
||||
<button type="button" class="btn btn-outline-primary" @onclick=@AddNewSkill>Add a Skill</button>
|
||||
</h4>
|
||||
@foreach (var skill in ProfileForm.Skills)
|
||||
{
|
||||
<p>
|
||||
<br><a href="/profile/view/@state.User!.Id"><span class="oi oi-file"></span> View Your User Profile</a>
|
||||
</p>
|
||||
<SkillEdit Skill=@skill OnRemove=@RemoveSkill />
|
||||
}
|
||||
</ErrorList>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Loading your profile...</p>
|
||||
}
|
||||
<hr>
|
||||
<h4>Experience</h4>
|
||||
<p>
|
||||
This application does not have a place to individually list your chronological job history; however, you can
|
||||
use this area to list prior jobs, their dates, and anything else you want to include that’s not already a
|
||||
part of your Professional Biography above.
|
||||
</p>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<MarkdownEditor Id="experience" @bind-Text=@ProfileForm.Experience />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="isPublic" class="form-check-input" @bind-Value=@ProfileForm.IsPublic />
|
||||
<label for="isPublic" class="form-check-label">
|
||||
Allow my profile to be searched publicly (outside NA Social)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<br>
|
||||
<button type="submit" class="btn btn-outline-primary">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
@if (!IsNew)
|
||||
{
|
||||
<p>
|
||||
<br><a href="/profile/view/@state.User!.Id"><span class="oi oi-file"></span> View Your User Profile</a>
|
||||
</p>
|
||||
}
|
||||
</Loading>
|
||||
|
@ -18,11 +18,6 @@ namespace JobsJobsJobs.Client.Pages.Citizen
|
||||
/// </summary>
|
||||
private int _newSkillCounter = 0;
|
||||
|
||||
/// <summary>
|
||||
/// A flag that indicates all the required API calls have completed, and the form is ready to be displayed
|
||||
/// </summary>
|
||||
private bool AllLoaded { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the citizen is seeking employment at the time the profile is loaded (used to show success story
|
||||
/// link)
|
||||
@ -45,11 +40,10 @@ namespace JobsJobsJobs.Client.Pages.Citizen
|
||||
private bool IsNew { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Error messages from API access
|
||||
/// Set up the data needed to add or edit the user's profile
|
||||
/// </summary>
|
||||
private IList<string> ErrorMessages { get; } = new List<string>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
/// <param name="errors">The collection where errors can be reported</param>
|
||||
public async Task SetUpProfile(ICollection<string> errors)
|
||||
{
|
||||
ServerApi.SetJwt(http, state);
|
||||
var continentTask = state.GetContinents(http);
|
||||
@ -75,10 +69,8 @@ namespace JobsJobsJobs.Client.Pages.Citizen
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(profileTask.Result.Error);
|
||||
errors.Add(profileTask.Result.Error);
|
||||
}
|
||||
|
||||
AllLoaded = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -118,6 +110,5 @@ namespace JobsJobsJobs.Client.Pages.Citizen
|
||||
toast.ShowError($"{(int)res.StatusCode} {error}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,51 +2,44 @@
|
||||
@inject HttpClient http
|
||||
@inject AppState state
|
||||
|
||||
@if (IsLoading)
|
||||
{
|
||||
<p>Loading profile...</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<Loading OnLoad=@RetrieveProfile>
|
||||
<PageTitle Title=@($"Employment Profile for {Citizen.DisplayName}") />
|
||||
<ErrorList Errors=@ErrorMessages>
|
||||
<h2><a href="@Citizen.ProfileUrl" target="_blank">@Citizen.DisplayName</a></h2>
|
||||
<h4>@Profile.Continent!.Name, @Profile.Region</h4>
|
||||
<p>@WorkTypes</p>
|
||||
<h2><a href="@Citizen.ProfileUrl" target="_blank">@Citizen.DisplayName</a></h2>
|
||||
<h4>@Profile.Continent!.Name, @Profile.Region</h4>
|
||||
<p>@WorkTypes</p>
|
||||
|
||||
<hr>
|
||||
<hr>
|
||||
|
||||
<div>
|
||||
@(new MarkupString(Profile.Biography.ToHtml()))
|
||||
</div>
|
||||
<div>
|
||||
@(new MarkupString(Profile.Biography.ToHtml()))
|
||||
</div>
|
||||
|
||||
|
||||
@if (Profile.Skills.Length > 0)
|
||||
{
|
||||
<hr>
|
||||
<h4>Skills</h4>
|
||||
<ul>
|
||||
@foreach (var skill in Profile.Skills)
|
||||
{
|
||||
var notes = skill.Notes == null ? "" : $" ({skill.Notes})";
|
||||
<li>@skill.Description@notes</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
@if (Profile.Skills.Length > 0)
|
||||
{
|
||||
<hr>
|
||||
<h4>Skills</h4>
|
||||
<ul>
|
||||
@foreach (var skill in Profile.Skills)
|
||||
{
|
||||
var notes = skill.Notes == null ? "" : $" ({skill.Notes})";
|
||||
<li>@skill.Description@notes</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
||||
@if (Profile.Experience != null)
|
||||
{
|
||||
<hr>
|
||||
<h4>Experience / Employment History</h4>
|
||||
<div>
|
||||
@(new MarkupString(Profile.Experience.ToHtml()))
|
||||
</div>
|
||||
}
|
||||
@if (Profile.Experience != null)
|
||||
{
|
||||
<hr>
|
||||
<h4>Experience / Employment History</h4>
|
||||
<div>
|
||||
@(new MarkupString(Profile.Experience.ToHtml()))
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Id == state.User!.Id.ToString())
|
||||
{
|
||||
<hr>
|
||||
<p><a href="/citizen/profile"><span class="oi oi-pencil"></span> Edit Your Profile</a></p>
|
||||
}
|
||||
</ErrorList>
|
||||
}
|
||||
@if (Id == state.User!.Id.ToString())
|
||||
{
|
||||
<hr>
|
||||
<p><a href="/citizen/profile"><span class="oi oi-pencil"></span> Edit Your Profile</a></p>
|
||||
}
|
||||
</Loading>
|
||||
|
@ -1,6 +1,5 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Domain = JobsJobsJobs.Shared;
|
||||
|
||||
@ -8,11 +7,6 @@ namespace JobsJobsJobs.Client.Pages.Profile
|
||||
{
|
||||
public partial class View : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether data for this component is loading
|
||||
/// </summary>
|
||||
private bool IsLoading { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The citizen whose profile is being displayed
|
||||
/// </summary>
|
||||
@ -48,18 +42,17 @@ namespace JobsJobsJobs.Client.Pages.Profile
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Error messages from data retrieval
|
||||
/// </summary>
|
||||
private IList<string> ErrorMessages { get; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the citizen whose profile should be displayed
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public string Id { get; set; } = default!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
/// <summary>
|
||||
/// Retrieve the requested profile
|
||||
/// </summary>
|
||||
/// <param name="errors">A collection to report errors that may occur</param>
|
||||
public async Task RetrieveProfile(ICollection<string> errors)
|
||||
{
|
||||
ServerApi.SetJwt(http, state);
|
||||
var citizenTask = ServerApi.RetrieveOne<Domain.Citizen>(http, $"citizen/get/{Id}");
|
||||
@ -73,11 +66,11 @@ namespace JobsJobsJobs.Client.Pages.Profile
|
||||
}
|
||||
else if (citizenTask.Result.IsOk)
|
||||
{
|
||||
ErrorMessages.Add("Citizen not found");
|
||||
errors.Add("Citizen not found");
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(citizenTask.Result.Error);
|
||||
errors.Add(citizenTask.Result.Error);
|
||||
}
|
||||
|
||||
if (profileTask.Result.IsOk && profileTask.Result.Ok != null)
|
||||
@ -86,14 +79,12 @@ namespace JobsJobsJobs.Client.Pages.Profile
|
||||
}
|
||||
else if (profileTask.Result.IsOk)
|
||||
{
|
||||
ErrorMessages.Add("Profile not found");
|
||||
errors.Add("Profile not found");
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(profileTask.Result.Error);
|
||||
errors.Add(profileTask.Result.Error);
|
||||
}
|
||||
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,52 +6,44 @@
|
||||
@inject IToastService toast
|
||||
|
||||
<PageTitle Title=@Title />
|
||||
|
||||
<h3>@Title</h3>
|
||||
|
||||
<ErrorList Errors=@ErrorMessages>
|
||||
@if (Loading)
|
||||
<Loading OnLoad=@RetrieveStory>
|
||||
@if (IsNew)
|
||||
{
|
||||
<p>Loading...</p>
|
||||
<p>
|
||||
Congratulations on your employment! Your fellow citizens would enjoy hearing how it all came about; tell us
|
||||
about it below! <em>(These will be visible to other users, but not to the general public.)</em>
|
||||
</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (IsNew)
|
||||
{
|
||||
<p>
|
||||
Congratulations on your employment! Your fellow citizens would enjoy hearing how it all came about; tell us
|
||||
about it below! <em>(These will be visible to other users, but not to the general public.)</em>
|
||||
</p>
|
||||
}
|
||||
<EditForm Model=@Form OnValidSubmit=@SaveStory>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="fromHere" class="form-check-input" @bind-Value=@Form.FromHere />
|
||||
<label for="fromHere" class="form-check-label">I found my employment here</label>
|
||||
</div>
|
||||
<EditForm Model=@Form OnValidSubmit=@SaveStory>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-check">
|
||||
<InputCheckbox id="fromHere" class="form-check-input" @bind-Value=@Form.FromHere />
|
||||
<label for="fromHere" class="form-check-label">I found my employment here</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="story" class="jjj-label">The Success Story</label>
|
||||
<MarkdownEditor Id="story" @bind-Text=@Form.Story />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label for="story" class="jjj-label">The Success Story</label>
|
||||
<MarkdownEditor Id="story" @bind-Text=@Form.Story />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<br>
|
||||
<button type="submit" class="btn btn-outline-primary">Save</button>
|
||||
@if (IsNew)
|
||||
{
|
||||
<p>
|
||||
<em>(Saving this will set “Seeking Employment” to “No” on your profile.)</em>
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="col">
|
||||
<br>
|
||||
<button type="submit" class="btn btn-outline-primary">Save</button>
|
||||
@if (IsNew)
|
||||
{
|
||||
<p>
|
||||
<em>(Saving this will set “Seeking Employment” to “No” on your profile.)</em>
|
||||
</p>
|
||||
}
|
||||
</div>
|
||||
</EditForm>
|
||||
}
|
||||
</ErrorList>
|
||||
</div>
|
||||
</EditForm>
|
||||
</Loading>
|
||||
|
@ -16,11 +16,6 @@ namespace JobsJobsJobs.Client.Pages.SuccessStory
|
||||
[Parameter]
|
||||
public string? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether we are loading information
|
||||
/// </summary>
|
||||
private bool Loading { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The page title / header
|
||||
/// </summary>
|
||||
@ -37,11 +32,10 @@ namespace JobsJobsJobs.Client.Pages.SuccessStory
|
||||
private bool IsNew => Form.Id == "new";
|
||||
|
||||
/// <summary>
|
||||
/// Error messages from API access
|
||||
/// Retrieve the story
|
||||
/// </summary>
|
||||
private IList<string> ErrorMessages { get; } = new List<string>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
/// <param name="errors">A collection to use in reporting errors that may occur</param>
|
||||
public async Task RetrieveStory(ICollection<string> errors)
|
||||
{
|
||||
if (Id != null)
|
||||
{
|
||||
@ -58,14 +52,13 @@ namespace JobsJobsJobs.Client.Pages.SuccessStory
|
||||
}
|
||||
else if (story.IsOk)
|
||||
{
|
||||
ErrorMessages.Add($"The success story {Id} does not exist");
|
||||
errors.Add($"The success story {Id} does not exist");
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(story.Error);
|
||||
errors.Add(story.Error);
|
||||
}
|
||||
}
|
||||
Loading = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -3,15 +3,10 @@
|
||||
@inject AppState state
|
||||
|
||||
<PageTitle Title="Success Stories" />
|
||||
|
||||
<h3>Success Stories</h3>
|
||||
|
||||
<ErrorList Errors=@ErrorMessages>
|
||||
@if (Loading)
|
||||
{
|
||||
<p>Loading...</p>
|
||||
}
|
||||
else if (Stories.Any())
|
||||
<Loading OnLoad=@LoadStories>
|
||||
@if (Stories.Any())
|
||||
{
|
||||
<table class="table table-sm table-hover">
|
||||
<thead>
|
||||
@ -43,4 +38,4 @@
|
||||
{
|
||||
<p>There are no success stories recorded <em>(yet)</em></p>
|
||||
}
|
||||
</ErrorList>
|
||||
</Loading>
|
||||
|
@ -1,30 +1,22 @@
|
||||
using JobsJobsJobs.Shared.Api;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JobsJobsJobs.Client.Pages.SuccessStory
|
||||
{
|
||||
public partial class ListStories : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether we are still loading data
|
||||
/// </summary>
|
||||
private bool Loading { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// The story entries
|
||||
/// </summary>
|
||||
private IEnumerable<StoryEntry> Stories { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Error messages encountered
|
||||
/// Load all success stories
|
||||
/// </summary>
|
||||
private IList<string> ErrorMessages { get; set; } = new List<string>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
/// <param name="errors">The collection into which errors can be reported</param>
|
||||
public async Task LoadStories(ICollection<string> errors)
|
||||
{
|
||||
ServerApi.SetJwt(http, state);
|
||||
var stories = await ServerApi.RetrieveMany<StoryEntry>(http, "success/list");
|
||||
@ -35,10 +27,8 @@ namespace JobsJobsJobs.Client.Pages.SuccessStory
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessages.Add(stories.Error);
|
||||
errors.Add(stories.Error);
|
||||
}
|
||||
|
||||
Loading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18
src/JobsJobsJobs/Client/Shared/Loading.razor
Normal file
18
src/JobsJobsJobs/Client/Shared/Loading.razor
Normal file
@ -0,0 +1,18 @@
|
||||
@if (IsLoading)
|
||||
{
|
||||
<p>@Message</p>
|
||||
}
|
||||
else if (ErrorMessages.Count > 0)
|
||||
{
|
||||
<p>The following error@(ErrorMessages.Count == 1 ? "" : "s") occurred:</p>
|
||||
<ul>
|
||||
@foreach (var msg in ErrorMessages)
|
||||
{
|
||||
<li><pre>@msg</pre></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
else
|
||||
{
|
||||
@ChildContent
|
||||
}
|
58
src/JobsJobsJobs/Client/Shared/Loading.razor.cs
Normal file
58
src/JobsJobsJobs/Client/Shared/Loading.razor.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JobsJobsJobs.Client.Shared
|
||||
{
|
||||
public partial class Loading : ComponentBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The delegate to call to load the data for this page
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public EventCallback<ICollection<string>> OnLoad { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The message to display when the page is loading (optional)
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public MarkupString Message { get; set; } = new MarkupString("Loading…");
|
||||
|
||||
/// <summary>
|
||||
/// The content to be displayed once the data has been loaded
|
||||
/// </summary>
|
||||
[Parameter]
|
||||
public RenderFragment ChildContent { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Error messages that may arise from the data loading delegate
|
||||
/// </summary>
|
||||
private ICollection<string> ErrorMessages { get; set; } = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether we are currently loading data
|
||||
/// </summary>
|
||||
private bool IsLoading { get; set; } = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (OnLoad.HasDelegate)
|
||||
{
|
||||
try
|
||||
{
|
||||
await OnLoad.InvokeAsync(ErrorMessages);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IsLoading = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,10 +9,10 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="@NavMenuCssClass" @onclick="ToggleNavMenu">
|
||||
<div class="@NavMenuCssClass" @onclick=@ToggleNavMenu>
|
||||
<ul class="nav flex-column">
|
||||
<li class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
|
||||
<NavLink class="nav-link" href="" Match=@NavLinkMatch.All>
|
||||
<span class="oi oi-home" aria-hidden="true"></span> Home
|
||||
</NavLink>
|
||||
</li>
|
||||
|
Loading…
Reference in New Issue
Block a user