allow to pass a JSON filter object to application-type custom-fields:

adressbook: '{"owner":5,"cat_id":[1,3]}' will only return contacts from personal AB of user #5 with either cat_id 1 or 2
This commit is contained in:
ralf 2024-02-08 22:26:07 +02:00
parent 8750a9801c
commit 782bbec4cf
3 changed files with 34 additions and 3 deletions

View File

@ -377,6 +377,13 @@ class admin_customfields
{
$values['@'] = substr($content['cf_values'], $content['cf_values'][1] === '=' ? 2:1);
}
elseif (isset($GLOBALS['egw_info']['apps'][$content['cf_type']]))
{
if (!empty($content['cf_values']) && ($content['cf_values'][0] !== '{' || ($values=json_decode($content['cf_values'])) === null))
{
Api\Etemplate::set_validation_error('cf_values', lang('Invalid JSON object!'));
}
}
else
{
foreach(explode("\n",trim($content['cf_values'])) as $idx => $line)
@ -459,7 +466,10 @@ class admin_customfields
{
$readonlys['cf_name'] = true;
}
$content['cf_values'] = json_decode($content['cf_values'], true);
if (!isset($GLOBALS['egw_info']['apps'][$content['cf_type']]))
{
$content['cf_values'] = json_decode($content['cf_values'], true);
}
}
else
{

View File

@ -73,7 +73,13 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(SlotMixin(LitE
/**
* Displayed in the search / select when no value is selected
*/
placeholder: {type: String}
placeholder: {type: String},
/**
* Additional search parameters that are passed to the server
* when we query searchUrl
*/
searchOptions: {type: Object}
}
}
@ -219,6 +225,19 @@ export class Et2LinkEntry extends Et2InputWidget(FormControlMixin(SlotMixin(LitE
return this._appNode?.value || "";
}
set searchOptions(options)
{
this.updateComplete.then(() =>
{
this._searchNode.searchOptions = options;
});
}
get searchOptions()
{
return this._searchNode.searchOptions;
}
get _appNode() : Et2LinkAppSelect
{
return this.querySelector("[slot='app']");

View File

@ -284,7 +284,8 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
const type = attrs.type ? attrs.type : field.type;
// Set any additional attributes set in options, but not for widgets that pass actual options
if(['select','radio','radiogroup','checkbox','button'].indexOf(field.type) == -1 && !jQuery.isEmptyObject(field.values))
if(['select','radio','radiogroup','checkbox','button'].indexOf(field.type) == -1 &&
setup_function !== '_setup_link_entry' && !jQuery.isEmptyObject(field.values))
{
const w = et2_registry[type];
const wc = window.customElements.get('et2-' + type);
@ -769,6 +770,7 @@ export class et2_customfields_list extends et2_valueWidget implements et2_IDetac
attrs.type = "link-entry";
attrs[attrs.readonly ? "app" : "only_app"] = typeof field.only_app == "undefined" ? field.type : field.only_app;
attrs.searchOptions = {filter: field.values || {}};
return true;
}