Implement new nextmatch cat-filter including category colors

This commit is contained in:
Hadi Nategh 2016-07-07 15:44:55 +02:00
parent 5f7e13adaa
commit ea200604fb
4 changed files with 51 additions and 5 deletions

View File

@ -41,7 +41,7 @@ foreach($categories as $cat)
{
// Use slightly more specific selector that just class, to allow defaults
// if the category has no color
$content .= ".egwGridView_scrollarea tr.cat_{$cat['id']} > td:first-child {border-left-color: {$cat['data']['color']};} div.cat_{$cat['id']}, span.cat_{$cat['id']} { background-color: {$cat['data']['color']};} /*{$cat['name']}*/\n";
$content .= ".egwGridView_scrollarea tr.cat_{$cat['id']} > td:first-child, .select-cat li.cat_{$cat['id']}, .nextmatch_header_row .et2_selectbox.select-cat.cat_{$cat['id']} a.chzn-single {border-left-color: {$cat['data']['color']};} div.cat_{$cat['id']}, span.cat_{$cat['id']} { background-color: {$cat['data']['color']};} /*{$cat['name']}*/\n";
}
if (!empty($cat['data']['icon']))
{

View File

@ -2677,7 +2677,14 @@ var et2_nextmatch_header_bar = (function(){ "use strict"; return et2_DOMWidget.e
this.egw().debug('warn', 'Nextmatch filter options in a weird place - "%s". Should be in sel_options[%s].',row_id,name);
}
}
if (name == 'cat_id')
{
jQuery.extend(widget_options, {
multiple: false,
tags: true,
class: "select-cat"
});
}
// Legacy: Add in 'All' option for cat_id, if not provided.
if(name == 'cat_id' && options != null && (typeof options[''] == 'undefined' && typeof options[0] != 'undefined' && options[0].value != ''))
{

View File

@ -248,7 +248,10 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
var option = jQuery(document.createElement("option"))
.attr("value", _value)
.text(_label+"");
if (this.options.tags && this._type == 'select-cat')
{
option.addClass('cat_'+_value);
}
if (typeof _title != "undefined" && _title)
{
option.attr("title", _title);
@ -492,6 +495,16 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
// No options set yet
this.set_select_options(this.options.select_options);
}
// select-cat set/unset right cat_ color for selected value
if (this._type == 'select-cat' && this.options.tags) {
var chosen = this.input.siblings();
this.input.removeClass('cat_'+this._oldValue);
this.input.addClass('cat_'+this.value);
if (chosen.length > 0) {
chosen.removeClass('cat_'+this._oldValue);
chosen.addClass('cat_'+this.value);
}
}
this._oldValue = this.value;
if(this.input !== null && (this.options.tags || this.options.search))
{

View File

@ -1390,7 +1390,8 @@ div.message.floating {
.et2_nextmatch .egwGridView_outer thead tr > th:first-child {
border-left: 6px solid transparent;
}
.egwGridView_scrollarea tr.row_category > td:first-child {
.egwGridView_scrollarea tr.row_category > td:first-child,
.select-cat li{
border-left: 6px solid transparent;
}
.et2_nextmatch .egwGridView_grid, .et2_nextmatch .egwGridView_outer {
@ -2677,4 +2678,29 @@ tr.dialogHeader2 td {padding-top:15px;}
background-color: initial !important;
box-shadow: none !important;
cursor: default !important;
}
}
/*et2_selectbox select-cat chosen (cats selectbox with colors) */
.nextmatch_header_row .et2_selectbox.select-cat .chzn-single
{
border: none;
border-left: 6px solid transparent;
background: transparent;
box-shadow: none;
margin-top: 1px;
border-radius: 0;
}
.nextmatch_header_row .et2_selectbox.select-cat
{
padding-right: 3px !important;
-webkit-appearance: none;
height: 22px !important;
margin: 1px 4px 1px 0;
background-color: #fafafa;
border: 1px solid silver;
border-radius: 3px;
padding-left: 5px;
display: inline-block;
float: left;
min-height: 20px;
}