mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
Pass current selectbox value so the server can make sure it's there
This commit is contained in:
parent
f1837813a4
commit
dde1a5e51d
@ -831,11 +831,12 @@ class etemplate_widget_menupopup extends etemplate_widget
|
|||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @param Array|String $attributes
|
* @param Array|String $attributes
|
||||||
*
|
* @param string $value Optional current value, to make sure it's included
|
||||||
*/
|
*/
|
||||||
public static function ajax_get_options($type, $attributes)
|
public static function ajax_get_options($type, $attributes, $value = null)
|
||||||
{
|
{
|
||||||
$options = self::typeOptions($type, $attributes);
|
$no_lang = false;
|
||||||
|
$options = self::typeOptions($type, $attributes,$no_lang,false,$value);
|
||||||
self::fix_encoded_options($options,true);
|
self::fix_encoded_options($options,true);
|
||||||
$response = egw_json_response::get();
|
$response = egw_json_response::get();
|
||||||
$response->data($options);
|
$response->data($options);
|
||||||
|
@ -1103,7 +1103,7 @@ jQuery.extend(et2_selectbox,
|
|||||||
// and we can't do that when it's queued.
|
// and we can't do that when it's queued.
|
||||||
egw.window.et2_selectbox.type_cache[cache_id] = egw.json(
|
egw.window.et2_selectbox.type_cache[cache_id] = egw.json(
|
||||||
widget.getInstanceManager().app+'.etemplate_widget_menupopup.ajax_get_options.etemplate',
|
widget.getInstanceManager().app+'.etemplate_widget_menupopup.ajax_get_options.etemplate',
|
||||||
[widget._type,options_string]
|
[widget._type,options_string,attrs.value]
|
||||||
).sendRequest(true);
|
).sendRequest(true);
|
||||||
}
|
}
|
||||||
cache = egw.window.et2_selectbox.type_cache[cache_id];
|
cache = egw.window.et2_selectbox.type_cache[cache_id];
|
||||||
@ -1128,6 +1128,24 @@ jQuery.extend(et2_selectbox,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Check that the value is in there
|
||||||
|
if(attrs.value)
|
||||||
|
{
|
||||||
|
var missing_option = true;
|
||||||
|
for(var i = 0; i < cache.length && missing_option; i++)
|
||||||
|
{
|
||||||
|
if(cache[i].value == attrs.value)
|
||||||
|
{
|
||||||
|
missing_option = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Try again - ask the server with the current value this time
|
||||||
|
if(missing_option)
|
||||||
|
{
|
||||||
|
delete egw.window.et2_selectbox.type_cache[cache_id];
|
||||||
|
return this.cached_server_side_options(widget, options_string, attrs);
|
||||||
|
}
|
||||||
|
}
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user