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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc (-4 / +10 lines)
Lines 624-629 Link Here
624
                                }
624
                                }
625
                                [% CASE 'branch' %]
625
                                [% CASE 'branch' %]
626
                                {
626
                                {
627
                                    name: "library",
627
                                    data: "library.name:me.library_id",
628
                                    data: "library.name:me.library_id",
628
                                    dataFilter: "libraries",
629
                                    dataFilter: "libraries",
629
                                    searchable: true,
630
                                    searchable: true,
Lines 638-643 Link Here
638
                                }
639
                                }
639
                                [% CASE 'category' %]
640
                                [% CASE 'category' %]
640
                                {
641
                                {
642
                                    name: "category",
641
                                    data: "category_id",
643
                                    data: "category_id",
642
                                    dataFilter: "categories",
644
                                    dataFilter: "categories",
643
                                    searchable: true,
645
                                    searchable: true,
Lines 907-918 Link Here
907
                        [% SWITCH c %]
909
                        [% SWITCH c %]
908
                        [% CASE 'branch' %]
910
                        [% CASE 'branch' %]
909
                            let library_id = patron_search_form.find(".branchcode_filter").val() || "";
911
                            let library_id = patron_search_form.find(".branchcode_filter").val() || "";
910
                            patrons_table.find('thead tr:eq(1) th[data-filter="libraries"] select').val('^' + library_id + '$');
912
                            let library_column = table_dt.column('library:name');
911
                            table_dt.column([% loop.count - 1 %]).search(library_id ? '^'+library_id+'$' : '');
913
                            let library_visible_index = library_column.index("visible");
914
                            patrons_table.find(`thead tr:eq(1) th:eq(${library_visible_index}) select`).val('^' + library_id + '$');
915
                            library_column.search(library_id ? '^'+library_id+'$' : '');
912
                        [% CASE 'category' %]
916
                        [% CASE 'category' %]
913
                            let category_id = patron_search_form.find(".categorycode_filter").val() || "";
917
                            let category_id = patron_search_form.find(".categorycode_filter").val() || "";
914
                            patrons_table.find('thead tr:eq(1) th[data-filter="categories"] select').val('^' + category_id.toLowerCase() + '$');
918
                            let category_column = table_dt.column('category:name');
915
                            table_dt.column([% loop.count - 1 %]).search(category_id ? '^'+category_id+'$' : '');
919
                            let category_visible_index = category_column.index("visible");
920
                            patrons_table.find(`thead tr:eq(1) th:eq(${category_visible_index}) select`).val('^' + category_id.toLowerCase() + '$');
921
                            category_column.search(category_id ? '^'+category_id+'$' : '');
916
                        [% END %]
922
                        [% END %]
917
                    [% END %]
923
                    [% END %]
918
                }
924
                }
(-)a/t/cypress/integration/KohaTable/PatronSearch_spec.ts (-22 / +50 lines)
Lines 159-183 describe("Filters", () => { Link Here
159
                `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries`
159
                `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries`
160
            );
160
            );
161
161
162
            cy.get(`#${table_id} thead tr`).should("have.length", 2);
162
            cy.get(`#${table_id}`).then($table => {
163
163
                const dt = $table.DataTable();
164
            cy.get(
164
                const libraryCol = dt.column("library:name");
165
                `#${table_id} thead tr th[data-filter='libraries'] select`
165
                const libraryVisibleIndex = libraryCol.index("visible");
166
            ).should("have.value", "^CPL$");
166
                const categoryCol = dt.column("category:name");
167
            // Lowercase see bug 32517 and related code in datatables.js
167
                const categoryVisibleIndex = categoryCol.index("visible");
168
            cy.get(
168
169
                `#${table_id} thead tr th[data-filter='categories'] select`
169
                cy.get(`#${table_id} thead tr`).should("have.length", 2);
170
            ).should("have.value", "^s$");
170
                cy.get(`#${table_id} thead tr`)
171
171
                    .eq(1)
172
            cy.get(`form.patron_search_form input.clear_search`).click();
172
                    .find("th")
173
            cy.get("form.patron_search_form input[type='submit']").click();
173
                    .eq(libraryVisibleIndex)
174
            cy.get(
174
                    .find("select")
175
                `#${table_id} thead tr th[data-filter='libraries'] select`
175
                    .should("have.value", "^CPL$");
176
            ).should("have.value", null);
176
177
            // Lowercase see bug 32517 and related code in datatables.js
177
                // Lowercase see bug 32517 and related code in datatables.js
178
            cy.get(
178
                cy.get(`#${table_id} thead tr`)
179
                `#${table_id} thead tr th[data-filter='categories'] select`
179
                    .eq(1)
180
            ).should("have.value", null);
180
                    .find("th")
181
                    .eq(categoryVisibleIndex)
182
                    .find("select")
183
                    .should("have.value", "^s$");
184
185
                cy.get(`form.patron_search_form input.clear_search`).click();
186
                cy.get("form.patron_search_form input[type='submit']").click();
187
                cy.get(`#${table_id} thead tr`)
188
                    .eq(1)
189
                    .find("th")
190
                    .eq(libraryVisibleIndex)
191
                    .find("select")
192
                    .should("have.value", null);
193
                // Lowercase see bug 32517 and related code in datatables.js
194
                cy.get(`#${table_id} thead tr`)
195
                    .eq(1)
196
                    .find("th")
197
                    .eq(categoryVisibleIndex)
198
                    .find("select")
199
                    .should("have.value", null);
200
            });
181
        });
201
        });
182
    });
202
    });
183
203
Lines 257-265 describe("Filters", () => { Link Here
257
277
258
                cy.wait("@searchPatrons");
278
                cy.wait("@searchPatrons");
259
279
260
                cy.get(
280
                cy.get(`#${table_id}`).then($table => {
261
                    `#${table_id} thead tr th[data-filter='libraries'] select`
281
                    const dt = $table.DataTable();
262
                ).select("^CPL$");
282
                    const libraryCol = dt.column("library:name");
283
                    const libraryVisibleIndex = libraryCol.index("visible");
284
                    cy.get(`#${table_id} thead tr`)
285
                        .eq(1)
286
                        .find("th")
287
                        .eq(libraryVisibleIndex)
288
                        .find("select")
289
                        .select("^CPL$");
290
                });
263
291
264
                cy.wait("@searchPatrons").then(interception => {
292
                cy.wait("@searchPatrons").then(interception => {
265
                    const q = interception.request.query.q;
293
                    const q = interception.request.query.q;
(-)a/t/db_dependent/selenium/patrons_search.t (-2 / +2 lines)
Lines 342-350 subtest 'Search patrons' => sub { Link Here
342
        'Searching in standard brings back correct results'
342
        'Searching in standard brings back correct results'
343
    );
343
    );
344
344
345
    # Not ideal as there are 2 select.dt-select-filter in the header (for library and category)
345
    $s->driver->find_element( '//table[@id="'
346
    $s->driver->find_element( '//table[@id="'
346
            . $table_id
347
            . $table_id
347
            . '"]//th[@data-filter="libraries"]/select/option[@value="^'
348
            . '"]//th/select[@class="dt-select-filter"]/option[@value="^'
348
            . $first_patron->library->branchcode
349
            . $first_patron->library->branchcode
349
            . '$"]' )->click;
350
            . '$"]' )->click;
350
    sleep $DT_delay && $s->wait_for_ajax;
351
    sleep $DT_delay && $s->wait_for_ajax;
351
- 

Return to bug 38311