Author: nathangray
New Revision: 54991
URL: http://svn.stylite.de/viewvc/egroupware?rev=54991&view=rev
Log:
Owner widget changes:
- Now returns results with users, then groups, then other apps
- If a result is found in the static options, the server is not queried
- 2 character limit before searching
- Change event fires on blur, not change in selection
Modified:
trunk/calendar/inc/class.calendar_ui.inc.php
trunk/calendar/inc/class.calendar_uiforms.inc.php
trunk/calendar/js/app.js
trunk/calendar/js/et2_widget_owner.js
trunk/calendar/js/et2_widget_timegrid.js
trunk/etemplate/js/et2_widget_taglist.js
— trunk/calendar/inc/class.calendar_ui.inc.php (original)
+++ trunk/calendar/inc/class.calendar_ui.inc.php Thu Feb 11 21:30:55 2016
@@ -619,22 +619,29 @@
$owners = $this->owner ? is_array($this->owner) ? array($this->owner) : explode(’,’,$this->owner) : array($GLOBALS[‘egw_info’][‘user’][‘account_id’]);
-
// the ajax call calendar_uiforms->ajax_owner()
-
$account_options = array('account_type' => 'both');
-
$accounts = accounts::link_query('',$account_options);
-
// the ajax call calendar_uiforms->ajax_owner() - users first
-
$accounts = array();
-
$list = array('accounts', 'owngroups');
-
foreach($list as $type)
-
{
-
$account_options = array('account_type' => $type);
-
$accounts += accounts::link_query('',$account_options);
-
}
-
$accounts = array_intersect_key($accounts, $GLOBALS['egw']->acl->get_grants('calendar'));
$sel_options['owner'] = array_map(
function($account_id, $account_name) {
return array(
-
'value' => ''.$account_id,
'label' => $account_name,
'app' => lang('home-accounts')
);
},
array_keys($accounts), $accounts
);
-
// Add external owners that a select account widget will not find
$linked_owners = array();
— trunk/calendar/inc/class.calendar_uiforms.inc.php (original)
+++ trunk/calendar/inc/class.calendar_uiforms.inc.php Thu Feb 11 21:30:55 2016
@@ -2949,40 +2949,56 @@
public function ajax_owner()
{
$query = $_REQUEST[‘query’];
-
// Arbitrarily limited to 50 / resource
-
$options = ['start' => 0, 'num_rows' => 50];
$results = [];
if($query)
{
-
$resources = array_merge(array('' => $this->bo->resources['']),$this->bo->resources);
-
foreach($resources as $type => $data)
{
$mapped = array();
-
$_results = array();
-
-
// Handle accounts seperately
-
if($type == '')
-
{
-
$list = array('accounts', 'owngroups');
-
foreach($list as $a_type)
-
{
-
$account_options = $options + array('account_type' => $a_type);
-
$_results += accounts::link_query('',$account_options);
-
}
-
$_results = array_intersect_key($_results, $GLOBALS['egw']->acl->get_grants('calendar'));
-
}
-
else if ($data['app'] && egw_link::get_registry($data['app'], 'query'))
{
$_results = egw_link::query($data['app'], $query,$options);
-
}
-
if(!$_results) continue;
-
$_results = array_unique($_results);
-
-
foreach($_results as $id => $title)
-
{
-
if($id && $title)
-
{
-
// Magicsuggest uses id, not value.
-
$value = [
-
'id' => $type.$id,
-
'value'=> $type.$id,
-
'label' => $title,
-
'app' => lang($data['app'])
-
];
-
if(is_array($value['label']))
{
-
// Magicsuggest uses id, not value.
-
$value = [
-
'id' => $type.$id,
-
'value'=> $type.$id,
-
'label' => $title,
-
'app' => lang($data['app'])
-
];
-
if(is_array($value['label']))
-
{
-
$value = array_merge($value, $value['label']);
-
}
-
$mapped[] = $value;
— trunk/calendar/js/app.js (original)
+++ trunk/calendar/js/app.js Thu Feb 11 21:30:55 2016
@@ -824,6 +824,7 @@
swipe:function(event, direction, distance, duration, fingerCount) {
if(direction == “up” || direction == “down”)
{
@@ -834,7 +835,6 @@
}).each(function() {
at_top = at_top && this.scrollTop === 0;
});
— trunk/calendar/js/et2_widget_owner.js (original)
+++ trunk/calendar/js/et2_widget_owner.js Thu Feb 11 21:30:55 2016
@@ -53,7 +53,41 @@
// Allows sub-widgets to override options to the library
lib_options: {
groupBy: ‘app’,
-
minChars: 2,
-
// This option will also expand when the selection is changed
-
// via code, which we do not want
-
//expandOnFocus: true
-
toggleOnClick: true
- },
-
-
- doLoadingFinished: function() {
-
this._super.apply(this, arguments);
-
-
var widget = this;
-
// onChange fired when losing focus, which is different from normal
-
this._oldValue = this.taglist.getValue();
-
$j(this.taglist)
-
.off("selectionchange");
-
// .on('focus', function() {debugger; widget.taglist.expand();});
-
-
if(this.options.onchange && typeof this.onchange === 'function')
-
{
-
$j(this.taglist).on("blur", function() {
-
if(widget._oldValue.toString() !== widget.taglist.getValue().toString())
-
{
-
widget.onchange.call(widget, arguments);
-
}
-
widget._oldValue = widget.taglist.getValue();
-
});
-
}
-
return true;
- },
-
- getValue: function()
- {
-
if(this.taglist == null) return null;
-
return this.taglist.getValue();
}
});
et2_register_widget(et2_calendar_owner, [“calendar_owner”]);
— trunk/calendar/js/et2_widget_timegrid.js (original)
+++ trunk/calendar/js/et2_widget_timegrid.js Thu Feb 11 21:30:55 2016
@@ -1799,7 +1799,7 @@
this.div.css(‘height’, this.options.height);
// Re-do time grid
— trunk/etemplate/js/et2_widget_taglist.js (original)
+++ trunk/etemplate/js/et2_widget_taglist.js Thu Feb 11 21:30:55 2016
@@ -278,10 +278,27 @@
_data: function(query) {
if(query.trim() ===’’ || !this.options.autocomplete_url)
{
-
// No server - let magicsuggest handle options
return this.options.select_options;
}
-
if (!jQuery.isEmptyObject(this.options.select_options))
-
{
-
// Check options, if there's a match there (that is not already
-
// selected), do not ask server
-
var filtered = []
-
var selected = this.taglist.getSelection();
-
$j.each(this.options.select_options, function(index, obj) {
-
var name = obj.label;
-
if(selected.indexOf(obj) < 0 && name.toLowerCase().indexOf(query.toLowerCase()) > -1)
-
{
-
filtered.push(obj);
-
}
-
});
-
return filtered.length > 0 ? filtered : this.options.autocomplete_url
-
}
else
{
-
// No options - ask server
return this.options.autocomplete_url;
}
},
@@ -364,8 +381,11 @@
this.options.value = value;
if(this.taglist == null) return;
-
if(!value)
-
{
-
this.taglist.clear(true);
-
return;
-
}
var values = jQuery.isArray(value) ? jQuery.extend([],value) : [value];
var result = [];
@@ -374,10 +394,15 @@
var v = values[i];
if (v && typeof v == ‘object’ && typeof v.id != ‘undefined’ && typeof v.label != ‘undefined’)
{
-
// already in correct format
}
else if (this.options.select_options &&
-
// Check options
(result = $j.grep(this.options.select_options, function(e) {
-
return e.id == v;
-
})) ||
-
// Check current selection to avoid going back to server
-
(result = $j.grep(this.taglist.getSelection(), function(e) {
return e.id == v;
}))
)
@@ -405,7 +430,7 @@
}
}
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs