Skip to content

Commit 95eab55

Browse files
authored
Merge pull request #1071 from hargata/Hargata/make.search.optional
make garage search optional
2 parents 08fdd5e + 9dccce7 commit 95eab55

6 files changed

Lines changed: 34 additions & 18 deletions

File tree

Helper/ConfigHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,8 @@ public UserConfig GetUserConfig(ClaimsPrincipal user)
392392
TabOrder = _config.GetSection(nameof(UserConfig.TabOrder)).Get<List<ImportMode>>() ?? new UserConfig().TabOrder,
393393
UserColumnPreferences = _config.GetSection(nameof(UserConfig.UserColumnPreferences)).Get<List<UserColumnPreference>>() ?? new List<UserColumnPreference>(),
394394
DefaultTab = (ImportMode)int.Parse(CheckString(nameof(UserConfig.DefaultTab), "8")),
395-
ShowVehicleThumbnail = CheckBool(CheckString(nameof(UserConfig.ShowVehicleThumbnail)))
395+
ShowVehicleThumbnail = CheckBool(CheckString(nameof(UserConfig.ShowVehicleThumbnail))),
396+
ShowSearch = CheckBool(CheckString(nameof(UserConfig.ShowSearch)))
396397
};
397398
int userId = 0;
398399
if (user != null)

Models/UserConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class UserConfig
2424
public bool UseUnitForFuelCost { get; set; }
2525
public bool ShowCalendar { get; set; }
2626
public bool ShowVehicleThumbnail { get; set; }
27+
public bool ShowSearch { get; set; }
2728
public List<UserColumnPreference> UserColumnPreferences { get; set; } = new List<UserColumnPreference>();
2829
public string UserNameHash { get; set; }
2930
public string UserPasswordHash { get; set;}

Views/Home/_GarageDisplay.cshtml

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,40 @@
66
var userConfig = config.GetUserConfig(User);
77
var userLanguage = userConfig.UserLanguage;
88
var recordTags = Model.SelectMany(x => x.Tags).Distinct();
9+
var tagsExist = recordTags.Any();
10+
var searchExist = userConfig.ShowSearch && Model.Count() > 1;
11+
var renderTopRow = tagsExist || searchExist;
912
}
10-
@if (recordTags.Any())
13+
@if (renderTopRow)
1114
{
1215
<div class='row'>
13-
<div class="col-xl-10 col-lg-9 col-md-8 col-sm-8 col-12 d-flex align-items-center flex-wrap mb-2">
14-
@foreach (string recordTag in recordTags)
15-
{
16-
<span onclick="filterGarage(this)" class="user-select-none ms-1 me-1 mt-1 mb-1 rounded-pill badge bg-secondary tagfilter" style="cursor:pointer;">@recordTag</span>
17-
}
18-
<datalist id="tagList">
16+
@if (tagsExist)
17+
{
18+
<div class="@(searchExist ? "col-xl-10 col-lg-9 col-md-8 col-sm-8" : "") col-12 d-flex align-items-center flex-wrap mb-2">
1919
@foreach (string recordTag in recordTags)
2020
{
21-
<!option value="@recordTag"></!option>
21+
<span onclick="filterGarage(this)" class="user-select-none ms-1 me-1 mt-1 mb-1 rounded-pill badge bg-secondary tagfilter" style="cursor:pointer;">@recordTag</span>
2222
}
23-
</datalist>
24-
</div>
25-
<div class="col-xl-2 col-lg-3 col-md-4 col-sm-4 col-12 pt-2 pb-2">
26-
<div class="input-group">
27-
<input type="text" id="garageSearchInput" class="form-control" onkeyup="handleGarageSearchKeyPress(event)" placeholder="@translator.Translate(userLanguage, "Search")" />
28-
<button type="button" class="btn btn-outline-secondary" onclick="searchGarage()"><i class="bi bi-search"></i></button>
23+
<datalist id="tagList">
24+
@foreach (string recordTag in recordTags)
25+
{
26+
<!option value="@recordTag"></!option>
27+
}
28+
</datalist>
2929
</div>
30-
</div>
30+
}
31+
@if (searchExist)
32+
{
33+
<div class="@(tagsExist ? "col-xl-2 col-lg-3 col-md-4 col-sm-4" : "") col-12 pt-2 pb-2">
34+
<div class="input-group">
35+
<input type="text" id="garageSearchInput" class="form-control" onkeyup="handleGarageSearchKeyPress(event)" placeholder="@translator.Translate(userLanguage, "Search")" />
36+
<button type="button" class="btn btn-outline-secondary" onclick="searchGarage()"><i class="bi bi-search"></i></button>
37+
</div>
38+
</div>
39+
}
3140
</div>
3241
}
33-
<div class="row gy-3 align-items-stretch vehiclesContainer pb-2 @(recordTags.Any() ? "" : "mt-2")">
42+
<div class="row gy-3 align-items-stretch vehiclesContainer pb-2 @(renderTopRow ? "" : "mt-2")">
3443
@foreach (VehicleViewModel vehicle in Model)
3544
{
3645
@if (!(userConfig.HideSoldVehicles && !string.IsNullOrWhiteSpace(vehicle.SoldDate)))

Views/Home/_Settings.cshtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="showVehicleThumbnail" checked="@Model.UserConfig.ShowVehicleThumbnail">
5858
<label class="form-check-label" for="showVehicleThumbnail">@translator.Translate(userLanguage, "Show Vehicle Thumbnail in Header")</label>
5959
</div>
60+
<div class="form-check form-switch form-check-inline">
61+
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="showGarageSearch" checked="@Model.UserConfig.ShowSearch">
62+
<label class="form-check-label" for="showGarageSearch">@translator.Translate(userLanguage, "Show Garage Search")</label>
63+
</div>
6064
<hr />
6165
<div class="form-check form-switch">
6266
<input class="form-check-input" onChange="updateSettings()" type="checkbox" role="switch" id="useMPG" checked="@Model.UserConfig.UseMPG">

wwwroot/defaults/en_US.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

wwwroot/js/settings.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function updateSettings() {
6060
enableShopSupplies: $("#enableShopSupplies").is(":checked"),
6161
showCalendar: $("#showCalendar").is(":checked"),
6262
showVehicleThumbnail: $("#showVehicleThumbnail").is(":checked"),
63+
showSearch: $("#showGarageSearch").is(":checked"),
6364
enableExtraFieldColumns: $("#enableExtraFieldColumns").is(":checked"),
6465
hideSoldVehicles: $("#hideSoldVehicles").is(":checked"),
6566
preferredGasUnit: $("#preferredGasUnit").val(),

0 commit comments

Comments
 (0)