Feat: Add work creation form with real-time Wikidata autocomplete for work types

Closes T407558

Summary

Implemented a new "Add Work" form page (/add-work) that allows users to input work information including title, description, and work type. The work type field features real-time autocomplete functionality that searches Wikidata using the MediaWiki Action API, displaying results with labels, descriptions, and QIDs. The implementation includes keyboard navigation, debounced API calls, and a custom Bootstrap modal for form submission feedback. This is a proof of concept - form submissions are not persisted to the database.

Changes:

  • Added /add-work route to serve the form page
  • Built templates/add-work.html with form and autocomplete functionality
  • Implemented real-time search with 300ms debouncing to minimize API calls
  • Added keyboard navigation (arrow keys, enter, escape) for accessibility
  • Created custom success modal matching Paulina's design system

Screenshots

Form with autocomplete dropdown showing results: image

Selected work type with green confirmation: image

Success modal after form submission: image

Test Plan

Basic Functionality:

  1. Navigate to http://localhost:5000/add-work
  2. Verify form displays with Title, Description, and Type of work fields
  3. Type "novel" in Type of work field - verify dropdown appears with results
  4. Select a result - verify green success message shows with QID
  5. Fill all fields and click "Add Work" - verify custom modal displays form data
  6. Test validation: submit without selecting work type - verify error alert

Autocomplete Features:

  • Test minimum 2 characters trigger search
  • Test keyboard navigation (arrow keys, Enter, Escape)
  • Test Clear button removes selection

Expected Results:

  • Autocomplete responds within 1-2 seconds
  • Results show Wikidata items with labels, descriptions, and QIDs
  • Success modal matches Paulina's design (orange header, black borders)
Edited by System625

Merge request reports

Loading