Skip to content

Commit

Permalink
Implement a "return to search" functionality.
Browse files Browse the repository at this point in the history
Request: 12879
  • Loading branch information
mrubinsk committed Feb 17, 2014
1 parent e27e63c commit 10ab9e8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
4 changes: 4 additions & 0 deletions nag/app/controllers/SaveTask.php
Expand Up @@ -18,6 +18,10 @@ public function processRequest(Horde_Controller_Request $request, Horde_Controll
}
$form->getInfo($vars, $info);

// Check if we are here due to a search_return push.
if ($vars->search_return) {
Horde::url('list.php', true)->add('actionID', 'search_return')->redirect();
}
// Check if we are here due to a deletebutton push
if ($vars->deletebutton) {
try {
Expand Down
3 changes: 3 additions & 0 deletions nag/lib/Form/Task.php
Expand Up @@ -145,6 +145,9 @@ public function __construct($vars, $title = '')
if (!$vars->get('task_id')) {
$buttons[] = array('value' => _("Save and New"), 'name' => 'savenewbutton', 'class' => 'horde-create');
}
if (Horde_Util::getFormData('have_search')) {
$buttons[] = array('value' => _("Return to Search Results"), 'name' => 'search_return', 'class' => 'horde-button');
}
$this->setButtons($buttons);
}

Expand Down
17 changes: 16 additions & 1 deletion nag/lib/View/List.php
Expand Up @@ -54,6 +54,13 @@ class Nag_View_List
*/
protected $_vars;

/**
* Flag to indicate if we have a search.
*
* @var boolean
*/
protected $_haveSearch = false;

/**
* Const'r
*
Expand Down Expand Up @@ -121,6 +128,8 @@ public function render($output)
$view->dateFormat = $prefs->getValue('date_format');
$view->columns = @unserialize($prefs->getValue('tasklist_columns'));
$view->smartShare = $this->_smartShare;
$view->haveSearch = $this->_haveSearch;

if (empty($view->columns)) {
$view->columns = array();
}
Expand Down Expand Up @@ -176,6 +185,11 @@ protected function _handleActions($action = null)
$action = $this->_vars->actionID;
}
switch ($action) {
case 'search_return':
if ($search = $GLOBALS['session']->get('nag', 'search', Horde_Session::TYPE_OBJECT)) {
$search->getVars($this->_vars);
}
// Fall through
case 'search_tasks':
if ($this->_vars->deletebutton) {
$this->_doDeleteSmartList();
Expand Down Expand Up @@ -341,7 +355,8 @@ protected function _doSearch()
$this->_title .= sprintf(_("and tagged with %s"), $this->_vars->search_tags);
}
}

$GLOBALS['session']->set('nag', 'search', $search, Horde_Session::TYPE_OBJECT);
$this->_haveSearch = true;
$this->_tasks = $tasks;
}

Expand Down
4 changes: 2 additions & 2 deletions nag/templates/list/_task.html.php
Expand Up @@ -35,7 +35,7 @@
if ($have_edit &&
(!$task->private || $task->owner == $GLOBALS['registry']->getAuth())) {
$label = sprintf(_("Edit \"%s\""), $task->name);
echo Horde::link($task->edit_link, $label) . Horde::img('edit.png', $label) . '</a>';
echo Horde::link($task->edit_link->add('have_search', $this->haveSearch), $label) . Horde::img('edit.png', $label) . '</a>';
}
?>
</td>
Expand All @@ -46,7 +46,7 @@
? htmlspecialchars($task->name)
: _("[none]");
if ($have_read) {
echo Horde::linkTooltip($task->view_link, '', '', '', '', $task->desc)
echo Horde::linkTooltip($task->view_link->add('have_search', $this->haveSearch), '', '', '', '', $task->desc)
. $task_name . '</a>';
} else {
echo $task_name;
Expand Down
4 changes: 4 additions & 0 deletions nag/templates/view/task.inc
Expand Up @@ -11,6 +11,10 @@
<?php if ($share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)): ?>
<li class="horde-icon"><?php echo Horde::widget(array('url' => $taskurl->add('actionID', 'delete_task'), 'onclick' => $prefs->getValue('delete_opt') ? 'return window.confirm(\'' . addslashes(_("Really delete this task?")) . '\');' : '', 'title' => _("_Delete"), 'class' => 'nag-delete')) ?></li>
<?php endif ?>
<?php if (Horde_Util::getFormData('have_search')): ?>
<li class="horde-icon"><?php echo Horde::widget(array('url' => Horde::url('list.php', true)->add('actionID', 'search_return'), 'title' => _("Return to search results"), 'class' => 'nag-search')) ?></li>
<?php endif ?>

</ul>
</div>

Expand Down

0 comments on commit 10ab9e8

Please sign in to comment.