Bug 29815 - Pre-populate 'Date acquired' field when adding/editing items
Summary: Pre-populate 'Date acquired' field when adding/editing items
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Serials (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Alex Buckley
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks: 29963
  Show dependency treegraph
 
Reported: 2022-01-07 01:41 UTC by Alex Buckley
Modified: 2023-06-08 22:26 UTC (History)
6 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00


Attachments
Bug 29815: Pre-fill 952$d (Date acquired) when receiving serial items (1.36 KB, patch)
2022-01-07 01:51 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 29815: Pre-fill 952$d (Date acquired) when receiving serial items (1.37 KB, patch)
2022-01-07 01:55 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 29815: Pre-fill 952$d (Date acquired) when receiving serial items (1.43 KB, patch)
2022-01-07 21:47 UTC, Samu Heiskanen
Details | Diff | Splinter Review
Bug 29815: Pre-populate 'Date acquired' field when adding/editing items (2.12 KB, patch)
2022-01-10 04:46 UTC, Alex Buckley
Details | Diff | Splinter Review
Bug 29815: Pre-populate 'Date acquired' field when adding/editing items (2.17 KB, patch)
2022-04-12 15:11 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29815: Pre-populate 'Date acquired' field when adding/editing items (2.27 KB, patch)
2022-04-15 07:50 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Buckley 2022-01-07 01:41:03 UTC
When receiving serial issues the 952$d (Date acquired) field should be pre-populated with the current date.
Comment 1 Alex Buckley 2022-01-07 01:51:55 UTC Comment hidden (obsolete)
Comment 2 Alex Buckley 2022-01-07 01:52:31 UTC
Ready for testing
Comment 3 Alex Buckley 2022-01-07 01:55:05 UTC Comment hidden (obsolete)
Comment 4 Samu Heiskanen 2022-01-07 21:47:35 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2022-01-08 20:42:47 UTC
I am not sure about this one as it changes the behavior of one item form making it inconsistent with the others in cataloguing and acq.

Also, if you leave the date accessioned empty, it is automatically set to today's date without any interaction needed. 

It's here:

https://git.koha-community.org/Koha-community/Koha/src/branch/master/Koha/Item.pm#L117

On the other hand that's not obvious to the user. Maybe we should change the behavior of the other forms as well? Add a hint?
Comment 6 Alex Buckley 2022-01-10 04:46:43 UTC
Created attachment 129237 [details] [review]
Bug 29815: Pre-populate 'Date acquired' field when adding/editing items

This patch pre-fills the 952$d (Date acquired) item subfield on page
load. Users can still click on the field to fill this subfield.

Test plan:
1. Visit a biblio. Add an item, observe on page load the 'Date acquired' subfield is
empty
2. Visit a subscription. Receive a serial, observe after setting the serial status to 'Arrived' the item form loads with an empty 'Date acquired' subfield
3. Apply patch and restart services
4. Repeat step 1 and confirm now on page load the 'Date acquired'
subfield populates with today's date
5. Delete the populated 'Date acquired' subfield value. Click in the
field and confirm the field is populated and the calendar input displays
6. Delete the 'Date acquired' subfield value again. Confirm that tabbing
from a different field into the date acquired field behaves the same as
click
7. Repeat step 2. This time confirm on page load the 'Date acquired' subfield
contains the current date
8. Delete the populated 'Date acquired' subfield value. Click in the
field and confirm it is populated
9. Delete the populated 'Date acquired' subfield value. Tab to the field
from another field and confirm it behaves the same as click
10. Visit a biblio. Edit an item with a date acquired value in
the past. Confirm the date acquired value is unchanged after saving.

Sponsored-By: Brimbank Library, Australia
Comment 7 Alex Buckley 2022-01-10 04:47:27 UTC
Hi Samu and Katrin, 

Thank you for your testing and QA. 

Katrin, I have gone with your suggestion of changing the other forms to work the same as the serial edit one. To do this I have edited the dateaccessioned plugin itself.

I think this one is ready to test again now. 

Thanks!
Alex
Comment 8 Alex Buckley 2022-04-12 02:27:56 UTC
This patchset still applies cleanly to master and is ready for testing if someone is available :)
Comment 9 Owen Leonard 2022-04-12 15:11:02 UTC
Created attachment 133221 [details] [review]
Bug 29815: Pre-populate 'Date acquired' field when adding/editing items

This patch pre-fills the 952$d (Date acquired) item subfield on page
load. Users can still click on the field to fill this subfield.

