From 31cafcf2ddd743f7eea4d0bd995743c19cfc93cf Mon Sep 17 00:00:00 2001 From: Guillaume Lajarige Date: Thu, 23 Jun 2016 12:58:34 +0000 Subject: [PATCH] Customers portal : BrowseBrick : Extra field columns can be hidden in list mode while remaining filterable. (Use case example : Hide a "keywords" attribute to enable filtering on it) SVN:trunk[4257] --- .../src/controllers/browsebrickcontroller.class.inc.php | 5 +++-- .../portal/src/entities/browsebrick.class.inc.php | 8 +++++++- .../portal/src/views/bricks/browse/mode_list.html.twig | 2 ++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php index b19adf2d4..bd7decc4c 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/controllers/browsebrickcontroller.class.inc.php @@ -360,11 +360,12 @@ class BrowseBrickController extends BrickController { $aLevelsProperties[$sCurrentLevelAlias]['fields'] = array(); - foreach ($aLevel['fields'] as $sFieldAttCode) + foreach ($aLevel['fields'] as $sFieldAttCode => $aFieldProperties) { $aLevelsProperties[$sCurrentLevelAlias]['fields'][] = array( 'code' => $sFieldAttCode, - 'label' => MetaModel::GetAttributeDef($oSearch->GetClass(), $sFieldAttCode)->GetLabel() + 'label' => MetaModel::GetAttributeDef($oSearch->GetClass(), $sFieldAttCode)->GetLabel(), + 'hidden' => $aFieldProperties['hidden'] ); } } diff --git a/datamodels/2.x/itop-portal-base/portal/src/entities/browsebrick.class.inc.php b/datamodels/2.x/itop-portal-base/portal/src/entities/browsebrick.class.inc.php index b19177e1c..4569f21dc 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/entities/browsebrick.class.inc.php +++ b/datamodels/2.x/itop-portal-base/portal/src/entities/browsebrick.class.inc.php @@ -349,12 +349,18 @@ class BrowseBrick extends PortalBrick { if ($oFieldNode->hasAttribute('id') && $oFieldNode->getAttribute('id') !== '') { - $aLevel[$sTagName][] = $oFieldNode->getAttribute('id'); + $aLevel[$sTagName][$oFieldNode->getAttribute('id')] = array('hidden' => false); } else { throw new DOMFormatException('BrowseBrick : ' . $sTagName . '/* tag must have an "id" attribute and it must not be empty', null, null, $oFieldNode); } + + $oFieldSubNode = $oFieldNode->GetOptionalElement('hidden'); + if ($oFieldSubNode !== null) + { + $aLevel[$sTagName][$oFieldNode->getAttribute('id')]['hidden'] = ($oFieldSubNode->GetText() === 'true') ? true : false; + } } } break; diff --git a/datamodels/2.x/itop-portal-base/portal/src/views/bricks/browse/mode_list.html.twig b/datamodels/2.x/itop-portal-base/portal/src/views/bricks/browse/mode_list.html.twig index 2bd99bdc8..1c33aaee7 100644 --- a/datamodels/2.x/itop-portal-base/portal/src/views/bricks/browse/mode_list.html.twig +++ b/datamodels/2.x/itop-portal-base/portal/src/views/bricks/browse/mode_list.html.twig @@ -195,11 +195,13 @@ "width": "auto", "searchable": true, "sortable": false, + "visible": !oLevelsProperties[sKey].fields[i].hidden, "title": oLevelsProperties[sKey].fields[i].label, "defaultContent": "", "type": "html", "data": oLevelsProperties[sKey].alias+".fields."+oLevelsProperties[sKey].fields[i].code }); + console.log(oLevelsProperties[sKey].fields[i].visible); } } }