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

(-)a/C4/Items.pm (-6 / +18 lines)
Lines 59-64 use DateTime::Format::MySQL; Link Here
59
# debugging; so please don't remove this
59
# debugging; so please don't remove this
60
use Try::Tiny qw( catch try );
60
use Try::Tiny qw( catch try );
61
61
62
use Koha::AuthorisedValueCategories;
62
use Koha::AuthorisedValues;
63
use Koha::AuthorisedValues;
63
use Koha::DateUtils qw( dt_from_string );
64
use Koha::DateUtils qw( dt_from_string );
64
use Koha::Database;
65
use Koha::Database;
Lines 1377-1383 sub PrepareItemrecordDisplay { Link Here
1377
1378
1378
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1379
    my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{"branch"} : "";
1379
    my $query        = qq{
1380
    my $query        = qq{
1380
        SELECT authorised_value,lib FROM authorised_values
1381
        SELECT id, authorised_value, parent_authorised_value_id, lib FROM authorised_values
1381
    };
1382
    };
1382
    $query .= qq{
1383
    $query .= qq{
1383
        LEFT JOIN authorised_values_branches ON ( id = av_id )
1384
        LEFT JOIN authorised_values_branches ON ( id = av_id )
Lines 1513-1518 sub PrepareItemrecordDisplay { Link Here
1513
                if ( $subfield->{authorised_value} ) {
1514
                if ( $subfield->{authorised_value} ) {
1514
                    my @authorised_values;
1515
                    my @authorised_values;
1515
                    my %authorised_lib;
1516
                    my %authorised_lib;
1517
                    my %attributes;
1516
1518
1517
                    # builds list, depending on authorised value...
1519
                    # builds list, depending on authorised value...
1518
                    #---- branch
1520
                    #---- branch
Lines 1581-1596 sub PrepareItemrecordDisplay { Link Here
1581
                            $branch_limit ? $branch_limit : ()
1583
                            $branch_limit ? $branch_limit : ()
1582
                        );
1584
                        );
1583
                        push @authorised_values, "";
1585
                        push @authorised_values, "";
1584
                        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
1586
                        while ( my ( $id, $value, $parent_authorised_value_id, $lib ) =
1587
                            $authorised_values_sth->fetchrow_array )
1588
                        {
1585
                            push @authorised_values, $value;
1589
                            push @authorised_values, $value;
1586
                            $authorised_lib{$value} = $lib;
1590
                            $authorised_lib{$value} = $lib;
1591
                            $attributes{$value}     = {
1592
                                'data-id'                         => $id,
1593
                                'data-parent-authorised-value-id' => $parent_authorised_value_id,
1594
                            };
1587
                        }
1595
                        }
1588
                    }
1596
                    }
1589
                    $subfield_data{marc_value} = {
1597
                    $subfield_data{marc_value} = {
1590
                        type    => 'select',
1598
                        type                      => 'select',
1591
                        values  => \@authorised_values,
1599
                        values                    => \@authorised_values,
1592
                        default => $defaultvalue // q{},
1600
                        default                   => $defaultvalue // q{},
1593
                        labels  => \%authorised_lib,
1601
                        labels                    => \%authorised_lib,
1602
                        attributes                => \%attributes,
1603
                        category                  => $subfield->{authorised_value},
1604
                        authorised_value_category =>
1605
                            Koha::AuthorisedValueCategories->find( $subfield->{authorised_value} ),
1594
                    };
1606
                    };
1595
                } elsif ( $subfield->{value_builder} ) {
1607
                } elsif ( $subfield->{value_builder} ) {
1596
1608
(-)a/Koha/AuthorisedValue.pm (+15 lines)
Lines 131-136 sub is_integer_only { Link Here
131
    return $self->_result->category->is_integer_only;
131
    return $self->_result->category->is_integer_only;
132
}
132
}
133
133
134
=head3 parent_authorised_value
135
136
Return the parent authorised value (C<Koha::AuthorisedValue> object), or undef
137
138
    my $parent_authorised_value = $authorised_value->parent_authorised_value();
139
140
=cut
141
142
sub parent_authorised_value {
143
    my ($self) = @_;
144
145
    my $parent_authorised_value = $self->_result->parent_authorised_value;
146
    return $parent_authorised_value ? Koha::AuthorisedValue->_new_from_dbic($parent_authorised_value) : undef;
147
}
148
134
=head3 to_api
149
=head3 to_api
135
150
136
    my $json = $av->to_api;
151
    my $json = $av->to_api;
(-)a/Koha/AuthorisedValueCategory.pm (+15 lines)
Lines 45-50 sub authorised_values { Link Here
45
    return Koha::AuthorisedValues->_new_from_dbic($authorised_values_rs);
45
    return Koha::AuthorisedValues->_new_from_dbic($authorised_values_rs);
46
}
46
}
47
47
48
=head3 parent_category
49
50
Return the parent authorised value category (C<Koha::AuthorisedValueCategory> object), or undef
51
52
    my $parent_category = $authorised_value_category->parent_category();
