Bug 31339

Summary: Add Template::Toolkit WRAPPER for Koha Tool Plugins
Product: Koha Reporter: David Cook <dcook>
Component: Plugin architectureAssignee: David Cook <dcook>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: kyle, matt.blenkinsop, paul.derscheid, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30289
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=31380
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
23.11.00,23.05.02
Circulation function:
Bug Depends on:    
Bug Blocks: 34307    
Attachments: Bug 31339: Add staff wrapper template include for tool plugins
test plugin
Bug 31339: Add staff wrapper template include for tool plugins
Bug 31339: Add staff wrapper template include for tool plugins

Description David Cook 2022-08-11 06:18:02 UTC
Rather than requiring Koha plugins to create entire templates, let's provide Template::Toolkit WRAPPER files to allow them to more easily integrate. 

This should also make it easier for plugins to fit into different versions of Koha.
Comment 1 David Cook 2022-08-11 06:49:00 UTC Comment hidden (obsolete)
Comment 2 David Cook 2022-08-11 06:52:58 UTC Comment hidden (obsolete)
Comment 3 Paul Derscheid 2022-08-11 07:19:01 UTC
I love this approach. 

I could look it up myself but can you pass props to wrappers?
Comment 4 David Cook 2022-08-11 23:27:35 UTC
(In reply to Paul Derscheid from comment #3)
> I love this approach. 

Glad to hear it!
 
> I could look it up myself but can you pass props to wrappers?

You can! I was going to do a better example, but I was running out of time last night hehe. 

If you look at https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=30289&attachment=133074 you can see I'm passing in "bodyid", "breadcrumb_label", "columns", and "include_navigation" to the wrapper. In that case, I'm just passing strings, but you can pass variables too. 

You can define your jsinclude and cssinclude blocks in your individual pages and they'll still be processed via the includes in the wrapper.

So it's quite flexible and very powerful.
Comment 5 David Cook 2022-08-23 06:35:43 UTC
Created attachment 139647 [details] [review]
Bug 31339: Add staff wrapper template include for tool plugins

This change adds a template include which can be used as a
WRAPPER for tool plugins, which makes it easy to pages in tool
templates without having to copy and maintain a lot of template
boilerplate.

Test plan:
0. Apply patch and koha-plack --restart kohadev
1. Upload koha-plugin-test-wrapper
2. Enable the plugin
3. Click "Actions" and click "Run tool"
4. Note how the plugin page looks like a perfect Koha Tools page
5. Note that the plugin only contains 6 lines of template code
to achieve this effect
Comment 6 David Cook 2022-08-23 06:36:30 UTC
Created attachment 139648 [details]
test plugin
Comment 7 David Nind 2023-05-02 17:39:29 UTC
Created attachment 150528 [details] [review]
Bug 31339: Add staff wrapper template include for tool plugins

This change adds a template include which can be used as a
WRAPPER for tool plugins, which makes it easy to pages in tool
templates without having to copy and maintain a lot of template
boilerplate.

Test plan:
0. Apply patch and koha-plack --restart kohadev
1. Upload koha-plugin-test-wrapper
2. Enable the plugin
3. Click "Actions" and click "Run tool"
4. Note how the plugin page looks like a perfect Koha Tools page
5. Note that the plugin only contains 6 lines of template code
to achieve this effect

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 Kyle M Hall (khall) 2023-07-07 18:59:06 UTC
Created attachment 153201 [details] [review]
Bug 31339: Add staff wrapper template include for tool plugins

This change adds a template include which can be used as a
WRAPPER for tool plugins, which makes it easy to pages in tool
templates without having to copy and maintain a lot of template
boilerplate.

Test plan:
0. Apply patch and koha-plack --restart kohadev
1. Upload koha-plugin-test-wrapper
2. Enable the plugin
3. Click "Actions" and click "Run tool"
4. Note how the plugin page looks like a perfect Koha Tools page
5. Note that the plugin only contains 6 lines of template code
to achieve this effect

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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 9 David Cook 2023-07-10 01:09:31 UTC
Cheers, guys!

I haven't tried this out since the staff-side re-vamp, so it's cool to hear that this is still working as expected.
Comment 10 Tomás Cohen Arazi (tcohen) 2023-07-18 15:56:19 UTC
David, I'm pushing this one but please look at (for example) bug 33599, to see how the breadcrumbs should be built using the new wrapper Owen introduced.

And file a bug for fixing it. Thanks!
Comment 11 Tomás Cohen Arazi (tcohen) 2023-07-18 17:08:45 UTC
Pushed to master for 23.11.

Nice work everyone, thanks!
Comment 12 David Cook 2023-07-18 23:20:48 UTC
(In reply to Tomás Cohen Arazi from comment #10)
> David, I'm pushing this one but please look at (for example) bug 33599, to
> see how the breadcrumbs should be built using the new wrapper Owen
> introduced.
> 
> And file a bug for fixing it. Thanks!

Will do! Thanks!
Comment 13 David Cook 2023-07-19 05:38:36 UTC
(In reply to David Cook from comment #12)
> (In reply to Tomás Cohen Arazi from comment #10)
> > David, I'm pushing this one but please look at (for example) bug 33599, to
> > see how the breadcrumbs should be built using the new wrapper Owen
> > introduced.
> > 
> > And file a bug for fixing it. Thanks!
> 
> Will do! Thanks!

That's all ready to go on bug 34307 now.
Comment 14 Martin Renvoize (ashimema) 2023-07-19 08:30:36 UTC
Thanks for all the hard work!

Pushed to 23.05.x for the next release
Comment 15 Matt Blenkinsop 2023-07-19 10:12:30 UTC
Enhancement - not backporting to 22.11.x