From b852e720880c045fd2ef70252b9d99d59a19845c Mon Sep 17 00:00:00 2001 From: acognet Date: Thu, 25 May 2023 16:07:15 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B01386=20-=20Advanced=20Search:=20Navigati?= =?UTF-8?q?on=20in=20list=20-=20Browse=20this=20list=20-=20back=20from=20r?= =?UTF-8?q?un=5Fquery?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/composer/autoload_classmap.php | 1 + lib/composer/autoload_real.php | 2 +- lib/composer/autoload_static.php | 1 + pages/UI.php | 3 +- pages/run_query.php | 4 +- .../Component/DataTable/DataTableBasket.php | 48 +++++++++++++++++++ .../DataTable/DataTableUIBlockFactory.php | 11 ++++- .../Base/Component/Navigation/Navigation.php | 14 +++++- .../Navigation/NavigationUIBlockFactory.php | 4 +- .../Layout/PageContent/PageContentFactory.php | 5 +- .../components/datatable/basket.ready.js.twig | 7 +++ .../components/datatable/layout.live.js.twig | 9 ---- .../components/datatable/layout.ready.js.twig | 12 ++++- .../components/navigation/layout.html.twig | 47 +++++++++--------- .../base/components/navigation/layout.js.twig | 8 +++- 15 files changed, 132 insertions(+), 44 deletions(-) create mode 100644 sources/Application/UI/Base/Component/DataTable/DataTableBasket.php create mode 100644 templates/base/components/datatable/basket.ready.js.twig diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index 70c450fc0..d84b14d24 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -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', diff --git a/lib/composer/autoload_real.php b/lib/composer/autoload_real.php index f3b314bd7..142145f11 100644 --- a/lib/composer/autoload_real.php +++ b/lib/composer/autoload_real.php @@ -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; diff --git a/lib/composer/autoload_static.php b/lib/composer/autoload_static.php index 5438ed46a..7d7b6ea9f 100644 --- a/lib/composer/autoload_static.php +++ b/lib/composer/autoload_static.php @@ -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', diff --git a/pages/UI.php b/pages/UI.php index 97d824213..6209ad945 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -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); } } diff --git a/pages/run_query.php b/pages/run_query.php index fd337a85a..e7064d16e 100644 --- a/pages/run_query.php +++ b/pages/run_query.php @@ -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(); diff --git a/sources/Application/UI/Base/Component/DataTable/DataTableBasket.php b/sources/Application/UI/Base/Component/DataTable/DataTableBasket.php new file mode 100644 index 000000000..1c88d27e6 --- /dev/null +++ b/sources/Application/UI/Base/Component/DataTable/DataTableBasket.php @@ -0,0 +1,48 @@ +sPostedFieldsForBackUrl = json_encode($aPostedFieldsForBackUrl); + } + + /** + * @return string + */ + public function GetPostedFieldsForBackUrl(): string + { + return $this->sPostedFieldsForBackUrl; + } +} diff --git a/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php b/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php index 0ebe5713b..05bc8bbd3 100644 --- a/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php +++ b/sources/Application/UI/Base/Component/DataTable/DataTableUIBlockFactory.php @@ -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 */ ]; } + } \ No newline at end of file diff --git a/sources/Application/UI/Base/Component/Navigation/Navigation.php b/sources/Application/UI/Base/Component/Navigation/Navigation.php index d41961151..872fcd974 100644 --- a/sources/Application/UI/Base/Component/Navigation/Navigation.php +++ b/sources/Application/UI/Base/Component/Navigation/Navigation.php @@ -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; } /** diff --git a/sources/Application/UI/Base/Component/Navigation/NavigationUIBlockFactory.php b/sources/Application/UI/Base/Component/Navigation/NavigationUIBlockFactory.php index 60f502be7..e523fafff 100644 --- a/sources/Application/UI/Base/Component/Navigation/NavigationUIBlockFactory.php +++ b/sources/Application/UI/Base/Component/Navigation/NavigationUIBlockFactory.php @@ -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; } diff --git a/sources/Application/UI/Base/Layout/PageContent/PageContentFactory.php b/sources/Application/UI/Base/Layout/PageContent/PageContentFactory.php index bbb4060c9..c4cc41757 100644 --- a/sources/Application/UI/Base/Layout/PageContent/PageContentFactory.php +++ b/sources/Application/UI/Base/Layout/PageContent/PageContentFactory.php @@ -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); } diff --git a/templates/base/components/datatable/basket.ready.js.twig b/templates/base/components/datatable/basket.ready.js.twig new file mode 100644 index 000000000..01987df49 --- /dev/null +++ b/templates/base/components/datatable/basket.ready.js.twig @@ -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($('') + .attr({'type': 'hidden', 'name': 'back_posted_fields', 'value': '{{ oUIBlock.GetPostedFieldsForBackUrl()|raw }}'}) + ); +}); \ No newline at end of file diff --git a/templates/base/components/datatable/layout.live.js.twig b/templates/base/components/datatable/layout.live.js.twig index 2931795db..e02709635 100644 --- a/templates/base/components/datatable/layout.live.js.twig +++ b/templates/base/components/datatable/layout.live.js.twig @@ -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($('
') - .attr({'method': 'post', 'id': 'basket{{ oUIBlock.GetId() }}'}) - .append($('') - .attr({'type': 'hidden', 'name': 'filter', 'value': "{{ oUIBlock.GetFilter()|raw }}"}) - ) - .append($('') - .attr({'type': 'hidden', 'name': 'back_url', 'value': window.location.href}) - ) -); \ No newline at end of file diff --git a/templates/base/components/datatable/layout.ready.js.twig b/templates/base/components/datatable/layout.ready.js.twig index 79bda9199..87fb1841b 100644 --- a/templates/base/components/datatable/layout.ready.js.twig +++ b/templates/base/components/datatable/layout.ready.js.twig @@ -462,6 +462,16 @@ if ($('#datatable_dlg_{{ oUIBlock.GetId() }}').hasClass('itop-datatable')) } $('#datatable_dlg_{{ oUIBlock.GetId() }}').DataTableSettings(aOptions{{ sListIDForVarSuffix }}); +$('body').append($('') + .attr({'method': 'post', 'id': 'basket{{ oUIBlock.GetId() }}'}) + .append($('') + .attr({'type': 'hidden', 'name': 'filter', 'value': "{{ oUIBlock.GetFilter()|raw }}"}) + ) + .append($('') + .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 %} \ No newline at end of file +{% endif %} diff --git a/templates/base/components/navigation/layout.html.twig b/templates/base/components/navigation/layout.html.twig index ed3c29424..87ae29e2e 100644 --- a/templates/base/components/navigation/layout.html.twig +++ b/templates/base/components/navigation/layout.html.twig @@ -1,26 +1,27 @@ {# @copyright Copyright (C) 2010-2021 Combodo SARL #} {# @license http://opensource.org/licenses/AGPL-3.0 #} -
- {% block iboNavigation %} - - - - -
- {% if oUIBlock.HasPrec() %} -
-
- {% else %} -     - {% endif %} -
{{ oUIBlock.GetIdx() }} / {{ oUIBlock.GetCount() }}
- {% if oUIBlock.HasNext() %} -
-
- {% else %} -     - {% endif %} - - {% endblock %} +
+ {% block iboNavigation %} +
+ + + + +
+ {% if oUIBlock.HasPrec() %} +
+
+ {% else %} +     + {% endif %} +
{{ oUIBlock.GetIdx() }} / {{ oUIBlock.GetCount() }}
+ {% if oUIBlock.HasNext() %} +
+
+ {% else %} +     + {% endif %} +
+ {% endblock %}
\ No newline at end of file diff --git a/templates/base/components/navigation/layout.js.twig b/templates/base/components/navigation/layout.js.twig index f2e04442a..214b59e7e 100644 --- a/templates/base/components/navigation/layout.js.twig +++ b/templates/base/components/navigation/layout.js.twig @@ -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($('').attr({'type': 'hidden', 'name': key, 'value': value})); + }); + + $('#ibo-form-navigation').submit(); }); $('#{{ oUIBlock.GetId() }}-first').on('click', function () {