2
0
forked from Wavyzz/dolibarr

More ajax button in setup. Can reload after on ajaxonoff.

This commit is contained in:
Laurent Destailleur
2020-02-18 09:37:59 +01:00
parent 1d760f0e42
commit b618581692
6 changed files with 32 additions and 16 deletions

View File

@@ -248,7 +248,6 @@ print '</tr>';
// Multilingual GUI
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableMultilangInterface").'</td><td>';
//print $form->selectyesno('MAIN_MULTILANGS', $conf->global->MAIN_MULTILANGS, 1);
print ajax_constantonoff('MAIN_MULTILANGS');
print '</td>';
print '<td width="20">&nbsp;</td>';

View File

@@ -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();
}
});
}

View File

@@ -474,13 +474,14 @@ 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 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.');
}
});
});

View File

@@ -448,7 +448,8 @@ function showSkins($fuser, $edit = 0, $foruserprofile = false)
print '<tr class="oddeven"><td class="titlefield">'.$langs->trans("EnableShowLogo").'</td><td>';
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 '<td colspan="'.($colspan - 1).'">';
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
{

View File

@@ -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").' &quot;'.dol_escape_htmltag(strtr($helppage, '_', ' ')).'&quot;';
$title = $langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage');
if ($mode == 'wiki') $title .= ' - '.$langs->trans("PageWiki").' &quot;'.dol_escape_htmltag(strtr($helppage, '_', ' ')).'&quot;'."";
$text .= '<a class="help" target="_blank" rel="noopener" href="';
if ($mode == 'wiki') $text .= sprintf($helpbaseurl, urlencode(html_entity_decode($helppage)));
else $text .= sprintf($helpbaseurl, $helppage);
@@ -1726,11 +1726,12 @@ function top_menu($head, $title = '', $target = '', $disablejs = 0, $disablehead
$toprightmenu .= @Form::textwithtooltip('', $title, 2, 1, $text, 'login_block_elem', 2);
}
// Version
if (!empty($conf->global->MAIN_SHOWDATABASENAMEINHELPPAGESLINK)) {
$langs->load('admin');
$appli .= '<br>'.$langs->trans("Database").': '.$db->database_name;
}
$text = '<a href="#" class="aversion"><span class="hideonsmartphone small">'.DOL_VERSION.'</span></a>';
$text = '<span href="#" class="aversion"><span class="hideonsmartphone small">'.DOL_VERSION.'</span></span>';
$toprightmenu .= @Form::textwithtooltip('', $appli, 2, 1, $text, 'login_block_elem', 2);
}

View File

@@ -2105,6 +2105,9 @@ div.login_block a {
color: #<?php echo $colortextbackhmenu; ?>;
display: inline-block;
}
div.login_block span.aversion {
color: #888;
}
div.login_block table {
display: inline;
}