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

(-)a/Koha/Hold.pm (-1 / +18 lines)
Lines 695-700 sub item { Link Here
695
    return Koha::Item->_new_from_dbic($rs);
695
    return Koha::Item->_new_from_dbic($rs);
696
}
696
}
697
697
698
=head3 item_type
699
700
Returns the related Koha::ItemType object for this hold
701
702
=cut
703
704
sub item_type {
705
    my ($self) = @_;
706
    my $rs = $self->_result->itemtype;
707
    return unless $rs;
708
    return Koha::ItemType->_new_from_dbic($rs);
709
}
710
698
=head3 item_group
711
=head3 item_group
699
712
700
Returns the related Koha::Biblio::ItemGroup object for this Hold
713
Returns the related Koha::Biblio::ItemGroup object for this Hold
Lines 1281-1287 sub to_api_mapping { Link Here
1281
        lowestPriority         => 'lowest_priority',
1294
        lowestPriority         => 'lowest_priority',
1282
        suspend                => 'suspended',
1295
        suspend                => 'suspended',
1283
        suspend_until          => 'suspended_until',
1296
        suspend_until          => 'suspended_until',
1284
        itemtype               => 'item_type',
1297
        itemtype               => 'item_type_id',
1285
        item_level_hold        => 'item_level',
1298
        item_level_hold        => 'item_level',
1286
    };
1299
    };
1287
}
1300
}
Lines 1319-1324 sub strings_map { Link Here
1319
        pickup_library_id => { str => $self->pickup_library->branchname, type => 'library' },
1332
        pickup_library_id => { str => $self->pickup_library->branchname, type => 'library' },
1320
    };
1333
    };
1321
1334
1335
    if ( defined $self->itemtype ) {
1336
        $strings->{item_type_id} = { str => $self->item_type->description, type => 'item_type' };
1337
    }
