Skip to content

Commit 866de3e

Browse files
committed
Merge branch 'import-overhaul' into import-overhaul+CSS
2 parents 901db23 + 03a4571 commit 866de3e

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

MESS/MESS.Blazor/Components/Pages/ProductionLog/WorkInstructionNodes/StepNodeListItem.razor

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,26 +92,35 @@
9292
</div>
9393

9494
<div class="col col-md-6 secondary-content">
95-
@if (Step.PrimaryMedia.Count > 0 || Step.SecondaryMedia.Count > 0)
95+
@if (Step.PrimaryMedia.Count > 0 || Step.SecondaryMedia.Count > 0)
9696
{
97-
98-
@if (ShowDetails && Step.SecondaryMedia.Count > 0)
97+
@if (ShowDetails)
9998
{
100-
<Carousel
101-
Images="@Step.SecondaryMedia"
102-
AutoPlay="false"
103-
Interval="3000"
104-
ImageStyle="height: 500px; object-fit: contain;" />
99+
if (Step.SecondaryMedia.Count > 0)
100+
{
101+
<Carousel
102+
Images="@Step.SecondaryMedia"
103+
AutoPlay="false"
104+
Interval="3000"
105+
ImageStyle="height: 500px; object-fit: contain;" />
106+
}
107+
else if (Step.PrimaryMedia.Count > 0)
108+
{
109+
<Carousel
110+
Images="@Step.PrimaryMedia"
111+
AutoPlay="false"
112+
Interval="3000"
113+
ImageStyle="height: 500px; object-fit: contain;" />
114+
}
105115
}
106-
else if (!ShowDetails && Step.PrimaryMedia.Count > 0)
116+
else if (Step.PrimaryMedia.Count > 0)
107117
{
108118
<Carousel
109119
Images="@Step.PrimaryMedia"
110120
AutoPlay="false"
111121
Interval="3000"
112122
ImageStyle="height: 500px; object-fit: contain;" />
113123
}
114-
115124
}
116125
</div>
117126
</div>

MESS/MESS.Services/WorkInstruction/WorkInstructionService.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,16 @@ public async Task<WorkInstructionImportResult> ImportFromXlsx(IBrowserFile file)
741741
var shouldGenerateQrCode = worksheet.Cell(SHOULD_GENERATE_QR_CODE_CELL).GetValue<bool>();
742742
var collectsProductSerialNumber = worksheet.Cell(COLLECTS_PRODUCT_SERIAL_NUMBER_CELL).GetValue<bool>();
743743

744+
// Retrieve Product and assign relationship
745+
var productString = worksheet.Cell(PRODUCT_NAME_CELL).GetString();
746+
var product = await _productService.FindByTitleAsync(productString);
747+
748+
if (product == null)
749+
{
750+
Log.Information("Product not found. Cannot create Work Instruction");
751+
return WorkInstructionImportResult.NoProductFound(file.Name, productString);
752+
}
753+
744754
var originalIdString = worksheet.Cell(ORIGINAL_ID_CELL).GetString()?.Trim();
745755
int? originalId = null;
746756

@@ -760,7 +770,7 @@ public async Task<WorkInstructionImportResult> ImportFromXlsx(IBrowserFile file)
760770
else
761771
{
762772
versionQuery = context.WorkInstructions
763-
.Where(w => w.Title == workInstructionTitle);
773+
.Where(w => w.Title == workInstructionTitle && w.Products.Any(p => p.Id == product.Id));
764774
}
765775

766776
// Duplicate check
@@ -804,16 +814,6 @@ public async Task<WorkInstructionImportResult> ImportFromXlsx(IBrowserFile file)
804814
}
805815
}
806816

807-
// Retrieve Product and assign relationship
808-
var productString = worksheet.Cell(PRODUCT_NAME_CELL).GetString();
809-
var product = await _productService.FindByTitleAsync(productString);
810-
811-
if (product == null)
812-
{
813-
Log.Information("Product not found. Cannot create Work Instruction");
814-
return WorkInstructionImportResult.NoProductFound(file.Name, productString);
815-
}
816-
817817
workInstruction.Products.Add(product);
818818

819819
// Create all steps within instruction and add part nodes where logical

0 commit comments

Comments
 (0)