N°1386 - Advanced Search: Navigation in list - Browse this list - back from run_query

This commit is contained in:
acognet
2023-05-25 16:07:15 +02:00
parent 9ebcbf2459
commit b852e72088
15 changed files with 132 additions and 44 deletions

View File

@@ -225,6 +225,7 @@ return array(
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Dashlet\\DashletHeaderStatic' => $baseDir . '/sources/Application/UI/Base/Component/Dashlet/DashletHeaderStatic.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Dashlet\\DashletPlainText' => $baseDir . '/sources/Application/UI/Base/Component/Dashlet/DashletPlainText.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTable' => $baseDir . '/sources/Application/UI/Base/Component/DataTable/DataTable.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTableBasket' => $baseDir . '/sources/Application/UI/Base/Component/DataTable/DataTableBasket.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTableSettings' => $baseDir . '/sources/Application/UI/Base/Component/DataTable/DataTableSettings.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTableUIBlockFactory' => $baseDir . '/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\StaticTable\\FormTableRow\\FormTableRow' => $baseDir . '/sources/Application/UI/Base/Component/DataTable/StaticTable/FormTableRow/FormTableRow.php',

View File

@@ -36,7 +36,7 @@ class ComposerAutoloaderInit7f81b4a2a468a061c306af5e447a9a9f
call_user_func(\Composer\Autoload\ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->setApcuPrefix('jfuEJXXFngXWlQd9yQyh8');
$loader->setApcuPrefix('YzkejrfRDHz9hqMdq98PU');
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f::$files;

View File

@@ -580,6 +580,7 @@ class ComposerStaticInit7f81b4a2a468a061c306af5e447a9a9f
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Dashlet\\DashletHeaderStatic' => __DIR__ . '/../..' . '/sources/Application/UI/Base/Component/Dashlet/DashletHeaderStatic.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\Dashlet\\DashletPlainText' => __DIR__ . '/../..' . '/sources/Application/UI/Base/Component/Dashlet/DashletPlainText.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTable' => __DIR__ . '/../..' . '/sources/Application/UI/Base/Component/DataTable/DataTable.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTableBasket' => __DIR__ . '/../..' . '/sources/Application/UI/Base/Component/DataTable/DataTableBasket.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTableSettings' => __DIR__ . '/../..' . '/sources/Application/UI/Base/Component/DataTable/DataTableSettings.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\DataTableUIBlockFactory' => __DIR__ . '/../..' . '/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php',
'Combodo\\iTop\\Application\\UI\\Base\\Component\\DataTable\\StaticTable\\FormTableRow\\FormTableRow' => __DIR__ . '/../..' . '/sources/Application/UI/Base/Component/DataTable/StaticTable/FormTableRow/FormTableRow.php',

View File

@@ -439,6 +439,7 @@ try
$sBackUrl = utils::ReadPostedParam('back_url', '', false, 'raw');
$sFilter = utils::ReadPostedParam('filter', null, false, 'raw');
$sList = utils::ReadPostedParam('list_navigation', null, false, 'string');
$sPostedFieldsForBackUrl = utils::ReadPostedParam('back_posted_fields', "", false, 'raw');
$aList = [];
if ($sList != null) {
$aList = json_decode($sList);
@@ -446,7 +447,7 @@ try
$sClassLabel = MetaModel::GetName($sClass);
$oP->set_title(Dict::Format('UI:DetailsPageTitle', $oObj->GetRawName(), $sClassLabel)); // Set title will take care of the encoding
$oP->SetContentLayout(PageContentFactory::MakeForObjectDetails($oObj, $oP->IsPrintableVersion() ? cmdbAbstractObject::ENUM_DISPLAY_MODE_PRINT : cmdbAbstractObject::ENUM_DISPLAY_MODE_VIEW, $sFilter, $aList, $sBackUrl));
$oP->SetContentLayout(PageContentFactory::MakeForObjectDetails($oObj, $oP->IsPrintableVersion() ? cmdbAbstractObject::ENUM_DISPLAY_MODE_PRINT : cmdbAbstractObject::ENUM_DISPLAY_MODE_VIEW, $sFilter, $aList, $sBackUrl, $sPostedFieldsForBackUrl));
$oObj->DisplayDetails($oP);
}
}

View File

@@ -216,10 +216,12 @@ JS
if ($oFilter) {
//--- Query filter
$oPanelResult= PanelUIBlockFactory::MakeWithBrandingSecondaryColor(Dict::S('UI:RunQuery:QueryResults'));
$oPanelResult = PanelUIBlockFactory::MakeWithBrandingSecondaryColor(Dict::S('UI:RunQuery:QueryResults'));
$oP->AddSubBlock($oPanelResult);
$oResultBlock = new DisplayBlock($oFilter, 'list', false);
$oPanelResult->AddSubBlock($oResultBlock->GetDisplay($oP, 'runquery'));
//Added in order to go back to search from navigation in the basket
$oP->AddSubBlock(DataTableUIBlockFactory::MakeParamForBasket(['encoding' => $sEncoding, 'expression' => $sExpression]));
// Breadcrumb
//$iCount = $oResultBlock->GetDisplayedCount();

View File

@@ -0,0 +1,48 @@
<?php
/**
* @copyright Copyright (C) 2010-2023 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
*/
namespace Combodo\iTop\Application\UI\Base\Component\DataTable;
use ApplicationContext;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use Combodo\iTop\Application\UI\Base\tJSRefreshCallback;
use DataTableConfig;
/**
* Class DataTableBasket
*
* @package Combodo\iTop\Application\UI\Base\Component\DataTableBasket
* @since 3.1.0
*/
class DataTableBasket extends UIContentBlock
{
// Overloaded constants
public const BLOCK_CODE = 'ibo-datatable-basket';
public const DEFAULT_JS_ON_READY_TEMPLATE_REL_PATH = 'base/components/datatable/basket';
protected $sPostedFieldsForBackUrl;
/**
* Panel constructor.
*
*/
public function __construct(array $aPostedFieldsForBackUrl = [], ?string $sId = null)
{
parent::__construct($sId);
$this->sPostedFieldsForBackUrl = json_encode($aPostedFieldsForBackUrl);
}
/**
* @return string
*/
public function GetPostedFieldsForBackUrl(): string
{
return $this->sPostedFieldsForBackUrl;
}
}

View File

@@ -899,10 +899,18 @@ JS;
return $oTable;
}
public static function MakeParamForBasket(array $aPostedFields)
{
$oBlock = new DataTableBasket($aPostedFields);
return $oBlock;
}
/**
* @return array
*/
public static function GetAllowedParams(): array
public
static function GetAllowedParams(): array
{
return [
'surround_with_panel',
@@ -953,4 +961,5 @@ JS;
/** Don't provide the standard object creation feature */
];
}
}

