Bug 29278

Summary: write_age function broken by Flatpickr conversion
Product: Koha Reporter: Owen Leonard <oleonard>
Component: TemplatesAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: david, kyle, testopia
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes the display of a patron's age in the staff interface after the date of birth field (for example: Age: 63 years 4 months). This was not displaying after the switch to Flatpickr for date entry on this page in the 21.11 release development cycle.
Version(s) released in:
21.11.00
Bug Depends on: 28937    
Bug Blocks: 26244    
Attachments: Bug 29278: Fix selector of hint used to show age
Bug 29278: Fix selector of hint used to show age
Bug 29278: Fix selector of hint used to show age

Description Owen Leonard 2021-10-19 16:18:44 UTC
The write_age() function builds a string describing the patron's age based on the date of birth field in the patron entry form.

The function has been broken by Bug 28937 because the HTML structure of the page has changed.
Comment 1 Owen Leonard 2021-10-19 16:30:49 UTC
Created attachment 126528 [details] [review]
Bug 29278: Fix selector of hint used to show age

This patch modifies the patron entry form to correct a problem with the
write_age() function introduced by the switch to Flatpickr on this page
(Bug 28937).

Rather than selecting the element based on the sequence of elements on
the page, we should add an ID for direct selection.

To test, apply the patch and go to Patrons.

- Locate a patron record which has a date of birth saved.
  - When you open that patron for editing, you should see their age
    displayed below the date of birth input field, e.g. "Age: 23 years 9
    months."
  - Changing the date in the date of birth field should update the age
    string correctly.
- Go to Patrons -> New patron.
  - The date of birth field should have a hint showing the required date
    format, e.g. "(DD.MM.YYYY)".
  - When you select a date of birth using the Flatpickr calendar the age
    string should be updated correctly.
Comment 2 David Nind 2021-10-20 22:55:54 UTC
Created attachment 126631 [details] [review]
Bug 29278: Fix selector of hint used to show age

This patch modifies the patron entry form to correct a problem with the
write_age() function introduced by the switch to Flatpickr on this page
(Bug 28937).

Rather than selecting the element based on the sequence of elements on
the page, we should add an ID for direct selection.

To test, apply the patch and go to Patrons.

- Locate a patron record which has a date of birth saved.
  - When you open that patron for editing, you should see their age
    displayed below the date of birth input field, e.g. "Age: 23 years 9
    months."
  - Changing the date in the date of birth field should update the age
    string correctly.
- Go to Patrons -> New patron.
  - The date of birth field should have a hint showing the required date
    format, e.g. "(DD.MM.YYYY)".
  - When you select a date of birth using the Flatpickr calendar the age
    string should be updated correctly.

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Katrin Fischer 2021-10-21 14:19:43 UTC
While I LOVE the text to go in the release notes I wonder if it's useful for a case like this when the feature that causes it will only be released with 21.11 - so the bug this fixes hasn't had a chance to hit anyone (my favourite bugs of all). 

Maybe we should focus on the enh/new features and behaviour changing ones?
Comment 4 Katrin Fischer 2021-10-23 23:01:31 UTC
Created attachment 126794 [details] [review]
Bug 29278: Fix selector of hint used to show age

This patch modifies the patron entry form to correct a problem with the
write_age() function introduced by the switch to Flatpickr on this page
(Bug 28937).

Rather than selecting the element based on the sequence of elements on
the page, we should add an ID for direct selection.

To test, apply the patch and go to Patrons.

- Locate a patron record which has a date of birth saved.
  - When you open that patron for editing, you should see their age
    displayed below the date of birth input field, e.g. "Age: 23 years 9
    months."
  - Changing the date in the date of birth field should update the age
    string correctly.
- Go to Patrons -> New patron.
  - The date of birth field should have a hint showing the required date
    format, e.g. "(DD.MM.YYYY)".
  - When you select a date of birth using the Flatpickr calendar the age
    string should be updated correctly.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Jonathan Druart 2021-10-25 13:59:11 UTC
Pushed to master for 21.11, thanks to everybody involved!