Skip to content

Commit 3548c6c

Browse files
authored
Merge pull request #64 from SensitTechnologies/import-overhaul+CSS
Production Log Editing and Spreadsheet Changes
2 parents 6378503 + 866de3e commit 3548c6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3352
-481
lines changed

MESS/MESS.Blazor/Components/Pages/Auth/Login.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
<div @ref="_dropdownContainer"
4646
@onmouseenter="OnDropdownMouseEnter"
4747
@onmouseleave="OnDropdownMouseLeave"
48-
class="position-absolute w-100 mt-1 shadow bg-white border rounded"
49-
style="max-height: 200px; overflow-y: auto; z-index: 1000;">
48+
class="login-dropdown position-absolute w-100 mt-1 shadow border rounded"
49+
style="max-height: 200px; overflow-y: auto; z-index: 1000;">
5050
@if (ApplicationUsers != null)
5151
{
5252
@foreach (var lineOperator in ApplicationUsers.Where(u =>

MESS/MESS.Blazor/Components/Pages/Phoebe/WorkInstruction/WorkInstructionImport.razor

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,24 @@
1111
</button>
1212
<InputFile OnChange="LoadFile" accept=".xlsx" class="form-control mb-3"/>
1313
</div>
14+
15+
@if (IsImporting)
16+
{
17+
<div class="mt-3">
18+
<div class="progress">
19+
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width: 100%">
20+
Importing...
21+
</div>
22+
</div>
23+
</div>
24+
}
25+
26+
@if (!string.IsNullOrEmpty(StatusMessage))
27+
{
28+
<div class="alert alert-info mt-3">
29+
@StatusMessage
30+
</div>
31+
}
1432
</FluentCard>
1533

1634

MESS/MESS.Blazor/Components/Pages/ProductionLog/Create.razor.cs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal enum Status
1818
/// </summary>
1919
public partial class Create : ComponentBase, IAsyncDisposable
2020
{
21-
private string Title = "Add";
21+
private const string Title = "Production Log";
2222
private bool IsLoading { get; set; } = true;
2323
private ConfirmationModal? popupRef;
2424
private bool IsWorkflowActive { get; set; }
@@ -42,7 +42,7 @@ public partial class Create : ComponentBase, IAsyncDisposable
4242
private string? ProductSerialNumber { get; set; }
4343
private string? QRCodeDataUrl;
4444
private IJSObjectReference? module;
45-
private List<SerialNumberLog> _serialNumberLogs { get; set; } = [];
45+
private List<ProductionLogPart> ProductionLogParts { get; set; } = [];
4646

4747
private Func<ProductionLog, Task>? _autoSaveHandler;
4848
/// <inheritdoc />
@@ -82,9 +82,9 @@ await InvokeAsync((() =>
8282
ProductionLogEventService.AutoSaveTriggered += _autoSaveHandler;
8383
ProductSerialNumber = SerializationService.CurrentProductNumber;
8484

85-
SerializationService.CurrentSerialNumberLogChanged += HandleSerialNumberLogsChanged;
85+
SerializationService.CurrentProductionLogPartChanged += HandleProductionLogPartsChanged;
8686
SerializationService.CurrentProductNumberChanged += HandleProductNumberChanged;
87-
_serialNumberLogs = SerializationService.CurrentSerialNumberLogs;
87+
ProductionLogParts = SerializationService.CurrentProductionLogParts;
8888

8989
IsLoading = false;
9090
}
@@ -310,7 +310,7 @@ protected async Task HandleSubmit()
310310
}
311311

312312

313-
bool allStepsHavePartsNeeded = _serialNumberLogs.Count >= totalPartsNeeded;
313+
bool allStepsHavePartsNeeded = ProductionLogParts.Count >= totalPartsNeeded;
314314

315315
if (!allStepsHavePartsNeeded)
316316
{
@@ -353,12 +353,16 @@ private async Task CompleteSubmit()
353353
{
354354
await ProductionLogService.UpdateAsync(ProductionLog);
355355
}
356+
357+
if (ActiveWorkInstruction is { ShouldGenerateQrCode: true })
358+
{
359+
await PrintQRCode();
360+
}
356361

357-
await PrintQRCode();
358362
ToastService.ShowSuccess("Successfully Created Production Log", 3000);
359363

360364
// Create any associated SerialNumberLogs
361-
await SerializationService.SaveCurrentSerialNumberLogsAsync(ProductionLog.Id);
365+
await SerializationService.SaveCurrentProductionLogPartsAsync(ProductionLog.Id);
362366

363367
// Reset the local storage values
364368
await LocalCacheManager.SetNewProductionLogFormAsync(null);
@@ -369,9 +373,9 @@ private async Task CompleteSubmit()
369373
await ResetFormState();
370374
}
371375

372-
private void HandleSerialNumberLogsChanged()
376+
private void HandleProductionLogPartsChanged()
373377
{
374-
_serialNumberLogs = SerializationService.CurrentSerialNumberLogs;
378+
ProductionLogParts = SerializationService.CurrentProductionLogParts;
375379

376380
InvokeAsync(StateHasChanged);
377381
}
@@ -492,7 +496,7 @@ await Task.Run(() =>
492496
/// <inheritdoc />
493497
public async ValueTask DisposeAsync()
494498
{
495-
SerializationService.CurrentSerialNumberLogChanged -= HandleSerialNumberLogsChanged;
499+
SerializationService.CurrentProductionLogPartChanged -= HandleProductionLogPartsChanged;
496500
SerializationService.CurrentProductNumberChanged -= HandleProductNumberChanged;
497501
ProductionLogEventService.AutoSaveTriggered -= _autoSaveHandler;
498502
try

MESS/MESS.Blazor/Components/Pages/ProductionLog/CreateHeader.razor

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@using MESS.Data.Models
22
@using MESS.Services.ProductionLog
3-
@using Microsoft.AspNetCore.Components.Authorization
4-
@inject IProductionLogEventService ProductionLogEventService
3+
@inject NavigationManager NavigationManager
54

65
<div class="d-flex justify-content-between gap-4 flex-sm-wrap header-container">
76

@@ -13,6 +12,10 @@
1312
@if (!string.IsNullOrWhiteSpace(ActiveLineOperator))
1413
{
1514
<div class="d-flex align-items-center justify-content-end">
15+
<button class="btn btn-primary btn-sm me-4" @onclick="NavigateToLogs">
16+
<i class="bi bi-card-list me-1"></i>My Production Logs
17+
</button>
18+
1619
<span class="me-3">@ActiveLineOperator</span>
1720
<form method="post" action="/api/auth/logout">
1821
<button type="submit" class="btn btn-danger btn-sm">
@@ -68,4 +71,9 @@ else
6871
/// </summary>
6972
[Parameter]
7073
public string? ActiveLineOperator { get; set; }
74+
75+
private void NavigateToLogs()
76+
{
77+
NavigationManager.NavigateTo("/production-logs");
78+
}
7179
}

MESS/MESS.Blazor/Components/Pages/ProductionLog/RequiredPartInput.razor

Lines changed: 0 additions & 23 deletions
This file was deleted.

MESS/MESS.Blazor/Components/Pages/ProductionLog/RequiredPartsList.razor

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
@using MESS.Data.Models
2+
@using MESS.Services.Serialization
3+
@inject ISerializationService SerializationService
4+
5+
@if (_initialized)
6+
{
7+
<RequiredPartsList ProductionLogParts="ProductionLogParts" AfterSerialNumberInput="@AfterSerialNumberInput" />
8+
}
9+
10+
@code {
11+
12+
/// <summary>
13+
/// The part node that contains the parts to be displayed.
14+
/// This parameter is required.
15+
/// </summary>
16+
[Parameter]
17+
public required PartNode PartNode { get; set; }
18+
19+
private List<ProductionLogPart> ProductionLogParts { get; set; } = [];
20+
private bool _initialized = false;
21+
22+
/// <inheritdoc />
23+
protected override void OnAfterRender(bool firstRender)
24+
{
25+
base.OnAfterRender(firstRender);
26+
27+
if (firstRender)
28+
{
29+
_initialized = true;
30+
StateHasChanged();
31+
}
32+
}
33+
34+
/// <inheritdoc />
35+
protected override void OnParametersSet()
36+
{
37+
base.OnParametersSet();
38+
InitializeProductionLogParts();
39+
}
40+
41+
42+
/// Each part gets its own production log part
43+
private void InitializeProductionLogParts()
44+
{
45+
// No need to initialize production log parts if they are present in the UI
46+
if (ProductionLogParts.Count > 0)
47+
{
48+
return;
49+
}
50+
51+
foreach (var part in PartNode.Parts)
52+
{
53+
ProductionLogParts.Add(new ProductionLogPart
54+
{
55+
Part = part
56+
});
57+
}
58+
}
59+
60+
private void AfterSerialNumberInput(ProductionLogPart productionLogPart)
61+
{
62+
productionLogPart.SubmitTimeQc = DateTimeOffset.UtcNow;
63+
64+
var updatedList = new List<ProductionLogPart>(SerializationService.CurrentProductionLogParts);
65+
updatedList.Add(productionLogPart);
66+
67+
SerializationService.CurrentProductionLogParts = updatedList;
68+
}
69+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@using MESS.Data.Models
2+
3+
<div class="form-floating flex-grow-1 m-0">
4+
<InputText id="productionLogPart" class="form-control col custom-input" @bind-Value="@ActiveProductionLogPart.PartSerialNumber"
5+
@bind-Value:after="@(() => AfterSerialNumberInput.InvokeAsync(ActiveProductionLogPart))"></InputText>
6+
<label class="form-label col custom-label" for="productionLogPart" style="color: gray; background-color: transparent;">@ActiveProductionLogPart.Part?.PartName</label>
7+
</div>
8+
9+
@code {
10+
/// <summary>
11+
/// The active production log part.
12+
/// This parameter is required.
13+
/// </summary>
14+
[Parameter]
15+
public required ProductionLogPart ActiveProductionLogPart { get; set; }
16+
17+
/// <summary>
18+
/// The callback to be invoked after the serial number input is updated.
19+
/// This parameter is required.
20+
/// </summary>
21+
[Parameter]
22+
public required EventCallback<ProductionLogPart> AfterSerialNumberInput { get; set; }
23+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@using MESS.Data.Models
2+
<div class="d-flex flex-wrap gap-2 mt-2 justify-content-around align-content-center">
3+
@foreach (var log in ProductionLogParts)
4+
{
5+
<RequiredPartInput ActiveProductionLogPart="log" AfterSerialNumberInput="AfterSerialNumberInput" />
6+
}
7+
</div>
8+
9+
@code {
10+
/// <summary>
11+
/// A list of production log parts to be displayed in the component.
12+
/// </summary>
13+
[Parameter] public required List<ProductionLogPart> ProductionLogParts { get; set; }
14+
15+
/// <summary>
16+
/// An event callback triggered after a serial number input is processed.
17+
/// </summary>
18+
[Parameter]
19+
public required EventCallback<ProductionLogPart> AfterSerialNumberInput { get; set; }
20+
}

MESS/MESS.Blazor/Components/Pages/ProductionLog/RequiredPartsList.razor.js renamed to MESS/MESS.Blazor/Components/Pages/ProductionLog/WorkInstructionNodes/PartNode/RequiredPartsList.razor.js

File renamed without changes.

0 commit comments

Comments
 (0)