From 8acfc4ed2746f6d9d9b82e8816cabeee0c675f0f Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 23 Apr 2024 10:42:00 +0200 Subject: [PATCH] add NM-filter-header for type, entry-type and tab to custom-fields list currently header is somehow readonly --- admin/inc/class.admin_customfields.inc.php | 4 +- admin/templates/default/customfields.xet | 12 +++--- api/src/Etemplate/Widget/Customfields.php | 43 ++++++++++++++-------- 3 files changed, 36 insertions(+), 23 deletions(-) diff --git a/admin/inc/class.admin_customfields.inc.php b/admin/inc/class.admin_customfields.inc.php index e4cc9b5c88..b194ffc986 100644 --- a/admin/inc/class.admin_customfields.inc.php +++ b/admin/inc/class.admin_customfields.inc.php @@ -261,7 +261,7 @@ class admin_customfields $content['content_types']['no_edit_types'] = true; } // 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') { $readonlys['content_types']['delete'] = true; @@ -273,6 +273,8 @@ class admin_customfields // Disable content types $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( 'appname' => $this->appname, 'use_private' => $this->use_private, diff --git a/admin/templates/default/customfields.xet b/admin/templates/default/customfields.xet index 608b904b23..1f35c4c4ef 100644 --- a/admin/templates/default/customfields.xet +++ b/admin/templates/default/customfields.xet @@ -44,20 +44,20 @@ - + - + - + - - + + - + diff --git a/api/src/Etemplate/Widget/Customfields.php b/api/src/Etemplate/Widget/Customfields.php index 34a54bd694..4d26803c12 100644 --- a/api/src/Etemplate/Widget/Customfields.php +++ b/api/src/Etemplate/Widget/Customfields.php @@ -22,7 +22,6 @@ use EGroupware\Api; */ class Customfields extends Transformer { - /** * Allowed types of customfields * @@ -209,21 +208,7 @@ class Customfields extends Transformer switch($type = $this->type) { case 'customfields-types': - 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; - } - self::$transformation['type'][$type]['sel_options'] = $sel_options; + self::$transformation['type'][$type]['sel_options'] = self::getCfTypes($fields_with_vals); self::$transformation['type'][$type]['no_lang'] = true; return parent::beforeSendToClient($cname, $expand); 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 *