Filter project management

Hi,

We’ve been using Kanboard for since way-back-when (early 2015), and over that time have generated a lot of projects. The problem is, now when you look at the project management screen you get a 2 page list of projects with maybe only half a dozen active.

Is it possible to add a filter feature to that page, like the kanboard page itself, so I can type “status:open” and only see currently active/open projects? That’d be incredibly helpful.

Thanks,
Algy

It would be very simple to add a toggle on that page, that would allow you to hide/unhide closed projects.

Just to be clear, you are talking about this page, correct?

image

Working example:

which you can test out here: https://projects.nachostudio.ml/
user: admin
pw: admin

things change on that server daily so, no guarantee it will still be testable in x amount of days…

If this is what you are looking for, steps to reproduce would be:
1.) Register a plugin: https://docs.kanboard.org/en/latest/plugins/registration.html
2.) add a togglecontroller to set the toggle status in the configModel, and redirect back to ProjectListController, show function
3.) hook a toggle link that calls above controller to template:project-list:menu:after : https://docs.kanboard.org/en/latest/plugins/hooks.html#template-hooks

  • you might want to also add a condition to the template you are hooking that changes the verbiage of the link like i did, i.e. “Show Closed…” “Hide Closed…”
  • add array('plugin' => 'yourPluginName') to call your own controller, i.e. $this->url->icon('eye-slash', t('Show Closed Projects'), 'ToggleController', 'hideProjects', array('plugin' => 'yourPluginName'))

4.) copy and edit the template project_list/listing.php to include a conditional wrapper inside the contents of the foreach loop, i.e. if ($project['is_active'] != 0) : https://github.com/kanboard/kanboard/blob/11b6bf6d25668b8bb9d0304c30f803f8194ab1d8/app/Template/project_list/listing.php#L38-L52
5.) conditionally override project_list/listing.php when the toggle is on, don’t override when it is off : https://docs.kanboard.org/en/latest/plugins/overrides.html#template-overrides

I have decided to attempt your solution to show/hide closed projects, but i’m a bit lost. I have never worked on a project like this so I apologize if I ask some obvious questions. I have managed to set up the environment to create and register my plugin. So step 1 is done. Step 2: I have added file to my plugin folder: Controller/ToggleController.php. This file currently looks like this:

<?php

namespace Kanboard\Plugin\MyCustom\Controller;

use Kanboard\Model\ConfigModel;
use Kanboard\Controller\BaseController;
use Kanboard\Controller\ProjectListController;

/**
 * Class ConfigController 
 *
 * @package Kanboard\Plugin\MyCustom\Controller
 */
class ToggleController extends BaseController
{
/**
 * Show / Hide closed projects
 */

/**
 * Toggle status
 *
 */
public function showHideProjects()
{
    $status = $this->configModel->get('toggle_closed_projects', 'hide');
    
    if ($status == 'hide') { 
      $this->configModel->save(['toggle_closed_projects' => 'show']); 
    } else { 
      $this->configModel->save(['toggle_closed_projects' => 'hide']); 
    }

    $this->response->redirect($this->helper->url->to('ProjectListController', 'show', array('plugin' => 'MyCustom')));
}

}

Step 3: in my Plugin.php file in the initialize() method, I’ve added this:

$this->template->hook->attach('template:project-list:menu:after', 'ToggleController');

if ($this->configModel->get('toggle_closed_projects', 'hide') == 'show') {
    
    $this->url->icon('eye-slash', t('Show Closed Projects'), 'ToggleController', 'showHideProjects', array('plugin' => 'MyCustom'));
} else {
    $this->url->icon('eye-slash', t('Hide Closed Projects'), 'ToggleController', 'showHideProjects', array('plugin' => 'MyCustom'));
}

Step 4: I have created a Template folder in my plugin folder and copied project_list/listing.php file

Examining the foreach loop contents I’m unsure what to do with the:

if ($project['is_active'] != 0)

conditional.

Any tips/guidance you can provide will be much appreciated. Thank you very much for all your contributions to this project.

I’ll send you the repo next chance I get.

Awesome! Thank you so much!

i think this is it:

Thank you! I got it to work. I will fine tune it further. I really appreciate your help!