From b61858169256056e77a508e6de9543c7f39439be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 18 Feb 2020 09:37:59 +0100 Subject: [PATCH] More ajax button in setup. Can reload after on ajaxonoff. --- htdocs/admin/ihm.php | 1 - htdocs/core/js/lib_head.js.php | 14 ++++++++++++-- htdocs/core/lib/ajax.lib.php | 17 +++++++++-------- htdocs/core/lib/usergroups.lib.php | 6 ++++-- htdocs/main.inc.php | 7 ++++--- htdocs/theme/eldy/global.inc.php | 3 +++ 6 files changed, 32 insertions(+), 16 deletions(-) diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 3a9eed62fd0..de550c0ac12 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -248,7 +248,6 @@ print ''; // Multilingual GUI print ''.$langs->trans("EnableMultilangInterface").''; -//print $form->selectyesno('MAIN_MULTILANGS', $conf->global->MAIN_MULTILANGS, 1); print ajax_constantonoff('MAIN_MULTILANGS'); print ''; print ' '; diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 103e3df3c5b..9f8fda42d61 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -523,14 +523,16 @@ function hideMessage(fieldId,message) { * @param string intput Input * @param int entity Entity * @param int strict Strict + * @param int forcereload Force reload */ -function setConstant(url, code, input, entity, strict) { +function setConstant(url, code, input, entity, strict, forcereload) { $.get( url, { action: "set", name: code, entity: entity }, function() { + console.log("url request success forcereload="+forcereload); $("#set_" + code).hide(); $("#del_" + code).show(); $.each(input, function(type, data) { @@ -576,6 +578,9 @@ function setConstant(url, code, input, entity, strict) { }); } }); + if (forcereload) { + location.reload(); + } }); } @@ -587,14 +592,16 @@ function setConstant(url, code, input, entity, strict) { * @param string intput Input * @param int entity Entity * @param int strict Strict + * @param int forcereload Force reload */ -function delConstant(url, code, input, entity, strict) { +function delConstant(url, code, input, entity, strict, forcereload) { $.get( url, { action: "del", name: code, entity: entity }, function() { + console.log("url request success forcereload="+forcereload); $("#del_" + code).hide(); $("#set_" + code).show(); $.each(input, function(type, data) { @@ -636,6 +643,9 @@ function delConstant(url, code, input, entity, strict) { }); } }); + if (forcereload) { + location.reload(); + } }); } diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index d2626414ba6..ef76f426e4b 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -473,14 +473,15 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete = /** * On/off button for constant * - * @param string $code Name of constant - * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) - * @param int $entity Entity to set - * @param int $revertonoff Revert on/off - * @param bool $strict Use only "disabled" with delConstant and "enabled" with setConstant + * @param string $code Name of constant + * @param array $input Array of options. ("disabled"|"enabled'|'set'|'del') => CSS element to switch, 'alert' => message to show, ... Example: array('disabled'=>array(0=>'cssid')) + * @param int $entity Entity to set + * @param int $revertonoff Revert on/off + * @param bool $strict Use only "disabled" with delConstant and "enabled" with setConstant + * @param int $forcereload Force to reload page if we click/change value (this is supported only when there is no 'alert' option in input) * @return string */ -function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0) +function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcereload = 0) { global $conf, $langs; @@ -511,7 +512,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof if (input.alert.set.noButton) noButton = input.alert.set.noButton; confirmConstantAction("set", url, code, input, input.alert.set, entity, yesButton, noButton, strict); } else { - setConstant(url, code, input, entity); + setConstant(url, code, input, entity, 0, '.$forcereload.'); } }); @@ -522,7 +523,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof if (input.alert.del.noButton) noButton = input.alert.del.noButton; confirmConstantAction("del", url, code, input, input.alert.del, entity, yesButton, noButton, strict); } else { - delConstant(url, code, input, entity); + delConstant(url, code, input, entity, 0, '.$forcereload.'); } }); }); diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 709832118c2..a234f4ed5e0 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -448,7 +448,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''.$langs->trans("EnableShowLogo").''; if ($edit) { - print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1); + print ajax_constantonoff('MAIN_SHOW_LOGO', array(), null, 0, 0, 1); + //print $form->selectyesno('MAIN_SHOW_LOGO', $conf->global->MAIN_SHOW_LOGO, 1); } else { @@ -494,7 +495,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false) print ''; if ($edit) { - print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1); + print ajax_constantonoff('THEME_TOPMENU_DISABLE_IMAGE', array(), null, 0, 0, 1); + //print $form->selectyesno('THEME_TOPMENU_DISABLE_IMAGE', $conf->global->THEME_TOPMENU_DISABLE_IMAGE, 1); } else { diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 815674a5b76..738b8b6ec18 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1715,8 +1715,8 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead if ($helpbaseurl && $helppage) { $text = ''; - $title .= $langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage'); - if ($mode == 'wiki') $title .= ' - '.$langs->trans("PageWiki").' "'.dol_escape_htmltag(strtr($helppage, '_', ' ')).'"'; + $title = $langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage'); + if ($mode == 'wiki') $title .= ' - '.$langs->trans("PageWiki").' "'.dol_escape_htmltag(strtr($helppage, '_', ' ')).'"'.""; $text .= 'database_name; } - $text = ''.DOL_VERSION.''; + $text = ''.DOL_VERSION.''; $toprightmenu .= @Form::textwithtooltip('', $appli, 2, 1, $text, 'login_block_elem', 2); } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 2761b697ed7..f76a58d6f50 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -2105,6 +2105,9 @@ div.login_block a { color: #; display: inline-block; } +div.login_block span.aversion { + color: #888; +} div.login_block table { display: inline; }