Bugzilla – Attachment 188631 Details for
Bug 6473
Test bug for Git-bz ✔ ❤ ★
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40841: Add limits configuration UI
cb0bbc8.patch (text/plain), 8.64 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-10-30 11:57:38 UTC
(
hide
)
Description:
Bug 40841: Add limits configuration UI
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-10-30 11:57:38 UTC
Size:
8.64 KB
patch
obsolete
>From cb0bbc8560a7ecf1c079b6257dad04986f64be55 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Wed, 29 Oct 2025 10:01:27 -0300 >Subject: [PATCH] Bug 40841: Add limits configuration UI >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds branch limits selection to the Z30.50/SRU configuration >page. > >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >--- > admin/z3950servers.pl | 69 ++++++++++++------- > .../prog/en/modules/admin/z3950servers.tt | 32 ++++++++- > 2 files changed, 75 insertions(+), 26 deletions(-) > >diff --git a/admin/z3950servers.pl b/admin/z3950servers.pl >index 04d1f7310d6..02d4e5b00f5 100755 >--- a/admin/z3950servers.pl >+++ b/admin/z3950servers.pl >@@ -28,10 +28,10 @@ use CGI qw ( -utf8 ); > use C4::Context; > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); >-use Koha::Database; > use Koha::Z3950Servers; >+use Try::Tiny qw( catch try ); > >-# Initialize CGI, template, database >+# Initialize CGI, template > > my $input = CGI->new; > my $op = $input->param('op') || 'list'; >@@ -48,8 +48,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >-my $schema = Koha::Database->new()->schema(); >- > # Main code > # First process a confirmed delete, or save a validated record > >@@ -67,18 +65,30 @@ if ( $op eq 'cud-delete_confirmed' && $id ) { > recordtype checked servername servertype sru_options sru_fields attributes > add_xslt/; > my $formdata = _form_data_hashref( $input, \@fields ); >+ my @branches = grep { $_ ne q{} } $input->multi_param('branches'); >+ > if ($id) { > my $server = Koha::Z3950Servers->find($id); > if ($server) { >- $server->set($formdata)->store; >- $template->param( msg_updated => 1, msg_add => $formdata->{servername} ); >+ try { >+ $server->set($formdata)->store; >+ $server->replace_library_limits( \@branches ); >+ $template->param( msg_updated => 1, msg_add => $formdata->{servername} ); >+ } catch { >+ $template->param( msg_error => 1, msg_add => $formdata->{servername} ); >+ }; > } else { > $template->param( msg_notfound => 1, msg_add => $id ); > } > $id = 0; > } else { >- Koha::Z3950Server->new($formdata)->store; >- $template->param( msg_added => 1, msg_add => $formdata->{servername} ); >+ try { >+ my $server = Koha::Z3950Server->new($formdata)->store; >+ $server->replace_library_limits( \@branches ); >+ $template->param( msg_added => 1, msg_add => $formdata->{servername} ); >+ } catch { >+ $template->param( msg_error => 1, msg_add => $formdata->{servername} ); >+ }; > } > } elsif ( $op eq 'search' ) { > >@@ -88,18 +98,35 @@ if ( $op eq 'cud-delete_confirmed' && $id ) { > > # Now list multiple records, or edit one record > >-my $data = []; >-if ( $op eq 'add' || $op eq 'edit' ) { >- $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id; >- delete $data->[0]->{id} if @$data && $op eq 'add'; #cloning record >+if ( $op eq 'add' ) { >+ my $server; >+ >+ if ($id) { >+ $server = Koha::Z3950Servers->find($id); >+ if ($server) { >+ >+ # Cloning record - remove id >+ $server = $server->unblessed; >+ delete $server->{id}; >+ } >+ } >+ >+ $template->param( >+ add_form => 1, server => $server, >+ op => $op, type => lc $type >+ ); >+} elsif ( $op eq 'edit' ) { >+ my $server = Koha::Z3950Servers->find($id); > $template->param( >- add_form => 1, server => @$data ? $data->[0] : undef, >- op => $op, type => $op eq 'add' ? lc $type : '' >+ add_form => 1, server => $server, >+ op => $op, type => '' >+ ); >+} else { # search >+ my $data = Koha::Z3950Servers->search( >+ $id ? { id => $id } : { servername => { like => $searchfield . '%' } }, > ); >-} else { >- $data = ServerSearch( $schema, $id, $searchfield ); > $template->param( >- loop => \@$data, searchfield => $searchfield, id => $id, >+ loop => $data, searchfield => $searchfield, id => $id, > op => 'list' > ); > } >@@ -107,14 +134,6 @@ output_html_with_http_headers $input, $cookie, $template->output; > > # End of main code > >-sub ServerSearch { #find server(s) by id or name >- my ( $schema, $id, $searchstring ) = @_; >- >- return Koha::Z3950Servers->search( >- $id ? { id => $id } : { servername => { like => $searchstring . '%' } }, >- )->unblessed; >-} >- > sub _form_data_hashref { > my ( $input, $fieldref ) = @_; > return { map { ( $_ => scalar $input->param($_) // '' ) } @$fieldref }; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >index ef73637f27d..ce57b3df422 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/z3950servers.tt >@@ -2,6 +2,7 @@ > [% USE Koha %] > [% USE Asset %] > [% USE HtmlTags %] >+[% USE Branches %] > [% PROCESS 'i18n.inc' %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] >@@ -198,6 +199,13 @@ > <input type="text" name="add_xslt" id="add_xslt" size="100" value="[% server.add_xslt | html %]" /> > <div class="hint">Separate multiple filenames by commas.</div> > </li> >+ <li> >+ <label for="library_limitation">Library limitation: </label> >+ <select id="library_limitation" name="branches" multiple size="10"> >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => server.get_library_limits, unfiltered => 1, do_not_select_my_library => 1 ) %] >+ </select> >+ <div class="hint">Limits the use of this server to the selected libraries.</div> >+ </li> > </ol> > </fieldset> > >@@ -220,7 +228,7 @@ > <thead > ><tr > ><th>Target</th><th>Hostname/Port</th><th>Database</th><th>Userid</th><th>Password</th><th>Preselected</th><th>Rank</th><th>Syntax</th><th>Encoding</th><th>Timeout</th><th>Record type</th><th>Attributes</th >- ><th class="no-export no-sort">Actions</th> >+ ><th>Library limitations</th><th class="no-export no-sort">Actions</th> > </tr></thead > > > <tbody> >@@ -237,6 +245,28 @@ > [% END %] > </td> > <td>[% loo.attributes | html %]</td> >+ <td> >+ [% SET library_limits = loo.library_limits %] >+ [% IF library_limits && library_limits.count > 0 %] >+ [% library_str = "" %] >+ [% FOREACH library IN library_limits %] >+ [%- IF loop.first -%] >+ [% library_str = library.branchname _ " (" _ library.branchcode _ ")" %] >+ [% ELSE %] >+ [% library_str = library_str _ "\n" _ library.branchname _ " (" _ library.branchcode _ ")" %] >+ [% END %] >+ [% END %] >+ <span class="library_limitation" data-bs-toggle="tooltip" title="[% library_str | html %]"> >+ [% IF library_limits.count > 1 %] >+ <span>[% library_limits.count | html %] library limitations</span> >+ [% ELSE %] >+ <span>[% library_limits.count | html %] library limitation</span> >+ [% END %] >+ </span> >+ [% ELSE %] >+ <span>No limitation</span> >+ [% END %] >+ </td> > <td> > <div class="btn-group dropup"> > <a class="btn btn-default btn-xs dropdown-toggle" id="reportactions[% savedreport.id | html %]" role="button" data-bs-toggle="dropdown" href="#"> Actions </a> >-- >2.51.2
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 6473
:
4386
|
6837
|
6838
|
6839
|
6840
|
6841
|
6842
|
6843
|
7154
|
7155
|
7567
|
7994
|
7995
|
7996
|
7997
|
8018
|
9807
|
9808
|
9813
|
9831
|
9832
|
9836
|
9854
|
10842
|
10843
|
10844
|
10845
|
10846
|
10847
|
10848
|
10849
|
10850
|
10851
|
10852
|
10853
|
10854
|
10855
|
10856
|
10857
|
10858
|
11540
|
11543
|
11544
|
12502
|
12513
|
12514
|
12515
|
12516
|
12517
|
12518
|
12519
|
13473
|
13673
|
14955
|
14969
|
14970
|
14972
|
15201
|
18949
|
18950
|
18951
|
18952
|
18953
|
18954
|
18955
|
18956
|
18957
|
18958
|
18959
|
18960
|
18961
|
18962
|
18963
|
18971
|
18972
|
19518
|
19519
|
19591
|
19592
|
19871
|
19879
|
19880
|
19881
|
19882
|
20011
|
20012
|
20013
|
20014
|
22477
|
22481
|
22482
|
22496
|
22502
|
22503
|
31958
|
32444
|
32445
|
32446
|
32447
|
32448
|
32449
|
32450
|
32451
|
32452
|
34200
|
34201
|
34625
|
34999
|
35130
|
35269
|
35273
|
35274
|
35275
|
35276
|
35277
|
35279
|
35280
|
35303
|
40954
|
40957
|
45345
|
45349
|
45731
|
45732
|
45733
|
45734
|
47283
|
47284
|
47298
|
47299
|
47300
|
47334
|
47336
|
49083
|
56974
|
61059
|
61069
|
62038
|
65313
|
77301
|
78016
|
79959
|
80178
|
80179
|
80180
|
80181
|
80182
|
84400
|
86644
|
86645
|
87152
|
88128
|
95586
|
95716
|
97394
|
99026
|
99027
|
114217
|
114218
|
114219
|
114220
|
114221
|
114222
|
114223
|
114224
|
114225
|
114226
|
119255
|
121181
|
131891
|
131893
|
131894
|
134862
|
144109
|
144144
|
144671
|
144672
|
144673
|
147183
|
149030
|
149031
|
149032
|
149033
|
160566
|
160567
|
160568
|
182093
|
183107
|
183177
|
183178
|
183179
|
183180
|
183182
|
183183
|
183285
|
183286
|
187209
|
187321
|
187322
|
187323
|
187324
|
187325
|
187326
|
187327
|
187328
|
187329
|
187330
|
187331
|
187332
|
187333
|
187334
|
187335
|
187336
|
187337
|
187338
|
187339
|
187340
|
187341
|
187342
|
187343
|
187344
|
187345
|
187346
|
187347
|
187348
|
187349
|
187350
|
187351
|
187352
|
187353
|
187354
|
187355
|
187356
|
187357
|
187358
|
187359
|
187360
|
187361
|
187362
|
187363
|
187364
|
187365
|
187366
|
187367
|
187368
|
187369
|
187370
|
187371
|
187372
|
187545
|
187546
|
188609
|
188610
|
188611
|
188612
|
188613
|
188614
|
188626
|
188627
|
188628
|
188629
|
188630
|
188631
|
188632
|
188633
|
188634
|
188645
|
188647
|
188703
|
188929
|
188937
|
188975
|
190164
|
190165
|
190166
|
190167
|
190168
|
190169
|
190170
|
190171
|
190172
|
190173
|
190174
|
190175
|
190176
|
190177
|
190178
|
190179
|
190180
|
190181
|
190182
|
190183
|
190184
|
190185
|
190186
|
190187
|
190188
|
190240
|
190241
|
190242
|
190243
|
190244
|
190245
|
190246
|
190247
|
190248
|
190249
|
190250
|
190251
|
190252
|
190253
|
190255
|
190256