import torrus 1.0.9
[freeside.git] / rt / share / html / Elements / DashboardTabs
1 <%args>
2 $CurrentDashboard => undef
3 </%args>
4 <%init>
5 my @dashboards = $m->comp("/Dashboards/Elements/ListOfDashboards");
6 my $limit = 7;
7
8 $m->callback(
9     Dashboards   => \@dashboards,
10     Limit        => \$limit,
11     CallbackName => 'MassageDashboards',
12 );
13
14 my $more = 0;
15 if (@dashboards > $limit) {
16     $more = 1;
17     splice @dashboards, $limit;
18 }
19
20 # always include the current dashboard, even if it's not in the initial list
21 push @dashboards, $CurrentDashboard
22     if $CurrentDashboard
23     && 0 == grep { $_->Id == $CurrentDashboard->Id } @dashboards;
24
25 my $position = 0;
26
27 my $tabs = {
28     map {
29         ++$position;
30         my $key = sprintf 'D-%03d', $position;
31         $key => {
32             title => $_->Name,
33             path  => 'Dashboards/' . $_->Id . '/' . $_->Name,
34         }
35     }
36     @dashboards
37 };
38
39 $tabs->{"A"} = {
40     title => loc('Home'),
41     path  => 'index.html',
42 };
43
44 if ($more) {
45     $tabs->{"D-more"} = {
46         title => loc('More'),
47         path => 'Dashboards/index.html',
48     }
49 }
50
51 return $tabs;
52 </%init>