From eccf3d1a62bad5d9a2e4a5ed5f3580a30f0fa5aa Mon Sep 17 00:00:00 2001 From: Thierry Bugier Date: Wed, 8 Jun 2022 08:31:09 +0200 Subject: [PATCH] fix(abstracttarget): retrieve sub itemtype from question --- inc/abstracttarget.class.php | 2 +- js/scripts.js | 38 ++++++++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/inc/abstracttarget.class.php b/inc/abstracttarget.class.php index 4d43a3b00..d0a889fef 100644 --- a/inc/abstracttarget.class.php +++ b/inc/abstracttarget.class.php @@ -696,7 +696,7 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF if ($question->isNewItem()) { continue 2; } - $itemtype = $question->fields['values']; + $itemtype = DropdownField::getSubItemtypeForValues($question->fields['values']); if (!is_subclass_of($itemtype, CommonDBTM::class)) { continue 2; } diff --git a/js/scripts.js b/js/scripts.js index 575740124..48f1d56e2 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -158,7 +158,7 @@ $(function() { if (searchInput.length == 1) { // Dynamically update forms and faq items while the user types in the search bar var timer = getTimer(searchInput); - if ($('#plugin_formcreator_kb_categories .category_active').length > 0) { + if ($('#plugin_formcreator_kb_categories').length > 0) { var callback = function() { updateKbitemsView(currentCategory); } @@ -174,13 +174,25 @@ $(function() { $('#plugin_formcreator_searchBar input').focus(function(event) { if (searchInput.val().length > 0) { searchInput.val(''); - updateWizardFormsView(currentCategory); - $.when(getFormAndFaqItems(0)).then( - function (response) { - tiles = response; - showTiles(tiles.forms); - } - ); + if ($('#plugin_formcreator_kb_categories').length > 0) { + updateKbitemsView(null); + $.when(getFaqItems(0)) + .then( + function (response) { + tiles = response; + showTiles(tiles.forms); + } + ); + } else { + updateWizardFormsView(null); + $.when(getFormAndFaqItems(0)) + .then( + function (response) { + tiles = response; + showTiles(tiles.forms); + } + ); + } } }); } @@ -285,7 +297,8 @@ function getFaqItems(categoryId) { data: { categoriesId: categoryId, keywords: keywords, - helpdeskHome: 0}, + helpdeskHome: 0 + }, dataType: "json" }).done(function (response) { deferred.resolve(response); @@ -304,7 +317,12 @@ function getFormAndFaqItems(categoryId) { var deferred = jQuery.Deferred(); $.post({ url: formcreatorRootDoc + '/ajax/homepage_wizard.php', - data: {wizard: 'forms', categoriesId: categoryId, keywords: keywords, helpdeskHome: 0}, + data: { + wizard: 'forms', + categoriesId: categoryId, + keywords: keywords, + helpdeskHome: 0 + }, dataType: "json" }).done(function (response) { deferred.resolve(response);