Bug 33289

Summary: Vue - Add API client class to interact with svc/config/systempreferences
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: RESOLVED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook, lucas, martin.renvoize, pedro.amorim
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=34369
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00,22.11.05
Bug Depends on: 33290    
Bug Blocks: 30708, 33408    
Attachments: Bug 33289: Add API client class to interact with svc/config/systempreferences
Bug 33289: Add API client class to interact with svc/config/systempreferences
Bug 33289: DO NOT PUSH - test plan only
Bug 33289: Add API client class to interact with svc/config/systempreferences

Description Jonathan Druart 2023-03-21 07:47:10 UTC
From Vue components.
Comment 1 Jonathan Druart 2023-03-21 08:05:06 UTC
Created attachment 148442 [details] [review]
Bug 33289: Add API client class to interact with svc/config/systempreferences

On bug 30708 we will need to modify sysprefs from the UI (Vue app), it
could be useful for other developments as well and so it is moved on its
own bug report.

Test plan:
It can be tested independently of bug 30708 using the following code:

const client = APIClient.sysprefs
client.sysprefs
    .update(
        "CardnumberLength",
        "42"
    )

Sponsored-by: BULAC - http://www.bulac.fr/
Comment 2 Pedro Amorim 2023-03-23 10:12:23 UTC
Created attachment 148596 [details] [review]
Bug 33289: Add API client class to interact with svc/config/systempreferences

On bug 30708 we will need to modify sysprefs from the UI (Vue app), it
could be useful for other developments as well and so it is moved on its
own bug report.

Test plan:
It can be tested independently of bug 30708 using the following code:

const client = APIClient.sysprefs
client.sysprefs
    .update(
        "CardnumberLength",
        "42"
    )

Sponsored-by: BULAC - http://www.bulac.fr/
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Comment 3 Katrin Fischer 2023-04-09 13:31:49 UTC
Sorry, the test plan is not detailed enough for me - can you please add some more info?
Comment 4 Jonathan Druart 2023-04-11 10:34:46 UTC
(In reply to Katrin Fischer from comment #3)
> Sorry, the test plan is not detailed enough for me - can you please add some
> more info?

You need to play with the code, or test a follow-up bug.

The code I pasted in the commit message is enough to test the change. You can pick a place in a Vue component ('script' part),  add the change, hit the page when the component is mounted, then confirm that the syspref value has been changed in DB.
Comment 5 Katrin Fischer 2023-04-11 20:29:31 UTC
(In reply to Jonathan Druart from comment #4)
> (In reply to Katrin Fischer from comment #3)
> > Sorry, the test plan is not detailed enough for me - can you please add some
> > more info?
> 
> You need to play with the code, or test a follow-up bug.
> 
> The code I pasted in the commit message is enough to test the change. You
> can pick a place in a Vue component ('script' part),  add the change, hit
> the page when the component is mounted, then confirm that the syspref value
> has been changed in DB.

I only understood half of that, probably because I have not even basic knowledge of how Vue works. I'll leave this to someone more knowledgeable.
Comment 6 Pedro Amorim 2023-04-12 11:03:37 UTC
Created attachment 149525 [details] [review]
Bug 33289: DO NOT PUSH - test plan only
Comment 7 Pedro Amorim 2023-04-12 11:06:22 UTC
@Katrin:

Before applying patches:
* Verify that 'cardnumberlength' is empty in the system preferences

Apply both patches:
* Visit /cgi-bin/koha/erm/agreements
(it will run the test code to change a syspref value from the api-client.js + http-client.js)
* Go back to the system preferences and verify that 'cardnumberlength' now has a value of 42
Comment 8 Martin Renvoize 2023-04-12 11:18:51 UTC
Created attachment 149526 [details] [review]
Bug 33289: Add API client class to interact with svc/config/systempreferences

On bug 30708 we will need to modify sysprefs from the UI (Vue app), it
could be useful for other developments as well and so it is moved on its
own bug report.

Test plan:
It can be tested independently of bug 30708 using the following code:

const client = APIClient.sysprefs
client.sysprefs
    .update(
        "CardnumberLength",
        "42"
    )

Sponsored-by: BULAC - http://www.bulac.fr/
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize 2023-04-12 11:19:40 UTC
Clear and simple code all working as expected.

Passing QA
Comment 10 Tomás Cohen Arazi 2023-04-13 14:49:34 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 11 Matt Blenkinsop 2023-04-17 09:16:30 UTC
Nice work everyone!

Pushed to stable for 22.11.x
Comment 12 Lucas Gass 2023-05-05 22:09:33 UTC
Missing dependencies for 22.05.x backport.