M list/routes.go => list/routes.go +6 -2
@@ 1034,14 1034,17 @@ func (s *Service) ListingList(c echo.Context) error {
op.Var("orgSlug", org.Slug)
var tag, excludeTag string
+ queries := make(url.Values)
if c.QueryParam("tag") != "" {
tag = c.QueryParam("tag")
op.Var("tag", tag)
+ queries.Add("tag", tag)
}
if c.QueryParam("exclude") != "" {
excludeTag = c.QueryParam("exclude")
op.Var("excludeTag", excludeTag)
+ queries.Add("exclude", excludeTag)
}
if c.QueryParam("next") != "" {
@@ 1062,9 1065,10 @@ func (s *Service) ListingList(c echo.Context) error {
"org": org,
"navFlag": "listing",
"lists": result.Listings.Result,
- "tagFilter": tag,
- "excludeTagFilter": excludeTag,
+ "tagFilter": strings.Replace(tag, ",", ", ", -1),
+ "excludeTagFilter": strings.Replace(excludeTag, ",", ", ", -1),
"advancedSearch": true,
+ "queries": queries,
}
if result.Listings.PageInfo.HasPrevPage {
gmap["prevURL"] = links.GetPaginationParams("prev", tag, "", result.Listings.PageInfo.Cursor)
M static/js/advancedsearch.js => static/js/advancedsearch.js +12 -5
@@ 73,7 73,12 @@ form.addEventListener("submit", function(e) {
e.preventDefault();
var tagValue = form.elements.tag.value;
var excludeValue = form.elements.exclude.value;
- var qValue = form.elements.q.value;
+ var qValue = "";
+ var hasQ = false;
+ if (form.elements["q"] !== undefined) {
+ qValue = form.elements.q.value;
+ hasQ = true;
+ }
var qURL = new URLSearchParams();
if (tagValue === "") {
@@ 98,10 103,12 @@ form.addEventListener("submit", function(e) {
qURL.set("exclude", excludeValue);
}
- if (qValue === "") {
- form.elements.q.disabled = true;
- } else {
- qURL.set("q", qValue);
+ if (hasQ) {
+ if (qValue === "") {
+ form.elements.q.disabled = true;
+ } else {
+ qURL.set("q", qValue);
+ }
}
url = this.getAttribute("action");
M templates/listing_list.html => templates/listing_list.html +9 -9
@@ 3,12 3,10 @@
<h1 class="app-header__title">{{.org.Name}} {{.pd.Title}}</h1>
<a class="button primary is-small" href="{{reverse "list:listing_create" .org.Slug}}">{{.pd.Data.add}}</a>
</section>
-
-<section class="card shadow-card">
- {{if .advancedSearch}}
- <p><a href="#" id="advanced-search-btn">{{.pd.Data.advanced_search}}</a></p>
- <div id="advanced-search-div" {{if and (not .tagFilter) (not .excludeTagFilter)}}class="d-none"{{end}}>
- <form method="GET" id="advanced-search-form" action="{{.currURL}}">
+{{ if not .hideNav }}<p class="text-right"><a href="#" id="advanced-search-btn">{{.pd.Data.advanced_search}}</a></p>{{ end }}
+{{if and (not .hideNav) (.advancedSearch)}}
+ <section id="advanced-search-div" {{if and (not .tagFilter) (not .excludeTagFilter)}}class="d-none"{{end}}>
+ <form method="GET" id="advanced-search-form" action="{{reverse "list:listing_list" .org.Slug}}">
<div class="row">
<div class="col-5"><label>{{.pd.Data.include_tags}}</label></div>
<div class="col-5"><label>{{.pd.Data.exclude_tags}}</label></div>
@@ 29,8 27,10 @@
</div>
</div>
</form>
- </div>
- {{end}}
+ </section>
+{{end}}
+
+<section class="card shadow-card">
<table class="striped">
<thead>
<tr>
@@ 58,7 58,7 @@
<small class="link-tag__item">#{{.Name}}</small>
{{else}}
<a class="link-tag__item"
- href="{{if $.tagFilter}}?tag={{$.tagFilter}}, {{.Slug}}{{if $.excludeTagFilter}}&exclude={{$.excludeTagFilter}}{{end}}{{else}}?tag={{.Slug}}{{if $.excludeTagFilter}}&exclude={{$.excludeTagFilter}}{{end}}{{end}}">#{{.Name}}</a>
+ href="{{if $.queries}}?{{addQueryElement $.queries "tag" .Slug}}{{else}}?tag={{.Slug}}{{end}}">#{{.Name}}</a>
{{end}}
{{end}}
{{end}}