Jonathan Druart
0c04b397a4
This patch is the main patch of this patchset, you will find the description and the test plan. The idea of this new enhancement is to add the ability to define the default sort order and the default number of rows displayed on the acquisition basket page. The existing "columns settings" feature was replaced by a "tables settings" feature. To prepare the ground, there were some works that were needed: * rename variables and files * Modify the structure of the yml files * Create a new DB table to store the tables settings Test plan: 0) a. Execute the update DB entry to create the new table b. Restart all (to get a new version of the yml file, that is cached by memcached) c. Create several orders for a given basket 1) Go to the basket view page => The default values are the same than without this patchset, the number of entries to display is set to "20" and the table is sorted by basket number (first column) 2) Go to the "Columns settings" page 3) Unfold the "Acquisition" tab => Notice the 2 dropdown lists at the bottom of the basket table 4) Select different values for "Default display length" and "Default sort order" 5) Refresh the basket view page => Notice that the default settings are now effective on the table QA note: We can decide to replace the different occurrences of "Columns settings" by "Tables settings" if needed. Sponsored-by: Institute of Technology Tallaght Signed-off-by: Liz Rea <wizzyrea@gmail.com> Signed-off-by: Liz Rea <wizzyrea@gmail.com> Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
203 lines
6.9 KiB
Perl
203 lines
6.9 KiB
Perl
#!/usr/bin/perl;
|
|
|
|
use Modern::Perl;
|
|
use Test::More tests => 3;
|
|
use Test::MockModule;
|
|
|
|
use C4::Context;
|
|
use C4::Utils::DataTables::TablesSettings;
|
|
use Koha::Database;
|
|
|
|
my $schema = Koha::Database->new->schema;
|
|
$schema->storage->txn_begin;
|
|
my $dbh = C4::Context->dbh;
|
|
|
|
$dbh->do(q|DELETE FROM columns_settings|);
|
|
|
|
my $module = new Test::MockModule('C4::Utils::DataTables::TablesSettings');
|
|
$module->mock(
|
|
'get_yaml',
|
|
sub {
|
|
{
|
|
modules => {
|
|
admin => {
|
|
currency => {
|
|
'currencies-table' => {
|
|
default_display_length => 20,
|
|
default_sort_order => 1,
|
|
columns => [
|
|
{
|
|
columnname => 'currency',
|
|
cannot_be_toggled => '1',
|
|
cannot_be_modified => '1'
|
|
},
|
|
{
|
|
columnname => 'rate',
|
|
cannot_be_toggled => '1',
|
|
cannot_be_modified => '1'
|
|
},
|
|
{
|
|
columnname => 'symbol'
|
|
},
|
|
{
|
|
is_hidden => '1',
|
|
columnname => 'iso_code'
|
|
},
|
|
{
|
|
columnname => 'last_updated'
|
|
},
|
|
{
|
|
columnname => 'active'
|
|
},
|
|
{
|
|
columnname => 'actions'
|
|
}
|
|
]
|
|
}
|
|
}
|
|
},
|
|
}
|
|
};
|
|
}
|
|
);
|
|
|
|
C4::Utils::DataTables::TablesSettings::update_columns(
|
|
{
|
|
columns => [
|
|
{
|
|
module => 'admin',
|
|
page => 'currency',
|
|
tablename => 'currencies-table',
|
|
columnname => 'currency',
|
|
cannot_be_toggled => 1,
|
|
cannot_be_modified => 1,
|
|
},
|
|
{
|
|
module => 'admin',
|
|
page => 'currency',
|
|
tablename => 'currencies-table',
|
|
columnname => 'rate',
|
|
cannot_be_toggled => 1,
|
|
cannot_be_modified => 1,
|
|
},
|
|
{
|
|
module => 'admin',
|
|
page => 'currency',
|
|
tablename => 'currencies-table',
|
|
columnname => 'symbol',
|
|
},
|
|
{
|
|
module => 'admin',
|
|
page => 'currency',
|
|
tablename => 'currencies-table',
|
|
columnname => 'iso_code',
|
|
is_hidden => 0,
|
|
},
|
|
{
|
|
module => 'admin',
|
|
page => 'currency',
|
|
tablename => 'currencies-table',
|
|
columnname => 'last_updated',
|
|
},
|
|
{
|
|
module => 'admin',
|
|
page => 'currency',
|
|
tablename => 'currencies-table',
|
|
columnname => 'active',
|
|
is_hidden => 1,
|
|
},
|
|
{
|
|
module => 'admin',
|
|
page => 'currency',
|
|
tablename => 'currencies-table',
|
|
columnname => 'actions',
|
|
cannot_be_toggled => 1,
|
|
},
|
|
]
|
|
}
|
|
);
|
|
|
|
my $modules = C4::Utils::DataTables::TablesSettings::get_modules();
|
|
|
|
my $modules_expected = {
|
|
'admin' => {
|
|
'currency' => {
|
|
'currencies-table' => {
|
|
default_display_length => 20,
|
|
default_sort_order => 1,
|
|
columns => [
|
|
{
|
|
columnname => 'currency',
|
|
cannot_be_toggled => 1,
|
|
cannot_be_modified => 1,
|
|
is_hidden => 0,
|
|
},
|
|
{
|
|
columnname => 'rate',
|
|
cannot_be_toggled => 1,
|
|
cannot_be_modified => 1,
|
|
is_hidden => 0,
|
|
},
|
|
{
|
|
columnname => 'symbol',
|
|
cannot_be_toggled => 0,
|
|
cannot_be_modified => 0,
|
|
is_hidden => 0,
|
|
},
|
|
{
|
|
columnname => 'iso_code',
|
|
cannot_be_toggled => 0,
|
|
cannot_be_modified => 0,
|
|
is_hidden => 0,
|
|
},
|
|
{
|
|
columnname => 'last_updated',
|
|
cannot_be_toggled => 0,
|
|
cannot_be_modified => 0,
|
|
is_hidden => 0,
|
|
},
|
|
{
|
|
columnname => 'active',
|
|
cannot_be_toggled => 0,
|
|
cannot_be_modified => 0,
|
|
is_hidden => 1,
|
|
},
|
|
{
|
|
columnname => 'actions',
|
|
cannot_be_toggled => 1,
|
|
cannot_be_modified => 0,
|
|
is_hidden => 0,
|
|
},
|
|
]
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
is_deeply( $modules, $modules_expected, 'get_modules returns all values' );
|
|
|
|
for my $m ( keys %$modules ) {
|
|
for my $p ( keys %{ $modules->{$m} } ) {
|
|
for my $t ( keys %{ $modules->{$m}{$p} } ) {
|
|
my $columns =
|
|
C4::Utils::DataTables::TablesSettings::get_columns( $m, $p, $t );
|
|
is_deeply(
|
|
$columns,
|
|
$modules->{$m}{$p}{$t}{columns},
|
|
"columns for $m>$p>$t"
|
|
);
|
|
my $table_settings =
|
|
C4::Utils::DataTables::TablesSettings::get_table_settings( $m, $p, $t );
|
|
is_deeply(
|
|
{
|
|
default_display_length => $table_settings->{default_display_length},
|
|
default_sort_order => $table_settings->{default_sort_order}
|
|
},
|
|
{
|
|
default_display_length => $modules->{$m}{$p}{$t}{default_display_length},
|
|
default_sort_order => $modules->{$m}{$p}{$t}{default_sort_order},
|
|
}
|
|
);
|
|
}
|
|
}
|
|
}
|