View File

@@ -53,6 +53,7 @@ class Navigation extends UIContentBlock
protected $sFilter;
protected $sBackUrl;
protected $sClass;
protected $sPostedFields;
/**
* Panel constructor.
@@ -62,7 +63,7 @@ class Navigation extends UIContentBlock
* @param string $sColorScheme Color scheme code such as "success", "failure", "active", ... {@see css/backoffice/components/_panel.scss}
* @param string|null $sId
*/
public function __construct(string $sClass, int $iIdx, array $aList, string $sFilter, string $sBackUrl, ?string $sId = null)
public function __construct(string $sClass, int $iIdx, array $aList, string $sFilter, string $sBackUrl, string $sPostedFieldsForBackUrl = "", ?string $sId = null)
{
parent::__construct($sId);
$this->iCount = count($aList);
@@ -82,6 +83,7 @@ class Navigation extends UIContentBlock
$this->iIdNext = $aList[$iIdx + 1];
$this->iIdLast = $aList[$this->iCount - 1];
}
$this->sPostedFields = $sPostedFieldsForBackUrl;
}
/**
@@ -89,7 +91,15 @@ class Navigation extends UIContentBlock
*/
public function GetIdx(): int
{
return $this->iIdx+1;
return $this->iIdx + 1;
}
/**
* @return string
*/
public function GetPostedFields(): string
{
return $this->sPostedFields;
}
/**

View File

@@ -48,7 +48,7 @@ class NavigationUIBlockFactory extends AbstractUIBlockFactory
*
* @return \Combodo\iTop\Application\UI\Base\Component\Panel\Panel
*/
public static function MakeStandard($oObject, string $sFilter, array $aList = [], string $sBackUrl = '')
public static function MakeStandard($oObject, string $sFilter, array $aList = [], string $sBackUrl = '', $sPostedFieldsForBackUrl = "")
{
if ($sFilter != null && count($aList) === 0) {
$oFilter = DBObjectSearch::FromOQL($sFilter);
@@ -60,7 +60,7 @@ class NavigationUIBlockFactory extends AbstractUIBlockFactory
}
$iIdx = array_search($oObject->GetKey(), $aList);
$oNavigationBlock = new Navigation(get_class($oObject), $iIdx, $aList, $sFilter, $sBackUrl);
$oNavigationBlock = new Navigation(get_class($oObject), $iIdx, $aList, $sFilter, $sBackUrl, $sPostedFieldsForBackUrl);
return $oNavigationBlock;
}

