Debug topmenu search option

This commit is contained in:
Laurent Destailleur 2023-04-06 21:27:06 +02:00
parent 6fa9c8dea6
commit 8d75d7b466
7 changed files with 214 additions and 51 deletions

View File

@ -8377,18 +8377,18 @@ class Form
* Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter.
* Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice.
*
* @param string $htmlname Name of html select area
* @param array $array Array (key=>array('text'=>'A text', 'url'=>'An url'), ...)
* @param string $id Preselected key
* @param string $moreparam Add more parameters onto the select tag
* @param int $disableFiltering If set to 1, results are not filtered with searched string
* @param int $disabled Html select box is disabled
* @param int $minimumInputLength Minimum Input Length
* @param string $morecss Add more class to css styles
* @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected.
* @param string $placeholder String to use as placeholder
* @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
* @return string HTML select string
* @param string $htmlname Name of html select area
* @param array $array Array (key=>array('text'=>'A text', 'url'=>'An url'), ...)
* @param string $id Preselected key
* @param string $moreparam Add more parameters onto the select tag
* @param int $disableFiltering If set to 1, results are not filtered with searched string
* @param int $disabled Html select box is disabled
* @param int $minimumInputLength Minimum Input Length
* @param string $morecss Add more class to css styles
* @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected.
* @param string $placeholder String to use as placeholder
* @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect)
* @return string HTML select string
* @see selectArrayAjax(), ajax_combobox() in ajax.lib.php
*/
public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0)

View File

@ -199,9 +199,7 @@ Hide=Hide
ShowCardHere=Show card
Search=Search
SearchOf=Search
SearchMenuShortCut=Ctrl + shift + f
QuickAdd=Quick add
QuickAddMenuShortCut=Ctrl + shift + l
Valid=Valid
Approve=Approve
Disapprove=Disapprove

View File

@ -199,9 +199,7 @@ Hide=Cacher
ShowCardHere=Voir la fiche ici
Search=Rechercher
SearchOf=Recherche de
SearchMenuShortCut=Ctrl + Maj + f
QuickAdd=Création rapide
QuickAddMenuShortCut=Ctrl + Maj + l
Valid=Valider
Approve=Approuver
Disapprove=Désapprouver

View File

