Skip to content

Commit

Permalink
[IM] Limit switch list to active switches only
Browse files Browse the repository at this point in the history
You can opt to include inactive switches and to also display console switches.

WHen you do, these choices are retained for the session.
  • Loading branch information
barryo committed Mar 17, 2014
1 parent 057d435 commit 3a917f0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
20 changes: 19 additions & 1 deletion application/controllers/SwitchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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();
Expand Down
28 changes: 28 additions & 0 deletions application/views/switch/list-toolbar.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
<li class="pull-right" style="margin-top: -6px;">
<div class="btn-toolbar" style="display: inline;">

<div class="btn-group">
<a class="btn btn-mini dropdown-toggle" data-toggle="dropdown" href="#">
{if isset( $stype ) and $stype}Type: {$switchTypes.$stype}{else}Limit to type...{/if}
<span class="caret"></span>
</a>
<ul class="dropdown-menu pull-right">
<li {if not $stype}class="active"{/if}>
<a href="{genUrl controller='switch' action=$action stype=0}">All types</a> </li>
<li class="divider"></li>
{foreach $switchTypes as $stypeid => $stypename}
<li {if $stype eq $stypeid}class="active"{/if}> <a href="{genUrl controller='switch' action=$action stype=$stypeid}">
{$stypename}</a> </li>
{/foreach}
</ul>
</div>

<div class="btn-group">
{if $activeOnly}
<a class="btn btn-mini pull-right" href="{genUrl controller=$controller action=$action activeOnly=0}">
Include Inactive
</a>
{else}
<a class="btn btn-mini pull-right" href="{genUrl controller=$controller action=$action activeOnly=1}">
Show Active
</a>
{/if}
</div>

<div class="btn-group">
{if $action eq 'os-view'}
<a class="btn btn-mini pull-right" href="{genUrl controller=$controller action="list"}">Standard View</a>
Expand Down

0 comments on commit 3a917f0

Please sign in to comment.