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-workroute to serve the form page - Built
templates/add-work.htmlwith 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:

Selected work type with green confirmation:

Success modal after form submission:

Test Plan
Basic Functionality:
- Navigate to
http://localhost:5000/add-work - Verify form displays with Title, Description, and Type of work fields
- Type "novel" in Type of work field - verify dropdown appears with results
- Select a result - verify green success message shows with QID
- Fill all fields and click "Add Work" - verify custom modal displays form data
- 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)