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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc (-6 / +20 lines)
Lines 123-131 Link Here
123
        }
123
        }
124
    }
124
    }
125
125
126
    function update_columns_visibility(settings){
126
    function update_columns_visibility(table_dt, table_settings, user_colvis){
127
        let table = settings.oInstance.api();
127
        table_dt.columns().visible(true, false);
128
        table.columns().every(function(){
128
        let hidden_ids = _dt_visibility(table_settings, table_dt);
129
        table_dt.columns(hidden_ids).visible(false, false);
130
        table_dt.columns().every(function(){
129
            let i = this.index();
131
            let i = this.index();
130
            let is_empty = true;
132
            let is_empty = true;
131
            let nodes = this.nodes();
133
            let nodes = this.nodes();
Lines 136-144 Link Here
136
                }
138
                }
137
            });
139
            });
138
            if ( is_empty ) {
140
            if ( is_empty ) {
139
                table.columns(i).visible(false, false);
141
                table_dt.columns(i).visible(false, false);
140
            }
142
            }
141
        });
143
        });
144
        for (const [key, value] of Object.entries(user_colvis)) {
145
            table_dt.columns(key).visible(value, false);
146
        }
142
    }
147
    }
143
148
144
149
Lines 264-269 Link Here
264
        otherholdings: [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json')  | $raw %],
269
        otherholdings: [% TablesSettings.GetTableSettings('catalogue', 'detail','otherholdings_table','json')  | $raw %],
265
    };
270
    };
266
271
272
    let user_colvis = {holdings: {}, otherholdings: {}};
267
    let table_nodes = {
273
    let table_nodes = {
268
        holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]",
274
        holdings: "[% PROCESS 'build_table' tab="holdings" | collapse | $tojson %]",
269
        otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]",
275
        otherholdings: "[% PROCESS 'build_table' tab="otherholdings" | collapse | $tojson %]",
Lines 849-855 Link Here
849
                [% END %]
855
                [% END %]
850
856
851
                if ( api.data().length ) {
857
                if ( api.data().length ) {
852
                    update_columns_visibility(settings);
858
                    update_columns_visibility(api, items_table_settings[tab_id], user_colvis[tab_id]);
853
                }
859
                }
854
860
855
                if ( drawcallback ) { drawcallback(this); }
861
                if ( drawcallback ) { drawcallback(this); }
Lines 862-867 Link Here
862
        filters_options,
868
        filters_options,
863
        );
869
        );
864
870
871
        let table_dt = items_table.DataTable();
872
        table_dt.on("column-visibility.dt", function(e, settings, column, state, recalc ){
873
            if (recalc === false) return;
874
875
            _dt_add_filters(this, table_dt, filters_options);
876
877
            user_colvis[tab_id][column] = state;
878
879
        });
865
        return items_table;
880
        return items_table;
866
    }
881
    }
867
    function safe_link(uri,link_text) {
882
    function safe_link(uri,link_text) {
868
- 

Return to bug 38485