Skip to content

Commit

Permalink
Merge pull request #24725 from AlainBenbassat/profilesforadminui
Browse files Browse the repository at this point in the history
Adds Profiles to civicrm_admin_ui
  • Loading branch information
colemanw authored Oct 17, 2022
2 parents 0f2621d + 599e677 commit 115ab30
Show file tree
Hide file tree
Showing 20 changed files with 581 additions and 19 deletions.
16 changes: 14 additions & 2 deletions CRM/Core/DAO/UFField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/UFField.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:2de519ddf9c147c5716678f35b566cd7)
* (GenCodeChecksum:0982114cb58272a51643c9e8738e40d4)
*/

/**
Expand All @@ -30,6 +30,18 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
*/
public static $_log = TRUE;

/**
* Paths for accessing this entity in the UI.
*
* @var string[]
*/
protected static $_paths = [
'add' => 'civicrm/admin/uf/group/field/add?reset=1&action=add&gid=[uf_group_id]',
'preview' => 'civicrm/admin/uf/group/preview?reset=1&gid=[uf_group_id]&fieldId=[id]',
'update' => 'civicrm/admin/uf/group/field/update?reset=1&action=update&id=[id]',
'delete' => 'civicrm/admin/uf/group/field/update?reset=1&action=delete&id=[id]',
];

/**
* Unique table ID
*
Expand Down Expand Up @@ -216,7 +228,7 @@ public function __construct() {
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? ts('UFFields') : ts('UFField');
return $plural ? ts('Profile Fields') : ts('Profile Field');
}

/**
Expand Down
19 changes: 17 additions & 2 deletions CRM/Core/DAO/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/UFGroup.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:513714296a3ef044028606deeb7015f2)
* (GenCodeChecksum:fc9170f1bad42b21ea21305fa9cf7135)
*/

/**
Expand All @@ -30,6 +30,18 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
*/
public static $_log = TRUE;

/**
* Paths for accessing this entity in the UI.
*
* @var string[]
*/
protected static $_paths = [
'add' => 'civicrm/admin/uf/group/add?action=add&reset=1',
'preview' => 'civicrm/admin/uf/group/preview?reset=1&gid=[id]',
'update' => 'civicrm/admin/uf/group/update?action=update&reset=1&id=[id]',
'delete' => 'civicrm/admin/uf/group/update?action=delete&reset=1&id=[id]',
];

/**
* Unique table ID
*
Expand Down Expand Up @@ -286,7 +298,7 @@ public function __construct() {
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? ts('UFGroups') : ts('UFGroup');
return $plural ? ts('Profiles') : ts('Profile');
}

/**
Expand Down Expand Up @@ -619,6 +631,9 @@ public static function &fields() {
'entity' => 'UFGroup',
'bao' => 'CRM_Core_BAO_UFGroup',
'localizable' => 0,
'html' => [
'type' => 'Radio',
],
'add' => '3.0',
],
'name' => [
Expand Down
4 changes: 2 additions & 2 deletions CRM/Core/DAO/UFJoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* Generated from xml/schema/CRM/Core/UFJoin.xml
* DO NOT EDIT. Generated by CRM_Core_CodeGen
* (GenCodeChecksum:d7cc3d08c4c2ea8b556a3590e94792a0)
* (GenCodeChecksum:bb54d87bfa1cc4ad4cdbe8ddb817be08)
*/

/**
Expand Down Expand Up @@ -117,7 +117,7 @@ public function __construct() {
* Whether to return the plural version of the title.
*/
public static function getEntityTitle($plural = FALSE) {
return $plural ? ts('UFJoins') : ts('UFJoin');
return $plural ? ts('Profile Uses') : ts('Profile Use');
}

