• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

samsmithnz / SatisfactoryTree / 17925206634

22 Sep 2025 06:44PM UTC coverage: 66.166% (-2.0%) from 68.215%
17925206634

Pull #314

github

web-flow
Merge b687d718f into 9b5cf3f1d
Pull Request #314: Add "Add exported Part" button functionality to factory exported parts section

427 of 754 branches covered (56.63%)

Branch coverage included in aggregate %.

0 of 54 new or added lines in 3 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

1159 of 1643 relevant lines covered (70.54%)

1126.78 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/SatisfactoryTree.Web/Components/FactoryItems.razor
1
@using SatisfactoryTree.Logic.Models
2
@using SatisfactoryTree.Web.Services
3
@inject IFactoryItemDisplayService DisplayService
4
@inject PlanService PlanService
5

6
@code {
7
    [Parameter]
8
    public Factory? Factory { get; set; }
×
9
    [Parameter]
10
    public Dictionary<string, Part>? Parts { get; set; }
×
11

NEW
12
    private bool isAddingExportedPart = false;
×
NEW
13
    private Part? selectedPartToExport = null;
×
NEW
14
    private double exportedQuantity = 1.0;
×
15

16
    private void OnPartSelected(Part selectedPart, Item item)
17
    {
×
18
        item.Name = selectedPart.Name ?? selectedPart.Name ?? "";
×
19
        StateHasChanged();
×
20
    }
×
21

22
    private Part? GetCurrentPart(Item item)
23
    {
×
24
        if (Parts == null) return null;
×
25
        Parts.TryGetValue(item.Name, out Part? part);
×
26
        return part;
×
27
    }
×
28

29
    private void StartAddingExportedPart()
NEW
30
    {
×
NEW
31
        isAddingExportedPart = true;
×
NEW
32
        selectedPartToExport = null;
×
NEW
33
        exportedQuantity = 1.0;
×
NEW
34
        StateHasChanged();
×
NEW
35
    }
×
36

37
    private void CancelAddingExportedPart()
NEW
38
    {
×
NEW
39
        isAddingExportedPart = false;
×
NEW
40
        selectedPartToExport = null;
×
NEW
41
        StateHasChanged();
×
NEW
42
    }
×
43

44
    private void OnExportPartSelected(Part selectedPart)
NEW
45
    {
×
NEW
46
        selectedPartToExport = selectedPart;
×
NEW
47
        StateHasChanged();
×
NEW
48
    }
×
49

50
    private void AddExportedPart()
NEW
51
    {
×
NEW
52
        if (Factory != null && selectedPartToExport != null)
×
NEW
53
        {
×
NEW
54
            var newItem = new Item { Name = selectedPartToExport.Name, Quantity = exportedQuantity };
×
NEW
55
            var exportedItem = new ExportedItem(newItem);
×
NEW
56
            Factory.ExportedParts.Add(exportedItem);
×
57
            
58
            // Update calculations after adding the exported part
NEW
59
            if (PlanService.Plan != null && PlanService.FactoryCatalog != null)
×
NEW
60
            {
×
NEW
61
                PlanService.Plan.UpdatePlanCalculations(PlanService.FactoryCatalog);
×
NEW
62
                PlanService.NotifyPlanChanged();
×
NEW
63
            }
×
64
            
NEW
65
            isAddingExportedPart = false;
×
NEW
66
            selectedPartToExport = null;
×
NEW
67
            StateHasChanged();
×
NEW
68
        }
×
NEW
69
    }
×
70
}
71

