From 3a917f0fd7d72652f700cd6047a1b97636984267 Mon Sep 17 00:00:00 2001 From: Barry O'Donovan Date: Mon, 17 Mar 2014 11:29:17 +0000 Subject: [PATCH] [IM] Limit switch list to active switches only You can opt to include inactive switches and to also display console switches. WHen you do, these choices are retained for the session. --- application/controllers/SwitchController.php | 20 +++++++++++++- application/views/switch/list-toolbar.phtml | 28 ++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/application/controllers/SwitchController.php b/application/controllers/SwitchController.php index ea6783d9e..7c1f509d8 100644 --- a/application/controllers/SwitchController.php +++ b/application/controllers/SwitchController.php @@ -146,6 +146,19 @@ protected function listGetData( $id = null ) $qb->andWhere( 'i = :infra' )->setParameter( 'infra', $infra ); $this->view->infra = $infra; } + + $this->view->switchTypes = $switchTypes = \Entities\Switcher::$TYPES; + $this->view->stype = $stype = $this->getSessionNamespace()->switch_list_stype + = $this->getParam( 'stype', ( $this->getSessionNamespace()->switch_list_stype !== null + ? $this->getSessionNamespace()->switch_list_stype : \Entities\Switcher::TYPE_SWITCH ) ); + if( $stype && isset( $switchTypes[$stype] ) ) + $qb->andWhere( 's.switchtype = :stype' )->setParameter( 'stype', $stype ); + + $this->view->activeOnly = $activeOnly = $this->getSessionNamespace()->switch_list_active_only + = $this->getParam( 'activeOnly', ( $this->getSessionNamespace()->switch_list_active_only !== null + ? $this->getSessionNamespace()->switch_list_active_only : true ) ); + if( $activeOnly ) + $qb->andWhere( 's.active = :active' )->setParameter( 'active', true ); if( isset( $this->_feParams->listOrderBy ) ) $qb->orderBy( $this->_feParams->listOrderBy, isset( $this->_feParams->listOrderByDir ) ? $this->_feParams->listOrderByDir : 'ASC' ); @@ -186,7 +199,12 @@ public function osViewAction() 'type' => self::$FE_COL_TYPES[ 'DATETIME' ] ], - 'active' => 'Active' + 'active' => [ + 'title' => 'Active', + 'type' => self::$FE_COL_TYPES[ 'SCRIPT' ], + 'script' => 'frontend/list-column-active.phtml', + 'colname' => 'active' + ] ]; return $this->listAction(); diff --git a/application/views/switch/list-toolbar.phtml b/application/views/switch/list-toolbar.phtml index 016033210..b9ebd6bdf 100644 --- a/application/views/switch/list-toolbar.phtml +++ b/application/views/switch/list-toolbar.phtml @@ -1,6 +1,34 @@
  • +
    + + {if isset( $stype ) and $stype}Type: {$switchTypes.$stype}{else}Limit to type...{/if} + + + +
    + +
    + {if $activeOnly} + + Include Inactive + + {else} + + Show Active + + {/if} +
    +
    {if $action eq 'os-view'} Standard View