From 040ee0253fbc7a2b7fb764c6e5d60fbe0558a745 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Thu, 10 Mar 2016 17:44:51 +0000 Subject: [PATCH] Taglist fixes: - Fix toggle multiple got stuck with single value - Fix keyboard navigation --- .../class.etemplate_widget_taglist.inc.php | 6 +++- etemplate/js/et2_widget_taglist.js | 29 ++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_taglist.inc.php b/etemplate/inc/class.etemplate_widget_taglist.inc.php index 535f374b1b..c5623c5153 100644 --- a/etemplate/inc/class.etemplate_widget_taglist.inc.php +++ b/etemplate/inc/class.etemplate_widget_taglist.inc.php @@ -107,7 +107,7 @@ class etemplate_widget_taglist extends etemplate_widget foreach((array) $value as $key => $val) { - if(!$this->attrs['allowFreeEntries'] && !array_key_exists($val,$allowed)) + if(count($allowed) && !$this->attrs['allowFreeEntries'] && !array_key_exists($val,$allowed)) { self::set_validation_error($form_name,lang("'%1' is NOT allowed ('%2')!",$val,implode("','",array_keys($allowed))),''); unset($value[$key]); @@ -132,6 +132,10 @@ class etemplate_widget_taglist extends etemplate_widget { self::set_validation_error($form_name,lang('Field must not be empty !!!',$value),''); } + if($this->attrs['multiple'] == false) + { + $value = array_shift($value); + } $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 diff --git a/etemplate/js/et2_widget_taglist.js b/etemplate/js/et2_widget_taglist.js index 31be528628..bd4be71ac2 100644 --- a/etemplate/js/et2_widget_taglist.js +++ b/etemplate/js/et2_widget_taglist.js @@ -277,6 +277,20 @@ var et2_taglist = (function(){ "use strict"; return et2_selectbox.extend([et2_IR $j('.egw_tooltip').hide(); widget.div.addClass('ui-state-active'); }) + // If not using autoSelect, avoid some errors with selection starting + // with the group + .on('load expand', function() { + if(widget.taglist && widget.taglist_options.groupBy) + { + window.setTimeout(function() { + if(widget && widget.taglist.combobox) + { + widget.taglist.combobox.find('.ms-res-group.ms-res-item-active') + .removeClass('ms-res-item-active'); + } + },1); + } + }) // Position absolute to break out of containers .on('expand', jQuery.proxy(function(c) { var taglist = this.taglist; @@ -714,11 +728,14 @@ var et2_taglist = (function(){ "use strict"; return et2_selectbox.extend([et2_IR if(this.taglist == null) return; - // Switch to multiple if allowed and more than 1 value - var multiple = this.options.multiple ? values.length > 1 : false; - if(multiple !== this._multiple) + // Switch multiple according to attribute and more than 1 value + if(this.options.multiple !== true) { - this._set_multiple(multiple); + var multiple = this.options.multiple ? values.length > 1 : false; + if(multiple !== this._multiple) + { + this._set_multiple(multiple); + } } this.taglist.clear(true); @@ -785,8 +802,7 @@ var et2_taglist_account = (function(){ "use strict"; return et2_taglist.extend( }, }, lib_options: { - minChars: 2, - toggleOnClick: true + minChars: 2 }, init:function () @@ -1082,7 +1098,6 @@ var et2_taglist_category = (function(){ "use strict"; return et2_taglist.extend( } }, lib_options: { - toggleOnClick: true }, init: function() {