View | Details | Raw Unified | Return to bug 35659
Collapse All | Expand All

(-)a/admin/oaiservers.pl (-7 / +7 lines)
Lines 23-29 Link Here
23
use Modern::Perl;
23
use Modern::Perl;
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use C4::Context;
25
use C4::Context;
26
use C4::Auth qw( get_template_and_user );
26
use C4::Auth   qw( get_template_and_user );
27
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output qw( output_html_with_http_headers );
28
use Koha::Database;
28
use Koha::Database;
29
use Koha::OaiServers;
29
use Koha::OaiServers;
Lines 31-38 use Koha::OaiServers; Link Here
31
# Initialize CGI, template, database
31
# Initialize CGI, template, database
32
32
33
my $input       = CGI->new;
33
my $input       = CGI->new;
34
my $op          = $input->param('op') || 'list';
34
my $op          = $input->param('op')   || 'list';
35
my $id          = $input->param('id') || 0;
35
my $id          = $input->param('id')   || 0;
36
my $type        = $input->param('type') || '';
36
my $type        = $input->param('type') || '';
37
my $searchfield = '';
37
my $searchfield = '';
38
38
Lines 54-60 my $schema = Koha::Database->new()->schema(); Link Here
54
# Main code
54
# Main code
55
# First process a confirmed delete, or save a validated record
55
# First process a confirmed delete, or save a validated record
56
56
57
if ( $op eq 'delete_confirmed' && $id ) {
57
if ( $op eq 'cud-delete_confirmed' && $id ) {
58
    my $server = Koha::OaiServers->find($id);
58
    my $server = Koha::OaiServers->find($id);
59
    if ($server) {
59
    if ($server) {
60
        $server->delete;
60
        $server->delete;
Lines 63-69 if ( $op eq 'delete_confirmed' && $id ) { Link Here
63
        $template->param( msg_notfound => 1, msg_add => $id );
63
        $template->param( msg_notfound => 1, msg_add => $id );
64
    }
64
    }
65
    $id = 0;
65
    $id = 0;
66
} elsif ( $op eq 'add_validated' ) {
66
} elsif ( $op eq 'cud-add_validated' ) {
67
    my @fields = qw/endpoint oai_set dataformat
67
    my @fields = qw/endpoint oai_set dataformat
68
        recordtype servername
68
        recordtype servername
69
        add_xslt/;
69
        add_xslt/;
Lines 81-87 if ( $op eq 'delete_confirmed' && $id ) { Link Here
81
        Koha::OaiServer->new($formdata)->store;
81
        Koha::OaiServer->new($formdata)->store;
82
        $template->param( msg_added => 1, msg_add => $formdata->{servername} );
82
        $template->param( msg_added => 1, msg_add => $formdata->{servername} );
83
    }
83
    }
84
} else {
84
} elsif ( $op eq 'search' ) {
85
85
86
    #use searchfield only in remaining operations
86
    #use searchfield only in remaining operations
87
    $searchfield = $input->param('searchfield') || '';
87
    $searchfield = $input->param('searchfield') || '';
Lines 92-98 if ( $op eq 'delete_confirmed' && $id ) { Link Here
92
my $data = [];
92
my $data = [];
93
if ( $op eq 'add' || $op eq 'edit' ) {
93
if ( $op eq 'add' || $op eq 'edit' ) {
94
    $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id;
94
    $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id;
95
    delete $data->[0]->{id} if @$data && $op eq 'add';    #cloning record
95
    delete $data->[0]->{id}                            if @$data && $op eq 'add';    #cloning record
96
    $template->param(
96
    $template->param(
97
        add_form => 1, server => @$data ? $data->[0] : undef,
97
        add_form => 1, server => @$data ? $data->[0] : undef,
98
        op => $op, type => $op eq 'add' ? lc $type : ''
98
        op => $op, type => $op eq 'add' ? lc $type : ''
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/oai-admin-search.inc (-4 / +4 lines)
Lines 3-18 Link Here
3
<div id="header_search" role="tablist">
3
<div id="header_search" role="tablist">
4
    <div class="tab-content">
4
    <div class="tab-content">
5
        <div id="oai_search" role="tabpanel" class="tab-pane active">
5
        <div id="oai_search" role="tabpanel" class="tab-pane active">
6
            <form action="/cgi-bin/koha/admin/oaiservers.pl" method="post">
6
            <form action="/cgi-bin/koha/admin/oaiservers.pl" method="get">
7
                <div class="form-title">
7
                <div class="form-title">
8
                    <label class="control-label">Search OAI repositories</label>
8
                    <label class="control-label" for="searchfield">Search OAI repositories</label>
9
                </div>
9
                </div>
10
10
11
                <div class="form-content">
11
                <div class="form-content">
12
                    <input class="head-searchbox form-control" type="text" name="searchfield" id="searchfield" value="[% searchfield | html %]" placeholder="OAI repository search" />
12
                    <input class="head-searchbox form-control" type="text" name="searchfield" id="searchfield" value="[% searchfield | html %]" placeholder="OAI repository search" />
13
                </div>
13
                </div>
14
14
                <input type="hidden" name="op" value="search" />
15
                <button type="submit"><i class="fa fa-arrow-right"></i></button>
15
                <button type="submit" aria-label="Search"><i class="fa fa-arrow-right"></i></button>
16
            </form>
16
            </form>
17
        </div>
17
        </div>
18
18
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oaiservers.tt (-3 / +14 lines)
Lines 67-79 Link Here
67
67
68
[% IF ( add_form ) %]
68
[% IF ( add_form ) %]
69
    <form action="[% script_name | html %]" name="Aform" method="post" id="serverentry">
69
    <form action="[% script_name | html %]" name="Aform" method="post" id="serverentry">
70
        <input type="hidden" name="op" value="add_validated" />
70
        [% INCLUDE 'csrf-token.inc' %]
71
        [% IF op == 'edit' %]
71
        [% IF op == 'edit' %]
72
            <h1>Modify OAI repository</h1>
72
            <h1>Modify OAI repository</h1>
73
            <input type="hidden" name="id" value="[% server.id | html %]" />
73
            <input type="hidden" name="id" value="[% server.id | html %]" />
74
        [% ELSE %]
74
        [% ELSE %]
75
            <h1>New OAI repository</h1>
75
            <h1>New OAI repository</h1>
76
        [% END %]
76
        [% END %]
77
78
        <input type="hidden" name="op" value="cud-add_validated" />
77
        <fieldset class="rows">
79
        <fieldset class="rows">
78
        <ol>
80
        <ol>
79
        <li><label for="name" class="required">Repository name: </label>
81
        <li><label for="name" class="required">Repository name: </label>
Lines 153-159 Link Here
153
                    <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
155
                    <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
154
                        <li><a href="/cgi-bin/koha/admin/oaiservers.pl?op=edit&amp;id=[% loo.id | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li>
156
                        <li><a href="/cgi-bin/koha/admin/oaiservers.pl?op=edit&amp;id=[% loo.id | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li>
155
                        <li><a href="/cgi-bin/koha/admin/oaiservers.pl?op=add&amp;id=[% loo.id | uri %]"><i class="fa fa-copy"></i> Copy</a></li>
157
                        <li><a href="/cgi-bin/koha/admin/oaiservers.pl?op=add&amp;id=[% loo.id | uri %]"><i class="fa fa-copy"></i> Copy</a></li>
156
                        <li><a href="/cgi-bin/koha/admin/oaiservers.pl?op=delete_confirmed&amp;id=[% loo.id | uri %]" class="delete" data-servername="[% loo.servername | html %]"><i class="fa fa-trash-can"></i> Delete</a></li>
158
                        <li>
159
                            <a href="#" class="delete" data-formid="server_row_[% loo.id | uri %]" data-servername="[% loo.servername | html %]"><i class="fa fa-trash-can"></i> Delete</a>
160
                            <form id="server_row_[% loo.id | uri %]" action="/cgi-bin/koha/admin/oaiservers.pl" method="post">
161
                                [% INCLUDE 'csrf-token.inc' %]
162
                                <input type="hidden" name="op" value="cud-delete_confirmed">
163
                                <input type="hidden" name="id" value="[% loo.id | uri %]">
164
                            </form>
165
                        </li>
166
157
                    </ul>
167
                    </ul>
158
                </div>
168
                </div>
159
            </td>
169
            </td>
Lines 216-222 Link Here
216
                }));
226
                }));
217
                $(".delete").on("click",function(e){
227
                $(".delete").on("click",function(e){
218
                    var servername = $(this).data("servername");
228
                    var servername = $(this).data("servername");
229
                    let formid = $(this).data("formid");
219
                    if( confirm( _("Are you sure you want to delete repository %s?").format(servername) ) ) {
230
                    if( confirm( _("Are you sure you want to delete repository %s?").format(servername) ) ) {
231
                        $('#'+formid).submit();
220
                        return true;
232
                        return true;
221
                    } else {
233
                    } else {
222
                        e.preventDefault();
234
                        e.preventDefault();
223
- 

Return to bug 35659