From cd78efd917c9ff062a0dc247b3ceec21fe2b1f1c Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Mon, 4 May 2015 20:23:42 +0000 Subject: [PATCH] Support complex submenus with attributes --- .../staff/templates/sub-navigation.tmpl.php | 10 ++++++-- scp/tasks.php | 24 +++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/staff/templates/sub-navigation.tmpl.php b/include/staff/templates/sub-navigation.tmpl.php index 0cb5e6ed4..6e40d33c8 100644 --- a/include/staff/templates/sub-navigation.tmpl.php +++ b/include/staff/templates/sub-navigation.tmpl.php @@ -17,7 +17,13 @@ if(($subnav=$nav->getSubMenu()) && is_array($subnav)){ if (!($id=$item['id'])) $id="subnav$k"; - echo sprintf('<li><a class="%s" href="%s" title="%s" id="%s">%s</a></li>', - $class, $item['href'], $item['title'], $id, $item['desc']); + //Extra attributes + $attr = ''; + if ($item['attr']) + foreach ($item['attr'] as $name => $value) + $attr.= sprintf("%s='%s' ", $name, $value); + + echo sprintf('<li><a class="%s" href="%s" title="%s" id="%s" %s>%s</a></li>', + $class, $item['href'], $item['title'], $id, $attr, $item['desc']); } } diff --git a/scp/tasks.php b/scp/tasks.php index f7edead6c..ab0996e88 100644 --- a/scp/tasks.php +++ b/scp/tasks.php @@ -117,8 +117,8 @@ if ($stats['overdue']) { } if ($stats['closed']) { - $nav->addSubMenu(array('desc' => __('Closed').' ('.number_format($stats['closed']).')', - 'title'=>__('Closed Tasks'), + $nav->addSubMenu(array('desc' => __('Completed').' ('.number_format($stats['closed']).')', + 'title'=>__('Completed Tasks'), 'href'=>'tasks.php?status=closed', 'iconclass'=>'closedTickets'), ($_REQUEST['status']=='closed')); @@ -129,12 +129,12 @@ if (isset($_SESSION['advsearch'])) { $search = SavedSearch::create(); $form = $search->getFormFromSession('advsearch'); $form->loadState($_SESSION['advsearch']); - $tickets = TicketModel::objects(); - $tickets = $search->mangleQuerySet($tickets, $form); - $count = $tickets->count(); + $tasks = Task::objects(); + $tasks = $search->mangleQuerySet($tasks, $form); + $count = $tasks->count(); $nav->addSubMenu(array('desc' => __('Search').' ('.number_format($count).')', - 'title'=>__('Advanced Ticket Search'), - 'href'=>'tickets.php?status=search', + 'title'=>__('Advanced Task Search'), + 'href'=>'tasks.php?status=search', 'iconclass'=>'Ticket'), (!$_REQUEST['status'] || $_REQUEST['status']=='search')); } @@ -142,9 +142,13 @@ if (isset($_SESSION['advsearch'])) { if ($thisstaff->hasPerm(TaskModel::PERM_CREATE)) { $nav->addSubMenu(array('desc'=>__('New Task'), 'title'=> __('Open a New Task'), - 'href'=>'tasks.php?a=open', - 'iconclass'=>'newTicket', - 'id' => 'new-task'), + 'href'=>'#tasks/add', + 'iconclass'=>'newTicket task-action', + 'id' => 'new-task', + 'attr' => array( + 'data-dialog' => '{"size":"large"}' + ) + ), ($_REQUEST['a']=='open')); } -- GitLab