From 43490f4eb58ae5bf12be3639d5a95266483e74df Mon Sep 17 00:00:00 2001 From: ralf Date: Mon, 16 Sep 2024 15:10:12 +0200 Subject: [PATCH] improve type-filter in customfield list to be able to select fields for all type and always show the fields for all types too, when a certain type is select --- admin/inc/class.admin_customfields.inc.php | 19 ++++++++++++++++++- admin/templates/default/customfield_edit.xet | 4 ++-- infolog/inc/class.infolog_ui.inc.php | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/admin/inc/class.admin_customfields.inc.php b/admin/inc/class.admin_customfields.inc.php index daf8453629..79e3209492 100644 --- a/admin/inc/class.admin_customfields.inc.php +++ b/admin/inc/class.admin_customfields.inc.php @@ -239,7 +239,7 @@ class admin_customfields } $this->types2[$type] = $entry['name']; } - $sel_options['types'] = $sel_options['cf_type2'] = $this->types2; + $sel_options['types'] = $sel_options['cf_type2'] = ['~~all~~' => lang('All')]+$this->types2; $content['type_template'] = $this->appname . '.admin.types'; $content['content_types']['appname'] = $this->appname; @@ -756,8 +756,25 @@ class admin_customfields $rows = array(); $query['col_filter']['cf_app'] = $query['appname']; + if (!empty($t2=$query['col_filter']['cf_type2'])) + { + if ($t2 === '~~all~~') + { + $query['col_filter'][0] = 'cf_type2 IS NULL'; + } + else + { + $query['col_filter'][0] = '(cf_type2 IS NULL OR cf_type2='.$GLOBALS['egw']->db->quote($t2).')'; + } + unset($query['col_filter']['cf_type2']); + } $total = $this->so->get_rows($query, $rows, $readonlys); unset($query['col_filter']['cf_app']); + if (isset($t2)) + { + unset($query['col_filter'][0]); + $query['col_filter']['cf_type2'] = $t2; + } foreach($rows as &$row) { diff --git a/admin/templates/default/customfield_edit.xet b/admin/templates/default/customfield_edit.xet index f900f2700b..e22e0ee527 100644 --- a/admin/templates/default/customfield_edit.xet +++ b/admin/templates/default/customfield_edit.xet @@ -12,7 +12,7 @@ - + @@ -33,7 +33,7 @@ - + diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index 88f7656520..f53e1f1659 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -2010,7 +2010,7 @@ class infolog_ui } } // on a type-change, set the status to the default status of that type, if the actual status is not supported by the new type - if (!array_key_exists($content['info_status'],$this->bo->status[$content['info_type']])) + if (!array_key_exists($content['info_status'],$this->bo->status[$content['info_type']] ?? [])) { $content['info_status'] = $this->bo->status['defaults'][$content['info_type']]; // Make sure we don't end up with invalid status / percent combinations