Skip to content

Commit

Permalink
Evarisk#1907 [Dashboard] add: name on graph to remove it
Browse files Browse the repository at this point in the history
  • Loading branch information
evarisk-kilyan committed Oct 17, 2024
1 parent b448e50 commit a91a06d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
35 changes: 29 additions & 6 deletions class/control.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -762,13 +762,32 @@ public function initAsSpecimen()
*/
public function load_dashboard(): array
{
$getNbControlsTagsByVerdict = $this->getNbControlsTagsByVerdict();
$getNbControlsByVerdict = $this->getNbControlsByVerdict();
$getNbControlsByMonth = $this->getNbControlsByMonth();
$getControlListsByNextControl = $this->getControlListsByNextControl();
global $user, $langs;

$array['graphs'] = [$getNbControlsTagsByVerdict, $getNbControlsByVerdict, $getNbControlsByMonth];
$array['lists'] = [$getControlListsByNextControl];
$confName = strtoupper($this->module) . '_DASHBOARD_CONFIG';
$dashboardConfig = json_decode($user->conf->$confName);
$array = ['graphs' => [], 'lists' => [], 'disabledGraphs' => []];

if (empty($dashboardConfig->graphs->ControlsTagsRepartition->hide)) {
$array['graphs'][] = $this->getNbControlsTagsByVerdict();
} else {
$array['disabledGraphs']['ControlsTagsRepartition'] = $langs->transnoentities('ControlsTagsRepartition');
}
if (empty($dashboardConfig->graphs->ControlsRepartition->hide)) {
$array['graphs'][] = $this->getNbControlsByVerdict();
} else {
$array['disabledGraphs']['ControlsRepartition'] = $langs->transnoentities('ControlsRepartition');
}
if (empty($dashboardConfig->graphs->ControlsByFiscalYear->hide)) {
$array['graphs'][] = $this->getNbControlsByMonth();
} else {
$array['disabledGraphs']['ControlsByFiscalYear'] = $langs->transnoentities('ControlsByFiscalYear');
}
if (empty($dashboardConfig->graphs->ControlListsByNextControl->hide)) {
$array['lists'][] = $this->getControlListsByNextControl();
} else {
$array['disabledGraphs']['ControlListsByNextControl'] = $langs->transnoentities('ControlListsByNextControl');
}

return $array;
}
Expand All @@ -785,6 +804,7 @@ public function getNbControlsByVerdict(): array

// Graph Title parameters.
$array['title'] = $langs->transnoentities('ControlsRepartition');
$array['name'] = 'ControlsRepartition';
$array['picto'] = $this->picto;

// Graph parameters.
Expand Down Expand Up @@ -842,6 +862,7 @@ public function getNbControlsTagsByVerdict(): array

// Graph Title parameters.
$array['title'] = $langs->transnoentities('ControlsTagsRepartition');
$array['name'] = 'ControlsTagsRepartition';
$array['picto'] = $this->picto;

// Graph parameters.
Expand Down Expand Up @@ -902,6 +923,7 @@ public function getNbControlsByMonth(): array

// Graph Title parameters.
$array['title'] = $langs->transnoentities('ControlsByFiscalYear');
$array['name'] = 'ControlsByFiscalYear';
$array['picto'] = $this->picto;

// Graph parameters.
Expand Down Expand Up @@ -957,6 +979,7 @@ public function getControlListsByNextControl(): array

// Graph Title parameters.
$array['title'] = $langs->transnoentities('ControlListsByNextControl');
$array['name'] = 'ControlListsByNextControl';
$array['picto'] = $this->picto;

// Graph parameters.
Expand Down
13 changes: 11 additions & 2 deletions class/survey.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,17 @@ public function initAsSpecimen()
*/
public function load_dashboard(): array
{
$getNbSurveysByMonth = $this->getNbSurveysByMonth();
global $user, $langs;

$array['graphs'] = [$getNbSurveysByMonth];
$confName = strtoupper($this->module) . '_DASHBOARD_CONFIG';
$dashboardConfig = json_decode($user->conf->$confName);
$array = ['graphs' => [], 'disabledGraphs' => []];

if (empty($dashboardConfig->graphs->SurveysByFiscalYear->hide)) {
$array['graphs'][] = $this->getNbSurveysByMonth();
} else {
$array['disabledGraphs']['SurveysByFiscalYear'] = $langs->transnoentities('SurveysByFiscalYear');
}

return $array;
}
Expand All @@ -523,6 +531,7 @@ public function getNbSurveysByMonth(): array

// Graph Title parameters
$array['title'] = $langs->transnoentities('SurveysByFiscalYear');
$array['name'] = 'SurveysByFiscalYear';
$array['picto'] = $this->picto;

// Graph parameters
Expand Down

0 comments on commit a91a06d

Please sign in to comment.