Skip to content

Commit

Permalink
feat(wizard): separate faqs and forms
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Aug 22, 2019
1 parent 309e7e4 commit a08541f
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 20 deletions.
1 change: 1 addition & 0 deletions inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ public function showFormList($rootCategory = 0, $keywords = '', $helpdeskHome =
'contains' => $keywords
]) . ') AS `faqs`');
$query_faqs = [
'SELECT' => ['faqs' => '*'],
'FROM' => $query_faqs,
];
if (count($selectedCategories) > 0) {
Expand Down
61 changes: 41 additions & 20 deletions js/scripts.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ function showTiles(tiles, defaultForms) {
$('#plugin_formcreator_formlist').masonry({
horizontalOrder: true
});
$('#plugin_formcreator_faqlist').masonry({
horizontalOrder: true
});
}

function updateWizardFormsView(categoryId) {
Expand All @@ -324,6 +327,9 @@ function () {
$('#plugin_formcreator_formlist').masonry({
horizontalOrder: true
});
$('#plugin_formcreator_faqlist').masonry({
horizontalOrder: true
});
}
);
}
Expand Down Expand Up @@ -357,47 +363,62 @@ function buildTiles(list) {
if (list.length == 0) {
html = '<p id="plugin_formcreator_formlist">'
+ "<?php echo Toolbox::addslashes_deep(__('No form yet in this category', 'formcreator')) ?>"
+ '</p>';
+ '</p>'
+'<p id="plugin_formcreator_faqlist"></p>';
} else {
var items = [];
$.each(list, function (key, form) {
var forms = [];
var faqs = [];
$.each(list, function (key, item) {
// Build a HTML tile
if (form.type == 'form') {
url = rootDoc + '/plugins/formcreator/front/formdisplay.php?id=' + form.id;
if (item.type == 'form') {
url = rootDoc + '/plugins/formcreator/front/formdisplay.php?id=' + item.id;
} else {
if (serviceCatalogEnabled) {
url = rootDoc + '/plugins/formcreator/front/knowbaseitem.form.php?id=' + form.id;
url = rootDoc + '/plugins/formcreator/front/knowbaseitem.form.php?id=' + item.id;
} else {
url = rootDoc + '/front/knowbaseitem.form.php?id=' + form.id;
url = rootDoc + '/front/knowbaseitem.form.php?id=' + item.id;
}
}

description = '';
if (form.description) {
if (item.description) {
description = '<div class="plugin_formcreator_formTile_description">'
+form.description
+item.description
+'</div>';
}

var default_class = '';
if (JSON.parse(form.is_default)) {
if (JSON.parse(item.is_default)) {
default_class = 'default_form';
}

items.push(
'<div class="plugin_formcreator_formTile '+form.type+' '+default_class+'" title="'+form.description+'">'
+ '<a href="' + url + '" class="plugin_formcreator_formTile_title">'
+ form.name
+ '</a>'
+ description
+ '</div>'
);
if (item.type == 'form') {
forms.push(
'<div class="plugin_formcreator_formTile '+item.type+' '+default_class+'" title="'+item.description+'">'
+ '<a href="' + url + '" class="plugin_formcreator_formTile_title">'
+ item.name
+ '</a>'
+ description
+ '</div>'
);
} else {
faqs.push(
'<div class="plugin_formcreator_formTile '+item.type+' '+default_class+'" title="'+item.description+'">'
+ '<a href="' + url + '" class="plugin_formcreator_formTile_title">'
+ item.name
+ '</a>'
+ description
+ '</div>'
);
}
});

// concatenate all HTML parts
html = '<div id="plugin_formcreator_formlist">'
+ items.join("")
+ '</div>';
+ forms.join("")
+ '</div><div id="plugin_formcreator_faqlist">'
+ faqs.join("")
+ '</div>'
}

return html;
Expand Down

0 comments on commit a08541f

Please sign in to comment.