Skip to content

Commit 541cc22

Browse files
committed
Persist search parameters in the web ui.
1 parent 765a508 commit 541cc22

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

src/SlimGet/Controllers/GalleryController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public async Task<IActionResult> Packages([FromQuery] int skip, CancellationToke
6969
var count = await dbpackages.CountAsync(cancellationToken);
7070
var next = skip + 20 <= count ? skip + 20 : -1;
7171

72-
return this.View("Packages", new GallerySearchListingModel(count, this.PreparePackages(dbpackages.Skip(skip).Take(20)), next, skip - 20, null));
72+
return this.View("Packages", new GallerySearchListModel(count, this.PreparePackages(dbpackages.Skip(skip).Take(20)), next, skip - 20, null));
7373
}
7474

7575
[HttpGet, SlimGetRoute(Routing.GalleryPackageRouteName)]
@@ -127,7 +127,7 @@ public async Task<IActionResult> Search([FromQuery] GallerySearchModel search, C
127127
var count = await dbpackages.CountAsync(cancellationToken);
128128
var next = skip + 20 <= count ? skip + 20 : -1;
129129

130-
return this.View("Packages", new GallerySearchListingModel(count, this.PreparePackages(dbpackages.Skip(skip).Take(20), prerelease), next, skip - 20, search));
130+
return this.View("Packages", new GallerySearchListModel(count, this.PreparePackages(dbpackages.Skip(skip).Take(20), prerelease), next, skip - 20, search));
131131
}
132132

133133
[HttpGet, SlimGetRoute(Routing.GalleryAboutRouteName)]

src/SlimGet/Models/GalleryModels.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public sealed class GalleryPackageListItemModel
7979
public string Description { get; set; }
8080
}
8181

82-
public sealed class GallerySearchListingModel
82+
public sealed class GallerySearchListModel
8383
{
8484
public int TotalCount { get; }
8585
public IEnumerable<GalleryPackageListItemModel> Items { get; }
@@ -89,7 +89,7 @@ public sealed class GallerySearchListingModel
8989
public bool IncludePrerelease => this.SearchQuery.Prerelease;
9090
public GallerySearchModel SearchQuery { get; }
9191

92-
public GallerySearchListingModel(int total, IEnumerable<GalleryPackageListItemModel> items, int next, int prev, GallerySearchModel searchQuery)
92+
public GallerySearchListModel(int total, IEnumerable<GalleryPackageListItemModel> items, int next, int prev, GallerySearchModel searchQuery)
9393
{
9494
this.TotalCount = total;
9595
this.Items = items;

src/SlimGet/Views/Gallery/Packages.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
limitations under the License.
1717
*@
1818

19-
@model GallerySearchListingModel
19+
@model GallerySearchListModel
2020
@{
2121
ViewData["Title"] = string.IsNullOrWhiteSpace(this.Model.Query) ? "Packages hosted in this feed" : "Package search results";
2222
}

src/SlimGet/Views/Gallery/SearchForm.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
<div class="search-form">
2323
<form method="get" asp-route="@Routing.GallerySearchRouteName">
2424
<div class="search-group search-query-group">
25-
<input type="text" name="q" placeholder="Search packages" />
25+
<input type="text" name="q" placeholder="Search packages" value="@this.Model?.Query" />
2626
<button type="submit"><i class="fas fa-search"></i></button>
2727
</div>
2828

2929
<div class="search-group search-prerelease-group">
30-
<input type="checkbox" name="pre" value="true" id="form-input-prerelease" />
30+
<input type="checkbox" name="pre" value="true" id="form-input-prerelease" @if (this.Model?.Prerelease == true) { <text>checked="checked"</text> } />
3131
<label for="form-input-prerelease"><i class="fas fa-check"></i></label>
3232
<label for="form-input-prerelease">Include prerelease packages</label>
3333
</div>

src/SlimGet/wwwroot/css/slimget.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ p.navigation > .navigation-pipe
441441
{
442442
font-size: 14pt;
443443
display: flex;
444+
flex-direction: row;
444445
}
445446

446447
.search-form > form > .search-query-group > input,
@@ -454,7 +455,7 @@ p.navigation > .navigation-pipe
454455
line-height: 28pt;
455456

456457
vertical-align: top;
457-
flex-direction: row;
458+
border-radius: 0;
458459

459460
transition: all 0.2s;
460461
}

0 commit comments

Comments
 (0)