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

(-)a/installer/data/mysql/atomicupdate/bug_19482_add_mandatory_field_to_mapping.perl (-1 / +1 lines)
Lines 2-8 $DBversion = 'XXX'; # will be replaced by the RM Link Here
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
3
4
    if( !column_exists( 'search_field', 'mandatory' ) ) {
4
    if( !column_exists( 'search_field', 'mandatory' ) ) {
5
        $dbh->do( "ALTER TABLE search_field ADD COLUMN mandatory tinyint(1) NULL DEFAULT NULL" );
5
        $dbh->do( "ALTER TABLE search_field ADD COLUMN mandatory tinyint(1) NULL DEFAULT NULL AFTER opac" );
6
    }
6
    }
7
7
8
    SetVersion( $DBversion );
8
    SetVersion( $DBversion );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/searchengine/elasticsearch/mappings.tt (-1 / +1 lines)
Lines 197-203 a.add, a.delete { Link Here
197
                        [% ELSE %]
197
                        [% ELSE %]
198
                            <input type="text" name="search_field_label" value="[% search_field.label | html %]" />
198
                            <input type="text" name="search_field_label" value="[% search_field.label | html %]" />
199
                        [% END %]
199
                        [% END %]
200
200
                      </td>
201
                      <td>
201
                      <td>
202
                        [% IF search_field.mandatory %]
202
                        [% IF search_field.mandatory %]
203
                            <input type="hidden" name="search_field_type" value="[% search_field.type | html %]" />
203
                            <input type="hidden" name="search_field_type" value="[% search_field.type | html %]" />
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/ExportConfig.t (-1 / +3 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 18;
20
use Test::More tests => 19;
21
21
22
use Koha::Database;
22
use Koha::Database;
23
use Koha::SearchFields;
23
use Koha::SearchFields;
Lines 43-48 my $search_field = Koha::SearchFields->find_or_create( Link Here
43
        weight  => 17,
43
        weight  => 17,
44
        staff_client => 0,
44
        staff_client => 0,
45
        opac         => 1,
45
        opac         => 1,
46
        mandatory    => 1
46
    },
47
    },
47
    { key => 'name' } );
48
    { key => 'name' } );
48
49
Lines 95-100 is( $mappings->{biblios}{title}{label}, 'Title', 'title has label Title'); Link Here
95
is( $mappings->{biblios}{title}{facet_order}, undef, 'Facet order is undef');
96
is( $mappings->{biblios}{title}{facet_order}, undef, 'Facet order is undef');
96
is( $mappings->{biblios}{title}{opac}, 1, 'title is opac searchable');
97
is( $mappings->{biblios}{title}{opac}, 1, 'title is opac searchable');
97
is( $mappings->{biblios}{title}{staff_client}, 0, 'title is not staff searchable');
98
is( $mappings->{biblios}{title}{staff_client}, 0, 'title is not staff searchable');
99
is( $mappings->{biblios}{title}{mandatory}, 1, 'title is mandatory');
98
100
99
is(scalar(@{ $mappings->{biblios}{title}{mappings} }), 3, 'Title has 3 mappings');
101
is(scalar(@{ $mappings->{biblios}{title}{mappings} }), 3, 'Title has 3 mappings');
100
102
(-)a/t/db_dependent/Koha/SearchEngine/Elasticsearch/Reset.t (-1 / +5 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 7;
21
use Test::MockModule;
21
use Test::MockModule;
22
22
23
use Koha::Database;
23
use Koha::Database;
Lines 29-34 my $indexes = { Link Here
29
            'label' => 'Match',
29
            'label' => 'Match',
30
            'type' => '',
30
            'type' => '',
31
            'weight' => 15,
31
            'weight' => 15,
32
            'mandatory' => 0,
32
            'mappings' => []
33
            'mappings' => []
33
        }
34
        }
34
    },
35
    },
Lines 37-42 my $indexes = { Link Here
37
            'label' => 'title',
38
            'label' => 'title',
38
            'type' => '',
39
            'type' => '',
39
            'weight' => 20,
40
            'weight' => 20,
41
            'mandatory' => 1,
40
            'mapping' => []
42
            'mapping' => []
41
        }
43
        }
42
    }
44
    }
Lines 66-74 is($search_fields->count, 2, 'There is 2 search fields after reset'); Link Here
66
68
67
my $match_sf = Koha::SearchFields->search({ name => 'Match' })->next;
69
my $match_sf = Koha::SearchFields->search({ name => 'Match' })->next;
68
is($match_sf->weight, '15.00', 'Match search field is weighted with 15');
70
is($match_sf->weight, '15.00', 'Match search field is weighted with 15');
71
is($match_sf->mandatory, '0', 'Match search field is not mandatory');
69
72
70
my $title_sf = Koha::SearchFields->search({ name => 'title' })->next;
73
my $title_sf = Koha::SearchFields->search({ name => 'title' })->next;
71
is($title_sf->weight, '20.00', 'Title search field is weighted with 20');
74
is($title_sf->weight, '20.00', 'Title search field is weighted with 20');
75
is($title_sf->mandatory, '1', 'Title search field is mandatory');
72
76
73
$schema->storage->txn_rollback;
77
$schema->storage->txn_rollback;
74
78
(-)a/t/db_dependent/Koha/SearchField.t (-2 / +8 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 8;
22
use Test::More tests => 10;
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::SearchFields;
25
use Koha::SearchFields;
Lines 128-138 ok($search_field->is_mapped_biblios, 'Search field is mapped with authorities an Link Here
128
128
129
my $sf3 = $builder->build({
129
my $sf3 = $builder->build({
130
    source => 'SearchField',
130
    source => 'SearchField',
131
    value => {
132
        mandatory => 1,
133
    }
131
});
134
});
132
135
133
$search_field = Koha::SearchFields->find($sf3->{id});
136
$search_field = Koha::SearchFields->find($sf3->{id});
134
ok(!$search_field->is_mapped_biblios, 'Search field is not mapped');
137
ok(!$search_field->is_mapped_biblios, 'Search field is not mapped');
135
138
139
ok($search_field->mandatory, 'Search field can be marked mandatory');
140
$search_field->mandatory(0)->store;
141
ok(!$search_field->mandatory, 'Search field can be marked not mandatory');
142
136
Koha::SearchFields->search({})->delete;
143
Koha::SearchFields->search({})->delete;
137
144
138
$schema->storage->txn_rollback;
145
$schema->storage->txn_rollback;
139
- 

Return to bug 19482