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

(-)a/admin/columns_settings.yml (+2 lines)
Lines 169-174 modules: Link Here
169
  admin:
169
  admin:
170
    cities:
170
    cities:
171
      table_cities:
171
      table_cities:
172
        default_display_length: 20
173
        default_sort_order: 0
172
        columns:
174
        columns:
173
            -
175
            -
174
              columnname: city_id
176
              columnname: city_id
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt (-2 / +2 lines)
Lines 214-220 Link Here
214
    [% INCLUDE 'columns_settings.inc' %]
214
    [% INCLUDE 'columns_settings.inc' %]
215
    <script>
215
    <script>
216
216
217
        var columns_settings = [% TablesSettings.GetColumns( 'admin', 'cities', 'table_cities', 'json' ) | $raw %];
217
        var table_settings = [% TablesSettings.GetTableSettings( 'admin', 'cities', 'table_cities', 'json' ) | $raw %];
218
        $(document).ready(function() {
218
        $(document).ready(function() {
219
            var cities_table_url = '/api/v1/cities?';
219
            var cities_table_url = '/api/v1/cities?';
220
220
Lines 279-285 Link Here
279
                        "orderable": false
279
                        "orderable": false
280
                    }
280
                    }
281
                ]
281
                ]
282
            }, columns_settings, 1);
282
            }, table_settings, 1);
283
283
284
        });
284
        });
285
    </script>
285
    </script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-15 / +27 lines)
Lines 523-535 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
523
    *                                   We extend the options set with the `criteria` key which allows
523
    *                                   We extend the options set with the `criteria` key which allows
524
    *                                   the developer to select the match type to be applied during searches
524
    *                                   the developer to select the match type to be applied during searches
525
    *                                   Valid keys are: `contains`, `starts_with`, `ends_with` and `exact`
525
    *                                   Valid keys are: `contains`, `starts_with`, `ends_with` and `exact`
526
    * @param  {Object}  column_settings The arrayref as returned by TableSettings.GetColums function available
526
    * @param  {Object}  table_settings The arrayref as returned by TableSettings.GetTableSettings function available
527
    *                                   from the columns_settings template toolkit include
527
    *                                   from the columns_settings template toolkit include
528
    * @param  {Boolean} add_filters     Add a filters row as the top row of the table
528
    * @param  {Boolean} add_filters     Add a filters row as the top row of the table
529
    * @param  {Object}  default_filters Add a set of default search filters to apply at table initialisation
529
    * @param  {Object}  default_filters Add a set of default search filters to apply at table initialisation
530
    * @return {Object}                  The dataTables instance
530
    * @return {Object}                  The dataTables instance
531
    */
531
    */
532
    $.fn.kohaTable = function(options, columns_settings, add_filters, default_filters) {
532
    $.fn.kohaTable = function(options, table_settings, add_filters, default_filters) {
533
        var settings = null;
533
        var settings = null;
534
534
535
        if ( add_filters ) {
535
        if ( add_filters ) {
Lines 667-685 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
667
        var hidden_ids = [];
667
        var hidden_ids = [];
668
        var included_ids = [];
668
        var included_ids = [];
669
669
670
        $(columns_settings).each( function() {
671
            var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', this ).index( 'th' );
672
            var used_id = settings.bKohaColumnsUseNames ? named_id : counter;
673
            if ( used_id == -1 ) return;
674
670
675
            if ( this['is_hidden'] == "1" ) {
671
        if ( table_settings ) {
676
                hidden_ids.push( used_id );
672
            var columns_settings = table_settings['columns'];
677
            }
673
            $(columns_settings).each( function() {
678
            if ( this['cannot_be_toggled'] == "0" ) {
674
                var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', this ).index( 'th' );
679
                included_ids.push( used_id );
675
                var used_id = settings.bKohaColumnsUseNames ? named_id : counter;
680
            }
676
                if ( used_id == -1 ) return;
681
            counter++;
677
682
        });
678
                if ( this['is_hidden'] == "1" ) {
679
                    hidden_ids.push( used_id );
680
                }
681
                if ( this['cannot_be_toggled'] == "0" ) {
682
                    included_ids.push( used_id );
683
                }
684
                counter++;
685
            });
686
        }
683
687
684
        var exportColumns = ":visible:not(.noExport)";
688
        var exportColumns = ":visible:not(.noExport)";
685
        if( settings.hasOwnProperty("exportColumns") ){
689
        if( settings.hasOwnProperty("exportColumns") ){
Lines 783-788 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
783
            settings['orderCellsTop'] = true;
787
            settings['orderCellsTop'] = true;
784
        }
788
        }
785
789
790
        if ( table_settings ) {
791
            if ( table_settings.hasOwnProperty('default_display_length') && table_settings['default_display_length'] != null ) {
792
                settings["pageLength"] = table_settings['default_display_length'];
793
            }
794
            if ( table_settings.hasOwnProperty('default_sort_order') && table_settings['default_sort_order'] != null ) {
795
                settings["order"] = [[ table_settings['default_sort_order'], 'asc' ]];
796
            }
797
        }
798
786
        var table = $(this).dataTable(settings);
799
        var table = $(this).dataTable(settings);
787
800
788
        table.DataTable().on("column-visibility.dt", function(){
801
        table.DataTable().on("column-visibility.dt", function(){
789
- 

Return to bug 29648