Verified Commit 36c0fa1f authored by Arnaud Pauget's avatar Arnaud Pauget
Browse files

feat (12179) : add title on buttons and change how to call the function in presenter (more options)

parent 95f6cd84
......@@ -336,7 +336,7 @@ EOS;
/**
* Add possibility to export datatable resuls in different formats
*
* @param array $exportType array containing one of following export format (copy, csv, excel, pdf, print)
* @param array $exportType array containing button objects to set
* @param boolean $onlyExportButton Either returning dom only consists of export button or full dataTable display
*
*/
......@@ -380,13 +380,17 @@ EOS;
$this->parameters->buttons = [];
foreach ($exportType as $type => $text) {
foreach ($exportType as $exportButton) {
$button = new \stdClass();
$button->extend = $type;
$button->text = $text;
$button->extend = $exportButton['exportType'];
$button->text = $exportButton['text'];
if (!empty($this->exportOptions)) {
$button->exportOptions = $this->exportOptions;
}
$button->titleAttr = 'Export to '.$type;
if (isset($exportButton['titleAttr'])) {
$button->titleAttr = $exportButton['titleAttr'];
}
$button->orientation = 'landscape';
$button->className = 'btn btn-default btn-sm';
array_push($this->parameters->buttons, $button);
......
......@@ -208,11 +208,28 @@ class archive
$dataTable->setUnsearchableColumns(0);
$dataTable->setSorting(array(array(5, 'desc')));
$titleExport = $this->view->translator->getText(
"Export to ",
false,
"recordsManagement/messages"
);
$dataTable->setColumnsToExport([1, 2, 3, 4, 5, 6, 7]);
$dataTable->setExport([
"csv" => "<i class='fa fa-download'></i> CSV",
"pdf" => "<i class='fa fa-download'></i> PDF"
], false);
$dataTable->setExport(
[
[
"exportType" => "csv",
"text" => "<i class='fa fa-download'></i> CSV",
"titleAttr" => $titleExport . "CSV"
],
[
"exportType" => "pdf",
"text" => "<i class='fa fa-download'></i> PDF",
"titleAttr" => $titleExport . "PDF"
]
],
false
);
$this->readPrivilegesOnArchives();
......
......@@ -1099,4 +1099,7 @@ msgid "Click to modify '%1$s'"
msgstr "Cliquer pour modifier '%1$s'"
msgid "* At least one field must be filled in."
msgstr "* Au moins un champ doit être renseigné."
\ No newline at end of file
msgstr "* Au moins un champ doit être renseigné."
msgid "Export to "
msgstr "Exporter en "
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment