mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
Change filterheaders to extend taglist instead of select
This commit is contained in:
parent
108860e4af
commit
457e05d920
@ -26,8 +26,9 @@
|
||||
// Include all widgets the nextmatch extension will create
|
||||
et2_widget_template;
|
||||
et2_widget_grid;
|
||||
et2_widget_selectbox;
|
||||
et2_widget_selectAccount;
|
||||
et2_widget_taglist;
|
||||
et2_widget_taglist_account;
|
||||
et2_widget_link;
|
||||
et2_extension_customfields;
|
||||
|
||||
// Include all nextmatch subclasses
|
||||
@ -3250,10 +3251,30 @@ var et2_nextmatch_sortheader = (function(){ "use strict"; return et2_nextmatch_h
|
||||
et2_register_widget(et2_nextmatch_sortheader, ['nextmatch-sortheader']);
|
||||
|
||||
/**
|
||||
* @augments et2_selectbox
|
||||
* @augments et2_taglist
|
||||
*/
|
||||
var et2_nextmatch_filterheader = (function(){ "use strict"; return et2_selectbox.extend([et2_INextmatchHeader, et2_IResizeable],
|
||||
var et2_nextmatch_filterheader = (function(){ "use strict"; return et2_taglist.extend([et2_INextmatchHeader, et2_IResizeable],
|
||||
{
|
||||
attributes: {
|
||||
autocomplete_url: { default: ''},
|
||||
multiple: { default: 'toggle'},
|
||||
onchange: {
|
||||
default: function(event) {
|
||||
if(typeof this.nextmatch === 'undefined')
|
||||
{
|
||||
// Not fully set up yet
|
||||
return;
|
||||
}
|
||||
var col_filter = {};
|
||||
col_filter[this.id] = this.getValue();
|
||||
// Set value so it's there for response (otherwise it gets cleared if options are updated)
|
||||
//event.data.set_value(event.data.input.val());
|
||||
|
||||
this.nextmatch.applyFilters({col_filter: col_filter});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Override to add change handler
|
||||
*
|
||||
@ -3266,21 +3287,6 @@ var et2_nextmatch_filterheader = (function(){ "use strict"; return et2_selectbox
|
||||
this.options.empty_label = this.options.label ? this.options.label : egw.lang("All");
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
this.input.change(this, function(event) {
|
||||
if(typeof event.data.nextmatch == 'undefined')
|
||||
{
|
||||
// Not fully set up yet
|
||||
return;
|
||||
}
|
||||
var col_filter = {};
|
||||
col_filter[event.data.id] = event.data.input.val();
|
||||
// Set value so it's there for response (otherwise it gets cleared if options are updated)
|
||||
event.data.set_value(event.data.input.val());
|
||||
|
||||
event.data.nextmatch.applyFilters({col_filter: col_filter});
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
@ -3313,8 +3319,33 @@ et2_register_widget(et2_nextmatch_filterheader, ['nextmatch-filterheader']);
|
||||
/**
|
||||
* @augments et2_selectAccount
|
||||
*/
|
||||
var et2_nextmatch_accountfilterheader = (function(){ "use strict"; return et2_selectAccount.extend([et2_INextmatchHeader, et2_IResizeable],
|
||||
var et2_nextmatch_accountfilterheader = (function(){ "use strict"; return et2_taglist_account.extend([et2_INextmatchHeader, et2_IResizeable],
|
||||
{
|
||||
attributes: {
|
||||
"multiple": {
|
||||
default: 'toggle'
|
||||
},
|
||||
onchange: {
|
||||
default: function(event) {
|
||||
if(typeof this.nextmatch === 'undefined')
|
||||
{
|
||||
// Not fully set up yet
|
||||
return;
|
||||
}
|
||||
var col_filter = {};
|
||||
col_filter[this.id] = this.getValue();
|
||||
if(!col_filter[this.id] || col_filter[this.id].length == 0)
|
||||
{
|
||||
col_filter[this.id] = null;
|
||||
}
|
||||
// Set value so it's there for response (otherwise it gets cleared if options are updated)
|
||||
//event.data.set_value(event.data.input.val());
|
||||
|
||||
this.nextmatch.applyFilters({col_filter: col_filter});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Override to add change handler
|
||||
*
|
||||
@ -3327,18 +3358,6 @@ var et2_nextmatch_accountfilterheader = (function(){ "use strict"; return et2_se
|
||||
this.options.empty_label = this.options.label ? this.options.label : egw.lang("All");
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
this.input.change(this, function(event) {
|
||||
if(typeof event.data.nextmatch == 'undefined')
|
||||
{
|
||||
// Not fully set up yet
|
||||
return;
|
||||
}
|
||||
var col_filter = {};
|
||||
col_filter[event.data.id] = event.data.getValue();
|
||||
event.data.nextmatch.applyFilters({col_filter: col_filter});
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -310,6 +310,14 @@ class Nextmatch extends Etemplate\Widget
|
||||
$template->run('validate', array('', $expand, $expand['cont'], &$valid_filters), false); // $respect_disabled=false: as client may disable things, here we validate everything and leave it to the get_rows to interpret
|
||||
$filters = $valid_filters[$form_name];
|
||||
}
|
||||
// Avoid empty arrays, they cause problems with db filtering
|
||||
foreach($filters['col_filter'] as $col => &$val)
|
||||
{
|
||||
if(is_array($val) && count($val) == 0)
|
||||
{
|
||||
$val = null;
|
||||
}
|
||||
}
|
||||
//error_log($this . " Valid filters: " . array2string($filters));
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ use EGroupware\Api\Etemplate\Widget;
|
||||
/**
|
||||
* Extend selectbox and change type so proper users / groups get loaded, according to preferences
|
||||
*/
|
||||
class Accountfilter extends Widget\Select
|
||||
class Accountfilter extends Widget\Taglist
|
||||
{
|
||||
/**
|
||||
* Parse and set extra attributes from xml in template object
|
||||
|
@ -59,5 +59,24 @@ class Customfilter extends Widget\Transformer
|
||||
}
|
||||
parent::beforeSendToClient($cname, $expand);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate input
|
||||
*
|
||||
* @param string $cname current namespace
|
||||
* @param array $expand values for keys 'c', 'row', 'c_', 'row_', 'cont'
|
||||
* @param array $content
|
||||
* @param array &$validated=array() validated content
|
||||
*/
|
||||
public function validate($cname, array $expand, array $content, &$validated=array())
|
||||
{
|
||||
$value = $value_in = self::get_array($content, $form_name);
|
||||
|
||||
$valid =& self::get_array($validated, $form_name, true);
|
||||
// returning null instead of array(), as array() will be overwritten by etemplate_new::complete_array_merge()
|
||||
// with preserved old content and therefore user can not empty a taglist
|
||||
$valid = $value ? $value : null;
|
||||
}
|
||||
}
|
||||
Customfilter::registerWidget(__NAMESPACE__.'\\Customfilter', array('nextmatch-customfilter'));
|
@ -18,7 +18,7 @@ use EGroupware\Api\Etemplate\Widget;
|
||||
/**
|
||||
* Extend selectbox so select options get parsed properly before being sent to client
|
||||
*/
|
||||
class Filterheader extends Widget\Select
|
||||
class Filterheader extends Widget\Taglist
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1049,6 +1049,7 @@ ul.et2_link_string {
|
||||
}
|
||||
/* Toggle single / multiple */
|
||||
.et2_taglist_toggle {
|
||||
position: relative;
|
||||
}
|
||||
.et2_taglist_toggle > div.ms-ctn {
|
||||
display: inline-block;
|
||||
|
Loading…
Reference in New Issue
Block a user