/**
Expand Down
5 changes: 5 additions & 0 deletions CRM/Core/xml/Menu/Admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
<adminGroup>Customize Data and Screens</adminGroup>
<weight>20</weight>
</item>
<item>
<path>civicrm/admin/uf/group/preview</path>
<title>Preview</title>
<page_callback>CRM_UF_Form_Preview</page_callback>
</item>
<item>
<path>civicrm/admin/uf/group/field</path>
<title>CiviCRM Profile Fields</title>
Expand Down
5 changes: 5 additions & 0 deletions CRM/UF/Form/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ class CRM_UF_Form_Field extends CRM_Core_Form {
public function preProcess() {
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this);
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this);

if (!$this->_gid && $this->_id) {
$this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $this->_id, 'uf_group_id');
$this->set('_gid', $this->_gid);
}
if ($this->_gid) {
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'title');

Expand Down
7 changes: 3 additions & 4 deletions CRM/UF/Form/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
9 changes: 6 additions & 3 deletions CRM/UF/Page/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static function &actionLinks() {
],
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 => [
Expand Down Expand Up @@ -259,6 +259,9 @@ public function run() {
/**
* Preview custom field.
*
* @deprecated
* Links should point directly to civicrm/admin/uf/group/preview
*
* @param int $fieldId
* Custom field id.
* @param int $groupId
Expand All @@ -272,7 +275,7 @@ public function preview($fieldId, $groupId) {
'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();
Expand Down
9 changes: 6 additions & 3 deletions CRM/UF/Page/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public static function &actionLinks() {
],
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 => [
Expand Down Expand Up @@ -372,14 +372,17 @@ public function browse($action = NULL) {
/**
* for preview mode for ufoup.
*
* @deprecated
* Links should point directly to civicrm/admin/uf/group/preview
*
* @param int $id
* Uf group id.
*
* @param int $action
*/
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();
Expand Down
1 change: 0 additions & 1 deletion Civi/Api4/UFField.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* UFField entity - aka profile fields.
*
* @see \Civi\Api4\UFGroup
* @searchable none
* @orderBy weight
* @groupWeightsBy uf_group_id
* @since 5.19
Expand Down
1 change: 0 additions & 1 deletion Civi/Api4/UFGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* UFGroup entity - AKA profiles.
*
* @see https://docs.civicrm.org/user/en/latest/organising-your-data/profiles/
* @searchable none
* @since 5.19
* @package Civi\Api4
*/
Expand Down
2 changes: 1 addition & 1 deletion Civi/Api4/UFJoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* UFJoin entity - links profiles to the components/extensions they are used for.
*
* @see \Civi\Api4\UFGroup
* @searchable none
* @searchable secondary
* @since 5.19
* @package Civi\Api4
*/
Expand Down
3 changes: 3 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div af-fieldset="">
<crm-search-display-table search-name="Profile_Fields" display-name="Profile_Fields" filters="{uf_group_id: routeParams.uf_group_id}"></crm-search-display-table>
</div>
18 changes: 18 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchProfileFields.aff.json
Original file line number Diff line number Diff line change
@@ -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
}
20 changes: 20 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchProfiles.aff.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<fieldset class="af-container af-layout-inline"></fieldset>
<div class="af-markup">




<div class="help">{{:: 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.') }} <a class="crm-doc-link no-popup" href="https://docs.civicrm.org/user/en/latest/organising-your-data/profiles/" target="_blank">{{:: ts('Learn more...') }}</a></div>





</div>
<div af-fieldset="" af-title="Filter">
<div class="af-container af-layout-inline">
<af-field name="title" defn="{required: false, input_attrs: {}}" />
<af-field name="is_reserved" defn="{input_attrs: {}, required: false}" />
</div>
<crm-search-display-table search-name="User_defined_Profiles" display-name="User_defined_Profiles"></crm-search-display-table>
</div>
18 changes: 18 additions & 0 deletions ext/civicrm_admin_ui/ang/afsearchProfiles.aff.json
Original file line number Diff line number Diff line change
@@ -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
}
Loading

0 comments on commit 115ab30

Please sign in to comment.