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

(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-4 / +34 lines)
Lines 56-67 var dataTablesDefaults = { Link Here
56
    "pageLength": 20,
56
    "pageLength": 20,
57
    "fixedHeader": true,
57
    "fixedHeader": true,
58
    initComplete: function( settings ) {
58
    initComplete: function( settings ) {
59
        var tableId = settings.nTable.id
59
        var tableId = settings.nTable.id;
60
        var state =  settings.oLoadedState;
60
        let table_node = $("#" + tableId);
61
62
        state =  settings.oLoadedState;
61
        state && state.search && toggledClearFilter(state.search.search, tableId);
63
        state && state.search && toggledClearFilter(state.search.search, tableId);
62
64
63
        if (settings.ajax) {
65
        if (settings.ajax) {
64
            let table_node = $("#" + tableId);
65
            if ( typeof this.api === 'function' ) {
66
            if ( typeof this.api === 'function' ) {
66
                _dt_add_delay(this.api(), table_node);
67
                _dt_add_delay(this.api(), table_node);
67
            } else {
68
            } else {
Lines 757-762 function _dt_buttons(params){ Link Here
757
        }
758
        }
758
    );
759
    );
759
760
761
    buttons.push(
762
        {
763
            autoClose: true,
764
            fade: 100,
765
            className: "copyConditions_controls",
766
            titleAttr: __("Copy conditions"),
767
            text: '<i class="fa fa-lg fa-copy"></i> <span class="dt-button-text">' + __("Copy conditions") + '</span>',
768
            action: function (e, dt, node, config) {
769
                let state = JSON.stringify(dt.state());
770
                delete state.time;
771
                let searchParams = new URLSearchParams(window.location.search);
772
                let table_id = dt.table().node().id;
773
                searchParams.set(table_id + '_state', btoa(state));
774
                let url = window.location.origin + window.location.pathname + '?' + searchParams.toString() + window.location.hash;
775
                if( navigator.clipboard && navigator.clipboard.writeText){
776
                    navigator.clipboard.writeText( url );
777
                    // TODO Add tooltip "State copied to the clipboard"
778
                }
779
            },
780
        }
781
    );
782
760
    if ( table_settings && CAN_user_parameters_manage_column_config ) {
783
    if ( table_settings && CAN_user_parameters_manage_column_config ) {
761
        buttons.push(
784
        buttons.push(
762
            {
785
            {
Lines 952-957 function _dt_save_restore_state(table_settings){ Link Here
952
        localStorage.setItem( table_key, JSON.stringify(data) )
975
        localStorage.setItem( table_key, JSON.stringify(data) )
953
    }
976
    }
954
    let stateLoadCallback = function(settings) {
977
    let stateLoadCallback = function(settings) {
978
979
        // Load state from URL
980
        const url = new URL(window.location.href);
981
        let state_from_url = url.searchParams.get( settings.nTable.id + '_state');
982
        if ( state_from_url ) {
983
            return JSON.parse(atob(state_from_url));
984
        }
985
955
        if (!default_save_state) return {};
986
        if (!default_save_state) return {};
956
987
957
        let state = localStorage.getItem(table_key);
988
        let state = localStorage.getItem(table_key);
958
- 

Return to bug 33484