From 599e677571234b144b15791c37607bf28e4c3929 Mon Sep 17 00:00:00 2001 From: Alain Benbassat Date: Wed, 12 Oct 2022 14:00:55 +0100 Subject: [PATCH] AdminUI - Add SearchKit screen for Administer Profiles --- CRM/Core/xml/Menu/Admin.xml | 5 + CRM/UF/Form/Preview.php | 7 +- CRM/UF/Page/Field.php | 9 +- CRM/UF/Page/Group.php | 9 +- .../ang/afsearchProfileFields.aff.html | 3 + .../ang/afsearchProfileFields.aff.json | 18 ++ .../ang/afsearchProfiles.aff.html | 20 ++ .../ang/afsearchProfiles.aff.json | 18 ++ ...vedSearch_Administer_ProfileFields.mgd.php | 187 +++++++++++++ .../SavedSearch_Administer_Profiles.mgd.php | 258 ++++++++++++++++++ 10 files changed, 524 insertions(+), 10 deletions(-) create mode 100644 ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.html create mode 100644 ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.json create mode 100644 ext/civicrm_admin_ui/ang/afsearchProfiles.aff.html create mode 100644 ext/civicrm_admin_ui/ang/afsearchProfiles.aff.json create mode 100644 ext/civicrm_admin_ui/managed/SavedSearch_Administer_ProfileFields.mgd.php create mode 100644 ext/civicrm_admin_ui/managed/SavedSearch_Administer_Profiles.mgd.php diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index 0b6a477fa2..b4c65b4391 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -65,6 +65,11 @@ Customize Data and Screens 20 + + civicrm/admin/uf/group/preview + Preview + CRM_UF_Form_Preview + civicrm/admin/uf/group/field CiviCRM Profile Fields diff --git a/CRM/UF/Form/Preview.php b/CRM/UF/Form/Preview.php index 7ef09e87a8..822951c675 100644 --- a/CRM/UF/Form/Preview.php +++ b/CRM/UF/Form/Preview.php @@ -33,11 +33,10 @@ class CRM_UF_Form_Preview extends CRM_UF_Form_AbstractPreview { */ public function preProcess() { $flag = FALSE; - $gid = $this->get('id'); - $this->set('gid', $gid); - $field = CRM_Utils_Request::retrieve('field', 'Boolean', $this, TRUE, 0); + $gid = CRM_Utils_Request::retrieve('gid', 'Integer', $this, TRUE); + $fieldId = CRM_Utils_Request::retrieve('fieldId', 'Integer', $this, FALSE, 0); - if ($field) { + if ($fieldId) { $fields = CRM_Core_BAO_UFGroup::getFields($gid, FALSE, NULL, NULL, NULL, TRUE); $fieldDAO = new CRM_Core_DAO_UFField(); $fieldDAO->id = $this->get('fieldId'); diff --git a/CRM/UF/Page/Field.php b/CRM/UF/Page/Field.php index 1c3e59d09e..b939f01fc5 100644 --- a/CRM/UF/Page/Field.php +++ b/CRM/UF/Page/Field.php @@ -57,8 +57,8 @@ class CRM_UF_Page_Field extends CRM_Core_Page { ], CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview'), - 'url' => 'civicrm/admin/uf/group/field', - 'qs' => 'action=preview&id=%%id%%&field=1', + 'url' => 'civicrm/admin/uf/group/preview', + 'qs' => 'action=preview&gid=%%gid%%&fieldId=%%id%%', 'title' => ts('Preview CiviCRM Profile Field'), ], CRM_Core_Action::DISABLE => [ @@ -259,6 +259,9 @@ class CRM_UF_Page_Field extends CRM_Core_Page { /** * Preview custom field. * + * @deprecated + * Links should point directly to civicrm/admin/uf/group/preview + * * @param int $fieldId * Custom field id. * @param int $groupId @@ -272,7 +275,7 @@ class CRM_UF_Page_Field extends CRM_Core_Page { 'reset=1&action=browse&gid=' . $this->_gid )); $controller->set('fieldId', $fieldId); - $controller->set('id', $groupId); + $controller->set('gid', $groupId); $controller->setEmbedded(TRUE); $controller->process(); $controller->run(); diff --git a/CRM/UF/Page/Group.php b/CRM/UF/Page/Group.php index c3b35bc0bb..e5bb967aae 100644 --- a/CRM/UF/Page/Group.php +++ b/CRM/UF/Page/Group.php @@ -59,8 +59,8 @@ class CRM_UF_Page_Group extends CRM_Core_Page { ], CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview'), - 'url' => 'civicrm/admin/uf/group', - 'qs' => 'action=preview&id=%%id%%&field=0&context=group', + 'url' => 'civicrm/admin/uf/group/preview', + 'qs' => 'action=preview&gid=%%id%%&context=group', 'title' => ts('Edit CiviCRM Profile Group'), ], CRM_Core_Action::ADD => [ @@ -372,6 +372,9 @@ class CRM_UF_Page_Group extends CRM_Core_Page { /** * for preview mode for ufoup. * + * @deprecated + * Links should point directly to civicrm/admin/uf/group/preview + * * @param int $id * Uf group id. * @@ -379,7 +382,7 @@ class CRM_UF_Page_Group extends CRM_Core_Page { */ public function preview($id, $action) { $controller = new CRM_Core_Controller_Simple('CRM_UF_Form_Preview', ts('CiviCRM Profile Group Preview'), NULL); - $controller->set('id', $id); + $controller->set('gid', $id); $controller->setEmbedded(TRUE); $controller->process(); $controller->run(); diff --git a/ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.html b/ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.html new file mode 100644 index 0000000000..85180ed32d --- /dev/null +++ b/ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.json b/ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.json new file mode 100644 index 0000000000..050dd2d1bf --- /dev/null +++ b/ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.json @@ -0,0 +1,18 @@ +{ + "type": "search", + "requires": [], + "entity_type": null, + "join_entity": null, + "title": "Profile Fields", + "description": "", + "is_dashlet": false, + "is_public": false, + "is_token": false, + "contact_summary": null, + "icon": "fa-list-alt", + "server_route": "civicrm/admin/uf/group/field", + "permission": "access CiviCRM", + "redirect": null, + "create_submission": false, + "navigation": null +} diff --git a/ext/civicrm_admin_ui/ang/afsearchProfiles.aff.html b/ext/civicrm_admin_ui/ang/afsearchProfiles.aff.html new file mode 100644 index 0000000000..6fffa3ea28 --- /dev/null +++ b/ext/civicrm_admin_ui/ang/afsearchProfiles.aff.html @@ -0,0 +1,20 @@ +
+
+ + + + +
{{:: ts('CiviCRM Profile(s) allow you to aggregate groups of fields and include them in your site as input forms, contact display pages, and search and listings features. They provide a powerful set of tools for you to collect information from constituents and selectively share contact information.') }} {{:: ts('Learn more...') }}
+ + + + + +
+
+
+ + +
+ +
diff --git a/ext/civicrm_admin_ui/ang/afsearchProfiles.aff.json b/ext/civicrm_admin_ui/ang/afsearchProfiles.aff.json new file mode 100644 index 0000000000..9be0002e90 --- /dev/null +++ b/ext/civicrm_admin_ui/ang/afsearchProfiles.aff.json @@ -0,0 +1,18 @@ +{ + "type": "search", + "requires": [], + "entity_type": null, + "join_entity": null, + "title": "Profiles", + "description": "", + "is_dashlet": false, + "is_public": false, + "is_token": false, + "contact_summary": null, + "icon": "fa-list-alt", + "server_route": "civicrm/admin/uf/group", + "permission": "access CiviCRM", + "redirect": null, + "create_submission": false, + "navigation": null +} diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Administer_ProfileFields.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Administer_ProfileFields.mgd.php new file mode 100644 index 0000000000..fafeaae766 --- /dev/null +++ b/ext/civicrm_admin_ui/managed/SavedSearch_Administer_ProfileFields.mgd.php @@ -0,0 +1,187 @@ + 'SavedSearch_Profile_Fields', + 'entity' => 'SavedSearch', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Profile_Fields', + 'label' => E::ts('Administer Profile Fields'), + 'form_values' => NULL, + 'mapping_id' => NULL, + 'search_custom_id' => NULL, + 'api_entity' => 'UFField', + 'api_params' => [ + 'version' => 4, + 'select' => [ + 'id', + 'label', + 'visibility:label', + 'is_searchable', + 'is_required', + 'is_view', + 'is_reserved', + 'is_active', + ], + 'orderBy' => [], + 'where' => [], + 'groupBy' => [], + 'join' => [], + 'having' => [], + ], + 'expires_date' => NULL, + 'description' => NULL, + ], + ], + ], + [ + 'name' => 'SavedSearch_Profile_Fields_SearchDisplay_Profile_Fields', + 'entity' => 'SearchDisplay', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Profile_Fields', + 'label' => E::ts('Table'), + 'saved_search_id.name' => 'Profile_Fields', + 'type' => 'table', + 'settings' => [ + 'actions' => FALSE, + 'limit' => 50, + 'classes' => [ + 'table', + 'table-striped', + ], + 'pager' => [], + 'placeholder' => 5, + 'sort' => [], + 'columns' => [ + [ + 'type' => 'field', + 'key' => 'label', + 'dataType' => 'String', + 'label' => E::ts('Field Name'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'visibility:label', + 'dataType' => 'String', + 'label' => E::ts('Visibility'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'is_searchable', + 'dataType' => 'Boolean', + 'label' => E::ts('Searchable'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'is_required', + 'dataType' => 'Boolean', + 'label' => E::ts('Required'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'is_active', + 'dataType' => 'Boolean', + 'label' => E::ts('Enabled'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'is_view', + 'dataType' => 'Boolean', + 'label' => E::ts('View Only'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'is_reserved', + 'dataType' => 'Boolean', + 'label' => E::ts('Reserved'), + 'sortable' => TRUE, + 'rewrite' => ' ', + 'icons' => [ + [ + 'icon' => 'fa-lock', + 'side' => 'left', + 'if' => ['is_reserved', '=', TRUE], + ], + ], + ], + [ + 'size' => 'btn-xs', + 'links' => [ + [ + 'entity' => 'UFField', + 'action' => 'update', + 'join' => '', + 'target' => 'crm-popup', + 'icon' => 'fa-pencil', + 'text' => E::ts('Edit'), + 'style' => 'default', + 'path' => '', + 'condition' => [], + ], + [ + 'entity' => 'UFField', + 'action' => 'preview', + 'join' => '', + 'target' => 'crm-popup', + 'icon' => 'fa-eye', + 'text' => E::ts('Preview'), + 'style' => 'default', + 'condition' => ['is_active', '=', TRUE], + ], + [ + 'entity' => 'UFField', + 'action' => 'delete', + 'join' => '', + 'target' => 'crm-popup', + 'icon' => 'fa-trash', + 'text' => E::ts('Delete'), + 'style' => 'danger', + 'path' => '', + 'condition' => [], + ], + ], + 'type' => 'buttons', + 'alignment' => 'text-right', + ], + ], + 'draggable' => 'weight', + 'button' => NULL, + 'addButton' => [ + 'path' => 'civicrm/admin/uf/group/field/add?reset=1&action=add&gid=[uf_group_id]', + 'text' => E::ts('Add Field'), + 'icon' => 'fa-plus', + ], + 'cssRules' => [ + [ + 'disabled', + 'is_active', + '=', + FALSE, + ], + ], + ], + 'acl_bypass' => FALSE, + ], + ], + ], +]; diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Profiles.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Profiles.mgd.php new file mode 100644 index 0000000000..1d80774b45 --- /dev/null +++ b/ext/civicrm_admin_ui/managed/SavedSearch_Administer_Profiles.mgd.php @@ -0,0 +1,258 @@ + 'SavedSearch_User_defined_Profiles', + 'entity' => 'SavedSearch', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'User_defined_Profiles', + 'label' => E::ts('Administer Profiles'), + 'form_values' => NULL, + 'mapping_id' => NULL, + 'search_custom_id' => NULL, + 'api_entity' => 'UFGroup', + 'api_params' => [ + 'version' => 4, + 'select' => [ + 'id', + 'title', + 'frontend_title', + 'created_id.display_name', + 'description', + 'group_type', + 'is_reserved', + 'is_active', + 'COUNT(UFGroup_UFField_uf_group_id_01.id) AS COUNT_UFGroup_UFField_uf_group_id_01_id', + ], + 'orderBy' => [], + 'where' => [], + 'groupBy' => [ + 'id', + ], + 'join' => [ + [ + 'UFField AS UFGroup_UFField_uf_group_id_01', + 'LEFT', + [ + 'id', + '=', + 'UFGroup_UFField_uf_group_id_01.uf_group_id', + ], + ], + ], + 'having' => [], + ], + 'expires_date' => NULL, + 'description' => NULL, + ], + ], + ], + [ + 'name' => 'SavedSearch_User_defined_Profiles_SearchDisplay_User_defined_Profiles', + 'entity' => 'SearchDisplay', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'User_defined_Profiles', + 'label' => E::ts('Administer Profiles'), + 'saved_search_id.name' => 'User_defined_Profiles', + 'type' => 'table', + 'settings' => [ + 'actions' => FALSE, + 'limit' => 50, + 'classes' => [ + 'table', + 'table-striped', + ], + 'pager' => [], + 'placeholder' => 5, + 'sort' => [], + 'columns' => [ + [ + 'type' => 'field', + 'key' => 'id', + 'dataType' => 'String', + 'label' => E::ts('ID'), + 'sortable' => TRUE, + 'editable' => FALSE, + ], + [ + 'type' => 'field', + 'key' => 'title', + 'dataType' => 'String', + 'label' => E::ts('Profile Title'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'frontend_title', + 'dataType' => 'String', + 'label' => E::ts('Public Title'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'created_id.display_name', + 'dataType' => 'String', + 'label' => E::ts('Created By'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'description', + 'dataType' => 'Text', + 'label' => E::ts('Description'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'group_type', + 'dataType' => 'String', + 'label' => E::ts('Type'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'is_active', + 'dataType' => 'Boolean', + 'label' => E::ts('Enabled'), + 'sortable' => TRUE, + 'editable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'is_reserved', + 'dataType' => 'Boolean', + 'label' => E::ts('Reserved'), + 'sortable' => TRUE, + 'rewrite' => ' ', + 'icons' => [ + [ + 'icon' => 'fa-lock', + 'side' => 'left', + 'if' => ['is_reserved', '=', TRUE], + ], + ], + ], + [ + 'size' => 'btn-xs', + 'links' => [ + [ + 'icon' => 'fa-pencil', + 'text' => E::ts('Settings'), + 'style' => 'default', + 'condition' => ['is_reserved', '=', FALSE], + 'entity' => 'UFGroup', + 'action' => 'update', + 'join' => '', + 'target' => 'crm-popup', + ], + [ + 'path' => 'civicrm/admin/uf/group/field#/?uf_group_id=[id]', + 'icon' => 'fa-list-alt', + 'text' => E::ts('Fields') . ' ([COUNT_UFGroup_UFField_uf_group_id_01_id])', + 'style' => 'default', + 'condition' => [], + 'entity' => '', + 'action' => '', + 'join' => '', + 'target' => '', + ], + ], + 'type' => 'buttons', + 'alignment' => 'text-right', + ], + [ + 'text' => '', + 'style' => 'default-outline', + 'size' => 'btn-xs', + 'icon' => 'fa-bars', + 'links' => [ + [ + 'text' => E::ts('Preview'), + 'style' => 'default', + 'condition' => ['COUNT_UFGroup_UFField_uf_group_id_01_id', '>', 0], + 'entity' => 'UFGroup', + 'action' => 'preview', + 'join' => '', + 'target' => 'crm-popup', + 'icon' => 'fa-eye', + ], + [ + 'path' => 'civicrm/profile/create?gid=[id]&reset=1', + 'icon' => 'fa-external-link', + 'text' => E::ts('Use - Create Mode'), + 'style' => 'default', + 'condition' => [], + 'entity' => '', + 'action' => '', + 'join' => '', + 'target' => '_blank', + ], + [ + 'path' => 'civicrm/profile/edit?gid=[id]&reset=1', + 'icon' => 'fa-external-link', + 'text' => E::ts('Use - Edit Mode'), + 'style' => 'default', + 'condition' => [], + 'entity' => '', + 'action' => '', + 'join' => '', + 'target' => '_blank', + ], + [ + 'path' => 'civicrm/profile?gid=[id]&reset=1', + 'icon' => 'fa-external-link', + 'text' => E::ts('Use - Listing Mode'), + 'style' => 'default', + 'condition' => [], + 'entity' => '', + 'action' => '', + 'join' => '', + 'target' => '_blank', + ], + [ + 'icon' => 'fa-trash', + 'text' => E::ts('Delete'), + 'style' => 'danger', + 'condition' => ['is_reserved', '=', FALSE], + 'entity' => 'UFGroup', + 'action' => 'delete', + 'join' => '', + 'target' => 'crm-popup', + ], + ], + 'type' => 'menu', + 'alignment' => 'text-right', + 'label' => '', + ], + ], + 'addButton' => [ + 'path' => 'civicrm/admin/uf/group/add?action=add&reset=1', + 'text' => E::ts('Add Profile'), + 'icon' => 'fa-plus', + ], + 'cssRules' => [ + [ + 'disabled', + 'is_active', + '=', + FALSE, + ], + ], + ], + 'acl_bypass' => FALSE, + ], + ], + ], +]; -- 2.25.1