Test plan:
1. Visit a biblio. Add an item, observe on page load the 'Date acquired' subfield is
empty
2. Visit a subscription. Receive a serial, observe after setting the serial status to 'Arrived' the item form loads with an empty 'Date acquired' subfield
3. Apply patch and restart services
4. Repeat step 1 and confirm now on page load the 'Date acquired'
subfield populates with today's date
5. Delete the populated 'Date acquired' subfield value. Click in the
field and confirm the field is populated and the calendar input displays
6. Delete the 'Date acquired' subfield value again. Confirm that tabbing
from a different field into the date acquired field behaves the same as
click
7. Repeat step 2. This time confirm on page load the 'Date acquired' subfield
contains the current date
8. Delete the populated 'Date acquired' subfield value. Click in the
field and confirm it is populated
9. Delete the populated 'Date acquired' subfield value. Tab to the field
from another field and confirm it behaves the same as click
10. Visit a biblio. Edit an item with a date acquired value in
the past. Confirm the date acquired value is unchanged after saving.

Sponsored-By: Brimbank Library, Australia

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 10 Alex Buckley 2022-04-12 21:08:44 UTC
Thanks for testing Owen!
Comment 11 Marcel de Rooy 2022-04-15 07:50:02 UTC
Created attachment 133343 [details] [review]
Bug 29815: Pre-populate 'Date acquired' field when adding/editing items

This patch pre-fills the 952$d (Date acquired) item subfield on page
load. Users can still click on the field to fill this subfield.

Test plan:
1. Visit a biblio. Add an item, observe on page load the 'Date acquired' subfield is
empty
2. Visit a subscription. Receive a serial, observe after setting the serial status to 'Arrived' the item form loads with an empty 'Date acquired' subfield
3. Apply patch and restart services
4. Repeat step 1 and confirm now on page load the 'Date acquired'
subfield populates with today's date
5. Delete the populated 'Date acquired' subfield value. Click in the
field and confirm the field is populated and the calendar input displays
6. Delete the 'Date acquired' subfield value again. Confirm that tabbing
from a different field into the date acquired field behaves the same as
click
7. Repeat step 2. This time confirm on page load the 'Date acquired' subfield
contains the current date
8. Delete the populated 'Date acquired' subfield value. Click in the
field and confirm it is populated
9. Delete the populated 'Date acquired' subfield value. Tab to the field
from another field and confirm it behaves the same as click
10. Visit a biblio. Edit an item with a date acquired value in
the past. Confirm the date acquired value is unchanged after saving.

Sponsored-By: Brimbank Library, Australia

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 12 Fridolin Somers 2022-04-21 00:44:54 UTC
Makes sens.
For a total free input, one must not use this value builder.
Comment 13 Fridolin Somers 2022-04-21 06:44:01 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 14 Alex Buckley 2022-05-01 21:36:08 UTC
Thank you all for your testing and QA!
Comment 15 Benjamin Daeuber 2022-06-03 13:16:52 UTC
Jumping in here regarding Bug 29963, but I think prepopulating date acquired when editing items is an undesirable behavior. It would need to be cleared more often than it would be useful. Makes sense when receiving serials or adding new items, but modification and batch modification it's just an annoyance.
Comment 16 Marcel de Rooy 2022-06-03 15:01:34 UTC
(In reply to Benjamin Daeuber from comment #15)
> Jumping in here regarding Bug 29963, but I think prepopulating date acquired
> when editing items is an undesirable behavior. It would need to be cleared
> more often than it would be useful. Makes sense when receiving serials or
> adding new items, but modification and batch modification it's just an
> annoyance.

How easy is it to have the plugin know in which context it works?
Comment 17 Andrii Nugged 2022-06-04 17:23:54 UTC
"Pre-populate 'Date acquired'" was the target, but not the plugin in general.

So because of this it covers much more, and those extras are not expected nor desirable:

1. this code in the ticket prepopulates ANY field to which the plugin added.
Wrong behavior. This plugin is not aimed to be ONLY for the 'Date acquired' field.

2. It also silenltly prepopulates the field in edit mode when it is expected to be empty by the wish of the librarian.

3. It also prepopulates fields for item batch edit form, which is even more undesired to be so.

These ticket changes need to be reverted.
Maybe re-thought for the solution needed later, but now it makes problems. For example, I released a quick patch for all productions which went to Koha 22.05 because of the above 3 bad effects.

Later - this might be, but the more complicated solution, as Marcel de Rooy said: the plugin should be aware in which context it is executed, but even with this, this requires to be with some preferences at least: after checking on production libraries most said this is not their wish to have this autofill, they ok to press "..." (three dots on the right to call plugin's 'today date fill' feature).
Comment 18 Martin Renvoize 2022-06-07 07:04:13 UTC
I think the original patch attached here is the better approach.. the one that changes PrepareItemForDisplay in C4::Items