N°900 Portal: Tabs in ManageBrick can now display the objects count.

SVN:trunk[4758]
This commit is contained in:
Guillaume Lajarige
2017-06-07 14:13:02 +00:00
parent 68ff589f9c
commit befa0b4429
6 changed files with 75 additions and 17 deletions

View File

@@ -140,7 +140,7 @@ class ManageBrickController extends BrickController
'value' => $aDistinctResult['grouped_by_1'],
'label' => strip_tags($oFieldExp->MakeValueLabel($oDistinctQuery, $aDistinctResult['grouped_by_1'], '')),
'condition' => $oConditionQuery,
'count' => $aDistinctResult['_itop_count_']
'count' => $aDistinctResult['_itop_count_'],
);
unset($oConditionQuery);
}
@@ -152,7 +152,7 @@ class ManageBrickController extends BrickController
'value' => 'undefined',
'label' => '',
'condition' => null,
'count' => null
'count' => null,
);
}
}
@@ -161,11 +161,14 @@ class ManageBrickController extends BrickController
{
foreach ($aGroupingTabs['groups'] as $aGroup)
{
$oConditionQuery = DBSearch::FromOQL($aGroup['condition']);
$oConditionSet = new DBObjectSet($oConditionQuery);
$aGroupingTabsValues[$aGroup['id']] = array(
'value' => $aGroup['id'],
'label' => Dict::S($aGroup['title']),
'condition' => DBSearch::FromOQL($aGroup['condition']),
'count' => null
'condition' => $oConditionQuery,
'count' => $oConditionSet->Count(),
);
}
}

View File

@@ -42,12 +42,14 @@ class ManageBrick extends PortalBrick
const DEFAULT_DATA_LOADING = self::ENUM_DATA_LOADING_LAZY;
const DEFAULT_COUNT_PER_PAGE_LIST = 20;
const DEFAULT_ZLIST_FIELDS = 'list';
const DEFAULT_SHOW_TAB_COUNTS = false;
static $sRouteName = 'p_manage_brick';
protected $sOql;
protected $sOpeningMode;
protected $aGrouping;
protected $aFields;
protected $bShowTabCounts;
public function __construct()
{
@@ -57,6 +59,7 @@ class ManageBrick extends PortalBrick
$this->sOpeningMode = static::DEFAULT_OPENING_MODE;
$this->aGrouping = array();
$this->aFields = array();
$this->bShowTabCounts = static::DEFAULT_SHOW_TAB_COUNTS;
// This is hardcoded for now, we might allow area grouping on another attribute in the futur
$this->AddGrouping('areas', array('attribute' => 'finalclass'));
@@ -102,6 +105,16 @@ class ManageBrick extends PortalBrick
return $this->aFields;
}
/**
* Returns if the brick should display objects count on tabs
*
* @return bool
*/
public function GetShowTabCounts()
{
return $this->bShowTabCounts;
}
/**
* Sets the oql of the brick
*
@@ -148,6 +161,18 @@ class ManageBrick extends PortalBrick
return $this;
}
/**
* Sets if the brick should display objects count on tab
*
* @param bool $bShowTabCounts
* @return \Combodo\iTop\Portal\Brick\ManageBrick
*/
public function SetShowTabCounts($bShowTabCounts)
{
$this->bShowTabCounts = $bShowTabCounts;
return $this;
}
/**
* Adds a grouping.
*
@@ -356,6 +381,10 @@ class ManageBrick extends PortalBrick
{
switch ($oGroupingNode->nodeName)
{
case 'show_tab_counts';
$bShowTabCounts = ( $oGroupingNode->GetText(static::DEFAULT_SHOW_TAB_COUNTS) === 'true' ) ? true : false;
$this->SetShowTabCounts($bShowTabCounts);
break;
case 'attribute':
$sAttribute = $oGroupingNode->GetText();
if ($sAttribute !== '')

View File

@@ -12,7 +12,12 @@
{% if aGroupingTabsValues|length > 1 %}
<div class="btn-group {#btn-group-sm#} btn_group_explicit">
{% for aGroupingTab in aGroupingTabsValues %}
<a href="{{ app.url_generator.generate('p_manage_brick', {'sBrickId': sBrickId, 'sGroupingTab': aGroupingTab.value}) }}" class="btn btn-default {% if sGroupingTab is defined and sGroupingTab == aGroupingTab.value %}active{% endif %}">{{ aGroupingTab.label|raw }}</a>
<a href="{{ app.url_generator.generate('p_manage_brick', {'sBrickId': sBrickId, 'sGroupingTab': aGroupingTab.value}) }}" id="btn_tab_for_{{ aGroupingTab.value }}" class="btn btn-default {% if sGroupingTab is defined and sGroupingTab == aGroupingTab.value %}active{% endif %}">
{{ aGroupingTab.label|raw }}
{% if oBrick.GetShowTabCounts() %}
<span class="btn_tab_count">{{ aGroupingTab.count|raw }}</span>
{% endif %}
</a>
{% endfor %}
</div>
{% endif %}

View File

@@ -4928,6 +4928,13 @@ label {
border-radius: 37px !important;
box-shadow: -1px 1px 2px rgba(0, 0, 0, 0.4);
}
.btn-group.btn_group_explicit .btn .btn_tab_count:before {
content: "(";
margin-left: 2px;
}
.btn-group.btn_group_explicit .btn .btn_tab_count:after {
content: ")";
}
/* Help blocks in forms */
.form_fields .form-group .help-block {
margin-top: 0px;

View File

@@ -5998,18 +5998,28 @@ label {
background-color: $combodo-dark-gray-darker;
border: 1px solid #EBEAEA;
border-radius: 30px;
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.4) inset;
}
.btn-group.btn_group_explicit .btn{
color: $white;
background-color: transparent;
border: none;
}
.btn-group.btn_group_explicit .btn.active{
color: #6B6965;
background-color: $body-bg;
border-radius: 37px !important;
box-shadow: -1px 1px 2px rgba(0, 0, 0, 0.4);
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.4) inset;
.btn{
color: $white;
background-color: transparent;
border: none;
&.active{
color: #6B6965;
background-color: $body-bg;
border-radius: 37px !important;
box-shadow: -1px 1px 2px rgba(0, 0, 0, 0.4);
}
.btn_tab_count:before{
content: "(";
margin-left: 2px;
}
.btn_tab_count:after{
content: ")";
}
}
}
/* Help blocks in forms */
.form_fields .form-group .help-block{

View File

@@ -1163,6 +1163,8 @@
<grouping>
<!-- Mandatory -->
<tabs>
<!-- Optional. Show object count for each tabs. Available values are true|false. Default is false. -->
<!--<show_tab_counts>false</show_tab_counts>-->
<!-- Mandatory. Grouping by tabs -->
<!--<attribute>operational_status</attribute>-->
<!-- attribute xor groups tag -->
@@ -1214,6 +1216,8 @@
</fields>
<grouping>
<tabs>
<!-- Optional. Show object count for each tabs. Available values are true|false. Default is false. -->
<!--<show_tab_counts>false</show_tab_counts>-->
<groups>
<group id="all">
<rank>1</rank>