From 47f92b096764b262fa40ae70f97cbb20dfe59830 Mon Sep 17 00:00:00 2001 From: Yader Velasquez Date: Tue, 13 Feb 2024 12:04:28 -0600 Subject: [PATCH] Add UI to shorts and links References: https://todo.code.netlandish.com/~netlandish/links/47 --- list/routes.go | 5 +++++ short/routes.go | 27 +++++++++++++++++++------ templates/link_short_list.html | 26 ++++++++++++++++++++++++ templates/listing_list.html | 37 +++++++++++++++++++++++++++++++--- 4 files changed, 86 insertions(+), 9 deletions(-) diff --git a/list/routes.go b/list/routes.go index 1c1f1ed..c486522 100644 --- a/list/routes.go +++ b/list/routes.go @@ -986,6 +986,11 @@ func (s *Service) ListingList(c echo.Context) error { pd.Data["tags"] = lt.Translate("Tags") pd.Data["delete"] = lt.Translate("Delete") pd.Data["analytics"] = lt.Translate("Analytics") + pd.Data["advanced_search"] = lt.Translate("Advanced Search") + pd.Data["include_tags"] = lt.Translate("Include Tags") + pd.Data["exclude_tags"] = lt.Translate("Exclude Tags") + pd.Data["apply"] = lt.Translate("Apply") + pd.Data["clear"] = lt.Translate("Clear") type GraphQLResponse struct { Listings struct { diff --git a/short/routes.go b/short/routes.go index 8976385..7fc9ab7 100644 --- a/short/routes.go +++ b/short/routes.go @@ -84,12 +84,13 @@ func (s *Service) LinkShortList(c echo.Context) error { var result GraphQLResponse op := gqlclient.NewOperation( - `query GetLinkShorts($slug: String!, $after: Cursor, $before: Cursor, $tag: String) { + `query GetLinkShorts($slug: String!, $after: Cursor, $before: Cursor, $tag: String, $excludeTag: String) { getLinkShorts(input: { orgSlug: $slug, after: $after, before: $before, tag: $tag, + excludeTag: $excludeTag, }) { result { id @@ -116,12 +117,17 @@ func (s *Service) LinkShortList(c echo.Context) error { op.Var("slug", slug) - var tag string + var tag, excludeTag string if c.QueryParam("tag") != "" { tag = c.QueryParam("tag") op.Var("tag", tag) } + if c.QueryParam("exclude") != "" { + excludeTag = c.QueryParam("exclude") + op.Var("excludeTag", excludeTag) + } + if c.QueryParam("next") != "" { op.Var("after", c.QueryParam("next")) } else if c.QueryParam("prev") != "" { @@ -150,12 +156,21 @@ func (s *Service) LinkShortList(c echo.Context) error { pd.Data["no_short_links"] = lt.Translate("No Short Links") pd.Data["delete"] = lt.Translate("Delete") pd.Data["analytics"] = lt.Translate("Analytics") + pd.Data["advanced_search"] = lt.Translate("Advanced Search") + pd.Data["include_tags"] = lt.Translate("Include Tags") + pd.Data["exclude_tags"] = lt.Translate("Exclude Tags") + pd.Data["apply"] = lt.Translate("Apply") + pd.Data["clear"] = lt.Translate("Clear") + linkShorts := result.LinkShorts.Result gmap := gobwebs.Map{ - "pd": pd, - "links": linkShorts, - "org": org, - "navFlag": "short", + "pd": pd, + "links": linkShorts, + "org": org, + "navFlag": "short", + "tagFilter": tag, + "excludeTagFilter": excludeTag, + "advancedSearch": true, } if result.LinkShorts.PageInfo.HasPrevPage { diff --git a/templates/link_short_list.html b/templates/link_short_list.html index 25beb4e..ec99b27 100644 --- a/templates/link_short_list.html +++ b/templates/link_short_list.html @@ -5,6 +5,32 @@
+ {{if .advancedSearch}} +

{{.pd.Data.advanced_search}}

+
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+ + {{.pd.Data.clear}} +
+
+
+
+ {{end}} diff --git a/templates/listing_list.html b/templates/listing_list.html index f1bdf15..36222aa 100644 --- a/templates/listing_list.html +++ b/templates/listing_list.html @@ -5,6 +5,32 @@
+ {{if .advancedSearch}} +

{{.pd.Data.advanced_search}}

+
+
+
+
+
+
+
+
+
+ +
+
+
+ +
+
+
+ + {{.pd.Data.clear}} +
+
+ +
+ {{end}}
@@ -27,9 +53,14 @@ -- 2.45.2