Skip to content

Commit

Permalink
fix: Adds a "disabled" option to the dashboard preferences for tickets (
Browse files Browse the repository at this point in the history
glpi-project#15757)

* fix: Adds a "disabled" option to the dashboard preferences for tickets

* Apply suggestions from code review

Co-authored-by: Johan Cwiklinski <trasher@x-tnd.be>

---------

Co-authored-by: Johan Cwiklinski <trasher@x-tnd.be>
  • Loading branch information
ccailly and trasher authored Oct 11, 2023
1 parent 1a4adc4 commit 80b3369
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ function formatGlobalLayout(layout) {
'value' => $data['default_dashboard_mini_ticket'],
'display_emptychoice' => true,
'context' => 'mini_core',
]);
], true);
echo "</td></tr>";
}

Expand Down
11 changes: 10 additions & 1 deletion src/Dashboard/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,11 @@ public static function getDefaultDashboardForMenu(string $menu = "", bool $stric
$config_key = 'default_dashboard_' . $menu;
$default = $_SESSION["glpi$config_key"] ?? "";
if (strlen($default)) {
// If default is "disabled", return empty string and skip default value from config
if ($default == 'disabled') {
return "";
}

$dasboard = new Dashboard($default);

if ($dasboard->load() && $dasboard->canViewCurrent()) {
Expand Down Expand Up @@ -1488,7 +1493,7 @@ public static function getDefaultDashboardForMenu(string $menu = "", bool $stric
}


public static function dropdownDashboard(string $name = "", array $params = []): string
public static function dropdownDashboard(string $name = "", array $params = [], bool $disabled_option = false): string
{
$to_show = Dashboard::getAll(false, true, $params['context'] ?? 'core');
$can_view_all = $params['can_view_all'] ?? false;
Expand All @@ -1500,6 +1505,10 @@ public static function dropdownDashboard(string $name = "", array $params = []):
}
}

if ($disabled_option) {
$options_dashboards = ['disabled' => __('Disabled')] + $options_dashboards;
}

return Dropdown::showFromArray($name, $options_dashboards, $params);
}
}

0 comments on commit 80b3369

Please sign in to comment.