Skip to content

Commit

Permalink
fix(wizard): fix KB only browsing
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Apr 29, 2022
1 parent bdae85a commit de78b9e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
22 changes: 16 additions & 6 deletions inc/knowbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ public function showServiceCatalog() {
public function showWizard() {
echo '<div id="plugin_formcreator_kb_categories" class="card">';
echo '<div><h2 class="card-title">'._n("Category", "Categories", 2, 'formcreator').'</h2></div>';
echo '<div><a href="#" id="kb_seeall"><i class="fas fa-home"></i></a></div>';
echo '<div class="slinky-menu"></div>';
echo '<div><a href="#" id="wizard_seeall">' . __('See all', 'formcreator') . '</a></div>';
echo '</div>';

echo '<div id="plugin_formcreator_wizard_right" class="card">';
Expand Down Expand Up @@ -100,11 +101,20 @@ public static function getCategoryTree() {
[
'SELECT' => ['COUNT DISTINCT' => KnowbaseItem::getTableField('id') . ' as cpt'],
'FROM' => KnowbaseItem::getTable(),
'WHERE' => [
KnowbaseItem::getTableField($cat_fk) => new QueryExpression(
DB::quoteName(KnowbaseItemCategory::getTableField('id'))
),
]
'LEFT JOIN' => [
KnowbaseItem_KnowbaseItemCategory::getTable() => [
'FKEY' => [
KnowbaseItem::getTable() => 'id',
KnowbaseItem_KnowbaseItemCategory::getTable() => KnowbaseItem::getForeignKeyField(),
],
],
KnowbaseItemCategory::getTable() => [
'FKEY' => [
KnowbaseItem_KnowbaseItemCategory::getTable() => KnowbaseItemCategory::getForeignKeyField(),
KnowbaseItemCategory::getTable() => 'id',
],
],
],
],
$kbitem_visibility_crit
),
Expand Down
10 changes: 5 additions & 5 deletions js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ $(function() {
} else if ($('#plugin_formcreator_kb_categories').length > 0) {
updateKbCategoriesView();

$('#plugin_formcreator_kb_categories #kb_seeall').on('click', function (event) {
$('#plugin_formcreator_kb_categories #wizard_seeall').on('click', function (event) {
slinkyCategories.home();
plugin_formcreator.updateKbitemsView(event.target);
$('#plugin_formcreator_kb_categories .category_active').removeClass('category_active');
Expand Down Expand Up @@ -210,9 +210,9 @@ function updateKbCategoriesView() {
});
$('#plugin_formcreator_kb_categories a.back').on('click',
function(event) {
parentItem = $(event.target).parentsUntil('#plugin_formcreator_kb_categories > div', 'li')[1];
parentAnchor = $(parentItem).children('a')[0];
updateKbitemsView(parentAnchor.getAttribute('data-parent-category-id'));
var parentItem = $(event.target).parentsUntil('#plugin_formcreator_kb_categories .slinky-menu > ul', 'li')[1];
var parentAnchor = $(parentItem).children('a')[0];
plugin_formcreator.updateKbitemsView(parentAnchor);
}
);

Expand Down Expand Up @@ -314,7 +314,7 @@ function buildKbCategoryList(tree) {
if (tree.id != 0) {
html += '<a href="#" data-parent-category-id="' + tree.parent +'"'
+ ' data-category-id="' + tree.id + '"'
+ ' onclick="plugin_formcreator.updateWizardFormsView(this)">'
+ ' onclick="plugin_formcreator.updateKbitemsView(this)">'
+ tree.name
+ '</a>';
}
Expand Down

0 comments on commit de78b9e

Please sign in to comment.