T406989: Proof of concept for adding new statements through the Add Information button

Summary

This patch implements a Proof-of-Concept (PoC) for the "Add information" feature on the author page. This functionality allows a user to dynamically select a missing biographical field and displays the appropriate input control based on the expected data type. This focuses solely on creating a functional, user-friendly interface without connecting to a backend service.

Key Features Implemented

  1. Dynamic Visibility: The "Add information" button is only displayed if the author is missing one or more biographical fields (e.g., 'Date of death', 'Nationality').

  2. Dropdown Population: Upon clicking the button, it is replaced by a dropdown menu that only lists the fields currently missing from the biography table.

  3. Dynamic Input Type: When a user selects a field from the dropdown, a text input box is displayed next to it.

  4. For fields requiring structured data (like 'Date of birth' or 'Date of death'), the input type is dynamically set to type="date".

  5. For all other fields, the input remains a standard type="text".

Code Changes

  1. templates/author.html (HTML): Added the "Add information" button and the dynamic container elements (#add-info-controls, #field-dropdown-container, etc.) below the biography section.

  2. templates/author.html (script): Added a new JavaScript block that:

  • Scans the DOM to determine truly missing fields from the biography table.

  • Hides the button if no fields are missing.

  • Handles the display toggle between the button and the controls.

  • Dynamically generates the dropdown and sets the correct input type (date or text) based on the field selected.

  • Jinja Templating: Used {% raw %} blocks and JavaScript variables to correctly handle Jinja translation calls within the script.

Testing Instructions

  • Navigate to an author page.

  • Scenario A (Missing Fields): If fields are missing in the biography table, verify the "Add information" button is visible. Click it. image

  • Verify the button disappears, and a dropdown appears. image

  • Verify the dropdown only contains the fields missing from the table. image

image

  • Select 'Date of birth or Date of Death': Verify a date picker input appears. image

  • Select 'Country of Birth': Verify a standard text input appears. image

  • Scenario B (No Missing Fields): Navigate to an author page where all biography fields are filled. Verify the "Add information" button is completely hidden. image

Edited by Kimondorose

Merge request reports

Loading