Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make improvements to org table #10679

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 31 additions & 5 deletions cgi/display_org_table.pl
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@
$query_ref->{name} = qr/\Q$name\E/i if defined $name && $name ne '';
$query_ref->{valid_org} = $valid_org if defined $valid_org && $valid_org ne '';

$template_data_ref->{name} = $name;
$template_data_ref->{valid_org} = $valid_org;
$template_data_ref->{query_filters} = [] unless defined $template_data_ref->{query_filters};

@orgs = $orgs_collection->find($query_ref)->sort({created_t => -1})->all;

$template_data_ref = {orgs => \@orgs, has_orgs => scalar @orgs > 0};
$template_data_ref->{orgs} = \@orgs;
$template_data_ref->{has_orgs} = scalar @orgs > 0;

my $html;
process_template('web/pages/dashboard/display_orgs_table.tt.html', $template_data_ref, \$html) or $html = '';
Expand All @@ -73,22 +76,45 @@
info: "_TOTAL_ labels",
infoFiltered: " - out of _MAX_"
},
paging: false,
paging: true,
order: [[ 0, "asc" ]],
scrollX: true,
dom: 'Bfrtip',
buttons: [
{
extend: 'colvis',
text: 'Column visibility',
columns: ':gt(1)'
}
]
});
JS
;

$request_ref->{scripts} .= <<SCRIPTS
<script src="https://static.openfoodfacts.org/js/datatables.min.js"></script>
<script src="$static_subdomain/js/datatables.min.js"></script>
SCRIPTS
;

$request_ref->{header} .= <<HEADER
<link rel="stylesheet" href="https://static.openfoodfacts.org/js/datatables.min.css">
<link rel="stylesheet" href="$static_subdomain/js/datatables.min.css">
<style>
/* Custom styling for the column visibility buttons */
.dt-button-collection .dt-button.active::before {
content: "✔";
display: inline-block;
margin-right: 6px;
}

.dt-button-collection .dt-button::before {
content: " ";
display: inline-block;
margin-right: 6px;
}
</style>
HEADER
;

$request_ref->{title} = "Organization List";
$request_ref->{title} = lang("organization_list");
$request_ref->{content_ref} = \$html;
display_page($request_ref);
Loading
Loading