Bug 30376

Summary: Unable to save item if field date acquired is set mandatory
Product: Koha Reporter: Lari Taskula <lari.taskula>
Component: CatalogingAssignee: Lari Taskula <lari.taskula>
Status: RESOLVED FIXED QA Contact: Joonas Kylmälä <joonas.kylmala>
Severity: normal    
Priority: P5 - low CC: andrewfh, johanna.raisa, jonathan.druart+koha, joonas.kylmala, kyle, m.de.rooy
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.05
Attachments: Bug 30376: Fix missing mandatory date acquired error on item save
Bug 30376: Fix missing mandatory date acquired error on item save
Bug 30376: [ALTERNATIVE PATCH] Fix missing mandatory date acquired error on item save
Bug 30376: [ALTERNATIVE PATCH] Fix missing mandatory date acquired error on item save
Bug 30376: Fix missing mandatory date acquired error on item save

Description Lari Taskula 2022-03-28 10:32:00 UTC
If you set 952$d (date acquired or "dateaccessioned") as mandatory in your MARC framework, you'll be unable to edit or add items because item form validation fails with error "1 mandatory fields empty".

To reproduce:

1. Edit a MARC framework of your choice (e.g. Default)
2. Locate 952$d "Date acquired" and click Edit
/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&tagfield=952&frameworkcode=#subdfield
3. Tick "Mandatory" checkbox
4. Save changes
5. Edit any item using MARC framework you edited in step 1
/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=123&itemnumber=456
6. Set "Date acquired" to any date
7. Click Save
8. Observe error "- 1 mandatory fields empty (highlighted)" (JavaScript alert)
Comment 1 Lari Taskula 2022-03-28 10:53:06 UTC
Created attachment 132317 [details] [review]
Bug 30376: Fix missing mandatory date acquired error on item save

If you set 952$d (date acquired or "dateaccessioned") as mandatory in
your MARC framework, you'll be unable to edit or add items because item
form validation fails with error "1 mandatory fields empty".

To test:

1. Edit a MARC framework of your choice (e.g. Default)
2. Locate 952$d "Date acquired" and click Edit
/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&tagfield=952&frameworkcode=#subdfield
3. Tick "Mandatory" checkbox
4. Save changes
5. Edit any item using MARC framework you edited in step 1
/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=123&itemnumber=456
6. Set "Date acquired" to any date
7. Click Save
8. Observe error "- 1 mandatory fields empty (highlighted)" (JavaScript alert)
9. Apply patch
10. Repeat steps 5-7
11. Observe no error, item saves as expected
Comment 2 Johanna Räisä 2022-04-06 10:02:02 UTC
Created attachment 132985 [details] [review]
Bug 30376: Fix missing mandatory date acquired error on item  save

If you set 952$d (date acquired or "dateaccessioned") as mandatory in
your MARC framework, you'll be unable to edit or add items because item
form validation fails with error "1 mandatory fields empty".

To test:

1. Edit a MARC framework of your choice (e.g. Default)
2. Locate 952$d "Date acquired" and click Edit
/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&tagfield=952&frameworkcode=#subdfield
3. Tick "Mandatory" checkbox
4. Save changes
5. Edit any item using MARC framework you edited in step 1
/cgi-bin/koha/cataloguing/additem.pl?op=edititem&biblionumber=123&itemnumber=456
6. Set "Date acquired" to any date
7. Click Save
8. Observe error "- 1 mandatory fields empty (highlighted)" (JavaScript alert)
9. Apply patch
10. Repeat steps 5-7
11. Observe no error, item saves as expected

Signed-off-by: Johanna Raisa <johanna.raisa@gmail.com>
Comment 3 Jonathan Druart 2022-04-06 14:48:56 UTC
This patch does not work for me, I get an error in the console

Uncaught ReferenceError: flatpick_editor is not defined
Comment 4 Jonathan Druart 2022-04-06 14:56:25 UTC
Well, the patch is actually working if you follow your test plan, but you forgot a regression step: don't fill in a date and expect the alert.
Comment 5 Jonathan Druart 2022-04-06 15:01:32 UTC
Created attachment 133043 [details] [review]
Bug 30376: [ALTERNATIVE PATCH] Fix missing mandatory date acquired error on item save
Comment 6 Jonathan Druart 2022-04-06 15:01:47 UTC
This patch seems to work as expected. Please confirm.
Comment 7 Johanna Räisä 2022-04-07 05:53:41 UTC
Created attachment 133054 [details] [review]
Bug 30376: [ALTERNATIVE PATCH] Fix missing mandatory date  acquired error on item save

Signed-off-by: Johanna Raisa <johanna.raisa@gmail.com>

This alternative patch works better. After testing the first patch more there was a problem of saving mandatory fields, it allowed to save all empty mandatory fields.
Comment 8 Joonas Kylmälä 2022-04-10 18:24:58 UTC
Created attachment 133134 [details] [review]
Bug 30376: Fix missing mandatory date acquired error on item save

Signed-off-by: Johanna Raisa <johanna.raisa@gmail.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Comment 9 Joonas Kylmälä 2022-04-10 18:25:29 UTC
Passing QA
Comment 10 Fridolin Somers 2022-04-13 13:57:44 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄
Comment 11 Kyle M Hall 2022-04-15 12:03:20 UTC
Unable to replicate bug in 21.11.x. If I am mistaken please let me know!
Comment 12 Johanna Räisä 2022-04-19 08:48:44 UTC
(In reply to Kyle M Hall from comment #11)
> Unable to replicate bug in 21.11.x. If I am mistaken please let me know!

I tested on 21.11.x and the bug was also in it.
Comment 13 Kyle M Hall 2022-04-19 10:11:18 UTC
(In reply to Johanna Räisä from comment #12)
> (In reply to Kyle M Hall from comment #11)
> > Unable to replicate bug in 21.11.x. If I am mistaken please let me know!
> 
> I tested on 21.11.x and the bug was also in it.

Thanks for the confirmation! I'll get this backported.
Comment 14 Kyle M Hall 2022-04-19 10:13:32 UTC
Pushed to 21.11.x for 21.11.05
Comment 15 Andrew Fuerste-Henry 2022-05-03 19:41:10 UTC
Unable to recreate on 21.05. Not backporting.