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

samsmithnz / SatisfactoryTree / 17921157049

22 Sep 2025 04:01PM UTC coverage: 66.639% (-1.6%) from 68.215%
17921157049

Pull #314

github

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

427 of 748 branches covered (57.09%)

Branch coverage included in aggregate %.

0 of 43 new or added lines in 1 file covered. (0.0%)

56 existing lines in 5 files now uncovered.

1159 of 1632 relevant lines covered (71.02%)

1134.38 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

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

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

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

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

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

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

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

49
    private void AddExportedPart()
NEW
50
    {
×
NEW
51
        if (Factory != null && selectedPartToExport != null)
×
NEW
52
        {
×
NEW
53
            var newItem = new Item { Name = selectedPartToExport.Name, Quantity = exportedQuantity };
×
NEW
54
            var exportedItem = new ExportedItem(newItem);
×
NEW
55
            Factory.ExportedParts.Add(exportedItem);
×
56
            
NEW
57
            isAddingExportedPart = false;
×
NEW
58
            selectedPartToExport = null;
×
NEW
59
            StateHasChanged();
×
NEW
60
        }
×
NEW
61
    }
×
62
}
63

64
@if (Factory != null)
×
65
{
×
66
    <div class="factory-container">
67
        <h3><input type="text" value="@Factory.Name" class="form-control" /></h3>
UNCOV
68
        @if (Factory.ExportedParts != null && Factory.ExportedParts.Any())
×
69
        {
×
70
            <p><b>Exported parts:</b></p>
71
            <ul>
72
                @foreach (ExportedItem item in Factory.ExportedParts)
×
73
                {
×
74
                    <li>
75
                        <img src="@DisplayService.GetPartImagePath(item.Item.Name)" alt="@item.Item.Name" class="part-image" />
76
                                                <strong>@item.Item.Name</strong> - @item.Item.Quantity per/min (@item.PartQuantityExported per/min exported)
×
77
                    </li>
78
                }
×
79
            </ul>
80

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

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

192
            <p><b>Imported parts:</b></p>
193
            <ul>
194
                @if (Factory.ImportedParts != null && Factory.ImportedParts.Any())
×
195
                {
×
196
                    @foreach (KeyValuePair<int, ImportedItem> item in Factory.ImportedParts)
×
197
                    {
×
198
                        <li>
199
                            <img src="@DisplayService.GetPartImagePath(item.Value.Item.Name)" alt="@item.Value.Item.Name" class="part-image" />
200
                            <strong>@item.Value.Item.Name</strong> - Quantity: @item.Value.Item.Quantity - from factory: @item.Value.FactoryName (@item.Value.PartQuantityImported per/min imported)
×
201
                        </li>
202
                    }
×
203
                }
×
204
                else
205
                {
×
206
                    <li>No imported parts.</li>
UNCOV
207
                }
×
208
            </ul>
209

210
            <p><b>Raw resources:</b></p>
211
            <span class="badge badge-blue">
212
                <img src='@DisplayService.GetPartImagePath("OreIron")' alt="OreIron" class="ingredient-image" />
213
                <span>Iron Ore 60 per/min</span>
214
            </span>
215
        }
×
216
        else
217
        {
×
218
            <p>No items in this factory.</p>
219
        }
×
220
    </div>
221
}
×
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

© 2025 Coveralls, Inc