1338
1322
    if ( defined $self->cancellation_reason ) {
1339
    if ( defined $self->cancellation_reason ) {
1323
        my $av = Koha::AuthorisedValues->search(
1340
        my $av = Koha::AuthorisedValues->search(
1324
            {
1341
            {
(-)a/api/v1/swagger/definitions/hold.yaml (-1 / +1 lines)
Lines 101-107 properties: Link Here
101
  non_priority:
101
  non_priority:
102
    description: Set this hold as non priority
102
    description: Set this hold as non priority
103
    type: boolean
103
    type: boolean
104
  item_type:
104
  item_type_id:
105
    type:
105
    type:
106
      - string
106
      - string
107
      - "null"
107
      - "null"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt (-6 / +40 lines)
Lines 1-3 Link Here
1
[% USE To %]
1
[% USE raw %]
2
[% USE raw %]
2
[% USE Asset %]
3
[% USE Asset %]
3
[% USE KohaDates %]
4
[% USE KohaDates %]
Lines 158-163 Link Here
158
    [% INCLUDE 'str/members-menu.inc' %]
159
    [% INCLUDE 'str/members-menu.inc' %]
159
    [% Asset.js("js/members-menu.js") | $raw %]
160
    [% Asset.js("js/members-menu.js") | $raw %]
160
    [% INCLUDE 'js-biblio-format.inc' %]
161
    [% INCLUDE 'js-biblio-format.inc' %]
162
    <script>
163
        const all_libraries = [% To.json(Branches.all) | $raw %].map(e => {
164
                    e["_id"] = e["branchcode"];
165
                    e["_str"] = e["branchname"];
166
                    return e;
167
                });
168
169
        const all_item_types = [% To.json(ItemTypes.Get) | $raw %].map(e => {
170
                    e["_id"] = e["itemtype"];
171
                    e["_str"] = e["translated_description"];
172
                    return e;
173
                });
174
175
        var coded_values = {
176
            library: new Map(all_libraries.map( l => [l.branchname, l.branchcode] )),
177
            item_type: new Map(all_item_types.map( i => [i.translated_description, i.itemtype] )),
178
        };
179
180
        let filters_options = {
181
            item_types: all_item_types,
182
            libraries: all_libraries,
183
        };
184
    </script>
161
    <script>
185
    <script>
162
        $(document).ready(function() {
186
        $(document).ready(function() {
163
            var table_settings = [% TablesSettings.GetTableSettings('members', 'holdshistory', 'holdshistory-table', 'json') | $raw %];
187
            var table_settings = [% TablesSettings.GetTableSettings('members', 'holdshistory', 'holdshistory-table', 'json') | $raw %];
Lines 165-170 Link Here
165
              //Remove item type column settings
189
              //Remove item type column settings
166
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
190
              table_settings['columns'] = table_settings['columns'].filter(function(c){return c['columnname'] != 'itemtype';});
167
            [% END %]
191
            [% END %]
192
168
            let current_holds_table = build_holds_table("#table_holdshistory");
193
            let current_holds_table = build_holds_table("#table_holdshistory");
169
            let old_holds_table = build_holds_table("#table_oldholdshistory", 1);
194
            let old_holds_table = build_holds_table("#table_oldholdshistory", 1);
170
            function build_holds_table(table_id, old){
195
            function build_holds_table(table_id, old){
Lines 253-263 Link Here
253
                            }
278
                            }
254
                        },
279
                        },
255
                        {
280
                        {
256
                            data: "pickup_library_id:pickup_library.name",
281
                            data: "me.pickup_library_id",
282
                            datatype: "coded_value:library",
283
                            dataFilter: "libraries",
257
                            searchable: true,
284
                            searchable: true,
258
                            orderable: true,
285
                            orderable: true,
259
                            render: function (data, type, row, meta) {
286
                            render: function (data, type, row, meta) {
260
                                return row.pickup_library.name;
287
                                return escape_str(row._strings.pickup_library_id ? row._strings.pickup_library_id.str : row.pickup_library_id);
261
                            }
288
                            }
262
                        },
289
                        },
263
                        {
290
                        {
Lines 298-309 Link Here
298
                        },
325
                        },
299
                        [% IF show_itemtype_column %]
326
                        [% IF show_itemtype_column %]
300
                        {
327
                        {
301
                            data: "item_type",
328
                            data: "item_type_id",
329
                            datatype: "coded_value:item_type",
330
                            dataFilter: "item_types",
302
                            searchable: true,
331
                            searchable: true,
303
                            orderable: true,
332
                            orderable: true,
304
                            render: function (data, type, row, meta) {
333
                            render: function (data, type, row, meta) {
305
                                if ( row.item_type ) {
334
                                if ( row.item_type_id ) {
306
                                    return row.item_type;
335
                                    return row._strings.item_type_id ? row._strings.item_type_id.str : row.item_type_id;
307
                                } else {
336
                                } else {
308
                                    return _("Any item type");
337
                                    return _("Any item type");
309
                                }
338
                                }
Lines 343-349 Link Here
343
                            }
372
                            }
344
                        },
373
                        },
345
                    ],
374
                    ],
346
                }, table_settings, true, additional_filters);
375
                },
376
                table_settings,
377
                true,
378
                additional_filters,
379
                filters_options,
380
                );
347
            }
381
            }
