Refactor AddParam to AddParamIfExist (#29834)
When read the code: `pager.AddParam(ctx, "search", "search")`, the
question always comes: What is it doing? Where is the value from? Why
"search" / "search" ?
Now it is clear: `pager.AddParamIfExist("search", ctx.Data["search"])`
This commit is contained in:
@@ -125,8 +125,8 @@ func ListPackages(ctx *context.Context) {
|
||||
}
|
||||
|
||||
pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5)
|
||||
pager.AddParam(ctx, "q", "Query")
|
||||
pager.AddParam(ctx, "type", "PackageType")
|
||||
pager.AddParamIfExist("q", ctx.Data["Query"])
|
||||
pager.AddParamIfExist("type", ctx.Data["PackageType"])
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.HTML(http.StatusOK, tplPackagesList)
|
||||
|
||||
Reference in New Issue
Block a user