Permalink
Browse files

add show all packages option on userprofile

  • Loading branch information...
1 parent d25db2e commit f683d296cfd4f725523f3d1afdae63cca6eca70b @robertmuehsig robertmuehsig committed Jun 18, 2014
@@ -66,6 +66,12 @@ h6 {
font-size: 1em;
}
+
+small {
+ font-size: 0.5em;
+}
+
+
h1 img, h2 img, h3 img,
h4 img, h5 img, h6 img {
margin: 0;
@@ -253,7 +253,7 @@ public virtual ActionResult ResetPassword(bool forgot)
return View(model);
}
- public virtual ActionResult Profiles(string username, int page = 1)
+ public virtual ActionResult Profiles(string username, int page = 1, bool showAllPackages = false)
{
var user = UserService.FindByUsername(username);
if (user == null)
@@ -270,6 +270,7 @@ public virtual ActionResult Profiles(string username, int page = 1)
}).ToList();
var model = new UserProfileModel(user, packages, page - 1, Constants.DefaultPackageListPageSize, Url);
+ model.ShowAllPackages = showAllPackages;
return View(model);
}
@@ -222,6 +222,16 @@ public static string User(this UrlHelper url, User user, int page = 1, string sc
return result;
}
+ public static string UserShowAllPackages(this UrlHelper url, string username, string scheme = null)
+ {
+ string result;
+ result = url.Action(actionName: "Profiles",
+ controllerName: "Users",
+ routeValues: new { username = username, showAllPackages = true },
+ protocol: scheme);
+ return result;
+ }
+
public static string EditPackage(this UrlHelper url, string id, string version)
{
if (String.IsNullOrEmpty(version))
@@ -39,6 +39,6 @@ public UserProfileModel(User user, List<PackageViewModel> allPackages, int pageI
public int PackagePage { get; private set; }
public int PackagePageSize { get; private set; }
public IPreviousNextPager Pager { get; private set; }
-
+ public bool ShowAllPackages { get; set; }
}
}
@@ -25,12 +25,22 @@
<h1 class="page-heading">@Model.Username's Profile</h1>
<h2>Packages
- @if (Model.PackagePageTotalCount > 1)
+@if (Model.PackagePageTotalCount > 1 && Model.ShowAllPackages == false)
{
- <small>(Page @(Model.PackagePage + 1) of @Model.PackagePageTotalCount)</small>
-}</h2>
+ <small>(Page @(Model.PackagePage + 1) of @Model.PackagePageTotalCount) <a href="@Url.UserShowAllPackages(Model.Username)">Show all packages</a></small>
+}
+</h2>
<ul id="searchResults">
- @foreach (var package in Model.PagedPackages)
+@{
+ var allOrPagedPackages = Model.PagedPackages;
+
+ if (Model.ShowAllPackages)
+ {
+ allOrPagedPackages = Model.AllPackages;
+ }
+}
+
+ @foreach (var package in allOrPagedPackages)
{
<li>
<section class="package">
@@ -65,4 +75,8 @@
}
</ul>
-@ViewHelpers.PreviousNextPager(Model.Pager)
+@if (Model.ShowAllPackages == false)
+{
+ @ViewHelpers.PreviousNextPager(Model.Pager)
+}
+

0 comments on commit f683d29

Please sign in to comment.