348
            $("#current_holds_filters :checkbox, #old_holds_filters :checkbox").on("change", function(e){
382
            $("#current_holds_filters :checkbox, #old_holds_filters :checkbox").on("change", function(e){
349
                e.preventDefault();
383
                e.preventDefault();
(-)a/t/db_dependent/Koha/Hold.t (-6 / +40 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::NoWarnings;
22
use Test::NoWarnings;
23
use Test::More tests => 20;
23
use Test::More tests => 21;
24
24
25
use Test::Exception;
25
use Test::Exception;
26
use Test::MockModule;
26
use Test::MockModule;
Lines 92-97 subtest 'biblio() tests' => sub { Link Here
92
    $schema->storage->txn_rollback;
92
    $schema->storage->txn_rollback;
93
};
93
};
94
94
95
subtest 'item_type() tests' => sub {
96
97
    plan tests => 2;
98
99
    $schema->storage->txn_begin;
100
101
    my $hold = $builder->build_object(
102
        {
103
            class => 'Koha::Holds',
104
            value => { itemtype => undef },
105
        }
106
    );
107
108
    is( $hold->item_type, undef, 'Koha::Hold->item_type returns undef if no item type selected' );
109
    my $item_type = $builder->build_object( { class => "Koha::ItemTypes" } );
110
    $hold->itemtype( $item_type->itemtype )->store;
111
    is( $hold->item_type->itemtype, $item_type->itemtype, 'Koha::Hold->item_type returns the correct item type' );
112
113
    $schema->storage->txn_rollback;
114
};
115
95
subtest 'pickup_library/branch tests' => sub {
116
subtest 'pickup_library/branch tests' => sub {
96
117
97
    plan tests => 1;
118
    plan tests => 1;
Lines 1207-1213 subtest 'change_type() tests' => sub { Link Here
1207
1228
1208
subtest 'strings_map() tests' => sub {
1229
subtest 'strings_map() tests' => sub {
1209
1230
1210
    plan tests => 3;
1231
    plan tests => 4;
1211
1232
1212
    $schema->txn_begin;
1233
    $schema->txn_begin;
1213
1234
Lines 1233-1239 subtest 'strings_map() tests' => sub { Link Here
1233
    is_deeply(
1254
    is_deeply(
1234
        $strings_map,
1255
        $strings_map,
1235
        {
1256
        {
1236
            pickup_library_id   => { str => $library->branchname, type => 'library' },
1257
            pickup_library_id   => { str => $library->branchname,          type => 'library' },
1258
            item_type_id        => { str => $hold->item_type->description, type => 'item_type' },
1237
            cancellation_reason => { str => $av->lib, type => 'av', category => 'HOLD_CANCELLATION' },
1259
            cancellation_reason => { str => $av->lib, type => 'av', category => 'HOLD_CANCELLATION' },
1238
        },
1260
        },
1239
        'Strings map is correct'
1261
        'Strings map is correct'
Lines 1243-1249 subtest 'strings_map() tests' => sub { Link Here
1243
    is_deeply(
1265
    is_deeply(
1244
        $strings_map,
1266
        $strings_map,
1245
        {
1267
        {
1246
            pickup_library_id   => { str => $library->branchname, type => 'library' },
1268
            pickup_library_id   => { str => $library->branchname,          type => 'library' },
1269
            item_type_id        => { str => $hold->item_type->description, type => 'item_type' },
1247
            cancellation_reason => { str => $av->lib_opac, type => 'av', category => 'HOLD_CANCELLATION' },
1270
            cancellation_reason => { str => $av->lib_opac, type => 'av', category => 'HOLD_CANCELLATION' },
1248
        },
1271
        },
1249
        'Strings map is correct (OPAC)'
1272
        'Strings map is correct (OPAC)'
Lines 1255-1266 subtest 'strings_map() tests' => sub { Link Here
1255
    is_deeply(
1278
    is_deeply(
1256
        $strings_map,
1279
        $strings_map,
1257
        {
1280
        {
1258
            pickup_library_id   => { str => $library->branchname, type => 'library' },
1281
            pickup_library_id   => { str => $library->branchname,          type => 'library' },
1282
            item_type_id        => { str => $hold->item_type->description, type => 'item_type' },
1259
            cancellation_reason => { str => $hold->cancellation_reason, type => 'av', category => 'HOLD_CANCELLATION' },
1283
            cancellation_reason => { str => $hold->cancellation_reason, type => 'av', category => 'HOLD_CANCELLATION' },
1260
        },
1284
        },
1261
        'Strings map shows the cancellation_value when AV not present'
1285
        'Strings map shows the cancellation_value when AV not present'
1262
    );
1286
    );
1263
1287
1288
    $hold->itemtype(undef)->store;
1289
    $strings_map = $hold->strings_map( { public => 1 } );
1290
    is_deeply(
1291
        $strings_map,
1292
        {
1293
            pickup_library_id   => { str => $library->branchname, type => 'library' },
1294
            cancellation_reason => { str => $hold->cancellation_reason, type => 'av', category => 'HOLD_CANCELLATION' },
1295
        },
1296
        'Strings map does not show item_type_id if none selected'
1297
    );
1298
1264
    $schema->txn_rollback;
1299
    $schema->txn_rollback;
1265
};
1300
};
1266
1301
1267
- 

Return to bug 41456