72
@if (Factory != null)
×
73
{
×
74
    <div class="factory-container">
75
        <h3><input type="text" value="@Factory.Name" class="form-control" /></h3>
76
        @if (Factory.ExportedParts != null && Factory.ExportedParts.Any())
×
77
        {
×
78
            <p><b>Exported parts:</b></p>
79
            <ul>
80
                @foreach (ExportedItem item in Factory.ExportedParts)
×
81
                {
×
82
                    <li>
83
                        <img src="@DisplayService.GetPartImagePath(item.Item.Name)" alt="@item.Item.Name" class="part-image" />
84
                                                <strong>@item.Item.Name</strong> - @item.Item.Quantity per/min (@item.PartQuantityExported per/min exported)
×
85
                    </li>
86
                }
×
87
            </ul>
88

NEW
89
            @if (!isAddingExportedPart)
×
NEW
90
            {
×
91
                <button class="btn btn-primary me-2" @onclick="StartAddingExportedPart">Add Exported Part</button>
NEW
92
            }
×
93
            else
NEW
94
            {
×
95
                <div class="add-exported-part-form">
96
                    <h5>Add New Exported Part</h5>
97
                    <div class="mb-2">
98
                        <label>Select Part:</label>
99
                        <TypeaheadDropdown TItem="Part"
100
                                         Items="@(Parts?.Values)"
NEW
101
                                         DisplayNameSelector="@(part => DisplayService.GetPartDisplayName(part))"
×
NEW
102
                                         IdSelector="@(part => DisplayService.GetPartDisplayName(part))"
×
103
                                         SelectedItem="@selectedPartToExport"
104
                                         SelectedItemChanged="@OnExportPartSelected"
105
                                         Placeholder="Search for parts to export..."
106
                                         CssClass="me-2">
107
                            <ItemTemplate Context="part">
NEW
108
                                <strong>@DisplayService.GetPartDisplayName(part)</strong>
×
NEW
109
                                @if (DisplayService.GetPartIsFluid(part))
×
NEW
110
                                {
×
111
                                    <span class="badge badge-small badge-fluid">Fluid</span>
NEW
112
                                }
×
NEW
113
                                @if (DisplayService.GetPartIsFicsmas(part))
×
NEW
114
                                {
×
115
                                    <span class="badge badge-small badge-ficsmas">FICSMAS</span>
NEW
116
                                }
×
117
                            </ItemTemplate>
118
                        </TypeaheadDropdown>
119
                    </div>
120
                    <div class="mb-2">
121
                        <label>Quantity per/min:</label>
122
                        <input type="number" class="form-control" @bind="exportedQuantity" min="0" step="0.1" />
123
                    </div>
124
                    <div>
125
                        <button class="btn btn-success me-2" @onclick="AddExportedPart" disabled="@(selectedPartToExport == null)">Add</button>
126
                        <button class="btn btn-secondary" @onclick="CancelAddingExportedPart">Cancel</button>
127
                    </div>
128
                </div>
NEW
129
            }
×
130

131
            <p><b>Component parts:</b></p>
132
            <ul>
133
                @if (Factory.ComponentParts != null && Factory.ComponentParts.Any())
×
134
                {
×
135
                    @foreach (Item item in Factory.ComponentParts)
×
136
                    {
×
137
                        <li>
138
                            <div class="component-part-row">
139
                                <img src="@DisplayService.GetPartImagePath(item.Name)" alt="@item.Name" class="part-image" />
140
                                <TypeaheadDropdown TItem="Part"
141
                                                 Items="@(Parts?.Values)"
142
                                                 DisplayNameSelector="@(part => DisplayService.GetPartDisplayName(part))"
×
143
                                                 IdSelector="@(part => DisplayService.GetPartDisplayName(part))"
×
144
                                                 SelectedItem="@GetCurrentPart(item)"
145
                                                 SelectedItemChanged="@(part => OnPartSelected(part, item))"
×
146
                                                 Placeholder="Search for parts..."
147
                                                 CssClass="me-2">
148
                                    <ItemTemplate Context="part">
149
                                        <strong>@DisplayService.GetPartDisplayName(part)</strong>
×
150
                                        @if (DisplayService.GetPartIsFluid(part))
×
151
                                        {
×
152
                                            <span class="badge badge-small badge-fluid">Fluid</span>
153
                                        }
×
154
                                        @if (DisplayService.GetPartIsFicsmas(part))
×
155
                                        {
×
156
                                            <span class="badge badge-small badge-ficsmas">FICSMAS</span>
157
                                        }
×
158
                                    </ItemTemplate>
159
                                </TypeaheadDropdown>
160
                                <span class="quantity-label">Quantity:</span>
161
                                <input type="text" value="@item.Quantity.ToString()" class="form-control quantity-input" />
162
                            </div>
163
                            
164
                            <div class="component-badges">
165
                                @if (item.Ingredients != null)
×
166
                                {
×
167
                                    @foreach (Item ingredient in item.Ingredients)
×
168
                                    {
×
169
                                        <span class="badge badge-blue">
170
                                            <img src="@DisplayService.GetPartImagePath(ingredient.Name)" alt="@ingredient.Name" class="ingredient-image" />
171
                                            @ingredient.Name @ingredient.Quantity per/min
×
172
                                        </span>
173
                                    }
×
174
                                }
×
175
                                <span class="badge badge-yellow"> 
176
                                    @if (!string.IsNullOrEmpty(item.Building) && DisplayService.HasBuildingImage(item.Building))
×
177
                                    {
×
178
                                        <img src="@DisplayService.GetBuildingImagePath(item.Building)" alt="@item.Building" class="building-image" />
179
                                    }
×
180
                                    else if (!string.IsNullOrEmpty(item.Building))
×
181
                                    {
×
182
                                        <i class="fas fa-building building-icon" title="@item.Building"></i>
183
                                    }
×
184
                                    @item.Building x @Math.Round(item.BuildingQuantity, 2)
×
185
                                </span>
186
                                <span class="badge badge-grey">
187
                                    <i class="fas fa-bolt power-icon" title="Power Usage"></i> @Math.Round(item.BuildingPowerUsage, 1) MW
×
188
                                </span>
189
                            </div>
190
                        </li>
191
                        <hr>
192
                    }
×
193
                }
×
194
                else
195
                {
×
196
                    <li>No component parts.</li>
197
                }
×
198
            </ul>
199

200
            <p><b>Imported parts:</b></p>
201
            <ul>
202
                @if (Factory.ImportedParts != null && Factory.ImportedParts.Any())
×
203
                {
×
204
                    @foreach (KeyValuePair<int, ImportedItem> item in Factory.ImportedParts)
×
205
                    {
×
206
                        <li>
207
                            <img src="@DisplayService.GetPartImagePath(item.Value.Item.Name)" alt="@item.Value.Item.Name" class="part-image" />
208
                            <strong>@item.Value.Item.Name</strong> - Quantity: @item.Value.Item.Quantity - from factory: @item.Value.FactoryName (@item.Value.PartQuantityImported per/min imported)
×
209
                        </li>
210
                    }
×
211
                }
×
212
                else
213
                {
×
214
                    <li>No imported parts.</li>
215
                }
×
216
            </ul>
217

218
            <p><b>Raw resources:</b></p>
219
            <span class="badge badge-blue">
220
                <img src='@DisplayService.GetPartImagePath("OreIron")' alt="OreIron" class="ingredient-image" />
221
                <span>Iron Ore 60 per/min</span>
222
            </span>
223
        }
×
224
        else
225
        {
×
226
            <p>No items in this factory.</p>
227
        }
×
228
    </div>
229
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc