mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-18 11:58:24 +01:00
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
This commit is contained in:
parent
3ebfe5d650
commit
5955705002
@ -619,16 +619,22 @@ class calendar_ui
|
|||||||
$owners = $this->owner ? is_array($this->owner) ? array($this->owner) : explode(',',$this->owner) : array($GLOBALS['egw_info']['user']['account_id']);
|
$owners = $this->owner ? is_array($this->owner) ? array($this->owner) : explode(',',$this->owner) : array($GLOBALS['egw_info']['user']['account_id']);
|
||||||
|
|
||||||
|
|
||||||
$sel_options = array();
|
$sel_options = array('owner' => array());
|
||||||
|
|
||||||
// Get user accounts, formatted nicely for grouping and matching
|
// Get user accounts, formatted nicely for grouping and matching
|
||||||
// the ajax call calendar_uiforms->ajax_owner()
|
// the ajax call calendar_uiforms->ajax_owner() - users first
|
||||||
$account_options = array('account_type' => 'both');
|
$accounts = array();
|
||||||
$accounts = accounts::link_query('',$account_options);
|
$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(
|
$sel_options['owner'] = array_map(
|
||||||
function($account_id, $account_name) {
|
function($account_id, $account_name) {
|
||||||
return array(
|
return array(
|
||||||
'value' => $account_id,
|
'value' => ''.$account_id,
|
||||||
'label' => $account_name,
|
'label' => $account_name,
|
||||||
'app' => lang('home-accounts')
|
'app' => lang('home-accounts')
|
||||||
);
|
);
|
||||||
@ -636,6 +642,7 @@ class calendar_ui
|
|||||||
array_keys($accounts), $accounts
|
array_keys($accounts), $accounts
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// Add external owners that a select account widget will not find
|
// Add external owners that a select account widget will not find
|
||||||
$linked_owners = array();
|
$linked_owners = array();
|
||||||
foreach($owners as &$owner)
|
foreach($owners as &$owner)
|
||||||
|
@ -2949,18 +2949,35 @@ class calendar_uiforms extends calendar_ui
|
|||||||
public function ajax_owner()
|
public function ajax_owner()
|
||||||
{
|
{
|
||||||
$query = $_REQUEST['query'];
|
$query = $_REQUEST['query'];
|
||||||
$options = ['num_rows' => 100];
|
// Arbitrarily limited to 50 / resource
|
||||||
|
$options = ['start' => 0, 'num_rows' => 50];
|
||||||
$results = [];
|
$results = [];
|
||||||
if($query)
|
if($query)
|
||||||
{
|
{
|
||||||
foreach($this->bo->resources as $type => $data)
|
$resources = array_merge(array('' => $this->bo->resources['']),$this->bo->resources);
|
||||||
|
foreach($resources as $type => $data)
|
||||||
{
|
{
|
||||||
$mapped = array();
|
$mapped = array();
|
||||||
if ($data['app'] && egw_link::get_registry($data['app'], 'query'))
|
$_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);
|
$_results = egw_link::query($data['app'], $query,$options);
|
||||||
|
}
|
||||||
if(!$_results) continue;
|
if(!$_results) continue;
|
||||||
$r_results = array_unique($_results);
|
$_results = array_unique($_results);
|
||||||
|
|
||||||
foreach($_results as $id => $title)
|
foreach($_results as $id => $title)
|
||||||
{
|
{
|
||||||
if($id && $title)
|
if($id && $title)
|
||||||
@ -2985,7 +3002,6 @@ class calendar_uiforms extends calendar_ui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// switch regular JSON response handling off
|
// switch regular JSON response handling off
|
||||||
egw_json_request::isJSONRequest(false);
|
egw_json_request::isJSONRequest(false);
|
||||||
|
|
||||||
|
@ -824,6 +824,7 @@ app.classes.calendar = AppJS.extend(
|
|||||||
swipe:function(event, direction, distance, duration, fingerCount) {
|
swipe:function(event, direction, distance, duration, fingerCount) {
|
||||||
if(direction == "up" || direction == "down")
|
if(direction == "up" || direction == "down")
|
||||||
{
|
{
|
||||||
|
if(fingerCount <= 1) return;
|
||||||
var at_bottom = direction !== -1;
|
var at_bottom = direction !== -1;
|
||||||
var at_top = direction !== 1;
|
var at_top = direction !== 1;
|
||||||
|
|
||||||
@ -834,7 +835,6 @@ app.classes.calendar = AppJS.extend(
|
|||||||
}).each(function() {
|
}).each(function() {
|
||||||
at_top = at_top && this.scrollTop === 0;
|
at_top = at_top && this.scrollTop === 0;
|
||||||
});
|
});
|
||||||
if(!at_bottom && !at_top && fingerCount == 1) return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var delta = direction == "down" || direction == "right" ? -1 : 1;
|
var delta = direction == "down" || direction == "right" ? -1 : 1;
|
||||||
|
@ -53,7 +53,41 @@ var et2_calendar_owner = et2_taglist_email.extend(
|
|||||||
// Allows sub-widgets to override options to the library
|
// Allows sub-widgets to override options to the library
|
||||||
lib_options: {
|
lib_options: {
|
||||||
groupBy: 'app',
|
groupBy: 'app',
|
||||||
expandOnFocus: true
|
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"]);
|
et2_register_widget(et2_calendar_owner, ["calendar_owner"]);
|
@ -1799,7 +1799,7 @@ var et2_calendar_timegrid = et2_calendar_view.extend([et2_IDetachedDOM, et2_IRes
|
|||||||
this.div.css('height', this.options.height);
|
this.div.css('height', this.options.height);
|
||||||
|
|
||||||
// Re-do time grid
|
// Re-do time grid
|
||||||
if(!this.update_timer)// && this.options.height != old_height)
|
if(!this.update_timer)
|
||||||
{
|
{
|
||||||
this.resizeTimes();
|
this.resizeTimes();
|
||||||
}
|
}
|
||||||
|
@ -278,10 +278,27 @@ var et2_taglist = et2_selectbox.extend(
|
|||||||
_data: function(query) {
|
_data: function(query) {
|
||||||
if(query.trim() ==='' || !this.options.autocomplete_url)
|
if(query.trim() ==='' || !this.options.autocomplete_url)
|
||||||
{
|
{
|
||||||
|
// No server - let magicsuggest handle options
|
||||||
return this.options.select_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
|
else
|
||||||
{
|
{
|
||||||
|
// No options - ask server
|
||||||
return this.options.autocomplete_url;
|
return this.options.autocomplete_url;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -364,8 +381,11 @@ var et2_taglist = et2_selectbox.extend(
|
|||||||
this.options.value = value;
|
this.options.value = value;
|
||||||
if(this.taglist == null) return;
|
if(this.taglist == null) return;
|
||||||
|
|
||||||
|
if(!value)
|
||||||
|
{
|
||||||
this.taglist.clear(true);
|
this.taglist.clear(true);
|
||||||
if(!value) return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var values = jQuery.isArray(value) ? jQuery.extend([],value) : [value];
|
var values = jQuery.isArray(value) ? jQuery.extend([],value) : [value];
|
||||||
var result = [];
|
var result = [];
|
||||||
@ -374,11 +394,16 @@ var et2_taglist = et2_selectbox.extend(
|
|||||||
var v = values[i];
|
var v = values[i];
|
||||||
if (v && typeof v == 'object' && typeof v.id != 'undefined' && typeof v.label != 'undefined')
|
if (v && typeof v == 'object' && typeof v.id != 'undefined' && typeof v.label != 'undefined')
|
||||||
{
|
{
|
||||||
// alread in correct format
|
// already in correct format
|
||||||
}
|
}
|
||||||
else if (this.options.select_options &&
|
else if (this.options.select_options &&
|
||||||
|
// Check options
|
||||||
(result = $j.grep(this.options.select_options, function(e) {
|
(result = $j.grep(this.options.select_options, function(e) {
|
||||||
return e.id == v;
|
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 @@ var et2_taglist = et2_selectbox.extend(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.taglist.addToSelection(values);
|
this.taglist.setSelection(values);
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue: function()
|
getValue: function()
|
||||||
|
Loading…
Reference in New Issue
Block a user