From 6304dc5cc126cc2b6c5ef9d780d738c8eea94550 Mon Sep 17 00:00:00 2001 From: Ben Silverman Date: Mon, 30 Sep 2024 13:45:38 -0400 Subject: [PATCH] Update search results UI - change "label" to "title" in sort - only show date added if sorting by it - show collections in each result --- apps/readux/forms.py | 4 +- apps/templates/search_results.html | 13 +- apps/templates/search_results_backup.html | 152 --------------------- apps/templates/snippets/volume_result.html | 52 +++---- 4 files changed, 27 insertions(+), 194 deletions(-) delete mode 100644 apps/templates/search_results_backup.html diff --git a/apps/readux/forms.py b/apps/readux/forms.py index 74bdf68f..1179f59d 100644 --- a/apps/readux/forms.py +++ b/apps/readux/forms.py @@ -111,8 +111,8 @@ class ManifestSearchForm(forms.Form): ("created_at", "Date added (oldest first)"), ("-date_sort_descending", "Date published (newest first)"), ("date_sort_ascending", "Date published (oldest first)"), - ("label_alphabetical", "Label (A-Z)"), - ("-label_alphabetical", "Label (Z-A)"), + ("label_alphabetical", "Title (A-Z)"), + ("-label_alphabetical", "Title (Z-A)"), ("_score", "Relevance"), ), widget=forms.Select( diff --git a/apps/templates/search_results.html b/apps/templates/search_results.html index f699b007..489b58b8 100644 --- a/apps/templates/search_results.html +++ b/apps/templates/search_results.html @@ -48,8 +48,6 @@ - - {% include '_home/_nav.html' %}
@@ -76,10 +74,8 @@
-
{{ form.sort }} -
@@ -101,28 +96,28 @@
- +
{{ form.collection }}
- +
{{ form.author }}
- +
{{ form.language }}
- +
diff --git a/apps/templates/search_results_backup.html b/apps/templates/search_results_backup.html deleted file mode 100644 index dde8143f..00000000 --- a/apps/templates/search_results_backup.html +++ /dev/null @@ -1,152 +0,0 @@ -{% extends "base.html" %} -{% load wagtailcore_tags static readux_extras %} - -{% block extra_head %} - - - - - -{% endblock %} -{% block extra_javascript %} - - - - -{% endblock %} -{% block extra_css %} - - -{% endblock %} -{% block body_class %}template-homepage{% endblock %} - -{% block content %} -
- -
-
- {{ form.scope }} -
-
- - -
-
- -
-
- {{ form.sort }} - -
-
- -
-
- -
-
- -
- {{ form.collection }} -
- -
-
- -
- {{ form.author }} -
- -
-
- -
- {{ form.language }} -
- -
-
- - -
-
- -
- - {% for key in CUSTOM_METADATA_KEYS %} -
- {% with form|dict_item:key as field %} -
- -
- {{ field }} - {% endwith %} -
- {% endfor %} - -
- - -
-
- -
-
-
{{ volumes.count }} result{{ volumes.count|pluralize }}
-
{% include "snippets/pagination.html" %}
-
-
    - {% for volume in volumes %} - {% include "snippets/volume_result.html" %} - {% endfor %} -
-
- {% include "snippets/pagination.html" %} -
-
- -
-
-{% endblock content %} \ No newline at end of file diff --git a/apps/templates/snippets/volume_result.html b/apps/templates/snippets/volume_result.html index 136e48bd..e5ae0fb7 100644 --- a/apps/templates/snippets/volume_result.html +++ b/apps/templates/snippets/volume_result.html @@ -1,10 +1,7 @@ {% load readux_extras %}
  • -

    - +

    {% if volume.pid %} {% else %} @@ -25,31 +22,15 @@ {{ fragment|safe }} {% endfor %} {% else %} - {{ volume.label }} + {{ volume.label|default:"[no title]" }} {% endif %} {% endif %}

    -
    -
    - {% if volume.summary %} -
    Summary
    -
    - {% if 'highlight' in volume.meta and volume.meta.highlight.summary %} - {% for fragment in volume.meta.highlight.summary %} - {{ fragment|safe }} - {% endfor %} - {% else %} - {{ volume.summary|safe }} - {% endif %} -
    - {% endif %} -
    +
    {% if volume.authors and "[no author]" not in volume.authors %} -
    Author{{volume.authors|pluralize}}
    +
    Author{{volume.authors|pluralize}}
      @@ -88,13 +69,8 @@
      Published
      {{volume.published_date}}
      {% endif %} - - {% if volume.created_at %} -
      Added
      -
      {{volume.created_at}}
      - {% endif %} {% if volume.languages and "[no language]" not in volume.languages %} -
      Language{{volume.languages|pluralize}}
      +
      Language{{volume.languages|pluralize}}
        {% for lang in volume.languages %} @@ -103,6 +79,20 @@
      {% endif %} - + {% if volume.collections %} +
      Collection{{volume.collections|pluralize}}
      +
      +
        + {% for collection in volume.collections %} +
      • {{ collection.label }}
      • + {% endfor %} +
      +
      + {% endif %} + {# only show date added if it is the sort field #} + {% if "created_at" in request.GET.sort and volume.created_at %} +
      Added
      +
      {{volume.created_at}}
      + {% endif %}