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

(-)a/admin/columns_settings.yml (+2 lines)
Lines 197-202 modules: Link Here
197
  admin:
197
  admin:
198
    cities:
198
    cities:
199
      table_cities:
199
      table_cities:
200
        default_display_length: 20
201
        default_sort_order: 0
200
        columns:
202
        columns:
201
            -
203
            -
202
              columnname: city_id
204
              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 496-508 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
496
    *                                   We extend the options set with the `criteria` key which allows
496
    *                                   We extend the options set with the `criteria` key which allows
497
    *                                   the developer to select the match type to be applied during searches
497
    *                                   the developer to select the match type to be applied during searches
498
    *                                   Valid keys are: `contains`, `starts_with`, `ends_with` and `exact`
498
    *                                   Valid keys are: `contains`, `starts_with`, `ends_with` and `exact`
499
    * @param  {Object}  column_settings The arrayref as returned by TableSettings.GetColums function available
499
    * @param  {Object}  table_settings The arrayref as returned by TableSettings.GetTableSettings function available
500
    *                                   from the columns_settings template toolkit include
500
    *                                   from the columns_settings template toolkit include
501
    * @param  {Boolean} add_filters     Add a filters row as the top row of the table
501
    * @param  {Boolean} add_filters     Add a filters row as the top row of the table
502
    * @param  {Object}  default_filters Add a set of default search filters to apply at table initialisation
502
    * @param  {Object}  default_filters Add a set of default search filters to apply at table initialisation
503
    * @return {Object}                  The dataTables instance
503
    * @return {Object}                  The dataTables instance
504
    */
504
    */
505
    $.fn.kohaTable = function(options, columns_settings, add_filters, default_filters) {
505
    $.fn.kohaTable = function(options, table_settings, add_filters, default_filters) {
506
        var settings = null;
506
        var settings = null;
507
507
508
        if ( add_filters ) {
508
        if ( add_filters ) {
Lines 683-701 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
683
        var hidden_ids = [];
683
        var hidden_ids = [];
684
        var included_ids = [];
684
        var included_ids = [];
685
685
686
        $(columns_settings).each( function() {
687
            var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', this ).index( 'th' );
688
            var used_id = settings.bKohaColumnsUseNames ? named_id : counter;
689
            if ( used_id == -1 ) return;
690
686
691
            if ( this['is_hidden'] == "1" ) {
687
        if ( table_settings ) {
692
                hidden_ids.push( used_id );
688
            var columns_settings = table_settings['columns'];
693
            }
689
            $(columns_settings).each( function() {
694
            if ( this['cannot_be_toggled'] == "0" ) {
690
                var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', this ).index( 'th' );
695
                included_ids.push( used_id );
691
                var used_id = settings.bKohaColumnsUseNames ? named_id : counter;
696
            }
692
                if ( used_id == -1 ) return;
697
            counter++;
693
698
        });
694
                if ( this['is_hidden'] == "1" ) {
695
                    hidden_ids.push( used_id );
696
                }
697
                if ( this['cannot_be_toggled'] == "0" ) {
698
                    included_ids.push( used_id );
699
                }
700
                counter++;
701
            });
702
        }
699
703
700
        var exportColumns = ":visible:not(.noExport)";
704
        var exportColumns = ":visible:not(.noExport)";
701
        if( settings.hasOwnProperty("exportColumns") ){
705
        if( settings.hasOwnProperty("exportColumns") ){
Lines 799-804 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
799
            settings['orderCellsTop'] = true;
803
            settings['orderCellsTop'] = true;
800
        }
804
        }
801
805
806
        if ( table_settings ) {
807
            if ( table_settings.hasOwnProperty('default_display_length') && table_settings['default_display_length'] != null ) {
808
                settings["pageLength"] = table_settings['default_display_length'];
809
            }
810
            if ( table_settings.hasOwnProperty('default_sort_order') && table_settings['default_sort_order'] != null ) {
811
                settings["order"] = [[ table_settings['default_sort_order'], 'asc' ]];
812
            }
813
        }
814
802
        var table = $(this).dataTable(settings);
815
        var table = $(this).dataTable(settings);
803
816
804
817
805
- 

Return to bug 29648