UCL / frrant

2 stars 0 forks source link

Appositum fragment link form needs a filter #414

Closed tcouch closed 6 months ago

tcouch commented 8 months ago

The form to add a fragment link to an anonymous fragment is a simple drop down presenting all fragments which is very difficult to use now that the database has grown.

A solution would be to provide filters - Antiquarian and Work - in order to narrow down the number of items in the drop down. It's important that the results are also in numerical order as that will help quickly identify the right item.

tcouch commented 6 months ago

A couple of things I've noticed trying this out on preprod:

  1. If I type something that doesn't match anything, I don't get any feedback. I think rather than still saying "Results will appear here", the select box should change to something like "Sorry, no fragments matching that query were found"
  2. If I type "varro" and see a long list of fragments with the names of different works, I'm tempted to add something from one of the work's titles to narrow the search down. It'd be good to be able to search within works too.

Maybe a better approach would be to do something like:

# Given a query like "varro disciplinae 12" this would be split into a list of terms: ["varro", "disciplinae"]
antiquarians = Antiquarian.objects.none()
works = Work.objects.none()
for term in search_terms:  
    works = works.union(Work.objects.filter(name__icontains=term))
    antiquarians = antiquarians.union(Antiquarian.objects.filter(name__icontains=term))

# Return all fragments linked to any of the matching works or antiquarians
fragments = Fragment.objects.filter(
                        Q(antiquarian_fragmentlinks__work__in=works) |
                        Q(antiquarian_fragmentlinks__antiquarian__in=antiquarians)
                )

# Also handle order number and unknowns...
acholyn commented 6 months ago

After talking to researchers, they seem happy with the functionality of just a name and number, closing unless otherwise requested