View File

@@ -55,19 +55,20 @@ class PageContentFactory
* @param string $sBasketFilter filter to find list of objects in basket
* @param array $aBasketList list of id of objects in basket
* @param string $sBackUrl url to go back to list of ojects in basket
* @param string $sPostedFieldsForBackUrl fields to post for come back to main page
*
* @param \DBObject $oObject
*
* @return \Combodo\iTop\Application\UI\Base\Layout\PageContent\PageContentWithSideContent
* @throws \CoreException
*/
public static function MakeForObjectDetails(DBObject $oObject, string $sMode = cmdbAbstractObject::DEFAULT_DISPLAY_MODE, $sBasketFilter = null, $aBasketList = [], $sBackUrl = null)
public static function MakeForObjectDetails(DBObject $oObject, string $sMode = cmdbAbstractObject::DEFAULT_DISPLAY_MODE, $sBasketFilter = null, $aBasketList = [], $sBackUrl = null, $sPostedFieldsForBackUrl = "")
{
$oLayout = new PageContentWithSideContent();
if ($sBasketFilter != null) {
$oNavigationBlock = NavigationUIBlockFactory::MakeStandard($oObject, $sBasketFilter, $aBasketList, $sBackUrl);
$oNavigationBlock = NavigationUIBlockFactory::MakeStandard($oObject, $sBasketFilter, $aBasketList, $sBackUrl, $sPostedFieldsForBackUrl);
if ($oNavigationBlock != null) {
$oLayout->AddSubBlock($oNavigationBlock);
}

View File

@@ -0,0 +1,7 @@
{# @copyright Copyright (C) 2010-2023 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
$("form[id^='basket']").each(function () {
$(this).append($('<input/>')
.attr({'type': 'hidden', 'name': 'back_posted_fields', 'value': '{{ oUIBlock.GetPostedFieldsForBackUrl()|raw }}'})
);
});

View File

@@ -7,12 +7,3 @@ oSelectedItems{{ oUIBlock.GetOption('sListId')|sanitize(constant('utils::ENUM_SA
var bSelectAllowed{{ oUIBlock.GetId()|sanitize(constant('utils::ENUM_SANITIZATION_FILTER_VARIABLE_NAME')) }} = false;
$('body').append($('<form/>')
.attr({'method': 'post', 'id': 'basket{{ oUIBlock.GetId() }}'})
.append($('<input/>')
.attr({'type': 'hidden', 'name': 'filter', 'value': "{{ oUIBlock.GetFilter()|raw }}"})
)
.append($('<input/>')
.attr({'type': 'hidden', 'name': 'back_url', 'value': window.location.href})
)
);

View File

@@ -462,6 +462,16 @@ if ($('#datatable_dlg_{{ oUIBlock.GetId() }}').hasClass('itop-datatable'))
}
$('#datatable_dlg_{{ oUIBlock.GetId() }}').DataTableSettings(aOptions{{ sListIDForVarSuffix }});
$('body').append($('<form/>')
.attr({'method': 'post', 'id': 'basket{{ oUIBlock.GetId() }}'})
.append($('<input/>')
.attr({'type': 'hidden', 'name': 'filter', 'value': "{{ oUIBlock.GetFilter()|raw }}"})
)
.append($('<input/>')
.attr({'type': 'hidden', 'name': 'back_url', 'value': window.location.href})
)
);
if (window.ResizeObserver)
{
let oTable{{ sListIDForVarSuffix }}ResizeTimeout = null;
@@ -476,4 +486,4 @@ if (window.ResizeObserver)
{% if oUIBlock.HasRowActions() %}
{% include 'base/components/datatable/row-actions/handler.js.twig' %}
{% endif %}
{% endif %}

View File

@@ -1,26 +1,27 @@
{# @copyright Copyright (C) 2010-2021 Combodo SARL #}
{# @license http://opensource.org/licenses/AGPL-3.0 #}
<div id="{{ oUIBlock.GetId() }}"
class="{{ oUIBlock.GetBlocksInheritanceCSSClassesAsString() }} {{ oUIBlock.GetAdditionalCSSClassesAsString() }} {{ oUIBlock.GetCSSColorClass() }} {% if oUIBlock.IsHidden() %}ibo-is-hidden{% endif %} ibo-is-opened" data-role="ibo-navigation">
{% block iboNavigation %}
<form id="ibo-form-navigation" class="ibo-navigation-form" method="post">
<input type="hidden" name="list_navigation" value="{{ oUIBlock.GetList() }}"/>
<input type="hidden" name="filter" value="{{ oUIBlock.GetFilter() }}"/>
<input type="hidden" name="back_url" value="{{ oUIBlock.GetBackUrl()|raw }}"/>
<div class="ibo-form-navigation--nav fas fa-angle-up" id="{{ oUIBlock.GetId() }}-back"></div>
{% if oUIBlock.HasPrec() %}
<div class="ibo-form-navigation--nav fas fa-angle-double-left" id="{{ oUIBlock.GetId() }}-first"></div>
<div class="ibo-form-navigation--nav fas fa-angle-left" id="{{ oUIBlock.GetId() }}-prev"></div>
{% else %}
&#160;&#160;&#160;
{% endif %}
<div class="ibo-form-navigation--total">{{ oUIBlock.GetIdx() }} / {{ oUIBlock.GetCount() }}</div>
{% if oUIBlock.HasNext() %}
<div class="ibo-form-navigation--nav fas fa-angle-right" id="{{ oUIBlock.GetId() }}-next"></div>
<div class="ibo-form-navigation--nav fas fa-angle-double-right" id="{{ oUIBlock.GetId() }}-last"></div>
{% else %}
&#160;&#160;&#160;
{% endif %}
</form>
{% endblock %}
<div id='{{ oUIBlock.GetId() }}'
class='{{ oUIBlock.GetBlocksInheritanceCSSClassesAsString() }} {{ oUIBlock.GetAdditionalCSSClassesAsString() }} {{ oUIBlock.GetCSSColorClass() }} {% if oUIBlock.IsHidden() %}ibo-is-hidden{% endif %} ibo-is-opened' data-role='ibo-navigation'>
{% block iboNavigation %}
<form id='ibo-form-navigation' class='ibo-navigation-form' method='post'>
<input type='hidden' name='list_navigation' value='{{ oUIBlock.GetList() }}'/>
<input type='hidden' name='filter' value='{{ oUIBlock.GetFilter() }}'/>
<input type='hidden' name='back_posted_fields' value='{{ oUIBlock.GetPostedFields()|raw }}'/>
<input type='hidden' name='back_url' value='{{ oUIBlock.GetBackUrl()|raw }}'/>
<div class='ibo-form-navigation--nav fas fa-angle-up' id='{{ oUIBlock.GetId() }}-back'></div>
{% if oUIBlock.HasPrec() %}
<div class='ibo-form-navigation--nav fas fa-angle-double-left' id='{{ oUIBlock.GetId() }}-first'></div>
<div class='ibo-form-navigation--nav fas fa-angle-left' id='{{ oUIBlock.GetId() }}-prev'></div>
{% else %}
&#160;&#160;&#160;
{% endif %}
<div class='ibo-form-navigation--total'>{{ oUIBlock.GetIdx() }} / {{ oUIBlock.GetCount() }}</div>
{% if oUIBlock.HasNext() %}
<div class='ibo-form-navigation--nav fas fa-angle-right' id='{{ oUIBlock.GetId() }}-next'></div>
<div class='ibo-form-navigation--nav fas fa-angle-double-right' id='{{ oUIBlock.GetId() }}-last'></div>
{% else %}
&#160;&#160;&#160;
{% endif %}
</form>
{% endblock %}
</div>

View File

@@ -2,7 +2,13 @@
{# @license http://opensource.org/licenses/AGPL-3.0 #}
$('#{{ oUIBlock.GetId() }}-back').on('click', function () {
window.location = '{{ oUIBlock.GetBackUrl()|raw }}';
$('#ibo-form-navigation').attr('action', ' {{ oUIBlock.GetBackUrl() | raw }} ');
JSON.parse('{{ oUIBlock.GetPostedFields() | raw }}', (key, value) => {
$('#ibo-form-navigation').append($('<input/>').attr({'type': 'hidden', 'name': key, 'value': value}));
});
$('#ibo-form-navigation').submit();
});
$('#{{ oUIBlock.GetId() }}-first').on('click', function () {