Bug 32949

Summary: Smart-rules prefills junk date on page load
Product: Koha Reporter: Peter Vashchuk <stalkernoid>
Component: System AdministrationAssignee: Peter Vashchuk <stalkernoid>
Status: Pushed to main --- QA Contact: Nick Clemens (kidclamp) <nick>
Severity: normal    
Priority: P5 - low CC: gmcharlt
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:
Attachments: Bug 32949: Do not fill form with wrong shadow value to avoid data loss in smart-rules.tt
Bug 32949: Do not fill form with wrong shadow value to avoid data loss in smart-rules.tt
Bug 32949: Fix wrong input id
Bug 32949: Fix wrong input id
Bug 32949: Fix wrong input id

Description Peter Vashchuk 2023-02-13 13:51:06 UTC

    
Comment 1 Owen Leonard 2023-02-13 13:53:21 UTC
What is a junk date? How do you reproduce this bug?
Comment 2 Peter Vashchuk 2023-02-13 14:15:05 UTC Comment hidden (obsolete)
Comment 3 Peter Vashchuk 2023-02-13 14:21:27 UTC
(In reply to Owen Leonard from comment #1)
> What is a junk date? How do you reproduce this bug?

Hey Owen, I already had a fix for it, was meant to push it asap after I created this bug, please see the patch and description of it for more info.
Comment 4 Owen Leonard 2023-02-13 15:51:34 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2023-02-20 22:48:57 UTC
I don't have the patch applied, but I can't reproduce the issue.

I also tried using another date format, but it all behaves nicely:

* Set dateformat to DD.MM.YYYY
* Create a circulation rule ALL-ALL-Books, with 21.2.2023 as hard due date and auto-renewal before.
* Save rule.
* Edit rule and save without changes.
* Edit rule again - dates are still correct.

Tested on master as of today. Also with the standard format MM.DD.YYYY.

Can you please have a look?
Comment 6 Peter Vashchuk 2025-02-10 12:50:24 UTC
It doesn't seem to be working properly after the introduction of input id's, I will post a fix shortly :)
Comment 7 Peter Vashchuk 2025-02-10 12:54:20 UTC Comment hidden (obsolete)
Comment 8 Magnus Enger 2025-02-11 08:25:44 UTC
Created attachment 177724 [details] [review]
Bug 32949: Fix wrong input id

The input id was wrong, so instead "else" was handling the flatpickr data
as plain text, which prefilled junk data and therefore resetting value of
"Hard due date" field to "None defined".

To reproduce:
1. Head over to the smart rules admin page and create/use existing rule
for certain item type/category.
2. Set "hard due date" that rule to a certain date and save.
3. Edit that same rule again, but this time save it without any
changes. Do not click or interact with flatpickr field.
Date for hard due date will get lost and will be set as "None defined".
4. Apply the patch.
5. Repeat steps 2 and 3. Ensure that the data loss is not happening
anymore.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Followed test plan, works as advertised.
Comment 9 Nick Clemens (kidclamp) 2025-02-12 14:38:52 UTC
Created attachment 177925 [details] [review]
Bug 32949: Fix wrong input id

The input id was wrong, so instead "else" was handling the flatpickr data
as plain text, which prefilled junk data and therefore resetting value of
"Hard due date" field to "None defined".

To reproduce:
1. Head over to the smart rules admin page and create/use existing rule
for certain item type/category.
2. Set "hard due date" that rule to a certain date and save.
3. Edit that same rule again, but this time save it without any
changes. Do not click or interact with flatpickr field.
Date for hard due date will get lost and will be set as "None defined".
4. Apply the patch.
5. Repeat steps 2 and 3. Ensure that the data loss is not happening
anymore.

Signed-off-by: Magnus Enger <magnus@libriotech.no>
Followed test plan, works as advertised.
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 10 Katrin Fischer 2025-02-13 15:20:21 UTC
Pushed for 25.05!

Well done everyone, thank you!