document categorie may have a color

This commit is contained in:
Uwe Steinmann 2021-05-13 16:15:06 +02:00
parent 0192e0c288
commit 04d3251ef4
3 changed files with 15 additions and 4 deletions

View File

@ -108,6 +108,10 @@ else if ($action == "editcategory") {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
$color = $_POST["color"];
if (!$category->setColor($color)) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_edit_category')));
add_log_line(".php&action=editcategory&categoryid=".$categoryid);
}

View File

@ -120,6 +120,15 @@ $(document).ready( function() {
'value'=>($category ? htmlspecialchars($category->getName()) : '')
)
);
$this->formField(
getMLText("color"),
array(
'element'=>'input',
'type'=>'text',
'name'=>'color',
'value'=>($category ? htmlspecialchars($category->getColor()) : '')
)
);
$this->contentContainerEnd();
$this->formSubmit("<i class=\"fa fa-save\"></i> ".getMLText('save'));
?>

View File

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