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

#1907 [Dashboard] add: name on graph to remove it #1908

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
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