Skip to content

Commit

Permalink
fix: show menu when width is low
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Mar 10, 2021
1 parent daa7fb0 commit 9ec53fa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
26 changes: 24 additions & 2 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,30 @@ function plugin_formcreator_dynamicReport($params) {


function plugin_formcreator_redefine_menus($menus) {
if (isset($menus['tickets'])) {
unset($menus['tickets']);
if (!Session::getCurrentInterface() == "helpdesk") {
return $menus;
}

if (PluginFormcreatorEntityconfig::getUsedConfig(
'replace_helpdesk',
$_SESSION['glpiactive_entity']
)) {
if (isset($menus['tickets'])) {
unset($menus['tickets']);
}
} else {
$newMenus = [];
foreach ($menus as $key => $menu) {
$newMenus[$key] = $menu;
if ($key == 'create_ticket') {
$newMenus['forms'] = [
'default' => '/' . Plugin::getWebDir('formcreator', false) . '/front/formlist.php',
'title' => _n('Form', 'Forms', 2, 'formcreator'),
'content' => [0 => true]
];
}
}
$menus = $newMenus;
}

return $menus;
Expand Down
15 changes: 0 additions & 15 deletions js/scripts.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ function(event) {
}
}

// === MENU ===
var link = '';
link += '<li id="menu7">';
link += '<a href="' + formcreatorRootDoc + '/front/formlist.php" class="itemP">';
link += "<?php echo Toolbox::addslashes_deep(_n('Form', 'Forms', 2, 'formcreator')); ?>";
link += '</a>';
link += '</li>';

$(function() {
var target = $('body');
modalWindow = $("<div></div>").dialog({
Expand Down Expand Up @@ -108,13 +100,6 @@ function(event) {
}
});

<?php
if (Session::getCurrentInterface() == 'helpdesk'
&& PluginFormcreatorForm::countAvailableForm() > 0) {
echo "$('#c_menu #menu1:first-child').after(link);";
}
?>

if (location.pathname.indexOf("helpdesk.public.php") != -1) {

$('.ui-tabs-panel:visible').ready(function() {
Expand Down
9 changes: 1 addition & 8 deletions setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,7 @@ function plugin_init_formcreator() {

Plugin::registerClass(PluginFormcreatorEntityconfig::class, ['addtabon' => Entity::class]);

if (Session::getCurrentInterface() == "helpdesk"
&& PluginFormcreatorEntityconfig::getUsedConfig(
'replace_helpdesk',
$_SESSION['glpiactive_entity']
)
) {
$PLUGIN_HOOKS['redefine_menus']['formcreator'] = "plugin_formcreator_redefine_menus";
}
$PLUGIN_HOOKS['redefine_menus']['formcreator'] = "plugin_formcreator_redefine_menus";
}

// Load JS and CSS files if we are on a page which need them
Expand Down

0 comments on commit 9ec53fa

Please sign in to comment.