@ -2081,12 +2081,21 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
if ($_SESSION["dol_authmode"] != 'forceuser' && $_SESSION["dol_authmode"] != 'http') {
$logouthtmltext .= $langs->trans("Logout").'<br>';
$stringforfirstkey = $langs->trans("KeyboardShortcut");
if ($conf->browser->name == 'chrome') {
$stringforfirstkey .= ' ALT +';
} elseif ($conf->browser->name == 'firefox') {
$stringforfirstkey .= ' ALT + SHIFT +';
} else {
$stringforfirstkey .= ' CTL +';
}
$logouttext .= '<a accesskey="l" href="'.DOL_URL_ROOT.'/user/logout.php?token='.newToken().'">';
$logouttext .= img_picto($langs->trans('Logout'), 'sign-out', '', false, 0, 0, '', 'atoplogin valignmiddle');
$logouttext .= img_picto($langs->trans('Logout').' ('.$stringforfirstkey.' l)', 'sign-out', '', false, 0, 0, '', 'atoplogin valignmiddle');
$logouttext .= '</a>';
} else {
$logouthtmltext .= $langs->trans("NoLogoutProcessWithAuthMode", $_SESSION["dol_authmode"]);
$logouttext .= img_picto($langs->trans('Logout'), 'sign-out', '', false, 0, 0, '', 'atoplogin valignmiddle opacitymedium');
$logouttext .= img_picto($langs->trans('Logout').' ('.$stringforfirstkey.' l)', 'sign-out', '', false, 0, 0, '', 'atoplogin valignmiddle opacitymedium');
}
}
@ -2368,11 +2377,22 @@ function top_menu_user($hideloginname = 0, $urllogout = '')
$urllogout = DOL_URL_ROOT.'/user/logout.php?token='.newToken();
}
// accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox
// accesskey is for Mac: CTRL + key for all browsers
$stringforfirstkey = $langs->trans("KeyboardShortcut");
if ($conf->browser->name == 'chrome') {
$stringforfirstkey .= ' ALT +';
} elseif ($conf->browser->name == 'firefox') {
$stringforfirstkey .= ' ALT + SHIFT +';
} else {
$stringforfirstkey .= ' CTL +';
}
// Defined the links for bottom of card
$profilLink = '<a accesskey="c" href="'.DOL_URL_ROOT.'/user/card.php?id='.$user->id.'" class="button-top-menu-dropdown" title="'.dol_escape_htmltag($langs->trans("YourUserFile")).'"><i class="fa fa-user"></i> '.$langs->trans("Card").'</a>';
$profilLink = '<a accesskey="u" href="'.DOL_URL_ROOT.'/user/card.php?id='.$user->id.'" class="button-top-menu-dropdown" title="'.dol_escape_htmltag($langs->trans("YourUserFile").' ('.$stringforfirstkey.' u)').'"><i class="fa fa-user"></i> '.$langs->trans("Card").'</a>';
$urltovirtualcard = '/user/virtualcard.php?id='.((int) $user->id);
$virtuelcardLink = dolButtonToOpenUrlInDialogPopup('publicvirtualcardmenu', $langs->trans("PublicVirtualCardUrl").(is_object($user) ? ' - '.$user->getFullName($langs) : ''), img_picto($langs->trans("PublicVirtualCardUrl"), 'card', ''), $urltovirtualcard, '', 'button-top-menu-dropdown marginleftonly nohover', "closeTopMenuLoginDropdown()", '', 'v');
$logoutLink = '<a accesskey="l" href="'.$urllogout.'" class="button-top-menu-dropdown" title="'.dol_escape_htmltag($langs->trans("Logout")).'"><i class="fa fa-sign-out-alt padingright"></i><span class="hideonsmartphone">'.$langs->trans("Logout").'</span></a>';
$virtuelcardLink = dolButtonToOpenUrlInDialogPopup('publicvirtualcardmenu', $langs->trans("PublicVirtualCardUrl").(is_object($user) ? ' - '.$user->getFullName($langs) : '').' ('.$stringforfirstkey.' v)', img_picto($langs->trans("PublicVirtualCardUrl").' ('.$stringforfirstkey.' v)', 'card', ''), $urltovirtualcard, '', 'button-top-menu-dropdown marginleftonly nohover', "closeTopMenuLoginDropdown()", '', 'v');
$logoutLink = '<a accesskey="l" href="'.$urllogout.'" class="button-top-menu-dropdown" title="'.dol_escape_htmltag($langs->trans("Logout").' ('.$stringforfirstkey.' l)').'"><i class="fa fa-sign-out-alt padingright"></i><span class="hideonsmartphone">'.$langs->trans("Logout").'</span></a>';
$profilName = $user->getFullName($langs).' ('.$user->login.')';
if (!empty($user->admin)) {
@ -2525,9 +2545,20 @@ function top_menu_quickadd()
$html = '';
// accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox
// accesskey is for Mac: CTRL + key for all browsers
$stringforfirstkey = $langs->trans("KeyboardShortcut");
if ($conf->browser->name == 'chrome') {
$stringforfirstkey .= ' ALT +';
} elseif ($conf->browser->name == 'firefox') {
$stringforfirstkey .= ' ALT + SHIFT +';
} else {
$stringforfirstkey .= ' CTL +';
}
$html .= '<!-- div for quick add link -->
<div id="topmenu-quickadd-dropdown" class="atoplogin dropdown inline-block">
<a class="dropdown-toggle login-dropdown-a" data-toggle="dropdown" href="#" title="'.$langs->trans('QuickAdd').' ('.$langs->trans('QuickAddMenuShortCut').')"><i class="fa fa-plus-circle"></i></a>
<a accesskey="a" class="dropdown-toggle login-dropdown-a nofocusvisible" data-toggle="dropdown" href="#" title="'.$langs->trans('QuickAdd').' ('.$stringforfirstkey.' a)"><i class="fa fa-plus-circle"></i></a>
<div class="dropdown-menu">'.printDropdownQuickadd().'</div>
</div>';
$html .= '
@ -2544,6 +2575,7 @@ function top_menu_quickadd()
console.log("Click on #topmenu-quickadd-dropdown .dropdown-toggle");
openQuickAddDropDown();
});
// Key map shortcut
$(document).keydown(function(e){
if( e.which === 76 && e.ctrlKey && e.shiftKey ){
@ -2552,7 +2584,6 @@ function top_menu_quickadd()
}
});
var openQuickAddDropDown = function() {
event.preventDefault();
$("#topmenu-quickadd-dropdown").toggleClass("open");
@ -2759,6 +2790,17 @@ function top_menu_bookmark()
return $html;
}
// accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox
// accesskey is for Mac: CTRL + key for all browsers
$stringforfirstkey = $langs->trans("KeyboardShortcut");
if ($conf->browser->name == 'chrome') {
$stringforfirstkey .= ' ALT +';
} elseif ($conf->browser->name == 'firefox') {
$stringforfirstkey .= ' ALT + SHIFT +';
} else {
$stringforfirstkey .= ' CTL +';
}
if (!defined('JS_JQUERY_DISABLE_DROPDOWN') && !empty($conf->use_javascript_ajax)) { // This may be set by some pages that use different jquery version to avoid errors
include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php';
$langs->load("bookmarks");
@ -2770,7 +2812,7 @@ function top_menu_bookmark()
} else {
$html .= '<!-- div for bookmark link -->
<div id="topmenu-bookmark-dropdown" class="dropdown inline-block">
<a class="dropdown-toggle login-dropdown-a" data-toggle="dropdown" href="#" title="'.$langs->trans('Bookmarks').' ('.$langs->trans('BookmarksMenuShortCut').')"><i class="fa fa-star"></i></a>
<a accesskey="b" class="dropdown-toggle login-dropdown-a nofocusvisible" data-toggle="dropdown" href="#" title="'.$langs->trans('Bookmarks').' ('.$stringforfirstkey.' b)"><i class="fa fa-star"></i></a>
<div class="dropdown-menu">
'.printDropdownBookmarksList().'
</div>
@ -2831,6 +2873,8 @@ function top_menu_search()
$arrayresult = null;
include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This set $arrayresult
$searchInput = '<input name="search_all" id="top-global-search-input" class="dropdown-search-input search_component_input" placeholder="'.$langs->trans('Search').'" autocomplete="off">';
$defaultAction = '';
$buttonList = '<div class="dropdown-global-search-button-list" >';
// Menu with all searchable items
@ -2838,16 +2882,13 @@ function top_menu_search()
if (empty($defaultAction)) {
$defaultAction = $item['url'];
}
$buttonList .= '<button class="dropdown-item global-search-item" data-target="'.dol_escape_htmltag($item['url']).'" >';
$buttonList .= '<button class="dropdown-item global-search-item tdoverflowmax300" data-target="'.dol_escape_htmltag($item['url']).'" >';
$buttonList .= $item['text'];
$buttonList .= '</button>';
}
$buttonList .= '</div>';
$searchInput = '<input name="search_all" id="top-global-search-input" class="dropdown-search-input" placeholder="'.$langs->trans('Search').'" autocomplete="off" >';
$dropDownHtml = '<form id="top-menu-action-search" name="actionsearch" method="GET" action="'.$defaultAction.'" >';
$dropDownHtml = '<form id="top-menu-action-search" name="actionsearch" method="GET" action="'.$defaultAction.'">';
$dropDownHtml .= '
<!-- search input -->
@ -2865,10 +2906,20 @@ function top_menu_search()
$dropDownHtml .= '</form>';
// accesskey is for Windows or Linux: ALT + key for chrome, ALT + SHIFT + KEY for firefox
// accesskey is for Mac: CTRL + key for all browsers
$stringforfirstkey = $langs->trans("KeyboardShortcut");
if ($conf->browser->name == 'chrome') {
$stringforfirstkey .= ' ALT +';
} elseif ($conf->browser->name == 'firefox') {
$stringforfirstkey .= ' ALT + SHIFT +';
} else {
$stringforfirstkey .= ' CTL +';
}
$html .= '<!-- div for Global Search -->
<div id="topmenu-global-search-dropdown" class="atoplogin dropdown inline-block">
<a class="dropdown-toggle login-dropdown-a" data-toggle="dropdown" href="#" title="'.$langs->trans('Search').' ('.$langs->trans('SearchMenuShortCut').')">
<a accesskey="s" class="dropdown-toggle login-dropdown-a nofocusvisible" data-toggle="dropdown" href="#" title="'.$langs->trans('Search').' ('.$stringforfirstkey.' s)">
<i class="fa fa-search" ></i>
</a>
<div class="dropdown-menu dropdown-search">
@ -3004,11 +3055,11 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_
include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This make initHooks('searchform') then set $arrayresult
if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) {
$searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, '', 1, 0, (empty($conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY) ? 1 : 0), 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1);
$searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, 'accesskey="s"', 1, 0, (empty($conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY) ? 1 : 0), 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1);
} else {
if (is_array($arrayresult)) {
foreach ($arrayresult as $key => $val) {
$searchform .= printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', (empty($val['shortcut']) ? '' : $val['shortcut']), 'searchleft'.$key, $val['img']);
$searchform .= printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'search_all', (empty($val['shortcut']) ? '' : $val['shortcut']), 'searchleft'.$key, $val['img']);
}
}
}
@ -3022,7 +3073,7 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_
$searchform = $hookmanager->resPrint;
}
// Force special value for $searchform
// Force special value for $searchform for text browsers or very old search form
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) || empty($conf->use_javascript_ajax)) {
$urltosearch = DOL_URL_ROOT.'/core/search_page.php?showtitlebefore=1';
$searchform = '<div class="blockvmenuimpair blockvmenusearchphone"><div id="divsearchforms1"><a href="'.$urltosearch.'" accesskey="s" alt="'.dol_escape_htmltag($langs->trans("ShowSearchFields")).'">'.$langs->trans("Search").'...</a></div></div>';

View File

@ -123,10 +123,10 @@ button.dropdown-item.global-search-item {
/* CSS to hide the arrow to show open/close */
div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown {
div#topmenu-global-search-dropdown, div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown {
padding-right: 5px;
}
div#topmenu-quickadd-dropdown a::after, div#topmenu-bookmark-dropdown a::after {
div#topmenu-global-search-dropdown a::after, div#topmenu-quickadd-dropdown a::after, div#topmenu-bookmark-dropdown a::after {
display: none;
}
@ -290,7 +290,7 @@ a.top-menu-dropdown-link {
}
#topmenu-login-dropdown, #topmenu-bookmark-dropdown, #topmenu-global-search-dropdown {
#topmenu-login-dropdown, #topmenu-quickadd-dropdown, #topmenu-bookmark-dropdown, #topmenu-global-search-dropdown {
padding: 0 5px 0 5px;
}
#topmenu-login-dropdown a:hover{
@ -396,15 +396,15 @@ a.dropdown-item {
content: "\f35d";
}
.dropdown-item.active, .dropdown-item:hover, .dropdown-item:hover span::before, .dropdown-item:focus {
.dropdown-item.active, .dropdown-item:hover, .dropdown-item:hover span::before, .dropdown-item:focus, .dropdown-item:focus span::before {
color: #<?php echo $colortextbackhmenu; ?> !important;
text-decoration: none;
background: rgb(<?php echo $colorbackhmenu1 ?>);
}
/*
* SEARCH
*/
* SEARCH
*/
.dropdown-search-input {
width: 100%;
@ -436,9 +436,30 @@ a.dropdown-item {
display: none !important;
}
.search-dropdown-body {
padding: unset;
}
.global-search-item {
font-size: 1em;
padding-top: 6px;
padding-bottom: 6px;
}
.global-search-item:before {
content: none;
}
.global-search-header {
color: #444 !important;
}
/*
* QUICK ADD
*/
#topmenu-quickadd-dropdown .dropdown-menu {
width: 310px !important;
color: #444;
@ -449,6 +470,7 @@ a.dropdown-item {
}
.quickadd-item {
font-size: 1em;
padding-top: 6px;
padding-bottom: 6px;
}

View File

@ -21,9 +21,15 @@ button.dropdown-item.global-search-item {
}
#topmenu-quickadd-dropdown a.login-dropdown-a, #topmenu-bookmark-dropdown a.login-dropdown-a {
#topmenu-global-search-dropdown a.login-dropdown-a, #topmenu-quickadd-dropdown a.login-dropdown-a, #topmenu-bookmark-dropdown a.login-dropdown-a {
color: #fff;
}
div#topmenu-global-search-dropdown {
position: fixed;
<?php echo $right; ?>: 90px;
top: 0px;
}
div#topmenu-quickadd-dropdown {
position: fixed;
<?php echo $right; ?>: 55px;
@ -40,7 +46,7 @@ div#topmenu-bookmark-dropdown {
display: none;
}
#topmenu-quickadd-dropdown .dropdown-menu, #topmenu-bookmark-dropdown .dropdown-menu {
#topmenu-global-search-dropdown .dropdown-menu, #topmenu-quickadd-dropdown .dropdown-menu, #topmenu-bookmark-dropdown .dropdown-menu {
min-width: 300px;
max-width: 360px;
}
@ -125,10 +131,10 @@ button.dropdown-item.global-search-item {
/* CSS to hide the arrow to show open/close */
div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown {
div#topmenu-global-search-dropdown, , div#topmenu-quickadd-dropdown, div#topmenu-bookmark-dropdown {
padding-right: 2px;
}
div#topmenu-quickadd-dropdown a::after, div#topmenu-bookmark-dropdown a::after {
div#topmenu-global-search-dropdown a::after, div#topmenu-quickadd-dropdown a::after, div#topmenu-bookmark-dropdown a::after {
display: none;
}
@ -162,8 +168,9 @@ div#topmenu-quickadd-dropdown a::after, div#topmenu-bookmark-dropdown a::after {
}
/*
* MENU Dropdown
*/
* MENU Dropdown
*/
.login_block.usedropdown .logout-btn{
/* display: none; */
}
@ -400,15 +407,15 @@ a.dropdown-item {
content: "\f35d";
}
.dropdown-item.active, .dropdown-item:hover, .dropdown-item:hover::before, .dropdown-item:hover span::before, .dropdown-item:focus {
.dropdown-item.active, .dropdown-item:hover, .dropdown-item:hover::before, .dropdown-item:hover span::before, .dropdown-item:focus, .dropdown-item:focus span::before {
color: #<?php echo $colortextbackhmenu; ?> !important;
text-decoration: none;
background: rgb(<?php echo $colorbackhmenu1 ?>);
}
/*
* SEARCH
*/
* SEARCH
*/
.dropdown-search-input {
width: 100%;
@ -434,6 +441,92 @@ a.dropdown-item {
}
.search-dropdown-body {
padding: unset;
}
.global-search-item {
font-size: 1em;
padding-top: 6px;
padding-bottom: 6px;
}
.global-search-item:before {
content: none;
}
.global-search-header {
color: #444 !important;
}
/*
* QUICK ADD
*/
#topmenu-quickadd-dropdown .dropdown-menu {
width: 310px !important;
color: #444;
}
.quickadd-body.dropdown-body {
padding: unset;
}
.quickadd-item {
font-size: 1em;
padding-top: 6px;
padding-bottom: 6px;
}
.quickadd-item:before {
content: none;
}
.quickadd-header {
color: #444 !important;
}
div.quickadd {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
}
div.quickadd a {
color: #444;
}
div.quickadd a:hover, div.quickadd a:active {
color: #000000;
}
div.quickaddblock {
width: 95px;
height: 80px;
}
div.quickaddblock:hover,
div.quickaddblock:active,
div.quickaddblock:focus {
background: <?php print $colorbacklinepair1; ?>;
}
/* for the dropdown on action buttons */
dropdown-holder {
@ -491,6 +584,7 @@ dropdown-holder {
width: 230px;
}
div#topmenu-global-search-dropdown,
div#topmenu-quickadd-dropdown,
div#topmenu-bookmark-dropdown {
position: unset;

View File

@ -2239,7 +2239,7 @@ td.showDragHandle {
if (in_array($conf->browser->layout, array('phone', 'tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
} else { ?>
position: fixed;
top: 50px;
top: 75px;
<?php } ?>
z-index: 90;
-webkit-transform: translateZ(0);
@ -2366,7 +2366,7 @@ div.backgroundsemitransparent {
z-index: 91;
background: var(--colorbackvmenu1);
border-right: 1px solid rgba(0,0,0,0.3);
padding-top: 20px;
/* padding-top: 20px; */
<?php
if (in_array($conf->browser->layout, array('phone', 'tablet')) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { ?>
top: 66px ! important;
@ -3430,7 +3430,7 @@ a.vsmenu.addbookmarkpicto {
}
div.blockvmenufirst {
padding-top: 10px;
/* border-top: 1px solid #e0e0e0; */
border-top: 1px solid #e0e0e0;
}
div.blockvmenusearch, div.blockvmenubookmarks
{