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

(-)a/C4/Utils/DataTables/TablesSettings.pm (-3 / +8 lines)
Lines 103-109 sub get_table_settings { Link Here
103
        default_display_length => $rs ? $rs->default_display_length
103
        default_display_length => $rs ? $rs->default_display_length
104
        : $list->{modules}{$module}{$page}{$tablename}{default_display_length},
104
        : $list->{modules}{$module}{$page}{$tablename}{default_display_length},
105
        default_sort_order => $rs ? $rs->default_sort_order
105
        default_sort_order => $rs ? $rs->default_sort_order
106
        : $list->{modules}{$module}{$page}{$tablename}{default_sort_order}
106
        : $list->{modules}{$module}{$page}{$tablename}{default_sort_order},
107
        default_save_state => $rs ? $rs->default_save_state
108
        : $list->{modules}{$module}{$page}{$tablename}{default_save_state},
107
    };
109
    };
108
}
110
}
109
111
Lines 153-162 sub update_columns { Link Here
153
  C4::Utils::DataTables::TablesSettings::update_table_settings(
155
  C4::Utils::DataTables::TablesSettings::update_table_settings(
154
    {
156
    {
155
        module                 => $module,
157
        module                 => $module,
156
        pag                    => $page,
158
        page                   => $page,
157
        tablename              => $tablename,
159
        tablename              => $tablename,
158
        default_display_length => $default_display_length,
160
        default_display_length => $default_display_length,
159
        default_sort_order     => $default_sort_order
161
        default_sort_order     => $default_sort_order,
162
        default_save_state     => $default_save_state,
160
    }
163
    }
161
  );
164
  );
162
165
Lines 171-176 sub update_table_settings { Link Here
171
    my $tablename              = $params->{tablename};
174
    my $tablename              = $params->{tablename};
172
    my $default_display_length = $params->{default_display_length};
175
    my $default_display_length = $params->{default_display_length};
173
    my $default_sort_order     = $params->{default_sort_order};
176
    my $default_sort_order     = $params->{default_sort_order};
177
    my $default_save_state     = $params->{default_save_state};
174
178
175
    my $schema = Koha::Database->new->schema;
179
    my $schema = Koha::Database->new->schema;
176
180
Lines 181-186 sub update_table_settings { Link Here
181
            tablename              => $tablename,
185
            tablename              => $tablename,
182
            default_display_length => $default_display_length,
186
            default_display_length => $default_display_length,
183
            default_sort_order     => $default_sort_order,
187
            default_sort_order     => $default_sort_order,
188
            default_save_state     => $default_save_state,
184
        }
189
        }
185
    );
190
    );
186
}
191
}
(-)a/admin/columns_settings.pl (-1 / +4 lines)
Lines 50-60 if ( $op eq 'cud-save' ) { Link Here
50
        next unless $table_id =~ m{^([^\|]*)\|(.*)$};
50
        next unless $table_id =~ m{^([^\|]*)\|(.*)$};
51
        my $default_display_length = $input->param( $table_id . '_default_display_length' );
51
        my $default_display_length = $input->param( $table_id . '_default_display_length' );
52
        my $default_sort_order     = $input->param( $table_id . '_default_sort_order' );
52
        my $default_sort_order     = $input->param( $table_id . '_default_sort_order' );
53
        my $default_save_state     = $input->param( $table_id . '_default_save_state' );
53
54
54
        undef $default_display_length if defined $default_display_length && $default_display_length eq "";
55
        undef $default_display_length if defined $default_display_length && $default_display_length eq "";
55
        undef $default_sort_order if defined $default_sort_order && $default_sort_order eq "";
56
        undef $default_sort_order if defined $default_sort_order && $default_sort_order eq "";
57
        $default_save_state = 0 if !defined($default_save_state);
56
58
57
        if ( defined $default_display_length || defined $default_sort_order )
59
        if ( defined $default_display_length || defined $default_sort_order || defined $default_save_state )
58
        {
60
        {
59
            C4::Utils::DataTables::TablesSettings::update_table_settings(
61
            C4::Utils::DataTables::TablesSettings::update_table_settings(
60
                {
62
                {
Lines 63-68 if ( $op eq 'cud-save' ) { Link Here
63
                    tablename              => $2,
65
                    tablename              => $2,
64
                    default_display_length => $default_display_length,
66
                    default_display_length => $default_display_length,
65
                    default_sort_order     => $default_sort_order,
67
                    default_sort_order     => $default_sort_order,
68
                    default_save_state     => $default_save_state,
66
                }
69
                }
67
            );
70
            );
68
        }
71
        }
(-)a/installer/data/mysql/atomicupdate/bug_33484.pl (+17 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "33484",
5
    description => "Add state save as an option to datatables",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        if ( !column_exists( 'tables_settings', 'default_save_state' ) ) {
10
            $dbh->do(q{
11
                ALTER TABLE tables_settings
12
                  ADD COLUMN default_save_state tinyint(1) DEFAULT NULL AFTER default_sort_order
13
            });
14
            say $out "Added column 'tables_settings.default_save_state'";
15
        }
16
    },
17
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 6238-6243 CREATE TABLE `tables_settings` ( Link Here
6238
  `tablename` varchar(255) NOT NULL,
6238
  `tablename` varchar(255) NOT NULL,
6239
  `default_display_length` smallint(6) DEFAULT NULL,
6239
  `default_display_length` smallint(6) DEFAULT NULL,
6240
  `default_sort_order` varchar(255) DEFAULT NULL,
6240
  `default_sort_order` varchar(255) DEFAULT NULL,
6241
  `default_save_state` tinyint(1) DEFAULT NULL,
6241
  PRIMARY KEY (`module`(191),`page`(191),`tablename`(191))
6242
  PRIMARY KEY (`module`(191),`page`(191),`tablename`(191))
6242
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
6243
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
6243
/*!40101 SET character_set_client = @saved_cs_client */;
6244
/*!40101 SET character_set_client = @saved_cs_client */;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc (+4 lines)
Lines 45-50 function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { Link Here
45
            }
45
            }
46
            counter++;
46
            counter++;
47
        });
