summaryrefslogtreecommitdiff
path: root/rt/share/html/Elements/DashboardTabs
diff options
context:
space:
mode:
Diffstat (limited to 'rt/share/html/Elements/DashboardTabs')
-rw-r--r--rt/share/html/Elements/DashboardTabs52
1 files changed, 52 insertions, 0 deletions
diff --git a/rt/share/html/Elements/DashboardTabs b/rt/share/html/Elements/DashboardTabs
new file mode 100644
index 0000000..f9493d5
--- /dev/null
+++ b/rt/share/html/Elements/DashboardTabs
@@ -0,0 +1,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>