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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-1 / +2 lines)
Lines 656-665 Link Here
656
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
656
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'libraries', 'libraries', 'json' ) | $raw %];
657
        var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]';
657
        var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]';
658
658
659
        var libraries_table;
659
        $(document).ready(function() {
660
        $(document).ready(function() {
660
661
661
            var libraries_url = '/api/v1/libraries';
662
            var libraries_url = '/api/v1/libraries';
662
            var libraries = $("#libraries").kohaTable({
663
            libraries_table = $("#libraries").kohaTable({
663
                "ajax": {
664
                "ajax": {
664
                    "url": libraries_url
665
                    "url": libraries_url
665
                },
666
                },
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-10 / +15 lines)
Lines 595-600 function _dt_default_ajax (params){ Link Here
595
    }
595
    }
596
}
596
}
597
597
598
function build_url_with_state(dt, table_settings){
599
    let table_key = 'DataTables_%s_%s_%s'.format(
600
        table_settings.module,
601
        table_settings.page,
602
        table_settings.table);
603
604
    let state = JSON.stringify(dt.state());
605
    delete state.time;
606
    let searchParams = new URLSearchParams(window.location.search);
607
    searchParams.set(table_key + '_state', btoa(state));
608
609
    return window.location.origin + window.location.pathname + '?' + searchParams.toString() + window.location.hash;
610
}
611
598
function _dt_buttons(params){
612
function _dt_buttons(params){
599
    let settings = params.settings || {};
613
    let settings = params.settings || {};
600
    let table_settings = params.table_settings;
614
    let table_settings = params.table_settings;
Lines 723-739 function _dt_buttons(params){ Link Here
723
                titleAttr: __("Copy shareable link"),
737
                titleAttr: __("Copy shareable link"),
724
                text: '<i class="fa fa-lg fa-copy"></i> <span class="dt-button-text">' + __("Copy shareable link") + '</span>',
738
                text: '<i class="fa fa-lg fa-copy"></i> <span class="dt-button-text">' + __("Copy shareable link") + '</span>',
725
                action: function (e, dt, node, config) {
739
                action: function (e, dt, node, config) {
726
                    let table_key = 'DataTables_%s_%s_%s'.format(
740
                    const url = build_url_with_state(dt, table_settings);
727
                        table_settings.module,
728
                        table_settings.page,
729
                        table_settings.table);
730
731
                    let state = JSON.stringify(dt.state());
732
                    delete state.time;
733
                    let searchParams = new URLSearchParams(window.location.search);
734
                    searchParams.set(table_key + '_state', btoa(state));
735
741
736
                    let url = window.location.origin + window.location.pathname + '?' + searchParams.toString() + window.location.hash;
737
                    if( navigator.clipboard && navigator.clipboard.writeText){
742
                    if( navigator.clipboard && navigator.clipboard.writeText){
738
                        writeToClipboard(url, node);
743
                        writeToClipboard(url, node);
739
                    }
744
                    }
(-)a/t/cypress/integration/KohaTable_spec.ts (-55 / +42 lines)
Lines 264-328 describe("kohaTable (using REST API)", () => { Link Here
264
                    );
264
                    );
265
                    cy.get(`#${table_id} th`).contains("Name");
265
                    cy.get(`#${table_id} th`).contains("Name");
266
                    cy.get(`#${table_id} th`).contains("Code");
266
                    cy.get(`#${table_id} th`).contains("Code");
267
268
                    // Close the 'Columns' list
269
                    cy.get(".dt-button-background").click();
270
                    cy.get(".dt-button-background").should("not.exist");
271
                    cy.wait(500); // ensure the animation completes, random failures?
272
273
                    // Copy the shareable link (Name and Code shown)
274
                    cy.window().focus();
275
                    cy.get(
276
                        `#${table_id}_wrapper .copyConditions_controls`
277
                    ).click({ force: true });
278
                    cy.get(".tooltip").contains("Copied!");
279
                });
267
                });
280
268
281
                cy.window().then(win => {
269
                cy.window().then(win => {
282
                    // Retrieve the content of the clipboard
270
                    // Copy the shareable link (Name and Code shown)
283
                    win.navigator.clipboard.readText().then(url => {
271
                    const url = win.build_url_with_state(
284
                        expect(url).to.match(
272
                        win.libraries_table.DataTable(),
285
                            /branches.pl\?DataTables_admin_libraries_libraries_state=/
273
                        win.table_settings
274
                    );
275
                    expect(url).to.match(
276
                        /branches.pl\?DataTables_admin_libraries_libraries_state=/
277
                    );
278
279
                    // Remove localStorage
280
                    win.localStorage.clear();
281
282
                    // Use it
283
                    cy.visit(url);
284
285
                    // Code is shown whereas it is hidden in the config
286
                    cy.get("@columns").then(columns => {
287
                        cy.get(`#${table_id} th`).should(
288
                            "have.length",
289
                            columns.length
290
                        );
291
                        cy.get(`#${table_id} th`).contains("Name");
292
                        cy.get(`#${table_id} th`).contains("Code");
293
294
                        // Hide "Name"
295
                        cy.get(`#${table_id}_wrapper .buttons-colvis`).click();
296
                        cy.get(`#${table_id}_wrapper .dt-button-collection`)
297
                            .contains("Name")
298
                            .click();
299
                    });
300
301
                    // Go to the shareable link
302
                    // but do not remove localStorage!
303
                    cy.visit(url);
304
305
                    // Name is hidden and Code is shown
306
                    cy.get("@columns").then(columns => {
307
                        cy.get(`#${table_id} th`).should(
308
                            "have.length",
309
                            columns.length
286
                        );
310
                        );
287
311
288
                        // Remove localStorage
312
                        cy.get(`#${table_id} th`).contains("Name");
289
                        win.localStorage.clear();
313
                        cy.get(`#${table_id} th`).contains("Code");
290
291
                        // Use it
292
                        cy.visit(url);
293
294
                        // Code is shown whereas it is hidden in the config
295
                        cy.get("@columns").then(columns => {
296
                            cy.get(`#${table_id} th`).should(
297
                                "have.length",
298
                                columns.length
299
                            );
300
                            cy.get(`#${table_id} th`).contains("Name");
301
                            cy.get(`#${table_id} th`).contains("Code");
302
303
                            // Hide "Name"
304
                            cy.get(
305
                                `#${table_id}_wrapper .buttons-colvis`
306
                            ).click();
307
                            cy.get(`#${table_id}_wrapper .dt-button-collection`)
308
                                .contains("Name")
309
                                .click();
310
                        });
311
312
                        // Go to the shareable link
313
                        // but do not remove localStorage!
314
                        cy.visit(url);
315
316
                        // Name is hidden and Code is shown
317
                        cy.get("@columns").then(columns => {
318
                            cy.get(`#${table_id} th`).should(
319
                                "have.length",
320
                                columns.length
321
                            );
322
323
                            cy.get(`#${table_id} th`).contains("Name");
324
                            cy.get(`#${table_id} th`).contains("Code");
325
                        });
326
                    });
314
                    });
327
                });
315
                });
328
            });
316
            });
329
- 

Return to bug 38461