Bugzilla – Attachment 191161 Details for
Bug 41579
Tidy kohaTable block - suggestions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41579: Tidy kohaTable - suggestion/suggestion.tt
271922c.patch (text/plain), 8.49 KB, created by
Jonathan Druart
on 2026-01-09 14:53:08 UTC
(
hide
)
Description:
Bug 41579: Tidy kohaTable - suggestion/suggestion.tt
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2026-01-09 14:53:08 UTC
Size:
8.49 KB
patch
obsolete
>From 271922cddbef2ab817f72f589535fefec7d6a6c7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 8 Jan 2026 15:24:49 +0100 >Subject: [PATCH] Bug 41579: Tidy kohaTable - suggestion/suggestion.tt > >--- > .../prog/en/modules/suggestion/suggestion.tt | 58 +++++++++++-------- > 1 file changed, 34 insertions(+), 24 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >index 806d9a1b266..fe973dc6252 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt >@@ -1235,6 +1235,12 @@ > > [% MACRO jsinclude BLOCK %] > [% INCLUDE 'calendar.inc' %] >+ <script> >+ const logged_in_user_borrowernumber = "[% logged_in_user.borrowernumber | html %]"; >+ const managedby_patron_borrowernumber = "[% managedby_patron.borrowernumber | html %]"; >+ const op = "[% op | html %]"; >+ </script> >+ > <script> > function select_manager(borrowernumber, borrower) { > let tab = $('#suggestiontabs .active table').data('tab-name'); >@@ -1256,20 +1262,16 @@ > managedby.val(borrowernumber); > } > >- [% IF op == "save" %] >+ if (op == "save"){ > var notify = $('#notify'); > if ( notify.length ) { >- [% IF managedby_patron %] >- if ( borrowernumber == [% logged_in_user.borrowernumber | html %] || borrowernumber == [% managedby_patron.borrowernumber | html %] ) { >- [% ELSE %] >- if ( borrowernumber == [% logged_in_user.borrowernumber | html %] ) { >- [% END %] >+ if ((managedby_patron_borrowernumber && (borrowernumber == logged_in_user_borrowernumber || borrowernumber == managedby_patron_borrowernumber )) || (!managedby_patron_borrowernumber && borrowernumber == logged_in_user_borrowernumber )){ > $(notify).prop('checked', false).prop('disabled', true); > } else { > $(notify).prop('disabled', false); > } > } >- [% END %] >+ } > } > > function select_suggester(borrowernumber, borrower) { >@@ -1319,12 +1321,20 @@ > </script> > [% END %] > [% IF op == 'else' %] >+ <script> >+ const has_suggestions = [% suggestions.size ? 1 : 0 | html %]; >+ let suggestionData = [% To.json(suggestions) | $raw %]; >+ var suggestions_table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %] >+ addPermissions({ >+ CAN_user_suggestions_suggestions_manage: [% CAN_user_suggestions_suggestions_manage ? 1 : 0 | html %], >+ CAN_user_suggestions_suggestions_delete: [% CAN_user_suggestions_suggestions_delete ? 1 : 0 | html %], >+ }); >+ </script> >+ > [% INCLUDE 'datatables.inc' %] > <script> > $(document).ready(function() { >- [% IF suggestions.size %] >- let suggestionData = [% To.json(suggestions) | $raw %]; >- var table_settings = [% TablesSettings.GetTableSettings( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %] >+ if (has_suggestions){ > function loadDatatable(tabName) { > let tabSuggestionData = suggestionData.find(s => s.suggestiontype === `${tabName}`) > $("#table_" + tabName).kohaTable( >@@ -1510,14 +1520,14 @@ > searchable: false, > orderable: false, > render: function (data, type, row, meta) { >- [% IF CAN_user_suggestions_suggestions_manage %] >+ if (permissions.CAN_user_suggestions_suggestions_manage){ > let node = '<div class="btn-group dropup">' > node += '<a class="btn btn-default btn-xs" role="button" href="suggestion.pl?suggestionid=%s&op=edit_form"><i class="fa-solid fa-pencil" aria-hidden="true"></i> %s</a>'.format(row.suggestion_id, _("Edit")) > node += '<a class="btn btn-default btn-xs dropdown-toggle" id="more_actions_%s" role="button" data-bs-toggle="dropdown" href="#"><b class="caret"></b></a>'.format(row.suggestion_id) > node += '<ul class="dropdown-menu" role="menu" aria-labelledby="more_actions_%s">'.format(row.suggestion_id) >- [% IF CAN_user_suggestions_suggestions_delete %] >+ if (permissions.CAN_user_suggestions_suggestions_delete){ > node += '<li><a href="#" data-op="cud-delete" data-suggestionid="%s" class="dropdown-item trigger_action">%s</a></li>'.format(row.suggestion_id, _("Delete")) >- [% END %] >+ } > if (!row.archived){ > node += '<li><a href="#" class="dropdown-item trigger_action" data-op="cud-archive" data-suggestionid="%s">%s</a></li>'.format(row.suggestion_id, _("Archive")) > } else { >@@ -1525,9 +1535,9 @@ > } > node += '</ul></div>' > return node >- [% ELSIF CAN_user_suggestions_suggestions_delete %] >+ } else if (permissions.CAN_user_suggestions_suggestions_delete){ > return '<button data-op="cud-delete" data-suggestionid="%s" class="btn btn-xs btn-default trigger_action"><i class="fa fa-trash-can"></i> %s</button>'.format(row.suggestion_id, _("Delete")) >- [% END %] >+ } > }, > createdCell: function (cell, cellData, rowData, rowIndex, colIndex) { > $(cell).find(".trigger_action").on("click", function(e) { >@@ -1546,7 +1556,7 @@ > }, > ] > }, >- table_settings >+ suggestions_table_settings > ); > } > if( $("#suggestiontabs .tab-pane.active").length < 1 ){ >@@ -1555,19 +1565,19 @@ > $("#suggestiontabs a:first").attr("data-table_loaded", 'true') > } > >- [% FOREACH suggestion IN suggestions %] >- $("#suggestiontabs #[% suggestion.suggestiontype | html %]-tab").on("click", function() { >+ suggestionData.forEach(suggestion => { >+ $(`#suggestiontabs #${suggestion.suggestiontype}-tab`).on("click", function() { > if(!$(this).data("table_loaded")) { >- loadDatatable("[% suggestion.suggestiontype | html%]") >- $(this).attr("data-table_loaded", "true") >+ loadDatatable(`${suggestion.suggestiontype}`); >+ $(this).attr("data-table_loaded", "true"); > } > }); >- [% END %] >- [% END %] >+ }); >+ } > > $("#branchcode").on('change',function(){ >- [%# Modify the hidden input in the filters block from the library %] >- [%# dropdown list at the top of suggestion list %] >+ // Modify the hidden input in the filters block from the library >+ // dropdown list at the top of suggestion list > let branchcode = $(this).val(); > $('input[name="branchcode"]').val( branchcode ); > $('form[name="suggestionfilter"]').submit(); >-- >2.43.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41579
: 191161 |
191162