summaryrefslogtreecommitdiff
path: root/rt/share/html/Elements/DashboardTabs
blob: f9493d5fe0b85a658c19d71142d7aa12dbc6db78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<%args>
$CurrentDashboard => undef
</%args>
<%init>
my @dashboards = $m->comp("/Dashboards/Elements/ListOfDashboards");
my $limit = 7;

$m->callback(
    Dashboards   => \@dashboards,
    Limit        => \$limit,
    CallbackName => 'MassageDashboards',
);

my $more = 0;
if (@dashboards > $limit) {
    $more = 1;
    splice @dashboards, $limit;
}

# always include the current dashboard, even if it's not in the initial list
push @dashboards, $CurrentDashboard
    if $CurrentDashboard
    && 0 == grep { $_->Id == $CurrentDashboard->Id } @dashboards;

my $position = 0;

my $tabs = {
    map {
        ++$position;
        my $key = sprintf 'D-%03d', $position;
        $key => {
            title => $_->Name,
            path  => 'Dashboards/' . $_->Id . '/' . $_->Name,
        }
    }
    @dashboards
};

$tabs->{"A"} = {
    title => loc('Home'),
    path  => 'index.html',
};

if ($more) {
    $tabs->{"D-more"} = {
        title => loc('More'),
        path => 'Dashboards/index.html',
    }
}

return $tabs;
</%init>