add NM-filter-header for type, entry-type and tab to custom-fields list

currently header is somehow readonly
This commit is contained in:
ralf 2024-04-23 10:42:00 +02:00
parent 834e4f7824
commit 8acfc4ed27
3 changed files with 36 additions and 23 deletions

View File

@ -261,7 +261,7 @@ class admin_customfields
$content['content_types']['no_edit_types'] = true; $content['content_types']['no_edit_types'] = true;
} }
// do NOT allow to delete original contact content-type for addressbook, // do NOT allow to delete original contact content-type for addressbook,
// as it only creates support problems as users incidently delete it // as it only creates support problems as users accidentally delete it
if ($this->appname == 'addressbook' && $this->content_type == 'n') if ($this->appname == 'addressbook' && $this->content_type == 'n')
{ {
$readonlys['content_types']['delete'] = true; $readonlys['content_types']['delete'] = true;
@ -273,6 +273,8 @@ class admin_customfields
// Disable content types // Disable content types
$this->tmpl->disableElement('content_types', true); $this->tmpl->disableElement('content_types', true);
} }
$sel_options['cf_type'] = Etemplate\Widget\Customfields::getCfTypes();
$sel_options['cf_tab'] = $this->so->query_list('cf_tab', '', ['cf_app' => $this->appname]);
$preserve = array( $preserve = array(
'appname' => $this->appname, 'appname' => $this->appname,
'use_private' => $this->use_private, 'use_private' => $this->use_private,

View File

@ -44,20 +44,20 @@
</columns> </columns>
<rows> <rows>
<row class="th"> <row class="th">
<nextmatch-header label="Type" id="cf_type2"/> <et2-nextmatch-header-filter emptyLabel="Type" id="cf_type2"/>
<nextmatch-sortheader label="Name" id="cf_name"/> <nextmatch-sortheader label="Name" id="cf_name"/>
<nextmatch-sortheader label="Label" id="cf_label"/> <nextmatch-sortheader label="Label" id="cf_label"/>
<nextmatch-header label="Type of field" id="cf_type"/> <et2-nextmatch-header-filter emptyLabel="Type of field" id="cf_type"/>
<nextmatch-header label="Required" id="cf_needed"/> <nextmatch-header label="Required" id="cf_needed"/>
<nextmatch-header label="Private" id="cf_private"/> <nextmatch-header label="Private" id="cf_private"/>
<nextmatch-header label="Readonly" id="cf_readonly"/> <nextmatch-header label="Readonly" id="cf_readonly"/>
<nextmatch-header label="Options"/> <nextmatch-header label="Options" id="cf_values"/>
<et2-vbox> <et2-vbox>
<nextmatch-header label="Length"/> <nextmatch-header label="Length" id="cf_len"/>
<nextmatch-header label="Rows"/> <nextmatch-header label="Rows" id="cf_rows"/>
</et2-vbox> </et2-vbox>
<nextmatch-sortheader label="Order" id="cf_order"/> <nextmatch-sortheader label="Order" id="cf_order"/>
<nextmatch-sortheader label="Tab" id="cf_tab"/> <et2-nextmatch-header-filter emptyLabel="Tab" id="cf_tab"/>
<nextmatch-sortheader label="Last modified" id="cf_modified"/> <nextmatch-sortheader label="Last modified" id="cf_modified"/>
</row> </row>
<row class="row" valign="top"> <row class="row" valign="top">

View File

@ -22,7 +22,6 @@ use EGroupware\Api;
*/ */
class Customfields extends Transformer class Customfields extends Transformer
{ {
/** /**
* Allowed types of customfields * Allowed types of customfields
* *
@ -209,21 +208,7 @@ class Customfields extends Transformer
switch($type = $this->type) switch($type = $this->type)
{ {
case 'customfields-types': case 'customfields-types':
foreach(self::$cf_types as $lname => $label) self::$transformation['type'][$type]['sel_options'] = self::getCfTypes($fields_with_vals);
{
$sel_options[$lname] = lang($label);
$fields_with_vals[]=$lname;
}
$link_types = array_intersect_key(Api\Link::app_list('query'), Api\Link::app_list('title'));
// Explicitly add in filemanager, which does not support query or title
$link_types['filemanager'] = lang('filemanager');
ksort($link_types);
foreach($link_types as $lname => $label)
{
$sel_options[$lname] = '- '.$label;
}
self::$transformation['type'][$type]['sel_options'] = $sel_options;
self::$transformation['type'][$type]['no_lang'] = true; self::$transformation['type'][$type]['no_lang'] = true;
return parent::beforeSendToClient($cname, $expand); return parent::beforeSendToClient($cname, $expand);
case 'customfields-list': case 'customfields-list':
@ -294,6 +279,32 @@ class Customfields extends Transformer
} }
} }
/**
* Get cf types for sel_options
*
* @param array|null $fields_with_vals
* @return array
*/
public static function getCfTypes(?array &$fields_with_vals=null)
{
$sel_options = [];
foreach(self::$cf_types as $lname => $label)
{
$sel_options[$lname] = lang($label);
$fields_with_vals[]=$lname;
}
$link_types = array_intersect_key(Api\Link::app_list('query'), Api\Link::app_list('title'));
// Explicitly add in filemanager, which does not support query or title
$link_types['filemanager'] = lang('filemanager');
ksort($link_types);
foreach($link_types as $lname => $label)
{
$sel_options[$lname] = $label;
}
return $sel_options;
}
/** /**
* Instantiate (server-side) widget used to implement custom-field, to run its beforeSendToClient or validate method * Instantiate (server-side) widget used to implement custom-field, to run its beforeSendToClient or validate method
* *