47
        });
48
49
        if ( table_settings.hasOwnProperty('default_save_state') && table_settings['default_save_state'] === 0 ) {
50
            localStorage.removeItem(table_key);
51
        }
48
    }
52
    }
49
53
50
    var exportColumns = ":visible:not(.noExport)";
54
    var exportColumns = ":visible:not(.noExport)";
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/columns_settings.tt (+10 lines)
Lines 148-153 Link Here
148
                                        </select>
148
                                        </select>
149
                                    </p>
149
                                    </p>
150
                                [% END %]
150
                                [% END %]
151
                                [% IF table_settings.default_save_state.defined %]
152
                                    <p>
153
                                        Save state on page change: 
154
                                        [%- IF table_settings.default_save_state -%]
155
                                            <input type="checkbox" name="[% pagename | html %]#[% tablename | html %]_default_save_state" value="1" checked="checked" />
156
                                        [%- ELSE -%]
157
                                            <input type="checkbox" name="[% pagename | html %]#[% tablename | html %]_default_save_state" value="1" />
158
                                        [%- END -%]
159
                                    </p>
160
                                [% END %]
151
161
152
                            </div>
162
                            </div>
153
                        [% END %]
163
                        [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (+3 lines)
Lines 1035-1040 function _dt_get_saved_state( localstorage_config, columns_settings ){ Link Here
1035
            if ( table_settings.hasOwnProperty('default_sort_order') && table_settings['default_sort_order'] != null ) {
1035
            if ( table_settings.hasOwnProperty('default_sort_order') && table_settings['default_sort_order'] != null ) {
1036
                settings["order"] = [[ table_settings['default_sort_order'], 'asc' ]];
1036
                settings["order"] = [[ table_settings['default_sort_order'], 'asc' ]];
1037
            }
1037
            }
1038
            if ( table_settings.hasOwnProperty('default_save_state') && table_settings['default_save_state'] === 0 ) {
1039
                localStorage.removeItem(table_key);
1040
            }
1038
        }
1041
        }
1039
1042
1040
        var table = $(this).dataTable(settings);
1043
        var table = $(this).dataTable(settings);
(-)a/t/db_dependent/TablesSettings.t (-1 / +4 lines)
Lines 25-30 $module->mock( Link Here
25
                        'currencies-table' => {
25
                        'currencies-table' => {
26
                            default_display_length => 20,
26
                            default_display_length => 20,
27
                            default_sort_order => 1,
27
                            default_sort_order => 1,
28
                            default_save_state => 1,
28
                            columns => [
29
                            columns => [
29
                                {
30
                                {
30
                                    columnname         => 'currency',
31
                                    columnname         => 'currency',
Lines 125-130 my $modules_expected = { Link Here
125
            'currencies-table' => {
126
            'currencies-table' => {
126
                default_display_length => 20,
127
                default_display_length => 20,
127
                default_sort_order => 1,
128
                default_sort_order => 1,
129
                default_save_state => 1,
128
                columns => [
130
                columns => [
129
                    {
131
                    {
130
                        columnname         => 'currency',
132
                        columnname         => 'currency',
Lines 192-201 for my $m ( keys %$modules ) { Link Here
192
                {
194
                {
193
                    default_display_length => $table_settings->{default_display_length},
195
                    default_display_length => $table_settings->{default_display_length},
194
                    default_sort_order     => $table_settings->{default_sort_order}
196
                    default_sort_order     => $table_settings->{default_sort_order}
197
                    default_save_state     => $table_settings->{default_save_state}
195
                },
198
                },
196
                {
199
                {
197
                    default_display_length => $modules->{$m}{$p}{$t}{default_display_length},
200
                    default_display_length => $modules->{$m}{$p}{$t}{default_display_length},
198
                    default_sort_order     => $modules->{$m}{$p}{$t}{default_sort_order},
201
                    default_sort_order     => $modules->{$m}{$p}{$t}{default_sort_order},
202
                    default_save_state     => $modules->{$m}{$p}{$t}{default_save_state},
199
                }
203
                }
200
            );
204
            );
201
        }
205
        }
202
- 

Return to bug 33484