Skip to content

Commit de78b9e

Browse files
committed
fix(wizard): fix KB only browsing
1 parent bdae85a commit de78b9e

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

inc/knowbase.class.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public function showServiceCatalog() {
5858
public function showWizard() {
5959
echo '<div id="plugin_formcreator_kb_categories" class="card">';
6060
echo '<div><h2 class="card-title">'._n("Category", "Categories", 2, 'formcreator').'</h2></div>';
61-
echo '<div><a href="#" id="kb_seeall"><i class="fas fa-home"></i></a></div>';
61+
echo '<div class="slinky-menu"></div>';
62+
echo '<div><a href="#" id="wizard_seeall">' . __('See all', 'formcreator') . '</a></div>';
6263
echo '</div>';
6364

6465
echo '<div id="plugin_formcreator_wizard_right" class="card">';
@@ -100,11 +101,20 @@ public static function getCategoryTree() {
100101
[
101102
'SELECT' => ['COUNT DISTINCT' => KnowbaseItem::getTableField('id') . ' as cpt'],
102103
'FROM' => KnowbaseItem::getTable(),
103-
'WHERE' => [
104-
KnowbaseItem::getTableField($cat_fk) => new QueryExpression(
105-
DB::quoteName(KnowbaseItemCategory::getTableField('id'))
106-
),
107-
]
104+
'LEFT JOIN' => [
105+
KnowbaseItem_KnowbaseItemCategory::getTable() => [
106+
'FKEY' => [
107+
KnowbaseItem::getTable() => 'id',
108+
KnowbaseItem_KnowbaseItemCategory::getTable() => KnowbaseItem::getForeignKeyField(),
109+
],
110+
],
111+
KnowbaseItemCategory::getTable() => [
112+
'FKEY' => [
113+
KnowbaseItem_KnowbaseItemCategory::getTable() => KnowbaseItemCategory::getForeignKeyField(),
114+
KnowbaseItemCategory::getTable() => 'id',
115+
],
116+
],
117+
],
108118
],
109119
$kbitem_visibility_crit
110120
),

js/scripts.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ $(function() {
9999
} else if ($('#plugin_formcreator_kb_categories').length > 0) {
100100
updateKbCategoriesView();
101101

102-
$('#plugin_formcreator_kb_categories #kb_seeall').on('click', function (event) {
102+
$('#plugin_formcreator_kb_categories #wizard_seeall').on('click', function (event) {
103103
slinkyCategories.home();
104104
plugin_formcreator.updateKbitemsView(event.target);
105105
$('#plugin_formcreator_kb_categories .category_active').removeClass('category_active');
@@ -210,9 +210,9 @@ function updateKbCategoriesView() {
210210
});
211211
$('#plugin_formcreator_kb_categories a.back').on('click',
212212
function(event) {
213-
parentItem = $(event.target).parentsUntil('#plugin_formcreator_kb_categories > div', 'li')[1];
214-
parentAnchor = $(parentItem).children('a')[0];
215-
updateKbitemsView(parentAnchor.getAttribute('data-parent-category-id'));
213+
var parentItem = $(event.target).parentsUntil('#plugin_formcreator_kb_categories .slinky-menu > ul', 'li')[1];
214+
var parentAnchor = $(parentItem).children('a')[0];
215+
plugin_formcreator.updateKbitemsView(parentAnchor);
216216
}
217217
);
218218

@@ -314,7 +314,7 @@ function buildKbCategoryList(tree) {
314314
if (tree.id != 0) {
315315
html += '<a href="#" data-parent-category-id="' + tree.parent +'"'
316316
+ ' data-category-id="' + tree.id + '"'
317-
+ ' onclick="plugin_formcreator.updateWizardFormsView(this)">'
317+
+ ' onclick="plugin_formcreator.updateKbitemsView(this)">'
318318
+ tree.name
319319
+ '</a>';
320320
}

0 commit comments

Comments
 (0)