53
54
=cut
55
56
sub parent_category {
57
    my ($self) = @_;
58
59
    my $parent_category = $self->_result->parent_category_name;
60
    return $parent_category ? Koha::AuthorisedValueCategory->_new_from_dbic($parent_category) : undef;
61
}
62
48
=head3 delete
63
=head3 delete
49
64
50
Overridden delete method to prevent system default deletions
65
Overridden delete method to prevent system default deletions
(-)a/Koha/UI/Form/Builder/Biblio.pm (-10 / +22 lines)
Lines 20-25 use feature qw(fc); Link Here
20
20
21
use C4::Context;
21
use C4::Context;
22
use C4::ClassSource qw( GetClassSources );
22
use C4::ClassSource qw( GetClassSources );
23
use Koha::AuthorisedValueCategories;
23
use Koha::DateUtils qw( dt_from_string );
24
use Koha::DateUtils qw( dt_from_string );
24
use Koha::ItemTypes;
25
use Koha::ItemTypes;
25
use Koha::Libraries;
26
use Koha::Libraries;
Lines 312-317 sub build_authorized_values_list { Link Here
312
313
313
    my @authorised_values;
314
    my @authorised_values;
314
    my %authorised_lib;
315
    my %authorised_lib;
316
    my %attributes;
315
317
316
    # builds list, depending on authorised value...
318
    # builds list, depending on authorised value...
317
319
Lines 351-357 sub build_authorized_values_list { Link Here
351
        $value = $default_source unless $value;
353
        $value = $default_source unless $value;
352
    } else {
354
    } else {
353
        my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{branch} : '';
355
        my $branch_limit = C4::Context->userenv ? C4::Context->userenv->{branch} : '';
354
        my $query        = 'SELECT authorised_value, lib FROM authorised_values';
356
        my $query        = 'SELECT id, authorised_value, parent_authorised_value_id, lib FROM authorised_values';
355
        $query .= ' LEFT JOIN authorised_values_branches ON ( id = av_id )' if $branch_limit;
357
        $query .= ' LEFT JOIN authorised_values_branches ON ( id = av_id )' if $branch_limit;
356
        $query .= ' WHERE category = ?';
358
        $query .= ' WHERE category = ?';
357
        $query .= ' AND ( branchcode = ? OR branchcode IS NULL )' if $branch_limit;
359
        $query .= ' AND ( branchcode = ? OR branchcode IS NULL )' if $branch_limit;
Lines 365-389 sub build_authorized_values_list { Link Here
365
367
366
        push @authorised_values, "";
368
        push @authorised_values, "";
367
369
368
        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
370
        while ( my ( $id, $value, $parent_authorised_value_id, $lib ) = $authorised_values_sth->fetchrow_array ) {
369
            push @authorised_values, $value;
371
            push @authorised_values, $value;
370
            $authorised_lib{$value} = $lib;
372
            $authorised_lib{$value} = $lib;
373
            $attributes{$value}     = {
374
                'data-id'                         => $id,
375
                'data-parent-authorised-value-id' => $parent_authorised_value_id,
376
            };
371
        }
377
        }
372
    }
378
    }
373
379
374
    my $id_subfield = $subfield;
380
    my $id_subfield = $subfield;
375
    $id_subfield = "00" if $id_subfield eq "@";
381
    $id_subfield = "00" if $id_subfield eq "@";
376
382
377
    return {
383
    my $res = {
378
        type    => 'select',
384
        type       => 'select',
379
        id      => "tag_" . $tag . "_subfield_" . $id_subfield . "_" . $index_tag . "_" . $index_subfield,
385
        id         => "tag_" . $tag . "_subfield_" . $id_subfield . "_" . $index_tag . "_" . $index_subfield,
380
        name    => "tag_" . $tag . "_subfield_" . $id_subfield . "_" . $index_tag . "_" . $index_subfield,
386
        name       => "tag_" . $tag . "_subfield_" . $id_subfield . "_" . $index_tag . "_" . $index_subfield,
381
        default => $value,
387
        default    => $value,
382
        values  => \@authorised_values,
388
        values     => \@authorised_values,
383
        labels  => \%authorised_lib,
389
        labels     => \%authorised_lib,
384
        ( ( grep { $_ eq $category } (qw(branches itemtypes cn_source)) ) ? () : ( category => $category ) ),
390
        attributes => \%attributes,
385
    };
391
    };
386
392
393
    unless ( grep { $_ eq $category } (qw(branches itemtypes cn_source)) ) {
394
        $res->{category}                  = $category;
395
        $res->{authorised_value_category} = Koha::AuthorisedValueCategories->find($category);
396
    }
397
398
    return $res;
387
}
399
}
388
400
389
=head3 create_key
401
=head3 create_key
(-)a/Koha/UI/Form/Builder/Item.pm (-15 / +18 lines)
Lines 25-30 use C4::Biblio qw( GetFrameworkCode GetMarcStructure IsMarcStructureInterna Link Here
25
use C4::Koha        qw( GetAuthorisedValues );
25
use C4::Koha        qw( GetAuthorisedValues );
26
use C4::ClassSource qw( GetClassSources );
26
use C4::ClassSource qw( GetClassSources );
27
27
28
use Koha::AuthorisedValueCategories;
28
use Koha::Biblios;
29
use Koha::Biblios;
29
use Koha::DateUtils qw( dt_from_string );
30
use Koha::DateUtils qw( dt_from_string );
30
use Koha::Libraries;
31
use Koha::Libraries;
Lines 169-174 sub generate_subfield_form { Link Here
169
    if ( $subfield->{authorised_value} ) {
170
    if ( $subfield->{authorised_value} ) {
170
        my @authorised_values;
171
        my @authorised_values;
171
        my %authorised_lib;
172
        my %authorised_lib;
173
        my %attributes;
172
174
173
        # builds list, depending on authorised value...
175
        # builds list, depending on authorised value...
174
        if ( $subfield->{authorised_value} eq "LOST" ) {
176
        if ( $subfield->{authorised_value} eq "LOST" ) {
Lines 249-254 sub generate_subfield_form { Link Here
249
            for my $r (@$av) {
251
            for my $r (@$av) {
250
                push @authorised_values, $r->{authorised_value};
252
                push @authorised_values, $r->{authorised_value};
251
                $authorised_lib{ $r->{authorised_value} } = $r->{lib};
253
                $authorised_lib{ $r->{authorised_value} } = $r->{lib};
254
                $attributes{ $r->{authorised_value} }     = {
255
                    'data-id'                         => $r->{id},
256
                    'data-parent-authorised-value-id' => $r->{parent_authorised_value_id},
257
                };
252
            }
258
            }
253
        }
259
        }
254
260
Lines 258-283 sub generate_subfield_form { Link Here
258
                id        => $subfield_data{id},
264
                id        => $subfield_data{id},
259
                maxlength => $subfield_data{maxlength},
265
                maxlength => $subfield_data{maxlength},
260
                value     => $value,
266
                value     => $value,
261
                (
262
                      ( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) )
263
                    ? ()
264
                    : ( category => $subfield->{authorised_value} )
265
                ),
266
            };
267
            };
267
        } else {
268
        } else {
268
            $subfield_data{marc_value} = {
269
            $subfield_data{marc_value} = {
269
                type    => 'select',
270
                type       => 'select',
270
                id      => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield,
271
                id         => "tag_" . $tag . "_subfield_" . $subfieldtag . "_" . $index_subfield,
271
                values  => \@authorised_values,
272
                values     => \@authorised_values,
272
                labels  => \%authorised_lib,
273
                labels     => \%authorised_lib,
273
                default => $value,
274
                attributes => \%attributes,
274
                (
275
                default    => $value,
275
                      ( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) )
276
                    ? ()
277
                    : ( category => $subfield->{authorised_value} )
278
                ),
279
            };
276
            };
280
        }
277
        }
