PCRB webassembly

This commit is contained in:
Chase Tucker
2024-05-13 14:33:27 -07:00
parent 9b7e3ef897
commit 89790f4fc1
50 changed files with 5466 additions and 677 deletions

View File

@ -7,6 +7,7 @@
@inject NavigationManager navigationManager
@inject ISnackbar snackbar
@inject IMRBService mrbService
@inject IPCRBService pcrbService
@inject IECNService ecnService
@inject ICAService caService
@inject IJSRuntime jsRuntime
@ -88,6 +89,7 @@
<MudSpacer />
<MudTextField @bind-Value="mrbSearchString"
Placeholder="Search"
Immediate
Adornment="Adornment.Start"
AdornmentIcon="@Icons.Material.Filled.Search"
IconSize="Size.Medium"
@ -147,21 +149,100 @@
</MudOverlay>
}
</MudTabPanel>
<MudTabPanel Text="My PCRBs" Style="min-width:50%; text-align: center;">
@if (stateProvider.CurrentUser is not null && myPCRBs is not null && !myPcrbsProcessing) {
<MudPaper Outlined="true"
Class="p-2 m-2 d-flex flex-column justify-center">
<MudText Typo="Typo.h4" Align="Align.Center">My PCRBs</MudText>
<MudDivider DividerType="DividerType.Middle" Class="my-2" />
<MudTable Items="@myPCRBs"
Class="m-2"
Striped
SortLabel="Sort by"
Filter="new Func<PCRB, bool>(FilterFuncForPCRBTable)">
<ToolBarContent>
<MudSpacer />
<MudTextField @bind-Value="pcrbSearchString"
Placeholder="Search"
Adornment="Adornment.Start"
Immediate
AdornmentIcon="@Icons.Material.Filled.Search"
IconSize="Size.Medium"
Class="mt-0" />
</ToolBarContent>
<HeaderContent>
<MudTh>
<MudTableSortLabel InitialDirection="SortDirection.Descending" SortBy="new Func<PCRB,object>(x=>x.PlanNumber)">
PCRB#
</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<PCRB,object>(x=>x.Title)">
Title
</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<PCRB,object>(x=>x.CurrentStep)">
Current Step
</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<PCRB,object>(x=>x.InsertTimeStamp)">
Submitted Date
</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<PCRB,object>(x=>x.LastUpdateDate)">
Last Updated
</MudTableSortLabel>
</MudTh>
<MudTh>
<MudTableSortLabel SortBy="new Func<PCRB,object>(x=>x.ClosedDate)">
Completed Date
</MudTableSortLabel>
</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="PCRB#">
<MudLink OnClick="@(() => GoTo($"pcrb/{context.PlanNumber}"))">@context.PlanNumber</MudLink>
</MudTd>
<MudTd DataLabel="Title">@context.Title</MudTd>
<MudTd DataLabel="Current Step">@(GetCurrentPCRBStep(context.CurrentStep))</MudTd>
<MudTd DataLabel="Submitted Date">@DateTimeUtilities.GetDateAsStringMinDefault(context.InsertTimeStamp)</MudTd>
<MudTd DataLabel="Last Updated">@DateTimeUtilities.GetDateAsStringMinDefault(context.LastUpdateDate)</MudTd>
<MudTd DataLabel="Completed Date">@DateTimeUtilities.GetDateAsStringMaxDefault(context.ClosedDate)</MudTd>
</RowTemplate>
<PagerContent>
<MudTablePager />
</PagerContent>
</MudTable>
</MudPaper>
} else {
<MudOverlay Visible DarkBackground="true" AutoClose="false">
<MudText Align="Align.Center" Typo="Typo.h3">Processing</MudText>
<MudProgressCircular Color="Color.Info" Size="Size.Large" Indeterminate="true" />
</MudOverlay>
}
</MudTabPanel>
</MudTabs>
</MudPaper>
@code {
private IEnumerable<Approval> approvalList = new List<Approval>();
private IEnumerable<MRB> myMRBs = new List<MRB>();
private IEnumerable<PCRB> myPCRBs = new List<PCRB>();
private IEnumerable<int> ecnNumbers = new HashSet<int>();
private IEnumerable<int> caNumbers = new HashSet<int>();
private IEnumerable<int> mrbNumbers = new HashSet<int>();
private IEnumerable<int> pcrbNumbers = new HashSet<int>();
private bool myApprovalsProcessing = false;
private bool myMrbsProcessing = false;
private bool myPcrbsProcessing = false;
private string mrbSearchString = "";
private string pcrbSearchString = "";
protected async override Task OnParametersSetAsync() {
try {
@ -178,9 +259,17 @@
.ToList()
.OrderByDescending(x => x.SubmittedDate);
myMrbsProcessing = false;
myPcrbsProcessing = true;
myPCRBs = (await pcrbService.GetAllPCRBs(false)).Where(p => p.OwnerID == stateProvider.CurrentUser.UserID)
.ToList()
.OrderByDescending(p => p.InsertTimeStamp);
myPcrbsProcessing = false;
}
} catch (Exception ex) {
myApprovalsProcessing = false;
myMrbsProcessing = false;
myPcrbsProcessing = false;
snackbar.Add($"Unable to load the dashboard, because {ex.Message}", Severity.Error);
}
}
@ -191,12 +280,15 @@
bool isEcn = false;
bool isCa = false;
bool isMrb = false;
bool isPcrb = false;
if (ecnNumbers.Contains(issueId))
isEcn = true;
if (caNumbers.Contains(issueId))
isCa = true;
if (mrbNumbers.Contains(issueId))
isMrb = true;
if (pcrbNumbers.Contains(issueId))
isPcrb = true;
if (!isEcn && !isCa && !isMrb) {
Task<bool> isEcnTask = ecnService.ECNNumberIsValid(issueId);
@ -208,6 +300,9 @@
Task<bool> isMrbTask = mrbService.NumberIsValid(issueId);
tasks.Add(isMrbTask);
Task<bool> isPcrbTask = pcrbService.IdIsValid(issueId);
tasks.Add(isPcrbTask);
await Task.WhenAll(tasks);
if (isEcnTask.Result) {
@ -216,12 +311,15 @@
isCa = true;
} else if (isMrbTask.Result) {
isMrb = true;
} else if (isPcrbTask.Result) {
isPcrb = true;
}
}
if (isEcn) await GoToExternal($"{Configuration["OldFabApprovalUrl"]}/ECN/Edit?IssueID={issueId}", "");
if (isCa) await GoToExternal($"{Configuration["OldFabApprovalUrl"]}/CorrectiveAction/Edit?IssueID={issueId}", "");
if (isMrb) GoTo($"mrb/{issueId}");
if (isPcrb) GoTo($"pcrb/{issueId}");
}
private void GoTo(string page) {
@ -245,4 +343,21 @@
return true;
return false;
}
private bool FilterFuncForPCRBTable(PCRB pcrb) => PCRBFilterFunc(pcrb, pcrbSearchString);
private bool PCRBFilterFunc(PCRB pcrb, string searchString) {
if (string.IsNullOrWhiteSpace(searchString))
return true;
if (pcrb.Title.ToLower().Contains(searchString.Trim().ToLower()))
return true;
if (pcrb.PlanNumber.ToString().Contains(searchString.Trim()))
return true;
return false;
}
private string GetCurrentPCRBStep(int step) {
if (step < 0 || step > (PCRB.Stages.Length - 1)) return string.Empty;
else return PCRB.Stages[step];
}
}