Bug 31339 - Add Template::Toolkit WRAPPER for Koha Tool Plugins
Summary: Add Template::Toolkit WRAPPER for Koha Tool Plugins
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Plugin architecture (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 34307
  Show dependency treegraph
 
Reported: 2022-08-11 06:18 UTC by David Cook
Modified: 2023-07-19 10:12 UTC (History)
4 users (show)

See Also:
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


Attachments
Bug 31339: Add staff wrapper template include for tool plugins (2.62 KB, patch)
2022-08-23 06:35 UTC, David Cook
Details | Diff | Splinter Review
test plugin (2.00 KB, application/zip)
2022-08-23 06:36 UTC, David Cook
Details
Bug 31339: Add staff wrapper template include for tool plugins (2.67 KB, patch)
2023-05-02 17:39 UTC, David Nind
Details | Diff | Splinter Review
Bug 31339: Add staff wrapper template include for tool plugins (2.73 KB, patch)
2023-07-07 18:59 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 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 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 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 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