278
279
        unless ( grep { $_ eq $subfield->{authorised_value} } (qw(branches itemtypes cn_source)) ) {
280
            $subfield_data{marc_value}->{category} = $subfield->{authorised_value};
281
            $subfield_data{marc_value}->{authorised_value_category} =
282
                Koha::AuthorisedValueCategories->find( $subfield->{authorised_value} );
283
        }
281
    }
284
    }
282
285
283
    # it's a thesaurus / authority field
286
    # it's a thesaurus / authority field
(-)a/admin/authorised_values.pl (-23 / +40 lines)
Lines 80-85 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
80
80
81
    if ($av) {
81
    if ($av) {
82
        $template->param(
82
        $template->param(
83
            category      => Koha::AuthorisedValueCategories->find( $av->category ),
83
            category_name => $av->category,
84
            category_name => $av->category,
84
            av            => $av,
85
            av            => $av,
85
            imagesets     => C4::Koha::getImageSets( checked => $av->imageurl ),
86
            imagesets     => C4::Koha::getImageSets( checked => $av->imageurl ),
Lines 97-105 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
97
    );
98
    );
98
99
99
} elsif ( $op eq 'cud-add' ) {
100
} elsif ( $op eq 'cud-add' ) {
100
    my $new_authorised_value = $input->param('authorised_value');
101
    my $new_authorised_value       = $input->param('authorised_value');
101
    my $new_category         = $input->param('category');
102
    my $parent_authorised_value_id = $input->param('parent_authorised_value_id') // '';
102
    my $image                = $input->param('image') || '';
103
    my $new_category               = $input->param('category');
104
    my $image                      = $input->param('image') || '';
103
    my $imageurl =
105
    my $imageurl =
104
        $image eq 'removeImage' ? ''
106
        $image eq 'removeImage' ? ''
105
        : (
107
        : (
Lines 118-123 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
118
        $av->lib_opac( scalar $input->param('lib_opac') || undef );
120
        $av->lib_opac( scalar $input->param('lib_opac') || undef );
119
        $av->category($new_category);
121
        $av->category($new_category);
120
        $av->authorised_value($new_authorised_value);
122
        $av->authorised_value($new_authorised_value);
123
        $av->parent_authorised_value_id( $parent_authorised_value_id || undef );
121
        $av->imageurl($imageurl);
124
        $av->imageurl($imageurl);
122
        eval {
125
        eval {
123
            $av->store;
126
            $av->store;
Lines 132-142 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
132
        eval {
135
        eval {
133
            my $av = Koha::AuthorisedValue->new(
136
            my $av = Koha::AuthorisedValue->new(
134
                {
137
                {
135
                    category         => $new_category,
138
                    category                   => $new_category,
136
                    authorised_value => $new_authorised_value,
139
                    authorised_value           => $new_authorised_value,
137
                    lib              => scalar $input->param('lib')      || undef,
140
                    parent_authorised_value_id => $parent_authorised_value_id      || undef,
138
                    lib_opac         => scalar $input->param('lib_opac') || undef,
141
                    lib                        => scalar $input->param('lib')      || undef,
139
                    imageurl         => $imageurl,
142
                    lib_opac                   => scalar $input->param('lib_opac') || undef,
143
                    imageurl                   => $imageurl,
140
                }
144
                }
141
            )->store;
145
            )->store;
142
            $av->replace_library_limits( \@branches );
146
            $av->replace_library_limits( \@branches );
Lines 153-160 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
153
    $op          = 'list';
157
    $op          = 'list';
154
    $searchfield = $new_category;
158
    $searchfield = $new_category;
155
} elsif ( $op eq 'cud-add_category' ) {
159
} elsif ( $op eq 'cud-add_category' ) {
156
    my $new_category    = $input->param('category');
160
    my $new_category         = $input->param('category');
157
    my $is_integer_only = $input->param('is_integer_only') ? 1 : 0;
161
    my $parent_category_name = $input->param('parent_category_name');
162
    my $is_integer_only      = $input->param('is_integer_only') ? 1 : 0;
158
163
159
    my $already_exists = Koha::AuthorisedValueCategories->find(
164
    my $already_exists = Koha::AuthorisedValueCategories->find(
160
        {
165
        {
Lines 171-177 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
171
    } else {    # Insert
176
    } else {    # Insert
172
        my $av = Koha::AuthorisedValueCategory->new(
177
        my $av = Koha::AuthorisedValueCategory->new(
173
            {
178
            {
174
                category_name => $new_category, is_integer_only => $is_integer_only,
179
                category_name        => $new_category,
180
                parent_category_name => $parent_category_name,
181
                is_integer_only      => $is_integer_only,
175
            }
182
            }
176
        );
183
        );
177
184
Lines 187-198 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
187
194
188
    $op = 'list';
195
    $op = 'list';
189
} elsif ( $op eq 'cud-edit_category' ) {
196
} elsif ( $op eq 'cud-edit_category' ) {
190
    my $category_name   = $input->param('category');
197
    my $category_name        = $input->param('category');
191
    my $is_integer_only = $input->param('is_integer_only') ? 1 : 0;
198
    my $parent_category_name = $input->param('parent_category_name') // '';
192
    my $category        = Koha::AuthorisedValueCategories->find($category_name);
199
    my $is_integer_only      = $input->param('is_integer_only') ? 1 : 0;
200
    my $category             = Koha::AuthorisedValueCategories->find($category_name);
193
201
194
    if ($category) {
202
    if ($category) {
195
        $category->is_integer_only($is_integer_only)->store;
203
        my $old_parent_category_name = $category->parent_category_name // '';
204
205
        $category->parent_category_name( $parent_category_name ? $parent_category_name : undef );
206
        $category->is_integer_only($is_integer_only);
207
        $category->store;
208
209
        if ( $old_parent_category_name ne $parent_category_name ) {
210
            $category->authorised_values->update( { parent_authorised_value_id => undef } );
211
        }
196
    } else {
212
    } else {
197
        push @messages, { type => 'error', code => 'error_on_edit_cat' };
213
        push @messages, { type => 'error', code => 'error_on_edit_cat' };
198
    }
214
    }
Lines 246-259 if ( $op eq 'list' ) { Link Here
246
    # builds value list
262
    # builds value list
247
    for my $av (@avs_by_category) {
263
    for my $av (@avs_by_category) {
248
        my %row_data;    # get a fresh hash for the row data
264
        my %row_data;    # get a fresh hash for the row data
249
        $row_data{category}         = $av->category;
265
        $row_data{category}                = $av->category;
250
        $row_data{authorised_value} = $av->authorised_value;
266
        $row_data{authorised_value}        = $av->authorised_value;
251
        $row_data{lib}              = $av->lib;
267
        $row_data{parent_authorised_value} = $av->parent_authorised_value;
252
        $row_data{lib_opac}         = $av->lib_opac;
268
        $row_data{lib}                     = $av->lib;
253
        $row_data{image}            = getitemtypeimagelocation( 'intranet', $av->imageurl );
269
        $row_data{lib_opac}                = $av->lib_opac;
254
        $row_data{branches}         = $av->library_limits ? $av->library_limits->as_list : [];
270
        $row_data{image}                   = getitemtypeimagelocation( 'intranet', $av->imageurl );
255
        $row_data{id}               = $av->id;
271
        $row_data{branches}                = $av->library_limits ? $av->library_limits->as_list : [];
256
        $row_data{is_integer_only}  = $is_integer_only;
272
        $row_data{id}                      = $av->id;
273
        $row_data{is_integer_only}         = $is_integer_only;
257
        push( @loop_data, \%row_data );
274
        push( @loop_data, \%row_data );
258
    }
275
    }
259
276
(-)a/api/v1/swagger/definitions/authorised_value.yaml (+6 lines)
Lines 5-10 properties: Link Here
5
    type: integer
5
    type: integer
6
    description: internally assigned authorised value identifier
6
    description: internally assigned authorised value identifier
7
    readOnly: true
7
    readOnly: true
8
  parent_authorised_value_id:
9
    type:
10
      - integer
11
      - "null"
12
    description: id of parent authorised value
13
    readOnly: true
8
  category_name:
14
  category_name:
9
    description: the category of this authorised value
15
    description: the category of this authorised value
10
    type: string
16
    type: string
(-)a/api/v1/swagger/definitions/authorised_value_category.yaml (+6 lines)
Lines 12-17 properties: Link Here
12
  is_integer_only:
12
  is_integer_only:
13
    description: Is this category integer only or not
13
    description: Is this category integer only or not
14
    readOnly: true
14
    readOnly: true
15
  parent_category_name:
16
    type:
17
      - string
18
      - "null"
19
    description: Name of parent authorised value category
20
    readOnly: true
15
  authorised_values:
21
  authorised_values:
16
    type: array
22
    type: array
17
    description: This category's authorised values
23
    description: This category's authorised values
(-)a/authorities/authorities.pl (-10 / +23 lines)
Lines 30-35 use Date::Calc qw( Today ); Link Here
30
use MARC::File::USMARC;
30
use MARC::File::USMARC;
31
use MARC::File::XML;
31
use MARC::File::XML;
32
use C4::Biblio qw( TransformHtmlToMarc );
32
use C4::Biblio qw( TransformHtmlToMarc );
33
use Koha::AuthorisedValueCategories;
33
use Koha::Authority::Types;
34
use Koha::Authority::Types;
34
use Koha::Import::Records;
35
use Koha::Import::Records;
35
use Koha::ItemTypes;
36
use Koha::ItemTypes;
Lines 54-59 sub build_authorized_values_list { Link Here
54
55
55
    my @authorised_values;
56
    my @authorised_values;
56
    my %authorised_lib;
57
    my %authorised_lib;
58
    my %attributes;
57
59
58
    my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
60
    my $category = $tagslib->{$tag}->{$subfield}->{'authorised_value'};
59
    push @authorised_values, q{} unless $tagslib->{$tag}->{$subfield}->{mandatory} && $value;
61
    push @authorised_values, q{} unless $tagslib->{$tag}->{$subfield}->{mandatory} && $value;
Lines 73-93 sub build_authorized_values_list { Link Here
73
        }
75
        }
74
    } else {    # "true" authorised value
76
    } else {    # "true" authorised value
75
        $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} );
77
        $authorised_values_sth->execute( $tagslib->{$tag}->{$subfield}->{authorised_value} );
76
        while ( my ( $value, $lib ) = $authorised_values_sth->fetchrow_array ) {
78
        while ( my ( $id, $value, $parent_authorised_value_id, $lib ) = $authorised_values_sth->fetchrow_array ) {
77
            push @authorised_values, $value;
79
            push @authorised_values, $value;
78
            $authorised_lib{$value} = $lib;
80
            $authorised_lib{$value} = $lib;
81
            $attributes{$value}     = {
82
                'data-id'                         => $id,
83
                'data-parent-authorised-value-id' => $parent_authorised_value_id,
84
            };
79
        }
85
        }
80
    }
86
    }
81
87
82
    return {
88
    my $res = {
83
        type    => 'select',
89
        type       => 'select',
84
        id      => "tag_" . $tag . "_subfield_" . $subfield . "_" . $index_tag . "_" . $index_subfield,
90
        id         => "tag_" . $tag . "_subfield_" . $subfield . "_" . $index_tag . "_" . $index_subfield,
85
        name    => "tag_" . $tag . "_subfield_" . $subfield . "_" . $index_tag . "_" . $index_subfield,
91
        name       => "tag_" . $tag . "_subfield_" . $subfield . "_" . $index_tag . "_" . $index_subfield,
86
        values  => \@authorised_values,
92
        values     => \@authorised_values,
87
        labels  => \%authorised_lib,
93
        labels     => \%authorised_lib,
88
        default => $value,
94
        attributes => \%attributes,
89
        ( ( grep { $_ eq $category } (qw(branches itemtypes cn_source)) ) ? () : ( category => $category ) ),
95
        default    => $value,
90
    };
96
    };
97
98
    unless ( grep { $_ eq $category } (qw(branches itemtypes cn_source)) ) {
99
        $res->{category}                  = $category;
100
        $res->{authorised_value_category} = Koha::AuthorisedValueCategories->find($category);
101
    }
102
103
    return $res;
91
}
104
}
92
105
93
=item create_input
106
=item create_input
Lines 329-335 sub build_tabs { Link Here
329
    my $tag;
342
    my $tag;
330
343
331
    my $authorised_values_sth = $dbh->prepare(
344
    my $authorised_values_sth = $dbh->prepare(
332
        "SELECT authorised_value,lib
345
        "SELECT id, authorised_value, parent_authorised_value_id, lib
333
        FROM authorised_values
346
        FROM authorised_values
334
        WHERE category=? ORDER BY lib"
347
        WHERE category=? ORDER BY lib"
335
    );
348
    );
(-)a/installer/data/mysql/atomicupdate/bug-34198.pl (+36 lines)
Line 0 Link Here
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_success say_info);
3
4
return {
5
    bug_number  => "34198",
6
    description =>
7
        "Add authorised_value_categories.parent_category_name and authorised_values.parent_authorised_value_id",
8
    up => sub {
9
        my ($args) = @_;
10
        my ( $dbh, $out ) = @$args{qw(dbh out)};
11
12
        unless ( column_exists( 'authorised_value_categories', 'parent_category_name' ) ) {
13
            $dbh->do(
14
                q{
15
                ALTER TABLE `authorised_value_categories`
16
                ADD COLUMN `parent_category_name` varchar(32) NULL DEFAULT NULL COMMENT 'Name (primary key) of parent authorised value category' AFTER `category_name`,
17
                ADD CONSTRAINT `fk_authorised_value_categories_parent_category_name` FOREIGN KEY (`parent_category_name`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON UPDATE CASCADE
18
            }
19
            );
20
21
            say $out "Added authorised_value_categories.parent_category_name and corresponding foreign key";
22
        }
23
24
        unless ( column_exists( 'authorised_values', 'parent_authorised_value_id' ) ) {
25
            $dbh->do(
26
                q{
27
                ALTER TABLE `authorised_values`
28
                ADD COLUMN `parent_authorised_value_id` int(11) NULL DEFAULT NULL COMMENT 'id of parent authorised value' AFTER `authorised_value`,
29
                ADD CONSTRAINT `fk_authorised_values_parent_authorised_value_id` FOREIGN KEY (`parent_authorised_value_id`) REFERENCES `authorised_values` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
30
            }
31
            );
32
33
            say $out "Added authorised_values.parent_authorised_value_id and corresponding foreign key";
34
        }
35
    },
36
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +6 lines)
Lines 1013-1021 DROP TABLE IF EXISTS `authorised_value_categories`; Link Here
1013
/*!40101 SET character_set_client = utf8mb4 */;
1013
/*!40101 SET character_set_client = utf8mb4 */;
1014
CREATE TABLE `authorised_value_categories` (
1014
CREATE TABLE `authorised_value_categories` (
1015
  `category_name` varchar(32) NOT NULL DEFAULT '',
1015
  `category_name` varchar(32) NOT NULL DEFAULT '',
1016
  `parent_category_name` varchar(32) NULL DEFAULT NULL COMMENT 'Name (primary key) of parent authorised value category',
1016
  `is_system` tinyint(1) DEFAULT 0,
1017
  `is_system` tinyint(1) DEFAULT 0,
1017
  `is_integer_only` tinyint(1) NOT NULL DEFAULT 0,
1018
  `is_integer_only` tinyint(1) NOT NULL DEFAULT 0,
1018
  PRIMARY KEY (`category_name`)
1019
  PRIMARY KEY (`category_name`),
1020
  CONSTRAINT `fk_authorised_value_categories_parent_category_name` FOREIGN KEY (`parent_category_name`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON UPDATE CASCADE
1019
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1021
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1020
/*!40101 SET character_set_client = @saved_cs_client */;
1022
/*!40101 SET character_set_client = @saved_cs_client */;
1021
1023
Lines 1030-1035 CREATE TABLE `authorised_values` ( Link Here
1030
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify the authorized value',
1032
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique key, used to identify the authorized value',
1031
  `category` varchar(32) NOT NULL DEFAULT '' COMMENT 'key used to identify the authorized value category',
1033
  `category` varchar(32) NOT NULL DEFAULT '' COMMENT 'key used to identify the authorized value category',
1032
  `authorised_value` varchar(80) NOT NULL DEFAULT '' COMMENT 'code use to identify the authorized value',
1034
  `authorised_value` varchar(80) NOT NULL DEFAULT '' COMMENT 'code use to identify the authorized value',
1035
  `parent_authorised_value_id` int(11) NULL DEFAULT NULL COMMENT 'id of parent authorised value',
1033
  `lib` varchar(200) DEFAULT NULL COMMENT 'authorized value description as printed in the staff interface',
1036
  `lib` varchar(200) DEFAULT NULL COMMENT 'authorized value description as printed in the staff interface',
1034
  `lib_opac` varchar(200) DEFAULT NULL COMMENT 'authorized value description as printed in the OPAC',
1037
  `lib_opac` varchar(200) DEFAULT NULL COMMENT 'authorized value description as printed in the OPAC',
1035
  `imageurl` varchar(200) DEFAULT NULL COMMENT 'authorized value URL',
1038
  `imageurl` varchar(200) DEFAULT NULL COMMENT 'authorized value URL',
Lines 1038-1044 CREATE TABLE `authorised_values` ( Link Here
1038
  KEY `name` (`category`),
1041
  KEY `name` (`category`),
1039
  KEY `lib` (`lib`(191)),
1042
  KEY `lib` (`lib`(191)),
1040
  KEY `auth_value_idx` (`authorised_value`),
1043
  KEY `auth_value_idx` (`authorised_value`),
1041
  CONSTRAINT `authorised_values_authorised_values_category` FOREIGN KEY (`category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE CASCADE ON UPDATE CASCADE
1044
  CONSTRAINT `authorised_values_authorised_values_category` FOREIGN KEY (`category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE CASCADE ON UPDATE CASCADE,
1045
  CONSTRAINT `fk_authorised_values_parent_authorised_value_id` FOREIGN KEY (`parent_authorised_value_id`) REFERENCES `authorised_values` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
1042
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1046
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1043
/*!40101 SET character_set_client = @saved_cs_client */;
1047
/*!40101 SET character_set_client = @saved_cs_client */;
1044
1048
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc (-5 / +8 lines)
Lines 96-101 Link Here
96
[%- END %]
96
[%- END %]
97
97
98
[% BLOCK subfields_for_item %]
98
[% BLOCK subfields_for_item %]
99
    [% USE HTML %]
99
    <ol>
100
    <ol>
100
        [% FOREACH subfield IN subfields %]
101
        [% FOREACH subfield IN subfields %]
101
            [% IF subfield.kohafield == 'items.more_subfields_xml' %]
102
            [% IF subfield.kohafield == 'items.more_subfields_xml' %]
Lines 133-158 Link Here
133
                            [% select_readonly | html %]
134
                            [% select_readonly | html %]
134
                            [% select_disabled | html %]
135
                            [% select_disabled | html %]
135
                            data-category="[% mv.category | html %]"
136
                            data-category="[% mv.category | html %]"
137
                            data-parent-category="[% mv.authorised_value_category.parent_category_name | html %]"
136
                            data-width="50%"
138
                            data-width="50%"
137
                        >
139
                        >
138
                            [% SET matched = 0 %]
140
                            [% SET matched = 0 %]
139
                            [% FOREACH aval IN mv.values %]
141
                            [% FOREACH aval IN mv.values %]
142
                                [% attributes = HTML.attributes(mv.attributes.$aval) %]
140
                                [% IF aval == mv.default %]
143
                                [% IF aval == mv.default %]
141
                                    [% SET matched = 1 %]
144
                                    [% SET matched = 1 %]
142
                                    <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
145
                                    <option value="[%- aval | html -%]" selected="selected" [% attributes | $raw %]>[%- mv.labels.$aval | html -%]</option>
143
                                [% ELSE %]
146
                                [% ELSE %]
144
                                    [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %]
147
                                    [% IF subfield.IS_LOST_AV && Koha.Preference("ClaimReturnedLostValue") && aval == Koha.Preference("ClaimReturnedLostValue") %]
145
                                        <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page">[%- mv.labels.$aval | html -%]</option>
148
                                        <option disabled="disabled" value="[%- aval | html -%]" title="Return claims must be processed from the patron details page" [% attributes | $raw %]>[%- mv.labels.$aval | html -%]</option>
146
                                    [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %]
149
                                    [% ELSIF subfield.IS_LOST_AV && Koha.Preference("BundleLostValue") && aval == Koha.Preference("BundleLostValue") %]
147
                                        <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically">[%- mv.labels.$aval | html -%]</option>
150
                                        <option disabled="disabled" value="[%- aval | html -%]" title="Bundle losses are set at checkin automatically" [% attributes | $raw %]>[%- mv.labels.$aval | html -%]</option>
148
                                    [% ELSE %]
151
                                    [% ELSE %]
149
                                        <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
152
                                        <option value="[%- aval | html -%]" [% attributes | $raw %]>[%- mv.labels.$aval | html -%]</option>
150
                                    [% END %]
153
                                    [% END %]
151
                                [% END %]
154
                                [% END %]
152
                            [% END %]
155
                            [% END %]
153
                            [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %]
156
                            [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %]
154
                                [%# If the current value is not in the authorised list  and is not a field where 0 means unset #%]
157
                                [%# If the current value is not in the authorised list  and is not a field where 0 means unset #%]
155
                                <option value="[%- mv.default | html -%]" selected="selected">[%- mv.default | html -%] (Not an authorised value)</option>
158
                                <option value="[%- mv.default | html -%]" selected="selected" [% attributes | $raw %]>[%- mv.default | html -%] (Not an authorised value)</option>
156
                            [% END %]
159
                            [% END %]
157
                        </select>
160
                        </select>
158
                        [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %]
161
                        [% UNLESS matched || ( ( kohafield == 'items.damaged' || kohafield == 'items.itemlost' || kohafield == 'items.withdrawn' || kohafield == 'items.notforloan' ) && mv.default == '0' ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt (+33 lines)
Lines 1-7 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE Asset %]
3
[% USE Asset %]
4
[% USE AuthorisedValues %]
4
[% PROCESS 'i18n.inc' %]
5
[% PROCESS 'i18n.inc' %]
6
[% PROCESS 'html_helpers.inc' %]
5
[% SET footerjs = 1 %]
7
[% SET footerjs = 1 %]
6
[% INCLUDE 'doc-head-open.inc' %]
8
[% INCLUDE 'doc-head-open.inc' %]
7
<title
9
<title
Lines 138-143 Link Here
138
                            <span class="required">Required</span>
140
                            <span class="required">Required</span>
139
                            <input type="hidden" name="op" value="cud-add_category" />
141
                            <input type="hidden" name="op" value="cud-add_category" />
140
                        </li>
142
                        </li>
143
                        <li>
144
                            <label for="parent_category_name">Parent category:</label>
145
                            <select id="parent_category_name" name="parent_category_name">
146
                                <option value=""></option>
147
                                [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories() %]
148
                            </select>
149
                        </li>
141
                        <li> <input type="checkbox" name="is_integer_only" id="is_integer_only" /><label for="is_integer_only">Restrict value to numbers only</label> </li>
150
                        <li> <input type="checkbox" name="is_integer_only" id="is_integer_only" /><label for="is_integer_only">Restrict value to numbers only</label> </li>
142
                    </ol>
151
                    </ol>
143
                [% ELSIF op == 'edit_form' %]
152
                [% ELSIF op == 'edit_form' %]
Lines 146-151 Link Here
146
                            <label for="category" class="required">Category: </label>
155
                            <label for="category" class="required">Category: </label>
147
                            <input type="text" disabled value="[% category_name | html %]" />
156
                            <input type="text" disabled value="[% category_name | html %]" />
148
                        </li>
157
                        </li>
158
                        <li>
159
                            <label for="parent_category_name">Parent category:</label>
160
                            <select id="parent_category_name" name="parent_category_name">
161
                                <option value=""></option>
162
                                [% PROCESS options_for_authorised_value_categories authorised_value_categories => AuthorisedValues.GetCategories( selected => category.parent_category_name ) %]
163
                            </select>
164
                        </li>
149
                        <li>
165
                        <li>
150
                            [% IF category.is_integer_only %]
166
                            [% IF category.is_integer_only %]
151
                                <input type="checkbox" checked name="is_integer_only" id="is_integer_only" /><label for="is_integer_only">Restrict value to numbers only</label>
167
                                <input type="checkbox" checked name="is_integer_only" id="is_integer_only" /><label for="is_integer_only">Restrict value to numbers only</label>
Lines 187-192 Link Here
187
                                <input type="text" id="authorised_value" name="authorised_value" value="[% av.authorised_value | html %]" maxlength="80" class="focus" />
203
                                <input type="text" id="authorised_value" name="authorised_value" value="[% av.authorised_value | html %]" maxlength="80" class="focus" />
188
                            [% END %]
204
                            [% END %]
189
                        </li>
205
                        </li>
206
207
                        [% parent_category = category.parent_category %]
208
                        [% IF parent_category %]
209
                            <li>
210
                                <label for="parent_authorised_value_id">Parent authorised value: </label>
211
                                <select id="parent_authorised_value_id" name="parent_authorised_value_id">
212
                                    <option value=""></option>
213
                                    [% FOREACH authorised_value IN parent_category.authorised_values %]
214
                                        [% selected = authorised_value.id == av.parent_authorised_value_id %]
215
                                        <option value="[% authorised_value.id | html %]" [% IF selected %]selected[% END %]>[% authorised_value.lib | html %]</option>
216
                                    [% END %]
217
                                </select>
218
                            </li>
219
                        [% END %]
220
190
                        <li>
221
                        <li>
191
                            <label for="lib">Description: </label>
222
                            <label for="lib">Description: </label>
192
                            <input type="text" name="lib" id="lib" value="[% av.lib | html %]" maxlength="200" />
223
                            <input type="text" name="lib" id="lib" value="[% av.lib | html %]" maxlength="200" />
Lines 304-309 Link Here
304
                        <thead>
335
                        <thead>
305
                            <tr>
336
                            <tr>
306
                                <th>Authorized value</th>
337
                                <th>Authorized value</th>
338
                                [% IF category.parent_category_name %]<th>Parent authorised value</th>[% END %]
307
                                <th>Description</th>
339
                                <th>Description</th>
308
                                <th>Description (OPAC)</th>
340
                                <th>Description (OPAC)</th>
309
                                <th>Icon</th>
341
                                <th>Icon</th>
Lines 315-320 Link Here
315
                            [% FOREACH loo IN loop %]
347
                            [% FOREACH loo IN loop %]
316
                                <tr>
348
                                <tr>
317
                                    <td>[% loo.authorised_value | html %]</td>
349
                                    <td>[% loo.authorised_value | html %]</td>
350
                                    [% IF category.parent_category_name %]<td>[% loo.parent_authorised_value.lib | html %]</td>[% END %]
318
                                    <td>[% loo.lib | html %]</td>
351
                                    <td>[% loo.lib | html %]</td>
319
                                    <td>[% loo.lib_opac | html %]</td>
352
                                    <td>[% loo.lib_opac | html %]</td>
320
                                    <td> [% IF ( loo.image ) %]<img class="itemtype-image" src="[% loo.image | url %]" alt="" />[% ELSE %]&nbsp;[% END %]</td>
353
                                    <td> [% IF ( loo.image ) %]<img class="itemtype-image" src="[% loo.image | url %]" alt="" />[% ELSE %]&nbsp;[% END %]</td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt (-3 / +5 lines)
Lines 2-7 Link Here
2
[% USE Koha %]
2
[% USE Koha %]
3
[% USE To %]
3
[% USE To %]
4
[% USE Asset %]
4
[% USE Asset %]
5
[% USE HTML %]
5
[% PROCESS 'i18n.inc' %]
6
[% PROCESS 'i18n.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
7
<title
8
<title
Lines 715-729 Link Here
715
                                                            <div id="field_marceditor[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]" class="field_marceditor">
716
                                                            <div id="field_marceditor[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]" class="field_marceditor">
716
                                                                [% IF ( mv.type == 'select' ) %]
717
                                                                [% IF ( mv.type == 'select' ) %]
717
                                                                    [% IF mv.category AND CAN_user_parameters_manage_auth_values %]
718
                                                                    [% IF mv.category AND CAN_user_parameters_manage_auth_values %]
718
                                                                        <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]">
719
                                                                        <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]" data-parent-category="[% mv.authorised_value_category.parent_category_name | html %]">
719
                                                                    [% ELSE %]
720
                                                                    [% ELSE %]
720
                                                                        <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
721
                                                                        <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
721
                                                                    [% END %]
722
                                                                    [% END %]
722
                                                                        [% FOREACH aval IN mv.values %]
723
                                                                        [% FOREACH aval IN mv.values %]
724
                                                                            [% attributes = HTML.attributes(mv.attributes.$aval) %]
723
                                                                            [% IF aval == mv.default %]
725
                                                                            [% IF aval == mv.default %]
724
                                                                                <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
726
                                                                                <option value="[%- aval | html -%]" [% attributes | $raw %] selected="selected">[%- mv.labels.$aval | html -%]</option>
725
                                                                            [% ELSE %]
727
                                                                            [% ELSE %]
726
                                                                                <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
728
                                                                                <option value="[%- aval | html -%]" [% attributes | $raw %]>[%- mv.labels.$aval | html -%]</option>
727
                                                                            [% END %]
729
                                                                            [% END %]
728
                                                                        [% END %]
730
                                                                        [% END %]
729
                                                                    </select>
731
                                                                    </select>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-4 / +6 lines)
Lines 1-6 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Koha %]
3
[% USE Koha %]
4
[% USE HTML %]
4
[% USE HtmlTags %]
5
[% USE HtmlTags %]
5
[% PROCESS 'i18n.inc' %]
6
[% PROCESS 'i18n.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
Lines 1181-1202 Link Here
1181
                                                            <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
1182
                                                            <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1">[%- mv.value | html -%]</textarea>
1182
                                                        [% ELSIF ( mv.type == 'select' ) %]
1183
                                                        [% ELSIF ( mv.type == 'select' ) %]
1183
                                                        [% IF mv.category AND CAN_user_parameters_manage_auth_values %]
1184
                                                        [% IF mv.category AND CAN_user_parameters_manage_auth_values %]
1184
                                                            <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]">
1185
                                                            <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]" data-parent-category="[% mv.authorised_value_category.parent_category_name | html %]">
1185
                                                        [% ELSE %]
1186
                                                        [% ELSE %]
1186
                                                            <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
1187
                                                            <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
1187
                                                        [% END %]
1188
                                                        [% END %]
1188
                                                            [% SET matched = 0 %]
1189
                                                            [% SET matched = 0 %]
1189
                                                            [% FOREACH aval IN mv.values %]
1190
                                                            [% FOREACH aval IN mv.values %]
1191
                                                                [% attributes = HTML.attributes(mv.attributes.$aval) %]
1190
                                                                [% IF aval == mv.default %]
1192
                                                                [% IF aval == mv.default %]
1191
                                                                    [% SET matched = 1 %]
1193
                                                                    [% SET matched = 1 %]
1192
                                                                <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
1194
                                                                <option value="[%- aval | html -%]" selected="selected" [% attributes | $raw %]>[%- mv.labels.$aval | html -%]</option>
1193
                                                                [% ELSE %]
1195
                                                                [% ELSE %]
1194
                                                                <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
1196
                                                                <option value="[%- aval | html -%]" [% attributes | $raw %]>[%- mv.labels.$aval | html -%]</option>
1195
                                                                [% END %]
1197
                                                                [% END %]
1196
1198
1197
                                                            [% END %]
1199
                                                            [% END %]
1198
                                                            [% UNLESS matched # If the current value is not in the authorised value list %]
1200
                                                            [% UNLESS matched # If the current value is not in the authorised value list %]
1199
                                                                <option value="[%- mv.default | html -%]" selected="selected">[%- mv.default | html -%] (Not an authorised value)</option>
1201
                                                                <option value="[%- mv.default | html -%]" selected="selected" [% attributes | $raw %]>[%- mv.default | html -%] (Not an authorised value)</option>
1200
                                                            </select>
1202
                                                            </select>
1201
                                                            <span style="float:right;" title="The current value [% mv.default | html %] is not configured for the authorised value category controlling this subfield"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></span>
1203
                                                            <span style="float:right;" title="The current value [% mv.default | html %] is not configured for the authorised value category controlling this subfield"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i></span>
1202
                                                            [% ELSE %]
1204
                                                            [% ELSE %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt (-3 / +5 lines)
Lines 1-4 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE HTML %]
2
<ol>
3
<ol>
3
    [% FOREACH iteminfo IN iteminformation %]
4
    [% FOREACH iteminfo IN iteminformation %]
4
        <li style="[% iteminfo.hidden | html %];">
5
        <li style="[% iteminfo.hidden | html %];">
Lines 9-20 Link Here
9
                    <label>[% iteminfo.subfield | html %] - [% iteminfo.marc_lib | $raw %]</label>
10
                    <label>[% iteminfo.subfield | html %] - [% iteminfo.marc_lib | $raw %]</label>
10
                [% END %]
11
                [% END %]
11
                [% IF ( iteminfo.marc_value.type == 'select' ) %]
12
                [% IF ( iteminfo.marc_value.type == 'select' ) %]
12
                    <select name="field_value" class="input_marceditor">
13
                    <select name="field_value" class="input_marceditor" data-category="[% iteminfo.marc_value.category | html %]" data-parent-category="[% iteminfo.marc_value.authorised_value_category.parent_category_name | html %]">
13
                        [% FOREACH value IN iteminfo.marc_value.values %]
14
                        [% FOREACH value IN iteminfo.marc_value.values %]
15
                            [% attributes = HTML.attributes(iteminfo.marc_value.attributes.$value) %]
14
                            [% IF ( value == iteminfo.marc_value.default ) %]
16
                            [% IF ( value == iteminfo.marc_value.default ) %]
15
                                <option value="[% value | html %]" selected="selected">[% iteminfo.marc_value.labels.$value | html %]</option>
17
                                <option value="[% value | html %]" [% attributes | $raw %] selected="selected">[% iteminfo.marc_value.labels.$value | html %]</option>
16
                            [% ELSE %]
18
                            [% ELSE %]
17
                                <option value="[% value | html %]">[% iteminfo.marc_value.labels.$value | html %]</option>
19
                                <option value="[% value | html %]" [% attributes | $raw %]>[% iteminfo.marc_value.labels.$value | html %]</option>
18
                            [% END %]
20
                            [% END %]
19
                        [% END %]
21
                        [% END %]
20
                    </select>
22
                    </select>
(-)a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js (-1 / +33 lines)
Lines 853-856 $(document).ready(function () { Link Here
853
        "input.input_marceditor.framework_plugin",
853
        "input.input_marceditor.framework_plugin",
854
        callPluginEventHandler
854
        callPluginEventHandler
855
    );
855
    );
856
857
    // Enable/Disable authorised values depending on parent-child relationships
858
    $(".marc_editor").on(
859
        "change",
860
        "select.input_marceditor[data-category]",
861
        function (e) {
862
            const select = e.target;
863
            const category = select.dataset.category;
864
            const authorised_value_id = select.selectedOptions[0]?.dataset.id;
865
            const ancestor = select.closest(".tag, .marc_editor");
866
            const childSelects = Array.from(
867
                ancestor.querySelectorAll(`select[data-parent-category]`)
868
            ).filter(s => s.dataset.parentCategory === category);
869
870
            for (const s of childSelects) {
871
                for (const el of s.options) {
872
                    if (
873
                        authorised_value_id &&
874
                        el.dataset.parentAuthorisedValueId &&
875
                        el.dataset.parentAuthorisedValueId !==
876
                            authorised_value_id
877
                    ) {
878
                        el.disabled = true;
879
                        el.selected = false;
880
                    } else {
881
                        el.disabled = false;
882
                    }
883
                }
884
                $(s).trigger("change");
885
            }
886
        }
887
    );
888
    $(".marc_editor select.input_marceditor[data-category]").trigger("change");
856
});
889
});
857
- 

Return to bug 34198