Add common loading component
This has no specific issue associated, but reduces boilerplate in most page components
This commit is contained in:
@@ -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}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user