mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-13 17:38:28 +01:00
Enhanced nextmatch and link-widget to be able to use a link-entry
widget as a custom nextmatch header Allows eg. in InfoLog to search and then filter by any linked entry of an other application: - Infologs linked to a project or - Infologs linked to a contact
This commit is contained in:
parent
327bd79662
commit
a11a04b78d
@ -80,6 +80,12 @@ class link_widget
|
||||
*/
|
||||
var $debug = False;
|
||||
|
||||
/**
|
||||
* Flag that ajax_search needs to add onchange line
|
||||
*
|
||||
*/
|
||||
const AJAX_NEED_ONCHANGE = 987;
|
||||
|
||||
/**
|
||||
* Constructor of the extension
|
||||
*
|
||||
@ -367,6 +373,7 @@ class link_widget
|
||||
}
|
||||
if ($titles)
|
||||
{
|
||||
if ($cell['onchange']) $titles[0] = lang('Show all / cancel filter');
|
||||
$titles[''] = lang('new search').' ...';
|
||||
$selectbox =& $tpl->get_widget_by_name('id');
|
||||
$selectbox['sel_options'] = $titles;
|
||||
@ -396,6 +403,8 @@ class link_widget
|
||||
'no_app_sel' => !!$extension_data['app'],
|
||||
'id' => is_array($value) ? $value['current'] : $value,
|
||||
'query' => is_array($value) ? $value['query'] : '',
|
||||
'blur' => count($options) == 1 ? lang($app) : lang('Search'),
|
||||
'extra' => $cell['onchange'] ? ','.self::AJAX_NEED_ONCHANGE : null, // store flang for ajax_search, to display extra_line required by onchange
|
||||
);
|
||||
if ($options) // limit the app-selectbox to the given apps
|
||||
{
|
||||
@ -615,15 +624,19 @@ class link_widget
|
||||
// securize entries as they were html encoded and so not checked on the first pass
|
||||
_check_script_tag($extra_array,'extra_array');
|
||||
}
|
||||
if ($pattern == lang('Search') || $pattern == lang($app)) $pattern = '';
|
||||
if (empty($extra_array))
|
||||
{
|
||||
$search = ($pattern == lang('Search'))? '' : $pattern;
|
||||
$search = $pattern;
|
||||
}
|
||||
else
|
||||
{
|
||||
$extra_array['search']=($pattern == lang('Search'))? '' : $pattern;
|
||||
$extra_array['search']= $pattern;
|
||||
$search = $extra_array;
|
||||
}
|
||||
// open request
|
||||
if ($etemplate_exec_id) $request = etemplate_request::read($etemplate_exec_id);
|
||||
|
||||
$response = new xajaxResponse();
|
||||
//$args = func_get_args(); $response->addAlert("link_widget::ajax_search('".implode("',\n'",$args)."')\n calling link->query( $app , $search )" );
|
||||
//$args = func_get_args(); error_log(__METHOD__."('".implode("','",$args)."')");
|
||||
@ -636,6 +649,12 @@ class link_widget
|
||||
else
|
||||
{
|
||||
$script = "var select = document.getElementById('$id_res');\nselect.options.length=0;\n";
|
||||
|
||||
// check if we need to add extra line to produce an onchange to submit the form
|
||||
if (($data = $request->get_to_process($id_input)) && $data['maxlength'] == self::AJAX_NEED_ONCHANGE)
|
||||
{
|
||||
$script .= "opt = select.options[select.options.length] = new Option('".addslashes(lang('%1 entries found, select one ...',count($found)))."',' ');\n";
|
||||
}
|
||||
foreach($found as $id => $option)
|
||||
{
|
||||
if (!is_array($option)) $option = array('label' => $option);
|
||||
@ -661,7 +680,7 @@ class link_widget
|
||||
$response->addScript($script);
|
||||
}
|
||||
// store new allowed id's in the eT request
|
||||
if ($etemplate_exec_id && ($request = etemplate_request::read($etemplate_exec_id)))
|
||||
if ($request)
|
||||
{
|
||||
$data = $request->get_to_process($id_res);
|
||||
//error_log($id_res.'='.array2string($data));
|
||||
|
@ -224,7 +224,7 @@ class nextmatch_widget
|
||||
case 'nextmatch-filterheader': // Option: as for selectbox: [extra-label(default ALL)[,#lines(default 1)]]
|
||||
if (!$type) $type = 'select';
|
||||
$cell['type'] = $type;
|
||||
if (!$cell['size'])
|
||||
if (!$cell['size'] && $type != 'link-entry') // link-entry without option shows application selection!
|
||||
{
|
||||
$cell['size'] = 'All';
|
||||
}
|
||||
@ -571,7 +571,7 @@ class nextmatch_widget
|
||||
'readonly' => $cell['readonly'],
|
||||
));
|
||||
}
|
||||
elseif($GLOBALS['egw_info']['apps'][$field['type']])
|
||||
elseif($GLOBALS['egw_info']['apps'][$field['type']])
|
||||
{
|
||||
$header =& etemplate::empty_cell('link-entry', $cell_name . '['.self::CF_PREFIX.$name .']', array(
|
||||
'label' => $field['label'],
|
||||
@ -767,6 +767,16 @@ class nextmatch_widget
|
||||
case 'nextmatch-customfields':
|
||||
return $this->_post_process_cf_header($value, $extension_data, $tmpl, $value_in, $nm_global);
|
||||
|
||||
case 'link-entry': // allways return app:id, if an entry got selected, otherwise null
|
||||
if (is_array($value_in) && !empty($value_in['id']))
|
||||
{
|
||||
$value_in = (isset($value_in['app']) ? $value_in['app'] : $extension_data['app']).':'.$value_in['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$value_in = null;
|
||||
}
|
||||
// fall through
|
||||
default:
|
||||
case 'select-account': // used by nextmatch-accountfilter
|
||||
case 'nextmatch-filterheader':
|
||||
|
@ -1,4 +1,5 @@
|
||||
%1 (%2 new) messages writen for application '%3' and languages '%4' etemplate de %1 (%2 neue) Texte für die Anwendung '%3' und die Sprache '%4' geschrieben
|
||||
%1 entries found, select one ... etemplate de %1 Einträge gefunden, einen auswählen ...
|
||||
%1 etemplates deleted etemplate de %1 eTemplates gelöscht
|
||||
%1 etemplates for application '%2' dumped to '%3' etemplate de %1 eTemplates für die Anwendung '%2' nach '%3' geschrieben
|
||||
%1 etemplates found etemplate de %1 eTemplates gefunden
|
||||
@ -346,6 +347,7 @@ sets today as date etemplate de setzt heutiges Datum
|
||||
should the form be submitted or any custom javascript be executed etemplate de Soll das Formular abgeschickt werden oder beliebiges JavaScript ausgeführt werden
|
||||
show etemplate de Anzeigen
|
||||
show (no save) etemplate de Anzeigen (nicht speichern)
|
||||
show all / cancel filter etemplate de Alle anzeigen / Filter aufheben
|
||||
show values etemplate de Werte anzeigen
|
||||
showing etemplate de zeigt
|
||||
shows / allows you to enter values into the etemplate for testing etemplate de zeigt den Inhalt / Werte an und erlaubt welche zum Testen des eTemplates einzugeben
|
||||
|
@ -1,4 +1,5 @@
|
||||
%1 (%2 new) messages writen for application '%3' and languages '%4' etemplate en %1 (%2 new) Messages writen for Application '%3' and Languages '%4'
|
||||
%1 entries found, select one ... etemplate en %1 entries found, select one ...
|
||||
%1 etemplates deleted etemplate en %1 eTemplates deleted
|
||||
%1 etemplates for application '%2' dumped to '%3' etemplate en %1 eTemplates for Application '%2' dumped to '%3'
|
||||
%1 etemplates found etemplate en %1 eTemplates found
|
||||
@ -346,6 +347,7 @@ sets today as date etemplate en sets today as date
|
||||
should the form be submitted or any custom javascript be executed etemplate en Should the form be submitted or any custom javascript be executed
|
||||
show etemplate en Show
|
||||
show (no save) etemplate en Show (no save)
|
||||
show all / cancel filter etemplate en Show all / cancel filter
|
||||
show values etemplate en Show Values
|
||||
showing etemplate en showing
|
||||
shows / allows you to enter values into the etemplate for testing etemplate en shows / allows you to enter values into the eTemplate for testing
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user