mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°2598 - When refreshing a list, loosing page and order - improvement of code
This commit is contained in:
@@ -151,7 +151,7 @@ abstract class DashboardLayoutMultiCol extends DashboardLayout
|
||||
}
|
||||
$iCellIdx++;
|
||||
}
|
||||
$sJSReload .= $oDashboardRow->GetJSRefresh()."\n";
|
||||
$sJSReload .= $oDashboardRow->GetJSRefreshCallback()."\n";
|
||||
}
|
||||
|
||||
$oPage->add_script("function updateDashboard".$aExtraParams['dashboard_div_id']."(){".$sJSReload."}");
|
||||
|
||||
@@ -430,11 +430,7 @@ class DisplayBlock
|
||||
|
||||
public function GetDisplay(WebPage $oPage, $sId, $aExtraParams = array()): UIContentBlock
|
||||
{
|
||||
if (isset($aExtraParams['withJSRefreshCallBack'])) {
|
||||
$oHtml = new UIContentBlockWithJSRefreshCallback($sId);
|
||||
} else {
|
||||
$oHtml = new UIContentBlock($sId);
|
||||
}
|
||||
$oHtml = new UIContentBlock($sId);
|
||||
|
||||
$oHtml->AddCSSClass("display_block");
|
||||
$aExtraParams = array_merge($aExtraParams, $this->m_aParams);
|
||||
|
||||
@@ -276,8 +276,4 @@ class Alert extends UIContentBlock
|
||||
return $this->sSectionStateStorageKey;
|
||||
}
|
||||
|
||||
public function GetJSRefresh(): string
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,12 @@
|
||||
namespace Combodo\iTop\Application\UI\Base\Component\Dashlet;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\tJSRefreshCallback;
|
||||
|
||||
class DashletBadge extends DashletContainer
|
||||
{
|
||||
use tJSRefreshCallback;
|
||||
|
||||
public const BLOCK_CODE = 'ibo-dashlet-badge';
|
||||
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/dashlet/dashlet-badge';
|
||||
public const DEFAULT_JS_TEMPLATE_REL_PATH = 'base/components/dashlet/dashlet-badge';
|
||||
@@ -73,6 +77,7 @@ class DashletBadge extends DashletContainer
|
||||
public function SetCreateActionUrl(string $sCreateActionUrl): DashletBadge
|
||||
{
|
||||
$this->sCreateActionUrl = $sCreateActionUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -92,6 +97,7 @@ class DashletBadge extends DashletContainer
|
||||
public function SetCreateActionLabel(string $sCreateActionLabel): DashletBadge
|
||||
{
|
||||
$this->sCreateActionLabel = $sCreateActionLabel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -111,6 +117,7 @@ class DashletBadge extends DashletContainer
|
||||
public function SetClassIconUrl(string $sClassIconUrl): DashletBadge
|
||||
{
|
||||
$this->sClassIconUrl = $sClassIconUrl;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -130,6 +137,7 @@ class DashletBadge extends DashletContainer
|
||||
public function SetHyperlink(string $sHyperlink): DashletBadge
|
||||
{
|
||||
$this->sHyperlink = $sHyperlink;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -149,6 +157,7 @@ class DashletBadge extends DashletContainer
|
||||
public function SetCount(string $iCount): DashletBadge
|
||||
{
|
||||
$this->iCount = $iCount;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,11 +9,9 @@ namespace Combodo\iTop\Application\UI\Base\Component\Dashlet;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
|
||||
use Combodo\iTop\Application\UI\Base\tJSRefreshCallback;
|
||||
|
||||
class DashletContainer extends UIContentBlock
|
||||
{
|
||||
use tJSRefreshCallback;
|
||||
public const BLOCK_CODE = 'ibo-dashlet';
|
||||
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/layouts/content-block/layout';
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Combodo\iTop\Application\UI\Base\Component\DataTable;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
|
||||
use Combodo\iTop\Application\UI\Base\tJSRefreshCallback;
|
||||
use DataTableConfig;
|
||||
|
||||
/**
|
||||
@@ -18,6 +19,8 @@ use DataTableConfig;
|
||||
*/
|
||||
class DataTable extends UIContentBlock
|
||||
{
|
||||
use tJSRefreshCallback;
|
||||
|
||||
// Overloaded constants
|
||||
public const BLOCK_CODE = 'ibo-datatable';
|
||||
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/datatable/layout';
|
||||
@@ -159,8 +162,9 @@ class DataTable extends UIContentBlock
|
||||
$this->aOptions = $aOptions;
|
||||
}
|
||||
|
||||
public function GetJSRefresh():array{
|
||||
return ["$('#".$this->sId."').DataTable().clearPipeline();
|
||||
$('#".$this->sId."').DataTable().ajax.reload(null, false);"];
|
||||
public function GetJSRefresh(): string
|
||||
{
|
||||
return "$('#".$this->sId."').DataTable().clearPipeline();
|
||||
$('#".$this->sId."').DataTable().ajax.reload(null, false);";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,8 +355,4 @@ class Panel extends UIContentBlock
|
||||
return $aSubBlocks;
|
||||
}
|
||||
|
||||
public function GetJSRefresh(): string
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,34 +6,61 @@
|
||||
|
||||
namespace Combodo\iTop\Application\UI\Base;
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\Layout\iUIContentBlock;
|
||||
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
|
||||
use Dict;
|
||||
|
||||
/**
|
||||
* Trait tJSRefreshCallback
|
||||
*
|
||||
* This brings the ability to a UIBlock to have give the JS to use in order to refresh it
|
||||
* This brings the ability to a UIBlock to give the JS to use in order to refresh it
|
||||
* All bricks with JS refresh must use directly this trait in order to be found by the function class_uses in GetRecursiveJSRefresh
|
||||
*
|
||||
* @package Combodo\iTop\Application\UI\Base
|
||||
* @internal
|
||||
* @package Combodo\iTop\Application\UI\Base
|
||||
* @since 3.0.0
|
||||
*/
|
||||
trait tJSRefreshCallback {
|
||||
trait tJSRefreshCallback
|
||||
{
|
||||
/** @var string */
|
||||
protected $sJSRefresh = "";
|
||||
|
||||
|
||||
/**
|
||||
* Get JS refresh for $this
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetJSRefresh():string
|
||||
public function GetJSRefresh(): string
|
||||
{
|
||||
$sJSRefresh = $this->sJSRefresh;
|
||||
foreach ($this->GetSubBlocks() as $oSubBlock) {
|
||||
if( $oSubBlock->GetJSRefresh() !="") {
|
||||
$sJSRefresh =$oSubBlock->GetJSRefresh().'\n'.$sJSRefresh;
|
||||
return $this->sJSRefresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the global JS refresh for all subblocks
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function GetJSRefreshCallback(): string
|
||||
{
|
||||
$sJSRefresh = $this->GetJSRefresh();
|
||||
tJSRefreshCallback::GetRecursiveJSRefresh($this, $sJSRefresh);
|
||||
|
||||
return $sJSRefresh;
|
||||
}
|
||||
|
||||
/**
|
||||
* method only for private use in GetJSRefreshCallback
|
||||
*
|
||||
* @param $oBlock
|
||||
* @param $sJSRefresh
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function GetRecursiveJSRefresh($oBlock, &$sJSRefresh): string
|
||||
{
|
||||
foreach ($oBlock->GetSubBlocks() as $oSubBlock) {
|
||||
$usingTrait = in_array('Combodo\iTop\Application\UI\Base\tJSRefreshCallback', class_uses(get_class($oSubBlock)));
|
||||
if ($usingTrait && $oSubBlock->GetJSRefresh() != "") {
|
||||
$sJSRefresh = $oSubBlock->GetJSRefresh().'\n'.$sJSRefresh;
|
||||
}
|
||||
tJSRefreshCallback::GetRecursiveJSRefresh($oSubBlock, $sJSRefresh);
|
||||
}
|
||||
|
||||
return $sJSRefresh;
|
||||
|
||||
Reference in New Issue
Block a user