mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-20 00:58:48 +02:00
N°769 Portal: Add parameter to set default list length in ManageBrick and BrowseBrick
This commit is contained in:
@@ -96,6 +96,8 @@ class BrowseBrick extends PortalBrick
|
||||
protected $aAvailablesBrowseModes;
|
||||
/** @var string $sDefaultBrowseMode */
|
||||
protected $sDefaultBrowseMode;
|
||||
/** @var int $iDefaultListLength */
|
||||
protected $iDefaultListLength;
|
||||
|
||||
/**
|
||||
* BrowseBrick constructor.
|
||||
@@ -107,6 +109,7 @@ class BrowseBrick extends PortalBrick
|
||||
$this->aLevels = array();
|
||||
$this->aAvailablesBrowseModes = array();
|
||||
$this->sDefaultBrowseMode = static::DEFAULT_BROWSE_MODE;
|
||||
$this->iDefaultListLength = static::DEFAULT_LIST_LENGTH;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,6 +184,28 @@ class BrowseBrick extends PortalBrick
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default lists length to display
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function GetDefaultListLength()
|
||||
{
|
||||
return $this->iDefaultListLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default lists length to display
|
||||
*
|
||||
* @param int $iDefaultListLength
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetDefaultListLength($iDefaultListLength) {
|
||||
$this->iDefaultListLength = $iDefaultListLength;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the brick has levels
|
||||
*
|
||||
@@ -324,6 +349,18 @@ class BrowseBrick extends PortalBrick
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'default_list_length':
|
||||
$iNodeDefaultListLength = (int)$oBrickSubNode->GetText(static::DEFAULT_LIST_LENGTH);
|
||||
if(!in_array($iNodeDefaultListLength, array(10, 20, 50, -1),true))
|
||||
{
|
||||
throw new DOMFormatException(
|
||||
'BrowseBrick: Default list length must be contained in list length options. Expected -1/10/20/50, '.$iNodeDefaultListLength.' given.',
|
||||
null,
|
||||
null, $oBrickSubNode
|
||||
);
|
||||
}
|
||||
$this->SetDefaultListLength($iNodeDefaultListLength);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,8 @@ class ManageBrick extends PortalBrick
|
||||
protected $iGroupLimit;
|
||||
/** @var bool $bGroupShowOthers */
|
||||
protected $bGroupShowOthers;
|
||||
/** @var int $iDefaultListLength */
|
||||
protected $iDefaultListLength;
|
||||
|
||||
/**
|
||||
* Returns true if the $sDisplayMode need objects details for rendering.
|
||||
@@ -226,6 +228,7 @@ class ManageBrick extends PortalBrick
|
||||
$this->sTileMode = static::DEFAULT_TILE_MODE;
|
||||
$this->iGroupLimit = static::DEFAULT_GROUP_LIMIT;
|
||||
$this->bGroupShowOthers = static::DEFAULT_GROUP_SHOW_OTHERS;
|
||||
$this->iDefaultListLength = static::DEFAULT_LIST_LENGTH;
|
||||
|
||||
// This is hardcoded for now, we might allow area grouping on another attribute in the future
|
||||
$this->AddGrouping('areas', array('attribute' => 'finalclass'));
|
||||
@@ -440,6 +443,28 @@ class ManageBrick extends PortalBrick
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default lists length to display
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function GetDefaultListLength()
|
||||
{
|
||||
return $this->iDefaultListLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default lists length to display
|
||||
*
|
||||
* @param int $iDefaultListLength
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetDefaultListLength($iDefaultListLength) {
|
||||
$this->iDefaultListLength = $iDefaultListLength;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a grouping.
|
||||
*
|
||||
@@ -799,7 +824,18 @@ class ManageBrick extends PortalBrick
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case 'default_list_length':
|
||||
$iNodeDefaultListLength = (int)$oBrickSubNode->GetText(static::DEFAULT_LIST_LENGTH);
|
||||
if(!in_array($iNodeDefaultListLength, array(10, 20, 50, -1),true))
|
||||
{
|
||||
throw new DOMFormatException(
|
||||
'ManageBrick : Default list length must be contained in list length options. Expected -1/10/20/50, '.$iNodeDefaultListLength.' given.',
|
||||
null,
|
||||
null, $oBrickSubNode
|
||||
);
|
||||
}
|
||||
$this->SetDefaultListLength($iNodeDefaultListLength);
|
||||
break;
|
||||
case 'grouping':
|
||||
// Tabs grouping
|
||||
/** @var \Combodo\iTop\DesignElement $oGroupingNode */
|
||||
|
||||
@@ -410,6 +410,7 @@ class BrowseBrickController extends BrickController
|
||||
'aItems' => json_encode($aItems),
|
||||
'iItemsCount' => count($aItems),
|
||||
'aLevelsProperties' => json_encode($aLevelsProperties),
|
||||
'iDefaultLengthList' => $oBrick->GetDefaultListLength(),
|
||||
);
|
||||
|
||||
// Note : To extend this brick's template, depending on what you want to do :
|
||||
|
||||
@@ -96,6 +96,7 @@ class ManageBrickController extends BrickController
|
||||
$aData = $aData + array(
|
||||
'sDisplayMode' => $sDisplayMode,
|
||||
'bCanExport' => !empty($aExportFields),
|
||||
'iDefaultListLength' => $oBrick->GetDefaultListLength(),
|
||||
);
|
||||
// Preparing response
|
||||
if ($oRequest->isXmlHttpRequest())
|
||||
|
||||
@@ -224,7 +224,7 @@
|
||||
}
|
||||
},
|
||||
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "{{ 'Portal:Datatables:Language:DisplayLength:All'|dict_s }}"]],
|
||||
"displayLength": {{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::DEFAULT_LIST_LENGTH') }},
|
||||
"displayLength": {{ iDefaultLengthList }},
|
||||
"dom": '<"row"<"col-sm-6"l><"col-sm-6"<f><"visible-xs"p>>>t<"row"<"col-sm-6"i><"col-sm-6"p>>',
|
||||
"columns": getColumnsDefinition(),
|
||||
"order": [],
|
||||
|
||||
@@ -250,7 +250,7 @@
|
||||
}
|
||||
},
|
||||
"lengthMenu": [[10, 20, 50, -1], [10, 20, 50, "{{ 'Portal:Datatables:Language:DisplayLength:All'|dict_s }}"]],
|
||||
"displayLength": {{ constant('Combodo\\iTop\\Portal\\Brick\\ManageBrick::DEFAULT_LIST_LENGTH') }},
|
||||
"displayLength": {{ iDefaultListLength }},
|
||||
"dom": '<"row"<"col-sm-6"l><"col-sm-6"<f><"visible-xs"p>>>t<"row"<"col-sm-6"i><"col-sm-6"p>>',
|
||||
"columns": getColumnsDefinition('{{ sAreaId }}'),
|
||||
"order": [],
|
||||
|
||||
@@ -1188,6 +1188,8 @@
|
||||
</availables>
|
||||
<default>list</default>
|
||||
</browse_modes>
|
||||
<!-- Optional. Set the default number of item lists will display. -->
|
||||
<!-- <default_list_length>20</default_list_length> -->
|
||||
<data_loading>auto</data_loading>
|
||||
<!-- lazy|full|auto. Let the consultant choose if the list/tree data are load progressivly at each page/level or in one-shot or if it is up to the system regarding the "lazy_loading_threshold" parameter -->
|
||||
</brick>
|
||||
@@ -1258,6 +1260,8 @@
|
||||
</tabs>
|
||||
<!-- Implicit grouping on y axis by finalclass -->
|
||||
</grouping>
|
||||
<!-- Optional. Set the default number of item lists will display. -->
|
||||
<!-- <default_list_length>20</default_list_length> -->
|
||||
<data_loading>full</data_loading>
|
||||
<export>
|
||||
<export_default_fields>true</export_default_fields>
|
||||
|
||||
Reference in New Issue
Block a user