Skip to content

Commit eccf3d1

Browse files
committed
fix(abstracttarget): retrieve sub itemtype from question
1 parent 8086121 commit eccf3d1

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

inc/abstracttarget.class.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ protected function prepareActors(PluginFormcreatorForm $form, PluginFormcreatorF
696696
if ($question->isNewItem()) {
697697
continue 2;
698698
}
699-
$itemtype = $question->fields['values'];
699+
$itemtype = DropdownField::getSubItemtypeForValues($question->fields['values']);
700700
if (!is_subclass_of($itemtype, CommonDBTM::class)) {
701701
continue 2;
702702
}

js/scripts.js

+28-10
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ $(function() {
158158
if (searchInput.length == 1) {
159159
// Dynamically update forms and faq items while the user types in the search bar
160160
var timer = getTimer(searchInput);
161-
if ($('#plugin_formcreator_kb_categories .category_active').length > 0) {
161+
if ($('#plugin_formcreator_kb_categories').length > 0) {
162162
var callback = function() {
163163
updateKbitemsView(currentCategory);
164164
}
@@ -174,13 +174,25 @@ $(function() {
174174
$('#plugin_formcreator_searchBar input').focus(function(event) {
175175
if (searchInput.val().length > 0) {
176176
searchInput.val('');
177-
updateWizardFormsView(currentCategory);
178-
$.when(getFormAndFaqItems(0)).then(
179-
function (response) {
180-
tiles = response;
181-
showTiles(tiles.forms);
182-
}
183-
);
177+
if ($('#plugin_formcreator_kb_categories').length > 0) {
178+
updateKbitemsView(null);
179+
$.when(getFaqItems(0))
180+
.then(
181+
function (response) {
182+
tiles = response;
183+
showTiles(tiles.forms);
184+
}
185+
);
186+
} else {
187+
updateWizardFormsView(null);
188+
$.when(getFormAndFaqItems(0))
189+
.then(
190+
function (response) {
191+
tiles = response;
192+
showTiles(tiles.forms);
193+
}
194+
);
195+
}
184196
}
185197
});
186198
}
@@ -285,7 +297,8 @@ function getFaqItems(categoryId) {
285297
data: {
286298
categoriesId: categoryId,
287299
keywords: keywords,
288-
helpdeskHome: 0},
300+
helpdeskHome: 0
301+
},
289302
dataType: "json"
290303
}).done(function (response) {
291304
deferred.resolve(response);
@@ -304,7 +317,12 @@ function getFormAndFaqItems(categoryId) {
304317
var deferred = jQuery.Deferred();
305318
$.post({
306319
url: formcreatorRootDoc + '/ajax/homepage_wizard.php',
307-
data: {wizard: 'forms', categoriesId: categoryId, keywords: keywords, helpdeskHome: 0},
320+
data: {
321+
wizard: 'forms',
322+
categoriesId: categoryId,
323+
keywords: keywords,
324+
helpdeskHome: 0
325+
},
308326
dataType: "json"
309327
}).done(function (response) {
310328
deferred.resolve(response);

0 commit comments

Comments
 (0)