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

(-)a/admin/items_search_field.pl (-1 / +13 lines)
Lines 22-28 use CGI; Link Here
22
use C4::Auth qw( get_template_and_user );
22
use C4::Auth qw( get_template_and_user );
23
use C4::Output qw( output_html_with_http_headers );
23
use C4::Output qw( output_html_with_http_headers );
24
24
25
use Koha::Item::Search::Field qw(GetItemSearchField ModItemSearchField);
25
use Koha::Item::Search::Field qw(GetItemSearchField AddItemSearchField ModItemSearchField);
26
26
27
my $cgi = CGI->new;
27
my $cgi = CGI->new;
28
28
Lines 48-53 if ($op eq 'mod') { Link Here
48
    my $updated = ($field) ? 1 : 0;
48
    my $updated = ($field) ? 1 : 0;
49
    print $cgi->redirect('/cgi-bin/koha/admin/items_search_fields.pl?updated=' . $updated);
49
    print $cgi->redirect('/cgi-bin/koha/admin/items_search_fields.pl?updated=' . $updated);
50
    exit;
50
    exit;
51
} elsif ( $op eq 'add' ) {
52
    my %vars = $cgi->Vars;
53
    my $field;
54
    my @params = qw(name label tagfield tagsubfield authorised_values_category);
55
    @$field{@params} = @vars{@params};
56
    if ( $field->{authorised_values_category} eq '' ) {
57
        $field->{authorised_values_category} = undef;
58
    }
59
    $field = AddItemSearchField($field);
60
    my $added = ($field) ? 1 : 0;
61
    print $cgi->redirect( '/cgi-bin/koha/admin/items_search_fields.pl?added=' . $added );
62
    exit;
51
}
63
}
52
64
53
my $field = GetItemSearchField($name);
65
my $field = GetItemSearchField($name);
(-)a/admin/items_search_fields.pl (-16 / +2 lines)
Lines 22-28 use CGI; Link Here
22
use C4::Auth qw( get_template_and_user );
22
use C4::Auth qw( get_template_and_user );
23
use C4::Output qw( output_html_with_http_headers );
23
use C4::Output qw( output_html_with_http_headers );
24
24
25
use Koha::Item::Search::Field qw(AddItemSearchField GetItemSearchFields DelItemSearchField);
25
use Koha::Item::Search::Field qw(GetItemSearchFields DelItemSearchField);
26
26
27
my $cgi = CGI->new;
27
my $cgi = CGI->new;
28
28
Lines 35-55 my ($template, $borrowernumber, $cookie) = get_template_and_user({ Link Here
35
35
36
my $op = $cgi->param('op') || '';
36
my $op = $cgi->param('op') || '';
37
37
38
if ($op eq 'add') {
38
if ($op eq 'del') {
39
    my %vars = $cgi->Vars;
40
    my $field;
41
    my @params = qw(name label tagfield tagsubfield authorised_values_category);
42
    @$field{@params} = @vars{@params};
43
    if ( $field->{authorised_values_category} eq '' ) {
44
        $field->{authorised_values_category} = undef;
45
    }
46
    $field = AddItemSearchField($field);
47
    if ($field) {
48
        $template->param(field_added => $field);
49
    } else {
50
        $template->param(field_not_added => 1);
51
    }
52
} elsif ($op eq 'del') {
53
    my $name = $cgi->param('name');
39
    my $name = $cgi->param('name');
54
    my $rv = DelItemSearchField($name);
40
    my $rv = DelItemSearchField($name);
55
    if ($rv) {
41
    if ($rv) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_field.tt (-12 / +24 lines)
Lines 5-10 Link Here
5
[% SET footerjs = 1 %]
5
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
    <title>[% FILTER collapse %]
7
    <title>[% FILTER collapse %]
8
    [% IF (field) %]
9
        [% tx("Modify search field '{field}'", { field = field.name }) | html %]
10
    [% ELSE %]
11
        [% t("New search field") | html %]
12
    [% END %] &rsaquo;
8
    [% t("Item search fields") | html %] &rsaquo;
13
    [% t("Item search fields") | html %] &rsaquo;
9
    [% t("Administration") | html %] &rsaquo;
14
    [% t("Administration") | html %] &rsaquo;
10
    [% t("Koha") | html %]
15
    [% t("Koha") | html %]
Lines 23-39 Link Here
23
                <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
28
                <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
24
            [% END %]
29
            [% END %]
25
30
31
            [% WRAPPER breadcrumb_item %]
32
                <a href="/cgi-bin/koha/admin/items_search_fields.pl">Item search fields</a>
33
            [% END %]
26
            [% IF (field) %]
34
            [% IF (field) %]
27
                [% WRAPPER breadcrumb_item %]
28
                    <a href="/cgi-bin/koha/admin/items_search_fields.pl">Item search fields</a>
29
                [% END %]
30
                [% WRAPPER breadcrumb_item bc_active= 1 %]
35
                [% WRAPPER breadcrumb_item bc_active= 1 %]
31
                    <span>Modify search field [% field.name | html %]</span>
36
                    [% tx("Modify search field  '{field}'", { field = field.name }) | html %]
32
                [% END %]
37
                [% END %]
33
38
34
            [% ELSE %]
39
            [% ELSE %]
35
                [% WRAPPER breadcrumb_item bc_active= 1 %]
40
                [% WRAPPER breadcrumb_item bc_active= 1 %]
36
                    <span>Item search fields</span>
41
                    <span>New search field</span>
37
                [% END %]
42
                [% END %]
38
            [% END %]
43
            [% END %]
39
        [% END #/ WRAPPER breadcrumbs %]
44
        [% END #/ WRAPPER breadcrumbs %]
Lines 44-58 Link Here
44
            <div class="col-sm-10 col-sm-push-2">
49
            <div class="col-sm-10 col-sm-push-2">
45
                <main>
50
                <main>
46
51
47
                    <h1>Item search field: [% field.label | html %]</h1>
52
                    <h1>
53
                        [% IF (field) %]
54
                            [% tx("Modify search field  '{field}'", { field = field.name }) | html %]
55
                        [% ELSE %]
56
                            [% t("New search field") | html %]
57
                        [% END %]
58
                    </h1>
48
59
49
                    <form action="/cgi-bin/koha/admin/items_search_field.pl" method="POST" id="edit_search_fields">
60
                    <form action="/cgi-bin/koha/admin/items_search_field.pl" method="POST" id="search_fields">
50
                        <fieldset class="rows">
61
                        <fieldset class="rows">
51
                        <legend>Edit field</legend>
62
                            [% INCLUDE 'admin-items-search-field-form.inc' field=field %]
52
                        [% INCLUDE 'admin-items-search-field-form.inc' field=field %]
63
                            [% IF (field) %]
53
                        <div>
64
                                <input type="hidden" name="op" value="mod" />
54
                            <input type="hidden" name="op" value="mod" />
65
                            [% ELSE %]
55
                        </div>
66
                                <input type="hidden" name="op" value="add" />
67
                            [% END %]
56
                        </fieldset>
68
                        </fieldset>
57
                        <fieldset class="action">
69
                        <fieldset class="action">
58
                            <input type="submit" class="btn btn-primary" value="Submit" />
70
                            <input type="submit" class="btn btn-primary" value="Submit" />
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/items_search_fields.tt (-18 / +3 lines)
Lines 19-27 Link Here
19
19
20
    [% WRAPPER 'sub-header.inc' %]
20
    [% WRAPPER 'sub-header.inc' %]
21
        [% WRAPPER breadcrumbs %]
21
        [% WRAPPER breadcrumbs %]
22
            [% WRAPPER breadcrumb_item %]
23
                <a href="/cgi-bin/koha/mainpage.pl">Home</a>
24
            [% END %]
25
            [% WRAPPER breadcrumb_item %]
22
            [% WRAPPER breadcrumb_item %]
26
                <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
23
                <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
27
            [% END %]
24
            [% END %]
Lines 37-48 Link Here
37
                <main>
34
                <main>
38
35
39
                    <div id="toolbar" class="btn-toolbar">
36
                    <div id="toolbar" class="btn-toolbar">
40
                        <a class="btn btn-default" id="new_search_field" href="/cgi-bin/koha/admin/items_search_fields.pl"><i class="fa fa-plus"></i> New search field</a>
37
                        <a class="btn btn-default" href="/cgi-bin/koha/admin/items_search_field.pl"><i class="fa fa-plus"></i> New search field</a>
41
                    </div>
38
                    </div>
42
39
43
                    [% IF field_added %]
40
                    [% IF field_added %]
44
                        <div class="dialog message">
41
                        <div class="dialog message">
45
                            Field successfully added: [% field_added.label | html %]
42
                            Field successfully added
46
                        </div>
43
                        </div>
47
                    [% ELSIF field_not_added %]
44
                    [% ELSIF field_not_added %]
48
                        <div class="dialog alert">
45
                        <div class="dialog alert">
Lines 60-66 Link Here
60
                        </div>
57
                        </div>
61
                    [% ELSIF field_updated %]
58
                    [% ELSIF field_updated %]
62
                        <div class="dialog message">
59
                        <div class="dialog message">
63
                            Field successfully updated: [% field_updated.label | html %]
60
                            Field successfully updated
64
                        </div>
61
                        </div>
65
                    [% ELSIF field_not_updated %]
62
                    [% ELSIF field_not_updated %]
66
                        <div class="dialog alert">
63
                        <div class="dialog alert">
Lines 108-125 Link Here
108
                        </div>
105
                        </div>
109
                    [% END %]
106
                    [% END %]
110
107
111
                    <form id="add_field_form" action="/cgi-bin/koha/admin/items_search_fields.pl" method="POST">
112
                        <fieldset class="rows">
113
                            <legend><h1>Add a new field</h1></legend>
114
                            [% INCLUDE 'admin-items-search-field-form.inc' field=undef %]
115
                            <input type="hidden" name="op" value="add" />
116
                        </fieldset>
117
                        <fieldset class="action">
118
                            <input type="submit" class="btn btn-primary" value="Submit" />
119
                            <a href="#" class="cancel hide_form">Cancel</a>
120
                        </fieldset>
121
                    </form>
122
123
                </main>
108
                </main>
124
            </div> <!-- /.col-sm-10.col-sm-push-2 -->
109
            </div> <!-- /.col-sm-10.col-sm-push-2 -->
125
110
(-)a/koha-tmpl/intranet-tmpl/prog/js/item_search_fields.js (-28 / +1 lines)
Lines 5-23 jQuery.validator.addMethod("marcfield", function(value, element) { Link Here
5
}, __("Please enter letters or numbers") );
5
}, __("Please enter letters or numbers") );
6
6
7
$(document).ready(function(){
7
$(document).ready(function(){
8
    $("#add_field_form").hide();
9
    $("#new_search_field").on("click",function(e){
10
        e.preventDefault();
11
        $("#add_field_form").show();
12
        $(".dialog").hide();
13
        $("#search_fields_list,#toolbar").hide();
14
    });
15
    $(".hide_form").on("click",function(e){
16
        e.preventDefault();
17
        $("#add_field_form").hide();
18
        $(".dialog").show();
19
        $("#search_fields_list,#toolbar").show();
20
    });
21
    $(".field-delete").on("click",function(){
8
    $(".field-delete").on("click",function(){
22
        $(this).parent().parent().addClass("highlighted-row");
9
        $(this).parent().parent().addClass("highlighted-row");
23
        if (confirm( __("Are you sure you want to delete this field?") )) {
10
        if (confirm( __("Are you sure you want to delete this field?") )) {
Lines 28-47 $(document).ready(function(){ Link Here
28
        }
15
        }
29
    });
16
    });
30
17
31
    $("#add_field_form").validate({
18
    $("#search_fields").validate({
32
        rules: {
33
            label: "required",
34
            tagfield: {
35
                required: true,
36
                marcfield: true
37
            },
38
            tagsubfield: {
39
                marcfield: true
40
            }
41
        }
42
    });
43
44
    $("#edit_search_fields").validate({
45
        rules: {
19
        rules: {
46
            label: "required",
20
            label: "required",
47
            tagfield: {
21
            tagfield: {
48
- 

Return to bug 34401