~netlandish/links

9d9316a703523cd4f540cb490aff5af47d2d50b5 — Yader Velasquez 9 months ago 2b4b1ac
Prevent links of already filtered tags to be clickables

References: https://todo.code.netlandish.com/~netlandish/links/47
2 files changed, 10 insertions(+), 2 deletions(-)

M cmd/links/main.go
M templates/link_list.html
M cmd/links/main.go => cmd/links/main.go +3 -0
@@ 235,6 235,9 @@ func run() error {
			// Convert penies to dollar amount
			return links.FromPenniesToFloat(amt)
		},
		"isTagUsedInFilter": func(tag string, activeTags string) bool {
			return strings.Contains(activeTags, tag)
		},
	})
	err = srv.LoadTemplatesFS(links.TemplateFS, "templates/*.html", "templates/*.txt")
	if err != nil {

M templates/link_list.html => templates/link_list.html +7 -2
@@ 27,7 27,7 @@
                          <div class="d-none autocomplete-tags"></div>
                      </div>
                      <p class="mt-1 pull-right">
                      <a href="#" class="button primary is-small">{{.pd.Data.clear}}</a>
                      <a href="{{reverse "core:home_link_list"}}" class="button primary is-small">{{.pd.Data.clear}}</a>
                      <button type="submit" class="button primary is-small">{{.pd.Data.apply}}</button>
                      </p>
                  </div>


@@ 145,7 145,12 @@
        {{if .Tags}}
        <div class="link-tag mt-1">
          {{range .Tags}}
          <a class="link-tag__item link-tag__item--simple" href="{{if $.tagFilter}}?tag={{$.tagFilter}},{{.Slug}}{{else}}?tag={{.Slug}}{{end}}">#{{.Name}}</a>
            {{if isTagUsedInFilter .Name $.tagFilter}}
                <small class="link-tag__item link-tag__item--simple">#{{.Name}}</small>
            {{else}}
                <a class="link-tag__item link-tag__item--simple"
                   href="{{if $.tagFilter}}?tag={{$.tagFilter}},{{.Slug}}{{if $.excludeTagFilter}}&exclude={{$.excludeTagFilter}}{{end}}{{else}}?tag={{.Slug}}{{if $.excludeTagFilter}}&exclude={{$.excludeTagFilter}}{{end}}{{end}}">#{{.Name}}</a>
            {{end}}
          {{end}}
        </div>
        {{end}}