place button with color of category in front of title in select menu

This commit is contained in:
Uwe Steinmann 2023-02-22 10:00:31 +01:00
parent 9e6e13a041
commit 05c0f296fc
3 changed files with 6 additions and 1 deletions

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

@ -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;')+'';