2
0
forked from Wavyzz/dolibarr

Debug method MAIN_STATUS_USES_CSS

This commit is contained in:
Laurent Destailleur
2019-10-23 17:31:54 +02:00
parent a8ca8c7a1f
commit f4545a2068
4 changed files with 114 additions and 64 deletions

View File

@@ -8094,7 +8094,7 @@ function roundUpToNextMultiple($n, $x = 5)
function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = '', $params = array())
{
$attr=array(
'class'=>'badge'.(!empty($mode)?' badge-'.$mode:'').(!empty($type)?' badge-'.$type:'')
'class'=>'badge badge-status'.(!empty($mode)?' badge-'.$mode:'').(!empty($type)?' badge-'.$type:'')
);
if(empty($html)){
@@ -8155,13 +8155,35 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
global $conf;
$return = '';
$dolGetBadgeParams = array();
if(!empty($params['badgeParams'])){
if (!empty($params['badgeParams'])){
$dolGetBadgeParams = $params['badgeParams'];
}
// image's filename are still in French
// TODO : add a hook
if ($displayMode == 0) {
$return = !empty($html)?$html:$statusLabel;
}
elseif ($displayMode == 1) {
$return = !empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel);
}
// use status with images
elseif (empty($conf->global->MAIN_STATUS_USES_CSS)) {
$return = '';
$htmlLabel = (in_array($displayMode, array(1,2,5))?'<span class="hideonsmartphone">':'').(!empty($html)?$html:$statusLabel).(in_array($displayMode, array(1,2,5))?'</span>':'');
$htmlLabelShort = (in_array($displayMode, array(1,2,5))?'<span class="hideonsmartphone">':'').(!empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel)).(in_array($displayMode, array(1,2,5))?'</span>':'');
// For small screen, we use the short label instead of long label.
if (! empty($conf->dol_optimize_smallscreen))
{
if ($displayMode == 0) $displayMode = 1;
elseif ($displayMode == 4) $displayMode = 2;
elseif ($displayMode == 6) $displayMode = 5;
}
// image's filename are still in French, so we use this array to convert
$statusImg=array(
'status0' => 'statut0'
,'status1' => 'statut1'
@@ -8175,21 +8197,7 @@ function dolGetStatus($statusLabel = '', $statusLabelShort = '', $html = '', $st
,'status9' => 'statut9'
);
// TODO : add a hook
if ($displayMode == 0) {
$return = !empty($html)?$html:$statusLabel;
}
elseif ($displayMode == 1) {
$return = !empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel);
}
// use status with images
elseif (empty($conf->global->MAIN_STATUS_USES_CSS)){
$return = '';
$htmlLabel = (in_array($displayMode, array(1,2,5))?'<span class="hideonsmartphone">':'').(!empty($html)?$html:$statusLabel).(in_array($displayMode, array(1,2,5))?'</span>':'');
$htmlLabelShort = (in_array($displayMode, array(1,2,5))?'<span class="hideonsmartphone">':'').(!empty($html)?$html:(!empty($statusLabelShort)?$statusLabelShort:$statusLabel)).(in_array($displayMode, array(1,2,5))?'</span>':'');
if(!empty($statusImg[$statusType])){
if (!empty($statusImg[$statusType])){
$htmlImg = img_picto($statusLabel, $statusImg[$statusType]);
}else{
$htmlImg = img_picto($statusLabel, $statusType);

View File

@@ -22,6 +22,11 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
box-sizing: border-box;
}
.badge-status {
font-size: 1em;
padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */
}
.badge-pill, .tabs .badge {
padding-right: .5em;
padding-left: .5em;
@@ -31,7 +36,7 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
.badge-dot {
padding: 0;
border-radius: 50%;
padding: 0.25rem;
padding: 0.45em;
vertical-align: middle;
}
@@ -168,9 +173,10 @@ a.badge-dark:focus, a.badge-dark:hover {
background-color: <?php print colorDarker($badgeDark, 10); ?>;
}
/*
* STATUS BADGES
*/
* STATUS BADGES
*/
<?php for ($i = 0; $i <= 9; $i++){
/* Default Status */
_createStatusBadgeCss($i, '', "STATUS".$i);
@@ -180,7 +186,8 @@ a.badge-dark:focus, a.badge-dark:hover {
}
/**
* create status badge
* Create status badge
*
* @param string $statusName name of status
* @param string $statusVarNamePrefix a prefix for var ${$statusVarNamePrefix.'badgeStatus'.$statusName}
* @param string $commentLabel a comment label
@@ -200,7 +207,6 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL
$TBadgeBorderOnly = array(0, 3, 5, 7);
$thisBadgeTextColor = colorIsLight(${$statusVarNamePrefix . 'badgeStatus' . $statusName}) ? '#212529' : '#ffffff';
if (!empty(${$statusVarNamePrefix . 'badgeStatus_textColor' . $statusName})) {
$thisBadgeTextColor = ${$statusVarNamePrefix . 'badgeStatus_textColor' . $statusName};
}
@@ -210,6 +216,9 @@ function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentL
$thisBadgeBackgroundColor = "#fff";
}
if (in_array($statusName, array(0, 5, 9))) $thisBadgeTextColor = '#999999';
if (in_array($statusName, array(6))) $thisBadgeTextColor = '#777777';
print $cssPrefix . ".badge-status" . $statusName . " {\n";
print " color: " . $thisBadgeTextColor . " !important;\n";

View File

@@ -21,7 +21,11 @@ if (! defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?>
border-color: rgba(255,255,255,0);
box-sizing: border-box;
}
/* Themes for badges */
.badge-status {
font-size: 1em;
padding: .19em .35em; /* more than 0.19 generate a change into heigth of lines */
}
.badge-pill, .tabs .badge {
padding-right: .5em;
@@ -158,46 +162,74 @@ a.badge-dark:focus, a.badge-dark:hover {
background-color: <?php print colorDarker($badgeDark, 10); ?>;
}
/*
* STATUS BADGES
*/
/* Default Status */
* STATUS BADGES
*/
<?php for ($i = 0; $i <= 9; $i++){
print "\n/* STATUS".$i." */\n";
/* Default Status */
_createStatusBadgeCss($i, '', "STATUS".$i);
$thisBadgeBackgroundColor = $thisBadgeBorderColor = ${'badgeStatus'.$i};
// create status for accessibility
_createStatusBadgeCss($i, 'colorblind_deuteranopes_', "COLORBLIND STATUS".$i, 'body[class*="colorblind-"] ');
}
/**
* Create status badge
*
* @param string $statusName name of status
* @param string $statusVarNamePrefix a prefix for var ${$statusVarNamePrefix.'badgeStatus'.$statusName}
* @param string $commentLabel a comment label
* @param string $cssPrefix a css prefix
* @return void
*/
function _createStatusBadgeCss($statusName, $statusVarNamePrefix = '', $commentLabel = '', $cssPrefix = '')
{
global ${$statusVarNamePrefix.'badgeStatus'.$statusName}, ${$statusVarNamePrefix.'badgeStatus_textColor'.$statusName};
if(!empty(${$statusVarNamePrefix.'badgeStatus'.$statusName})) {
print "\n/* " . strtoupper($commentLabel) . " */\n";
$thisBadgeBackgroundColor = $thisBadgeBorderColor = ${$statusVarNamePrefix . 'badgeStatus' . $statusName};
$TBadgeBorderOnly = array(0,3,5,7);
$thisBadgeTextColor = colorIsLight(${'badgeStatus'.$i})?'#212529':'#ffffff';
if(in_array($i, $TBadgeBorderOnly)){
$TBadgeBorderOnly = array(0, 3, 5, 7);
$thisBadgeTextColor = colorIsLight(${$statusVarNamePrefix . 'badgeStatus' . $statusName}) ? '#212529' : '#ffffff';
if (!empty(${$statusVarNamePrefix . 'badgeStatus_textColor' . $statusName})) {
$thisBadgeTextColor = ${$statusVarNamePrefix . 'badgeStatus_textColor' . $statusName};
}
if (in_array($statusName, $TBadgeBorderOnly)) {
$thisBadgeTextColor = '#212529';
$thisBadgeBackgroundColor = "#fff";
}
print ".badge-status".$i." {\n";
print " color: ".$thisBadgeTextColor." !important;\n";
if (in_array($statusName, array(0, 5, 9))) $thisBadgeTextColor = '#999999';
if (in_array($statusName, array(6))) $thisBadgeTextColor = '#777777';
if(in_array($i, $TBadgeBorderOnly)){
print " border-color: ".$thisBadgeBorderColor.";\n";
print $cssPrefix . ".badge-status" . $statusName . " {\n";
print " color: " . $thisBadgeTextColor . " !important;\n";
if (in_array($statusName, $TBadgeBorderOnly)) {
print " border-color: " . $thisBadgeBorderColor . ";\n";
}
print " background-color: ".$thisBadgeBackgroundColor.";\n";
print " background-color: " . $thisBadgeBackgroundColor . ";\n";
print "}\n";
print ".badge-status".$i.".focus, .badge-status".$i.":focus {\n";
print $cssPrefix . ".badge-status" . $statusName . ".focus, " . $cssPrefix . ".badge-status" . $statusName . ":focus {\n";
print " outline: 0;\n";
print " box-shadow: 0 0 0 0.2rem ".colorHexToRgb($thisBadgeBackgroundColor, 0.5).";\n";
print " box-shadow: 0 0 0 0.2rem " . colorHexToRgb($thisBadgeBackgroundColor, 0.5) . ";\n";
print "}\n";
print ".badge-status".$i.":focus, .badge-status".$i.":hover {\n";
print " color: ".$thisBadgeTextColor." !important;\n";
print " background-color: ".colorDarker($thisBadgeBackgroundColor, 10).";\n";
if(in_array($i, $TBadgeBorderOnly)){
print " border-color: ".colorDarker($thisBadgeBorderColor, 10).";\n";
print $cssPrefix . ".badge-status" . $statusName . ":focus, " . $cssPrefix . ".badge-status" . $statusName . ":hover {\n";
print " color: " . $thisBadgeTextColor . " !important;\n";
print " background-color: " . colorDarker($thisBadgeBackgroundColor, 10) . ";\n";
if (in_array($statusName, $TBadgeBorderOnly)) {
print " border-color: " . colorDarker($thisBadgeBorderColor, 10) . ";\n";
}
print "}\n";
}
}

View File

@@ -1506,7 +1506,8 @@ table.noborder tr.liste_titre td {
padding-<?php echo $left; ?>: 3px;
}
.pictowarning {
vertical-align: text-bottom;
/* vertical-align: text-bottom; */
color: #9f4705;
}
.pictomodule {
width: 14px;