Merge branch 'seeddms-5.1.x' into seeddms-6.0.x

This commit is contained in:
Uwe Steinmann 2023-02-22 10:11:37 +01:00
commit cb1cb46cfe
7 changed files with 23 additions and 5 deletions

View File

@ -254,6 +254,7 @@
- conversion from pdf to png replaces alpha channel with white
- add list of conversion services in debug menu of admin tool
- use chosen select for custom attributes
- color category (use first 6 chars of md5(category name) as hex color)
--------------------------------------------------------------------------------
Changes in version 5.1.29

View File

@ -357,4 +357,12 @@ class SeedDMS_View_Common {
}
echo "};\n";
} /* }}} */
public static function getContrastColor($hexcolor) { /* {{{ */
$r = hexdec(substr($hexcolor, 1, 2));
$g = hexdec(substr($hexcolor, 3, 2));
$b = hexdec(substr($hexcolor, 5, 2));
$yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
return ($yiq >= 148) ? '000000' : 'ffffff';
} /* }}} */
}

View File

@ -3291,8 +3291,10 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
}
if($categories = $document->getCategories()) {
$content .= "<br />";
foreach($categories as $category)
$content .= "<span class=\"badge bg-secondary\">".$category->getName()."</span> ";
foreach($categories as $category) {
$color = substr(md5($category->getName()), 0, 6);
$content .= "<span class=\"badge\" style=\"background-color: #".$color."; color: #".self::getContrastColor($color).";\">".$category->getName()."</span> ";
}
}
if(!empty($extracontent['bottom_title']))
$content .= $extracontent['bottom_title'];

View File

@ -150,7 +150,8 @@ $(document).ready( function() {
$options[] = array("-1", getMLText("choose_category"));
$options[] = array("0", getMLText("new_document_category"));
foreach ($categories as $category) {
$options[] = array($category->getID(), htmlspecialchars($category->getName()), $selcat && $category->getID()==$selcat->getID(), array(array('data-subtitle', $category->countDocumentsByCategory().' '.getMLText('documents'))));
$color = substr(md5($category->getName()), 0, 6);
$options[] = array($category->getID(), htmlspecialchars($category->getName()), $selcat && $category->getID()==$selcat->getID(), array(array('data-before-title', "<i class='fa fa-circle' style='color: #".$color.";'></i> "), array('data-subtitle', $category->countDocumentsByCategory().' '.getMLText('documents'))));
}
$this->formField(
null, //getMLText("selection"),

View File

@ -12,6 +12,8 @@ chzn_template_func = function (state) {
if($(state.element).data('warning'))
warning = $(state.element).data('warning')+''; /* make sure it is a string */
var html = '<span>';
if($(state.element).data('before-title'))
html += $(state.element).data('before-title')+'';
if($(state.element).data('icon-before'))
html += '<i class="fa fa-'+$(state.element).data('icon-before')+'"></i> ';
html += state.text.replace(/</g, '&lt;')+'';

View File

@ -3287,8 +3287,10 @@ $('body').on('click', '[id^=\"table-row-folder\"] td:nth-child(2)', function(ev)
}
if($categories = $document->getCategories()) {
$content .= "<br />";
foreach($categories as $category)
$content .= "<span class=\"badge bg-secondary\">".$category->getName()."</span> ";
foreach($categories as $category) {
$color = substr(md5($category->getName()), 0, 6);
$content .= "<span class=\"badge\" style=\"background-color: #".$color."; color: #".self::getContrastColor($color).";\">".$category->getName()."</span> ";
}
}
if(!empty($extracontent['bottom_title']))
$content .= $extracontent['bottom_title'];

View File

@ -12,6 +12,8 @@ chzn_template_func = function (state) {
if($(state.element).data('warning'))
warning = $(state.element).data('warning')+''; /* make sure it is a string */
var html = '<span>';
if($(state.element).data('before-title'))
html += $(state.element).data('before-title')+'';
if($(state.element).data('icon-before'))
html += '<i class="fa fa-'+$(state.element).data('icon-before')+'"></i> ';
html += state.text.replace(/</g, '&lt;')+'';