Bugzilla – Attachment 117988 Details for
Bug 5697
Automatic linking in guided reports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 5697: Consolidate nodes construction and fix translation issue
Bug-5697-Consolidate-nodes-construction-and-fix-tr.patch (text/plain), 8.42 KB, created by
Jonathan Druart
on 2021-03-09 16:02:47 UTC
(
hide
)
Description:
Bug 5697: Consolidate nodes construction and fix translation issue
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-09 16:02:47 UTC
Size:
8.42 KB
patch
obsolete
>From 6f26b59db17b4618c537e62c84f91cf5f17f93bf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 9 Mar 2021 16:44:06 +0100 >Subject: [PATCH] Bug 5697: Consolidate nodes construction and fix translation > issue > >The way the buttons were created was not nice as it was a full HTML node >built with a JS string, on a single line. >I first tried to split the line and then realized but could put in a >function and reuse. Then noticed that the button's text was not >translatable. > >I ended up with this patch. I don't know if it's more readable, but at >least it seems a bit more robust and maintainable in the long term. >--- > .../modules/reports/guided_reports_start.tt | 60 +++++++++++++++++-- > 1 file changed, 56 insertions(+), 4 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index edae45d55a..a014088dc8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -1869,6 +1869,58 @@ > $("#limitselect").submit(); > }); > >+ function build_record_links(data, column_type){ >+ var node = $('<div class="btn-group dropup autolink"></div>'); >+ $(node).append('<a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">' + data + ' <b class="caret"></b></a>'); >+ var ul = $('<ul class="dropdown-menu pull-right" role="menu"></ul>'); >+ >+ var buttons = []; >+ if ( column_type == 'biblionumber' ) { >+ buttons.push({ href: '/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + data, >+ type:'view', >+ text: _("View record") }); >+ buttons.push({ href: '/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=' + data, >+ type: 'edit', >+ text: _("Edit record") }); >+ } else if ( column_type == 'itemnumber' ) { >+ buttons.push({ href: '/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=' + data, >+ type: 'view', >+ text: _("View item") }); >+ buttons.push({ href: '/cgi-bin/koha/cataloguing/additem.pl?op=edititem&itemnumber=' + data + '#edititem', >+ type: 'edit', >+ text: _("Edit item") }); >+ } else if ( column_type == 'borrowernumber' ) { >+ buttons.push({ href: '/cgi-bin/koha/members/moremember.pl?borrowernumber=' + data, >+ type: 'view', >+ text: _("View patron") }); >+ buttons.push({ href: '/cgi-bin/koha/members/memberentry.pl?borrowernumber=' + data, >+ type: 'edit', >+ text: _("Edit patron") }); >+ buttons.push({ href: '/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + data, >+ type: 'checkout', >+ text: _("Check out") }); >+ } else if ( column_type == 'cardnumber' ) { >+ buttons.push({ href: '/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + data, >+ type: 'checkout', >+ text: _("Check out") }); >+ } >+ var need_sep = 0; >+ while ( (b = buttons.pop()) != null ) { >+ if ( need_sep ) { >+ $(ul).append('<li role="separator" class="divider"></li>'); >+ } >+ var icon; >+ if (b['type'] == 'view') icon = 'fa fa-window-restore'; >+ else if (b['type'] == 'edit') icon = 'fa fa-pencil'; >+ else if (b['type'] == 'checkout') icon = 'fa fa-window-restore'; >+ $(ul).append('<li><a target="_blank" href="' + b['href'] + '"><i class="' + icon + '"></i> ' + b['text'] + '</a></li>') >+ need_sep = 1; >+ } >+ >+ $(node).append(ul); >+ return $(node)[0].outerHTML; >+ } >+ > if( $("#report_results").length > 0 ){ > $("#report_results").dataTable($.extend(true, {}, dataTablesDefaults, { > "dom": 't', >@@ -1878,25 +1930,25 @@ > { > targets: "biblionumber", > render: function ( data ) { >- return '<span class="data-plain">' + data + '</span><div class="btn-group dropup autolink"><a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">' + data + ' <b class="caret"></b></a><ul class="dropdown-menu pull-right" role="menu"><li><a target="_blank" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=' + data + '"><i class="fa fa-window-restore"></i> View record</a></li><li role="separator" class="divider"></li><li><a target="_blank" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=' + data + '"><i class="fa fa-pencil"></i> Edit record</a></li></ul></div>'; >+ return '<span class="data-plain">' + data + '</span>' + build_record_links(data, 'biblionumber'); > } > }, > { > targets: "itemnumber", > render: function ( data ) { >- return '<span class="data-plain">' + data + '</span><div class="btn-group dropup autolink"><a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">' + data + ' <b class="caret"></b></a><ul class="dropdown-menu pull-right" role="menu"><li><a target="_blank" href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=' + data + '"><i class="fa fa-window-restore"></i> View item</a></li><li role="separator" class="divider"></li><li><a target="_blank" href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&itemnumber=' + data + '#edititem"><i class="fa fa-pencil"></i> Edit item</a></li></ul></div>'; >+ return '<span class="data-plain">' + data + '</span>' + build_record_links(data, 'itemnumber'); > } > }, > { > targets: "borrowernumber", > render: function ( data ) { >- return '<span class="data-plain">' + data + '</span><div class="btn-group dropup autolink"><a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">' + data + ' <b class="caret"></b></a><ul class="dropdown-menu pull-right" role="menu"><li><a target="_blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' + data + '"><i class="fa fa-window-restore"></i> View patron</a></li><li role="separator" class="divider"></li><li><a target="_blank" href="/cgi-bin/koha/members/memberentry.pl?borrowernumber=' + data + '"><i class="fa fa-pencil"></i> Edit patron</a></li><li role="separator" class="divider"></li><li><a target="_blank" href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=' + data + '"><i class="fa fa-window-restore"></i> Check out</a></li></ul></div>'; >+ return '<span class="data-plain">' + data + '</span>' + build_record_links(data, 'borrowernumber'); > } > }, > { > targets: "cardnumber", > render: function ( data ) { >- return '<span class="data-plain">' + data + '</span><div class="btn-group dropup autolink"><a class="btn btn-link dropdown-toggle" role="button" data-toggle="dropdown" href="#">' + data + ' <b class="caret"></b></a><ul class="dropdown-menu pull-right" role="menu"><li><a target="_blank" href="/cgi-bin/koha/circ/circulation.pl?findborrower=' + data + '"><i class="fa fa-window-restore"></i> Check out</a></li></ul></div>'; >+ return '<span class="data-plain">' + data + '</span>' + build_record_links(data, 'cardnumber'); > } > }, > ] >-- >2.20.1
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 5697
:
110075
|
110668
|
110697
|
117096
|
117755
|
117765
|
117766
|
117988
|
118022
|
127484
|
128252
|
128277